From 0ddd1d48cbad095995cbe8d69a142fad4d2a8fee Mon Sep 17 00:00:00 2001 From: beingmartinbmc Date: Mon, 3 Aug 2026 00:42:31 +0530 Subject: [PATCH] feat: overhaul UI and add guarded code visualizer --- .gitignore | 1 + .pre-commit-config.yaml | 23 + README.md | 2 + docs/404.html | 4 +- ...F.js => AdvancedStructurePage-BNdv4Rsg.js} | 2 +- docs/assets/AlgorithmCodePanel-CE3r0DXd.js | 1 + docs/assets/AlgorithmCodePanel-DQpanVTO.js | 1 - ...js => AlgorithmPlaygroundPage-DJ5poldo.js} | 2 +- ...Page-Y8dJ1gfQ.js => ArrayPage-CbscCeVa.js} | 2 +- ...-O0xS6.js => BalancedTreePage-2nu-ZXqQ.js} | 2 +- ...age-BlVnZaDx.js => BattlePage-aVfnCuym.js} | 2 +- docs/assets/CodeVisualizerPage-CGESrDz0.js | 44 ++ ...LSsKgV.js => DijkstraGamePage-DovdEQ8Y.js} | 2 +- ....js => EvolutionSimulatorPage-C1Me-6kF.js} | 2 +- ...JID2A.js => FibonacciGamePage-Bd8sKYsw.js} | 2 +- ...itPage-2XUhCvHg.js => GitPage-B_7vY4jd.js} | 2 +- docs/assets/GraphTraversalPage-B_xobZ-f.js | 18 + docs/assets/GraphTraversalPage-Ck5aejUZ.js | 18 - ...NHuX.js => LinkedListAlgoPage-qNeBmS2f.js} | 2 +- ...s => LinkedListAlgorithmsPage-CUxv2ABR.js} | 2 +- ...DDic5oaj.js => LinkedListPage-CPh-u55R.js} | 2 +- ...5Ek5nyq.js => MahjongGamePage-CBqcyOb2.js} | 4 +- ...Page-Zbw6nZfN.js => QueuePage-0cpMqKev.js} | 2 +- ...MU17.js => RubiksCubeGamePage-B1qlWFPn.js} | 2 +- ...ge-CM1b7Xid.js => SortingPage-R3xRGgbf.js} | 6 +- ...Page-pml9_y3A.js => StackPage-0M1nrFIi.js} | 2 +- docs/assets/SudokuPage-C5NKtd3W.js | 13 + docs/assets/SudokuPage-SBA-_ued.js | 13 - ...msx8X.js => TreeTraversalPage-B0ns8Kv6.js} | 2 +- ...ePage-j3idk4E6.js => TriePage-CjYcQVOU.js} | 2 +- ...28xRb9.js => WorldMapGamePage-Dd7brX_d.js} | 2 +- ...eft-DiyrXoev.js => arrow-left-CTMPG6pL.js} | 2 +- ...-BZqZw4c2.js => chevron-right-CFBAUJsk.js} | 2 +- ...ye-off-EsCpy5pU.js => eye-off-BfEKGZbc.js} | 2 +- docs/assets/index-BWwyfYSG.css | 1 + docs/assets/index-DBkLeWDs.js | 16 + docs/assets/index-eCXyAnHs.js | 32 - docs/assets/index-yKJrWCHV.css | 1 - ...bulb-B7pRWk3f.js => lightbulb-xA5HFx8I.js} | 2 +- .../{map-4vhpgcAJ.js => map-9j6oGOs_.js} | 2 +- .../{pause-nC-0zhw8.js => pause-CG1snUW9.js} | 2 +- .../{play-BqZilH6N.js => play-mcIZClKO.js} | 2 +- .../{plus-CffLiizr.js => plus-DVazsZHX.js} | 2 +- ...ccw-B8GZP3d7.js => rotate-ccw-7GTUOPy4.js} | 2 +- .../{route-CjoQmFsM.js => route-C4zDL9m7.js} | 2 +- ...huffle-CdKU4ZYx.js => shuffle-Dlr-c52A.js} | 2 +- docs/assets/skip-forward-BOek2ZcD.js | 1 - docs/assets/skip-forward-C79KMIOU.js | 1 + docs/assets/sparkles-3Zw4K66N.js | 1 + ...{square-CEHTCuQK.js => square-Bc_q5e3l.js} | 2 +- .../{timer-DSbfy6P3.js => timer-e0gb0oZa.js} | 2 +- ...rash-2-DQ8BZrIf.js => trash-2-C6_cMdiI.js} | 2 +- ...{trophy-DkUzH7jB.js => trophy-C1QWh03u.js} | 2 +- ...und-CIDAFkgj.js => useDSSound-KKipmh13.js} | 2 +- ...ume-x-CTbtCvt-.js => volume-x-BSx9gxSg.js} | 2 +- .../{zap-DNziIfcU.js => zap-CUITaKA-.js} | 2 +- docs/index.html | 4 +- package-lock.json | 2 +- package.json | 1 + src/App.tsx | 4 +- src/components/BookSectionPage.tsx | 118 ++++ src/components/Layout/Header.tsx | 161 ++--- src/content/book.ts | 384 ++++++++++++ src/features/algorithms/AlgorithmsPage.tsx | 185 +----- .../code-visualizer/CodeVisualizerPage.tsx | 355 +++++++++++ .../engine/__tests__/visualizeCode.test.ts | 56 ++ .../code-visualizer/engine/visualizeCode.ts | 565 ++++++++++++++++++ .../data-structures/DataStructuresPage.tsx | 145 +---- src/features/games/GamesPage.tsx | 145 +---- src/index.css | 190 ++++-- src/pages/LandingPage.tsx | 258 ++++---- 71 files changed, 1989 insertions(+), 857 deletions(-) create mode 100644 .pre-commit-config.yaml rename docs/assets/{AdvancedStructurePage-Bo1GEm6F.js => AdvancedStructurePage-BNdv4Rsg.js} (97%) create mode 100644 docs/assets/AlgorithmCodePanel-CE3r0DXd.js delete mode 100644 docs/assets/AlgorithmCodePanel-DQpanVTO.js rename docs/assets/{AlgorithmPlaygroundPage-t8CIKD7f.js => AlgorithmPlaygroundPage-DJ5poldo.js} (98%) rename docs/assets/{ArrayPage-Y8dJ1gfQ.js => ArrayPage-CbscCeVa.js} (97%) rename docs/assets/{BalancedTreePage-pB-O0xS6.js => BalancedTreePage-2nu-ZXqQ.js} (99%) rename docs/assets/{BattlePage-BlVnZaDx.js => BattlePage-aVfnCuym.js} (99%) create mode 100644 docs/assets/CodeVisualizerPage-CGESrDz0.js rename docs/assets/{DijkstraGamePage-BLLSsKgV.js => DijkstraGamePage-DovdEQ8Y.js} (98%) rename docs/assets/{EvolutionSimulatorPage-AYe0wg-1.js => EvolutionSimulatorPage-C1Me-6kF.js} (98%) rename docs/assets/{FibonacciGamePage-CoiJID2A.js => FibonacciGamePage-Bd8sKYsw.js} (98%) rename docs/assets/{GitPage-2XUhCvHg.js => GitPage-B_7vY4jd.js} (99%) create mode 100644 docs/assets/GraphTraversalPage-B_xobZ-f.js delete mode 100644 docs/assets/GraphTraversalPage-Ck5aejUZ.js rename docs/assets/{LinkedListAlgoPage-k8JPNHuX.js => LinkedListAlgoPage-qNeBmS2f.js} (98%) rename docs/assets/{LinkedListAlgorithmsPage-bVyDUoFQ.js => LinkedListAlgorithmsPage-CUxv2ABR.js} (95%) rename docs/assets/{LinkedListPage-DDic5oaj.js => LinkedListPage-CPh-u55R.js} (97%) rename docs/assets/{MahjongGamePage-D5Ek5nyq.js => MahjongGamePage-CBqcyOb2.js} (91%) rename docs/assets/{QueuePage-Zbw6nZfN.js => QueuePage-0cpMqKev.js} (97%) rename docs/assets/{RubiksCubeGamePage-CY8zMU17.js => RubiksCubeGamePage-B1qlWFPn.js} (98%) rename docs/assets/{SortingPage-CM1b7Xid.js => SortingPage-R3xRGgbf.js} (74%) rename docs/assets/{StackPage-pml9_y3A.js => StackPage-0M1nrFIi.js} (97%) create mode 100644 docs/assets/SudokuPage-C5NKtd3W.js delete mode 100644 docs/assets/SudokuPage-SBA-_ued.js rename docs/assets/{TreeTraversalPage-D_fmsx8X.js => TreeTraversalPage-B0ns8Kv6.js} (97%) rename docs/assets/{TriePage-j3idk4E6.js => TriePage-CjYcQVOU.js} (97%) rename docs/assets/{WorldMapGamePage-DO28xRb9.js => WorldMapGamePage-Dd7brX_d.js} (99%) rename docs/assets/{arrow-left-DiyrXoev.js => arrow-left-CTMPG6pL.js} (61%) rename docs/assets/{chevron-right-BZqZw4c2.js => chevron-right-CFBAUJsk.js} (69%) rename docs/assets/{eye-off-EsCpy5pU.js => eye-off-BfEKGZbc.js} (85%) create mode 100644 docs/assets/index-BWwyfYSG.css create mode 100644 docs/assets/index-DBkLeWDs.js delete mode 100644 docs/assets/index-eCXyAnHs.js delete mode 100644 docs/assets/index-yKJrWCHV.css rename docs/assets/{lightbulb-B7pRWk3f.js => lightbulb-xA5HFx8I.js} (85%) rename docs/assets/{map-4vhpgcAJ.js => map-9j6oGOs_.js} (84%) rename docs/assets/{pause-nC-0zhw8.js => pause-CG1snUW9.js} (69%) rename docs/assets/{play-BqZilH6N.js => play-mcIZClKO.js} (66%) rename docs/assets/{plus-CffLiizr.js => plus-DVazsZHX.js} (58%) rename docs/assets/{rotate-ccw-B8GZP3d7.js => rotate-ccw-7GTUOPy4.js} (68%) rename docs/assets/{route-CjoQmFsM.js => route-C4zDL9m7.js} (74%) rename docs/assets/{shuffle-CdKU4ZYx.js => shuffle-Dlr-c52A.js} (83%) delete mode 100644 docs/assets/skip-forward-BOek2ZcD.js create mode 100644 docs/assets/skip-forward-C79KMIOU.js create mode 100644 docs/assets/sparkles-3Zw4K66N.js rename docs/assets/{square-CEHTCuQK.js => square-Bc_q5e3l.js} (56%) rename docs/assets/{timer-DSbfy6P3.js => timer-e0gb0oZa.js} (73%) rename docs/assets/{trash-2-DQ8BZrIf.js => trash-2-C6_cMdiI.js} (80%) rename docs/assets/{trophy-DkUzH7jB.js => trophy-C1QWh03u.js} (86%) rename docs/assets/{useDSSound-CIDAFkgj.js => useDSSound-KKipmh13.js} (95%) rename docs/assets/{volume-x-CTbtCvt-.js => volume-x-BSx9gxSg.js} (91%) rename docs/assets/{zap-DNziIfcU.js => zap-CUITaKA-.js} (75%) create mode 100644 src/components/BookSectionPage.tsx create mode 100644 src/content/book.ts create mode 100644 src/features/code-visualizer/CodeVisualizerPage.tsx create mode 100644 src/features/code-visualizer/engine/__tests__/visualizeCode.test.ts create mode 100644 src/features/code-visualizer/engine/visualizeCode.ts diff --git a/.gitignore b/.gitignore index a547bf3..d233d0d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ dist-ssr .vscode/* !.vscode/extensions.json .idea +.jambavan/ .DS_Store *.suo *.ntvs* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0bef357 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +--- +# Fast repository hygiene plus the same TypeScript checks used locally. +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: trailing-whitespace + - id: check-merge-conflict + - id: check-json + - id: check-yaml + - id: end-of-file-fixer +- repo: local + hooks: + - id: eslint + name: ESLint + entry: npm run lint + language: system + pass_filenames: false + - id: vitest + name: Vitest + entry: npm test + language: system + pass_filenames: false diff --git a/README.md b/README.md index cabe136..e1371ba 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ An interactive, browser-based playground for learning algorithms, data structure - Evolution Simulator (genetic algorithm) - Rubik's Cube Solver - **Git Visualizer** — a 1.7k-LOC pure-TS Git simulator with terminal, commit-DAG canvas, freeplay mode, and guided lessons (init/add/commit, branching, merging, rebase, reset, stash, cherry-pick, remotes, push/pull, etc.). +- **Visualize Your Code** — enter a bounded JavaScript subset and play through line highlights, variable snapshots, array bars, and console output. A whitelist interpreter enforces source, operation, loop, trace, time, and memory limits without `eval` or browser-code execution. ## Quick start @@ -83,6 +84,7 @@ The pure-TS layer (`algorithms/` or `engine/`) returns arrays of `Step` objects | Styling | Tailwind CSS v4 (`@tailwindcss/vite`) | | Routing | `react-router-dom` v7 with code-split routes | | Icons | `lucide-react` | +| Code parsing | Acorn 8 + a bounded, purpose-built interpreter | | Audio | Web Audio API (single shared `AudioContext`) | | Lint | ESLint flat config + `typescript-eslint` + `react-hooks` | diff --git a/docs/404.html b/docs/404.html index 00a8493..6d1b59f 100644 --- a/docs/404.html +++ b/docs/404.html @@ -5,8 +5,8 @@ Algorithm Visualizer - - + +
diff --git a/docs/assets/AdvancedStructurePage-Bo1GEm6F.js b/docs/assets/AdvancedStructurePage-BNdv4Rsg.js similarity index 97% rename from docs/assets/AdvancedStructurePage-Bo1GEm6F.js rename to docs/assets/AdvancedStructurePage-BNdv4Rsg.js index e8f3188..d6e4759 100644 --- a/docs/assets/AdvancedStructurePage-Bo1GEm6F.js +++ b/docs/assets/AdvancedStructurePage-BNdv4Rsg.js @@ -1 +1 @@ -import{r as N,j as t}from"./index-eCXyAnHs.js";import{u as O}from"./useDSSound-CIDAFkgj.js";import{S as P}from"./shuffle-CdKU4ZYx.js";import{C as E,a as D}from"./chevron-right-BZqZw4c2.js";import{P as F}from"./play-BqZilH6N.js";import{V,a as W}from"./volume-x-CTbtCvt-.js";import"./audioContext-NbgqvQGz.js";const Q={trie:{title:"Trie",subtitle:"Prefix tree for words",inputLabel:"Words; operation; query",defaultInput:"cat,car,cart,dog,dove;prefix;ca",helper:"Format: words; insert/delete/search/prefix; query"},"segment-tree":{title:"Segment Tree",subtitle:"Range query and point update",inputLabel:"Array; operation; args",defaultInput:"2,1,5,3,4,8;query;1,4",helper:"Operations: build, query;l,r, update;index,value"},"fenwick-tree":{title:"Fenwick Tree",subtitle:"Binary indexed tree",inputLabel:"Array; operation; args",defaultInput:"2,1,5,3,4,8;range;1,4",helper:"Operations use 1-based indexes: build, prefix;i, range;l,r, update;index,value"}};function re({structure:i}){const l=Q[i],[p,c]=N.useState(l.defaultInput),[e,d]=N.useState(()=>R(i,l.defaultInput)),[o,x]=N.useState(0),[h,f]=N.useState(650),{soundEnabled:n,toggleSound:s,playInsert:a,playDelete:r,playAccess:w,playTraverse:$,playFound:y,playNotFound:b}=O(),m=e[o]??e[0],j=(u,g)=>{u.event==="insert"?a():u.event==="delete"?r():u.event==="access"?w():u.event==="traverse"?$(g,e.length):u.event==="found"?y():b()},z=()=>{const u=R(i,p);d(u),x(0),u[0]&&j(u[0],0)},I=u=>{const g=Math.max(0,Math.min(e.length-1,u));x(g);const C=e[g];C&&j(C,g)},B=()=>{const u=J(i);c(u);const g=R(i,u);d(g),x(0)},L=()=>{for(let u=o;u{x(u);const g=e[u];g&&j(g,u)},(u-o)*h)};return t.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[t.jsxs("main",{className:"order-last flex min-h-[520px] flex-1 flex-col gap-4 xl:order-first",children:[t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-rose-300",children:"Data Structures"}),t.jsx("h2",{className:"mt-1 text-xl font-bold text-white",children:l.title}),t.jsx("p",{className:"mt-1 text-sm text-slate-400",children:l.subtitle})]}),t.jsx("section",{className:"flex flex-1 items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5",children:m?.nodes?t.jsx(U,{step:m}):t.jsx(X,{step:m,structure:i})})]}),t.jsxs("aside",{className:"w-full space-y-4 xl:w-80 xl:shrink-0",children:[t.jsxs(k,{title:"Operation",children:[t.jsx("label",{className:"text-[11px] text-slate-500",children:l.inputLabel}),t.jsx("textarea",{value:p,onChange:u=>c(u.target.value),rows:2,className:"mt-1 w-full resize-none rounded-xl bg-slate-950/70 px-3 py-2 text-xs font-mono text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-rose-500/50"}),t.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:l.helper}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[t.jsx("button",{onClick:z,className:"rounded-xl bg-rose-500/20 px-3 py-2 text-xs font-semibold text-rose-300 ring-1 ring-rose-500/40 hover:bg-rose-500/30",children:"Run"}),t.jsxs("button",{onClick:B,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[t.jsx(P,{size:13})," Random"]})]})]}),t.jsxs(k,{title:"Step Playback",children:[t.jsx("p",{className:"min-h-12 text-xs leading-relaxed text-slate-300",children:m?.description}),m?.meta&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:m.meta.map(u=>t.jsx("span",{className:"rounded-full bg-slate-800 px-2 py-0.5 text-[10px] font-mono text-slate-400",children:u},u))}),t.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs text-slate-500",children:[t.jsx("span",{children:"Step"}),t.jsxs("span",{className:"font-mono text-rose-300",children:[Math.min(o+1,e.length)," / ",e.length]})]}),t.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Animation Speed"}),t.jsxs("span",{className:"font-mono text-[10px] text-rose-300",children:[h,"ms"]})]}),t.jsx("input",{type:"range",min:120,max:1200,step:40,value:1320-h,onChange:u=>f(1320-Number(u.target.value)),className:"w-full accent-rose-400","aria-label":"Animation speed"}),t.jsxs("div",{className:"mt-1 flex justify-between text-[9px] uppercase tracking-wide text-slate-600",children:[t.jsx("span",{children:"Slow"}),t.jsx("span",{children:"Fast"})]})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[t.jsxs("button",{onClick:()=>I(o-1),disabled:o<=0,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:[t.jsx(E,{size:13})," Back"]}),t.jsxs("button",{onClick:L,disabled:o>=e.length-1,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-emerald-500/15 px-2 py-2 text-xs font-semibold text-emerald-300 ring-1 ring-emerald-500/30 disabled:opacity-30",children:[t.jsx(F,{size:13})," Play"]}),t.jsxs("button",{onClick:()=>I(o+1),disabled:o>=e.length-1,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:["Next ",t.jsx(D,{size:13})]})]})]}),t.jsx(k,{title:"Audio",children:t.jsxs("button",{onClick:()=>s(!n),className:`inline-flex w-full items-center justify-center gap-2 rounded-xl px-3 py-2 text-xs font-semibold ring-1 ${n?"bg-rose-500/15 text-rose-300 ring-rose-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[n?t.jsx(V,{size:14}):t.jsx(W,{size:14}),n?"Sound On":"Sound Off"]})})]})]})}function k({title:i,children:l}){return t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:i}),l]})}function U({step:i}){const l=i.nodes??[],p=new Set(i.highlights??[]);return t.jsxs("svg",{viewBox:"0 0 720 380",className:"h-full min-h-[420px] w-full",children:[l.map(c=>{const e=l.find(d=>d.id===c.parentId);return e?t.jsx("line",{x1:e.x,y1:e.y,x2:c.x,y2:c.y,stroke:"#475569",strokeWidth:1.5},`${e.id}-${c.id}`):null}),l.map(c=>{const e=p.has(Number(c.id.replace(/\D/g,"")))||p.has(l.indexOf(c));return t.jsxs("g",{children:[t.jsx("circle",{cx:c.x,cy:c.y,r:22,fill:e?"rgba(244,63,94,0.22)":"rgba(30,41,59,0.9)",stroke:e?"#fb7185":"#64748b",strokeWidth:2}),t.jsx("text",{x:c.x,y:c.y+4,textAnchor:"middle",fontSize:"12",fontWeight:"800",fill:e?"#fecdd3":"#cbd5e1",children:c.label}),c.value!==void 0&&t.jsx("text",{x:c.x,y:c.y+35,textAnchor:"middle",fontSize:"10",fill:"#94a3b8",children:c.value})]},c.id)})]})}function X({step:i,structure:l}){const p=i?.array??[],c=new Set(i?.highlights??[]);return t.jsxs("div",{className:"w-full space-y-6",children:[t.jsx("div",{className:"flex flex-wrap justify-center gap-2",children:p.map((e,d)=>t.jsxs("div",{className:`relative flex h-14 min-w-14 items-center justify-center rounded-xl px-3 font-mono text-sm font-black ring-1 ${c.has(d)?"bg-rose-500/20 text-rose-200 ring-rose-500/50":"bg-slate-800/70 text-slate-200 ring-slate-700/50"}`,children:[e,t.jsx("span",{className:"absolute -bottom-5 text-[9px] text-slate-500",children:l==="fenwick-tree"?d+1:d})]},`${e}-${d}`))}),i?.queryRange&&t.jsxs("p",{className:"text-center text-xs text-slate-400",children:["Active range: [",i.queryRange[0],", ",i.queryRange[1],"]"]})]})}function R(i,l){return i==="trie"?_(l):i==="segment-tree"?G(l):H(l)}function M(i){return i.split(",").map(l=>l.trim()).filter(Boolean).map(Number).filter(Number.isFinite)}function _(i){const[l="",p="prefix",c=""]=i.split(";"),e=l.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean),d=p.trim().toLowerCase(),o=c.trim().toLowerCase(),x=[];T=0;const h=A("*"),f=d==="insert"&&o?[...e,o]:e.filter(n=>!(d==="delete"&&n===o));if(e.forEach(n=>q(h,n)),x.push({description:`Build trie from ${e.length} word(s).`,event:"insert",nodes:v(h),meta:e}),d==="insert"&&o)q(h,o),x.push({description:`Insert "${o}" character by character.`,event:"insert",nodes:v(h),meta:f});else if(d==="delete"&&o){const n=A("*");f.forEach(s=>q(n,s)),x.push({description:`Delete "${o}" and rebuild active prefixes.`,event:"delete",nodes:v(n),meta:f})}else{let n=h;const s=[0];for(const r of o){if(n=n.children.get(r),!n)return x.push({description:`Character "${r}" is missing, so "${o}" was not found.`,event:"not-found",nodes:v(h),highlights:s,meta:e}),x;s.push(n.order),x.push({description:`Traverse character "${r}" in "${o}".`,event:"traverse",nodes:v(h),highlights:[...s],meta:e})}const a=e.filter(r=>d==="search"?r===o:r.startsWith(o));x.push({description:a.length?`Matched: ${a.join(", ")}.`:`No match for "${o}".`,event:a.length?"found":"not-found",nodes:v(h),highlights:s,meta:a})}return x}let T=0;function A(i){return{label:i,order:T++,terminal:!1,children:new Map}}function q(i,l){let p=i;for(const c of l)p.children.has(c)||p.children.set(c,A(c)),p=p.children.get(c);p.terminal=!0}function v(i){const l=[],p=new Map,c=(e,d,o)=>{const x=p.get(d)??[];x.push(e),p.set(d,x),l.push({id:`trie-${e.order}`,label:e.terminal?`${e.label}*`:e.label,x:0,y:d*72+42,parentId:o}),[...e.children.values()].forEach(h=>c(h,d+1,`trie-${e.order}`))};return c(i,0),l.forEach(e=>{const d=Math.round((e.y-42)/72),o=l.filter(h=>Math.round((h.y-42)/72)===d),x=o.indexOf(e);e.x=360+(x-(o.length-1)/2)*Math.max(46,520/Math.max(o.length,1))}),l}function G(i){const[l="",p="query",c="0,0"]=i.split(";"),e=M(l),d=p.trim(),o=M(c),x=Array(e.length*4).fill(0),h=[],f=(n,s,a)=>{if(s===a)x[n]=e[s];else{const r=Math.floor((s+a)/2);f(n*2,s,r),f(n*2+1,r+1,a),x[n]=x[n*2]+x[n*2+1]}h.push({description:`Build segment [${s}, ${a}] with sum ${x[n]}.`,event:"insert",array:[...e],highlights:S(s,a),queryRange:[s,a],meta:[`node:${n}`,`sum:${x[n]}`]})};if(e.length&&f(1,0,e.length-1),d==="query"){const[n,s]=o,a=Math.max(0,Math.min(e.length-1,n??0)),r=Math.max(a,Math.min(e.length-1,s??e.length-1)),w=(y,b,m)=>{if(h.push({description:`Visit segment [${b}, ${m}] for query [${a}, ${r}].`,event:"traverse",array:[...e],highlights:S(Math.max(b,a),Math.min(m,r)),queryRange:[a,r],meta:[`node:${y}`]}),r=0&&n{for(let r=s+1;r<=e.length;r+=r&-r)d[r]+=a,o.push({description:`Update BIT[${r}] += ${a}; next index is i + lowbit(i).`,event:"insert",array:d.slice(1),highlights:[r-1],meta:[`lowbit:${r&-r}`]})};e.forEach((s,a)=>x(a,s));const h=s=>{let a=0;for(let r=s+1;r>0;r-=r&-r)a+=d[r],o.push({description:`Read BIT[${r}] while computing prefix(${s}); next index is i - lowbit(i).`,event:"traverse",array:d.slice(1),highlights:[r-1],meta:[`partial:${a}`,`lowbit:${r&-r}`]});return a},f=p.trim(),n=M(c);if(f==="prefix"){const s=Math.max(0,Math.min(e.length-1,(n[0]??1)-1)),a=h(s);o.push({description:`Prefix sum up to position ${s+1} = ${a}.`,event:"found",array:d.slice(1),highlights:[s],meta:[`sum:${a}`]})}else if(f==="update"){const s=Math.max(0,Math.min(e.length-1,(n[0]??1)-1)),a=n[1]??e[s]??0;s>=0&&s0?h(s-1):0);o.push({description:`Range sum positions [${s+1}, ${a+1}] = ${r}.`,event:"found",array:d.slice(1),highlights:S(s,a),queryRange:[s+1,a+1],meta:[`sum:${r}`]})}return o}function S(i,l){return li+c)}function J(i){if(i==="trie")return"tree,trie,trial,algo,all,also;prefix;tr";const l=Array.from({length:6},()=>Math.floor(Math.random()*9)+1).join(",");return i==="segment-tree"?`${l};query;1,4`:`${l};range;1,4`}export{re as default}; +import{r as N,j as t}from"./index-DBkLeWDs.js";import{u as O}from"./useDSSound-KKipmh13.js";import{S as P}from"./shuffle-Dlr-c52A.js";import{C as E,a as D}from"./chevron-right-CFBAUJsk.js";import{P as F}from"./play-mcIZClKO.js";import{V,a as W}from"./volume-x-BSx9gxSg.js";import"./audioContext-NbgqvQGz.js";const Q={trie:{title:"Trie",subtitle:"Prefix tree for words",inputLabel:"Words; operation; query",defaultInput:"cat,car,cart,dog,dove;prefix;ca",helper:"Format: words; insert/delete/search/prefix; query"},"segment-tree":{title:"Segment Tree",subtitle:"Range query and point update",inputLabel:"Array; operation; args",defaultInput:"2,1,5,3,4,8;query;1,4",helper:"Operations: build, query;l,r, update;index,value"},"fenwick-tree":{title:"Fenwick Tree",subtitle:"Binary indexed tree",inputLabel:"Array; operation; args",defaultInput:"2,1,5,3,4,8;range;1,4",helper:"Operations use 1-based indexes: build, prefix;i, range;l,r, update;index,value"}};function re({structure:i}){const l=Q[i],[p,c]=N.useState(l.defaultInput),[e,d]=N.useState(()=>R(i,l.defaultInput)),[o,x]=N.useState(0),[h,f]=N.useState(650),{soundEnabled:n,toggleSound:s,playInsert:a,playDelete:r,playAccess:w,playTraverse:$,playFound:y,playNotFound:b}=O(),m=e[o]??e[0],j=(u,g)=>{u.event==="insert"?a():u.event==="delete"?r():u.event==="access"?w():u.event==="traverse"?$(g,e.length):u.event==="found"?y():b()},z=()=>{const u=R(i,p);d(u),x(0),u[0]&&j(u[0],0)},I=u=>{const g=Math.max(0,Math.min(e.length-1,u));x(g);const C=e[g];C&&j(C,g)},B=()=>{const u=J(i);c(u);const g=R(i,u);d(g),x(0)},L=()=>{for(let u=o;u{x(u);const g=e[u];g&&j(g,u)},(u-o)*h)};return t.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[t.jsxs("main",{className:"order-last flex min-h-[520px] flex-1 flex-col gap-4 xl:order-first",children:[t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-rose-300",children:"Data Structures"}),t.jsx("h2",{className:"mt-1 text-xl font-bold text-white",children:l.title}),t.jsx("p",{className:"mt-1 text-sm text-slate-400",children:l.subtitle})]}),t.jsx("section",{className:"flex flex-1 items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5",children:m?.nodes?t.jsx(U,{step:m}):t.jsx(X,{step:m,structure:i})})]}),t.jsxs("aside",{className:"w-full space-y-4 xl:w-80 xl:shrink-0",children:[t.jsxs(k,{title:"Operation",children:[t.jsx("label",{className:"text-[11px] text-slate-500",children:l.inputLabel}),t.jsx("textarea",{value:p,onChange:u=>c(u.target.value),rows:2,className:"mt-1 w-full resize-none rounded-xl bg-slate-950/70 px-3 py-2 text-xs font-mono text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-rose-500/50"}),t.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:l.helper}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[t.jsx("button",{onClick:z,className:"rounded-xl bg-rose-500/20 px-3 py-2 text-xs font-semibold text-rose-300 ring-1 ring-rose-500/40 hover:bg-rose-500/30",children:"Run"}),t.jsxs("button",{onClick:B,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[t.jsx(P,{size:13})," Random"]})]})]}),t.jsxs(k,{title:"Step Playback",children:[t.jsx("p",{className:"min-h-12 text-xs leading-relaxed text-slate-300",children:m?.description}),m?.meta&&t.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:m.meta.map(u=>t.jsx("span",{className:"rounded-full bg-slate-800 px-2 py-0.5 text-[10px] font-mono text-slate-400",children:u},u))}),t.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs text-slate-500",children:[t.jsx("span",{children:"Step"}),t.jsxs("span",{className:"font-mono text-rose-300",children:[Math.min(o+1,e.length)," / ",e.length]})]}),t.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Animation Speed"}),t.jsxs("span",{className:"font-mono text-[10px] text-rose-300",children:[h,"ms"]})]}),t.jsx("input",{type:"range",min:120,max:1200,step:40,value:1320-h,onChange:u=>f(1320-Number(u.target.value)),className:"w-full accent-rose-400","aria-label":"Animation speed"}),t.jsxs("div",{className:"mt-1 flex justify-between text-[9px] uppercase tracking-wide text-slate-600",children:[t.jsx("span",{children:"Slow"}),t.jsx("span",{children:"Fast"})]})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[t.jsxs("button",{onClick:()=>I(o-1),disabled:o<=0,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:[t.jsx(E,{size:13})," Back"]}),t.jsxs("button",{onClick:L,disabled:o>=e.length-1,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-emerald-500/15 px-2 py-2 text-xs font-semibold text-emerald-300 ring-1 ring-emerald-500/30 disabled:opacity-30",children:[t.jsx(F,{size:13})," Play"]}),t.jsxs("button",{onClick:()=>I(o+1),disabled:o>=e.length-1,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:["Next ",t.jsx(D,{size:13})]})]})]}),t.jsx(k,{title:"Audio",children:t.jsxs("button",{onClick:()=>s(!n),className:`inline-flex w-full items-center justify-center gap-2 rounded-xl px-3 py-2 text-xs font-semibold ring-1 ${n?"bg-rose-500/15 text-rose-300 ring-rose-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[n?t.jsx(V,{size:14}):t.jsx(W,{size:14}),n?"Sound On":"Sound Off"]})})]})]})}function k({title:i,children:l}){return t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:i}),l]})}function U({step:i}){const l=i.nodes??[],p=new Set(i.highlights??[]);return t.jsxs("svg",{viewBox:"0 0 720 380",className:"h-full min-h-[420px] w-full",children:[l.map(c=>{const e=l.find(d=>d.id===c.parentId);return e?t.jsx("line",{x1:e.x,y1:e.y,x2:c.x,y2:c.y,stroke:"#475569",strokeWidth:1.5},`${e.id}-${c.id}`):null}),l.map(c=>{const e=p.has(Number(c.id.replace(/\D/g,"")))||p.has(l.indexOf(c));return t.jsxs("g",{children:[t.jsx("circle",{cx:c.x,cy:c.y,r:22,fill:e?"rgba(244,63,94,0.22)":"rgba(30,41,59,0.9)",stroke:e?"#fb7185":"#64748b",strokeWidth:2}),t.jsx("text",{x:c.x,y:c.y+4,textAnchor:"middle",fontSize:"12",fontWeight:"800",fill:e?"#fecdd3":"#cbd5e1",children:c.label}),c.value!==void 0&&t.jsx("text",{x:c.x,y:c.y+35,textAnchor:"middle",fontSize:"10",fill:"#94a3b8",children:c.value})]},c.id)})]})}function X({step:i,structure:l}){const p=i?.array??[],c=new Set(i?.highlights??[]);return t.jsxs("div",{className:"w-full space-y-6",children:[t.jsx("div",{className:"flex flex-wrap justify-center gap-2",children:p.map((e,d)=>t.jsxs("div",{className:`relative flex h-14 min-w-14 items-center justify-center rounded-xl px-3 font-mono text-sm font-black ring-1 ${c.has(d)?"bg-rose-500/20 text-rose-200 ring-rose-500/50":"bg-slate-800/70 text-slate-200 ring-slate-700/50"}`,children:[e,t.jsx("span",{className:"absolute -bottom-5 text-[9px] text-slate-500",children:l==="fenwick-tree"?d+1:d})]},`${e}-${d}`))}),i?.queryRange&&t.jsxs("p",{className:"text-center text-xs text-slate-400",children:["Active range: [",i.queryRange[0],", ",i.queryRange[1],"]"]})]})}function R(i,l){return i==="trie"?_(l):i==="segment-tree"?G(l):H(l)}function M(i){return i.split(",").map(l=>l.trim()).filter(Boolean).map(Number).filter(Number.isFinite)}function _(i){const[l="",p="prefix",c=""]=i.split(";"),e=l.split(",").map(n=>n.trim().toLowerCase()).filter(Boolean),d=p.trim().toLowerCase(),o=c.trim().toLowerCase(),x=[];T=0;const h=A("*"),f=d==="insert"&&o?[...e,o]:e.filter(n=>!(d==="delete"&&n===o));if(e.forEach(n=>q(h,n)),x.push({description:`Build trie from ${e.length} word(s).`,event:"insert",nodes:v(h),meta:e}),d==="insert"&&o)q(h,o),x.push({description:`Insert "${o}" character by character.`,event:"insert",nodes:v(h),meta:f});else if(d==="delete"&&o){const n=A("*");f.forEach(s=>q(n,s)),x.push({description:`Delete "${o}" and rebuild active prefixes.`,event:"delete",nodes:v(n),meta:f})}else{let n=h;const s=[0];for(const r of o){if(n=n.children.get(r),!n)return x.push({description:`Character "${r}" is missing, so "${o}" was not found.`,event:"not-found",nodes:v(h),highlights:s,meta:e}),x;s.push(n.order),x.push({description:`Traverse character "${r}" in "${o}".`,event:"traverse",nodes:v(h),highlights:[...s],meta:e})}const a=e.filter(r=>d==="search"?r===o:r.startsWith(o));x.push({description:a.length?`Matched: ${a.join(", ")}.`:`No match for "${o}".`,event:a.length?"found":"not-found",nodes:v(h),highlights:s,meta:a})}return x}let T=0;function A(i){return{label:i,order:T++,terminal:!1,children:new Map}}function q(i,l){let p=i;for(const c of l)p.children.has(c)||p.children.set(c,A(c)),p=p.children.get(c);p.terminal=!0}function v(i){const l=[],p=new Map,c=(e,d,o)=>{const x=p.get(d)??[];x.push(e),p.set(d,x),l.push({id:`trie-${e.order}`,label:e.terminal?`${e.label}*`:e.label,x:0,y:d*72+42,parentId:o}),[...e.children.values()].forEach(h=>c(h,d+1,`trie-${e.order}`))};return c(i,0),l.forEach(e=>{const d=Math.round((e.y-42)/72),o=l.filter(h=>Math.round((h.y-42)/72)===d),x=o.indexOf(e);e.x=360+(x-(o.length-1)/2)*Math.max(46,520/Math.max(o.length,1))}),l}function G(i){const[l="",p="query",c="0,0"]=i.split(";"),e=M(l),d=p.trim(),o=M(c),x=Array(e.length*4).fill(0),h=[],f=(n,s,a)=>{if(s===a)x[n]=e[s];else{const r=Math.floor((s+a)/2);f(n*2,s,r),f(n*2+1,r+1,a),x[n]=x[n*2]+x[n*2+1]}h.push({description:`Build segment [${s}, ${a}] with sum ${x[n]}.`,event:"insert",array:[...e],highlights:S(s,a),queryRange:[s,a],meta:[`node:${n}`,`sum:${x[n]}`]})};if(e.length&&f(1,0,e.length-1),d==="query"){const[n,s]=o,a=Math.max(0,Math.min(e.length-1,n??0)),r=Math.max(a,Math.min(e.length-1,s??e.length-1)),w=(y,b,m)=>{if(h.push({description:`Visit segment [${b}, ${m}] for query [${a}, ${r}].`,event:"traverse",array:[...e],highlights:S(Math.max(b,a),Math.min(m,r)),queryRange:[a,r],meta:[`node:${y}`]}),r=0&&n{for(let r=s+1;r<=e.length;r+=r&-r)d[r]+=a,o.push({description:`Update BIT[${r}] += ${a}; next index is i + lowbit(i).`,event:"insert",array:d.slice(1),highlights:[r-1],meta:[`lowbit:${r&-r}`]})};e.forEach((s,a)=>x(a,s));const h=s=>{let a=0;for(let r=s+1;r>0;r-=r&-r)a+=d[r],o.push({description:`Read BIT[${r}] while computing prefix(${s}); next index is i - lowbit(i).`,event:"traverse",array:d.slice(1),highlights:[r-1],meta:[`partial:${a}`,`lowbit:${r&-r}`]});return a},f=p.trim(),n=M(c);if(f==="prefix"){const s=Math.max(0,Math.min(e.length-1,(n[0]??1)-1)),a=h(s);o.push({description:`Prefix sum up to position ${s+1} = ${a}.`,event:"found",array:d.slice(1),highlights:[s],meta:[`sum:${a}`]})}else if(f==="update"){const s=Math.max(0,Math.min(e.length-1,(n[0]??1)-1)),a=n[1]??e[s]??0;s>=0&&s0?h(s-1):0);o.push({description:`Range sum positions [${s+1}, ${a+1}] = ${r}.`,event:"found",array:d.slice(1),highlights:S(s,a),queryRange:[s+1,a+1],meta:[`sum:${r}`]})}return o}function S(i,l){return li+c)}function J(i){if(i==="trie")return"tree,trie,trial,algo,all,also;prefix;tr";const l=Array.from({length:6},()=>Math.floor(Math.random()*9)+1).join(",");return i==="segment-tree"?`${l};query;1,4`:`${l};range;1,4`}export{re as default}; diff --git a/docs/assets/AlgorithmCodePanel-CE3r0DXd.js b/docs/assets/AlgorithmCodePanel-CE3r0DXd.js new file mode 100644 index 0000000..86c3078 --- /dev/null +++ b/docs/assets/AlgorithmCodePanel-CE3r0DXd.js @@ -0,0 +1 @@ +import{c as b,r,j as a}from"./index-DBkLeWDs.js";import{g as f}from"./audioContext-NbgqvQGz.js";const k=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],j=b("code-xml",k),h=[220,261.63,293.66,329.63,392,440,523.25,659.25,783.99];function N(){const i=r.useRef(!0),[l,x]=r.useState(!0),u=r.useCallback(()=>f(),[]),e=r.useCallback((s,c=.08,g="sine",m=.04)=>{if(!i.current)return;const t=u();if(!t)return;const n=t.createOscillator(),p=t.createGain();n.type=g,n.frequency.setValueAtTime(s,t.currentTime),p.gain.setValueAtTime(m,t.currentTime),p.gain.exponentialRampToValueAtTime(.001,t.currentTime+c),n.connect(p),p.connect(t.destination),n.start(t.currentTime),n.stop(t.currentTime+c)},[u]),d=r.useCallback((s,c=0,g=1)=>{const m=h[Math.max(0,Math.min(h.length-1,Math.floor(c/Math.max(g-1,1)*(h.length-1))))];switch(s){case"compare":e(m,.055,"sine",.025);break;case"swap":e(329.63,.07,"square",.025),setTimeout(()=>e(523.25,.07,"square",.025),45);break;case"visit":case"enqueue":case"dequeue":e(m,.065,"triangle",.03);break;case"push":e(440,.08,"triangle",.035);break;case"pop":e(293.66,.08,"triangle",.035);break;case"recurse":e(392+c*24,.07,"sine",.03);break;case"found":[523.25,659.25,783.99].forEach((t,n)=>setTimeout(()=>e(t,.1,"sine",.045),n*70));break;case"not-found":e(185,.16,"sawtooth",.035);break;case"complete":[392,523.25,659.25,783.99].forEach((t,n)=>setTimeout(()=>e(t,.11,"sine",.045),n*75));break}},[e]),o=r.useCallback(s=>{i.current=s,x(s)},[]);return{soundEnabled:l,toggleSound:o,playEvent:d}}function C({pseudocode:i,activeLine:l=null,title:x="Code",language:u="pseudocode"}){const e=r.useRef(null);return r.useEffect(()=>{e.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[l]),a.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsxs("h3",{className:"inline-flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-slate-400",children:[a.jsx(j,{size:13,className:"text-indigo-400"})," ",x]}),a.jsx("span",{className:"rounded-full bg-slate-800/70 px-2 py-0.5 font-mono text-[9px] uppercase tracking-wide text-slate-500",children:u})]}),a.jsx("div",{className:"max-h-[420px] overflow-auto rounded-xl bg-slate-950/70 p-2 ring-1 ring-slate-800/70",children:a.jsx("pre",{className:"font-mono text-[11px] leading-relaxed",children:i.map((d,o)=>{const s=o===l;return a.jsxs("div",{ref:s?e:null,className:`flex gap-3 rounded-md px-2 py-0.5 transition-all duration-300 ${s?"bg-indigo-500/20 text-indigo-100 ring-1 ring-indigo-500/40":"text-slate-400"}`,children:[a.jsx("span",{className:`select-none text-right tabular-nums ${s?"text-indigo-300":"text-slate-600"}`,style:{minWidth:"1.6rem"},children:o+1}),a.jsx("span",{className:"whitespace-pre",children:d.length?d:" "})]},o)})})})]})}export{C as A,N as u}; diff --git a/docs/assets/AlgorithmCodePanel-DQpanVTO.js b/docs/assets/AlgorithmCodePanel-DQpanVTO.js deleted file mode 100644 index 2a2b407..0000000 --- a/docs/assets/AlgorithmCodePanel-DQpanVTO.js +++ /dev/null @@ -1 +0,0 @@ -import{r,j as a,C as b}from"./index-eCXyAnHs.js";import{g as f}from"./audioContext-NbgqvQGz.js";const h=[220,261.63,293.66,329.63,392,440,523.25,659.25,783.99];function T(){const l=r.useRef(!0),[i,x]=r.useState(!0),u=r.useCallback(()=>f(),[]),e=r.useCallback((s,c=.08,g="sine",m=.04)=>{if(!l.current)return;const t=u();if(!t)return;const n=t.createOscillator(),p=t.createGain();n.type=g,n.frequency.setValueAtTime(s,t.currentTime),p.gain.setValueAtTime(m,t.currentTime),p.gain.exponentialRampToValueAtTime(.001,t.currentTime+c),n.connect(p),p.connect(t.destination),n.start(t.currentTime),n.stop(t.currentTime+c)},[u]),d=r.useCallback((s,c=0,g=1)=>{const m=h[Math.max(0,Math.min(h.length-1,Math.floor(c/Math.max(g-1,1)*(h.length-1))))];switch(s){case"compare":e(m,.055,"sine",.025);break;case"swap":e(329.63,.07,"square",.025),setTimeout(()=>e(523.25,.07,"square",.025),45);break;case"visit":case"enqueue":case"dequeue":e(m,.065,"triangle",.03);break;case"push":e(440,.08,"triangle",.035);break;case"pop":e(293.66,.08,"triangle",.035);break;case"recurse":e(392+c*24,.07,"sine",.03);break;case"found":[523.25,659.25,783.99].forEach((t,n)=>setTimeout(()=>e(t,.1,"sine",.045),n*70));break;case"not-found":e(185,.16,"sawtooth",.035);break;case"complete":[392,523.25,659.25,783.99].forEach((t,n)=>setTimeout(()=>e(t,.11,"sine",.045),n*75));break}},[e]),o=r.useCallback(s=>{l.current=s,x(s)},[]);return{soundEnabled:i,toggleSound:o,playEvent:d}}function C({pseudocode:l,activeLine:i=null,title:x="Code",language:u="pseudocode"}){const e=r.useRef(null);return r.useEffect(()=>{e.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[i]),a.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[a.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[a.jsxs("h3",{className:"inline-flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-slate-400",children:[a.jsx(b,{size:13,className:"text-indigo-400"})," ",x]}),a.jsx("span",{className:"rounded-full bg-slate-800/70 px-2 py-0.5 font-mono text-[9px] uppercase tracking-wide text-slate-500",children:u})]}),a.jsx("div",{className:"max-h-[420px] overflow-auto rounded-xl bg-slate-950/70 p-2 ring-1 ring-slate-800/70",children:a.jsx("pre",{className:"font-mono text-[11px] leading-relaxed",children:l.map((d,o)=>{const s=o===i;return a.jsxs("div",{ref:s?e:null,className:`flex gap-3 rounded-md px-2 py-0.5 transition-all duration-300 ${s?"bg-indigo-500/20 text-indigo-100 ring-1 ring-indigo-500/40":"text-slate-400"}`,children:[a.jsx("span",{className:`select-none text-right tabular-nums ${s?"text-indigo-300":"text-slate-600"}`,style:{minWidth:"1.6rem"},children:o+1}),a.jsx("span",{className:"whitespace-pre",children:d.length?d:" "})]},o)})})})]})}export{C as A,T as u}; diff --git a/docs/assets/AlgorithmPlaygroundPage-t8CIKD7f.js b/docs/assets/AlgorithmPlaygroundPage-DJ5poldo.js similarity index 98% rename from docs/assets/AlgorithmPlaygroundPage-t8CIKD7f.js rename to docs/assets/AlgorithmPlaygroundPage-DJ5poldo.js index b1689ab..35bb1c3 100644 --- a/docs/assets/AlgorithmPlaygroundPage-t8CIKD7f.js +++ b/docs/assets/AlgorithmPlaygroundPage-DJ5poldo.js @@ -1 +1 @@ -import{r as b,j as i}from"./index-eCXyAnHs.js";import{u as M,A as C}from"./AlgorithmCodePanel-DQpanVTO.js";import{S as F}from"./shuffle-CdKU4ZYx.js";import{C as I,a as z}from"./chevron-right-BZqZw4c2.js";import{P as R}from"./play-BqZilH6N.js";import{R as A}from"./rotate-ccw-B8GZP3d7.js";import{V as P,a as E}from"./volume-x-CTbtCvt-.js";import"./audioContext-NbgqvQGz.js";const T={"binary-search":{title:"Binary Search",subtitle:"Search a sorted array in logarithmic time",inputLabel:"Sorted numbers; target",defaultInput:"2,5,8,12,16,23,38,56,72;23",helper:"Format: sorted comma-separated numbers; target",pseudocode:["function binarySearch(arr, target):"," low = 0; high = arr.length - 1"," while low <= high:"," mid = (low + high) / 2"," if arr[mid] == target: return mid"," if arr[mid] < target: low = mid + 1"," else: high = mid - 1"," return -1 // not found"]},"ternary-search":{title:"Ternary Search",subtitle:"Split a sorted search range into thirds",inputLabel:"Sorted numbers; target",defaultInput:"1,4,8,11,15,19,23,27,31,35,39;31",helper:"Format: sorted comma-separated numbers; target",pseudocode:["function ternarySearch(arr, target):"," low = 0; high = arr.length - 1"," while low <= high:"," mid1 = low + (high - low) / 3"," mid2 = high - (high - low) / 3"," if arr[mid1] == target: return mid1"," if arr[mid2] == target: return mid2"," if target < arr[mid1]: high = mid1 - 1"," elif target > arr[mid2]: low = mid2 + 1"," else: low = mid1 + 1; high = mid2 - 1"," return -1 // not found"]},"dutch-national-flag":{title:"Sort Colors",subtitle:"Dutch national flag partitioning",inputLabel:"Colors as 0, 1, 2",defaultInput:"2,0,2,1,1,0,2,0,1",helper:"Use only 0, 1, and 2.",pseudocode:["function sortColors(arr):"," low = 0; mid = 0; high = arr.length - 1"," while mid <= high:"," if arr[mid] == 0:"," swap(arr[low], arr[mid]); low++; mid++"," elif arr[mid] == 1:"," mid++"," else: // arr[mid] == 2"," swap(arr[mid], arr[high]); high--"," return arr"]},"top-k-frequent":{title:"Top K Frequent Elements",subtitle:"Count, rank, and extract frequent values",inputLabel:"Numbers; k",defaultInput:"1,1,1,2,2,3,3,3,3,4,5,5;3",helper:"Format: comma-separated numbers; k",pseudocode:["function topKFrequent(arr, k):"," counts = {}"," for value in arr:"," counts[value] += 1 // tally frequency"," ranked = sortByCountDescending(counts)"," return ranked[0 .. k]"]},"queue-using-stacks":{title:"Queue Using Two Stacks",subtitle:"Build FIFO behavior from LIFO stacks",inputLabel:"Enqueue values",defaultInput:"10,20,30,40",helper:"Values are enqueued, then all are dequeued.",pseudocode:["enqueue(x):"," input.push(x)","","dequeue():"," if output.isEmpty():"," while not input.isEmpty():"," output.push(input.pop()) // reverse order"," return output.pop()"]},"stack-using-queues":{title:"Stack Using Two Queues",subtitle:"Build LIFO behavior from FIFO queues",inputLabel:"Push values",defaultInput:"10,20,30,40",helper:"Values are pushed, then all are popped.",pseudocode:["push(x):"," helper.enqueue(x)"," while not primary.isEmpty():"," helper.enqueue(primary.dequeue())"," swap(primary, helper) // x now at front","","pop():"," return primary.dequeue()"]},"tower-of-hanoi":{title:"Tower of Hanoi",subtitle:"Recursive disk movement",inputLabel:"Disk count",defaultInput:"4",helper:"Use 2 to 5 disks for readable playback.",pseudocode:["function hanoi(n, from, to, aux):"," if n == 0: return"," hanoi(n - 1, from, aux, to) // move top n-1 aside"," move disk n: from -> to"," hanoi(n - 1, aux, to, from) // move them onto target"]},"rat-maze":{title:"Rat in a Maze",subtitle:"Recursive DFS and BFS on blocked cells",inputLabel:"Mode",defaultInput:"dfs",helper:"Use dfs or bfs. The maze is generated in the visualizer.",pseudocode:["function solve(grid, mode):"," frontier = [start]; visited = {start}"," while frontier not empty:"," cell = mode == DFS ? frontier.pop() : frontier.shift()"," if cell == target: break"," for n in freeNeighbors(cell):"," if n not visited:"," visited.add(n); parent[n] = cell"," frontier.push(n)"," return reconstructPath(parent, target)"]},"grid-search":{title:"Grid Search",subtitle:"Search allowed positions from source to target",inputLabel:"Mode",defaultInput:"bfs",helper:"Use bfs or dfs over free/occupied grid cells.",pseudocode:["function search(grid, mode):"," frontier = [start]; visited = {start}"," while frontier not empty:"," cell = mode == DFS ? frontier.pop() : frontier.shift()"," if cell == target: break"," for n in freeNeighbors(cell):"," if n not visited:"," visited.add(n); parent[n] = cell"," frontier.push(n)"," return reconstructPath(parent, target)"]}};function le({demo:a}){const n=T[a],[e,o]=b.useState(n.defaultInput),[s,t]=b.useState(()=>j(a,n.defaultInput)),[r,l]=b.useState(0),[d,u]=b.useState(800),{soundEnabled:p,toggleSound:g,playEvent:h}=M(),m=s[r]??s[0],$=s.length>0?(r+1)/s.length*100:0,S=()=>{const c=j(a,e);t(c),l(0),h(c[0]?.event??"visit",0,c.length)},L=()=>{const c=Z(a);o(c);const f=j(a,c);t(f),l(0)},w=c=>{const f=Math.max(0,Math.min(s.length-1,c));l(f);const y=s[f];y&&h(y.event,f,s.length)},q=()=>{for(let c=r;c{l(c);const f=s[c];f&&h(f.event,c,s.length)},(c-r)*d)};return i.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[i.jsxs("main",{className:"order-last flex min-h-[520px] flex-1 flex-col gap-4 xl:order-first",children:[i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm",children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-indigo-300",children:"Algorithms"}),i.jsx("h2",{className:"mt-1 text-xl font-bold text-white",children:n.title}),i.jsx("p",{className:"mt-1 text-sm text-slate-400",children:n.subtitle})]}),i.jsx(D,{step:m,demo:a}),i.jsx(C,{pseudocode:n.pseudocode,activeLine:m?.codeLine??null})]}),i.jsxs("aside",{className:"w-full space-y-4 xl:w-80 xl:shrink-0",children:[i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Input"}),i.jsx("label",{className:"text-[11px] text-slate-500",children:n.inputLabel}),i.jsx("textarea",{value:e,onChange:c=>o(c.target.value),rows:2,className:"mt-1 w-full resize-none rounded-xl bg-slate-950/70 px-3 py-2 text-xs font-mono text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-indigo-500/50"}),i.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:n.helper}),i.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[i.jsx("button",{onClick:S,className:"rounded-xl bg-indigo-500/20 px-3 py-2 text-xs font-semibold text-indigo-300 ring-1 ring-indigo-500/40 hover:bg-indigo-500/30",children:"Run"}),i.jsxs("button",{onClick:L,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[i.jsx(F,{size:13})," Random"]})]})]}),i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Step Playback"}),i.jsxs("span",{className:"font-mono text-xs text-indigo-300",children:[Math.min(r+1,s.length)," / ",s.length]})]}),i.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-slate-800",children:i.jsx("div",{className:"h-full rounded-full bg-indigo-400 transition-all",style:{width:`${$}%`}})}),i.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Animation Speed"}),i.jsxs("span",{className:"font-mono text-[10px] text-indigo-300",children:[(d/1e3).toFixed(2),"s"]})]}),i.jsx("input",{type:"range",min:120,max:3e3,step:20,value:3120-d,onChange:c=>u(3120-Number(c.target.value)),className:"w-full accent-indigo-400","aria-label":"Animation speed"}),i.jsxs("div",{className:"mt-1 flex justify-between text-[9px] uppercase tracking-wide text-slate-600",children:[i.jsx("span",{children:"Slow"}),i.jsx("span",{children:"Fast"})]})]}),i.jsx("p",{className:"mt-3 min-h-12 text-xs leading-relaxed text-slate-300",children:m?.description}),m?.meta&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:m.meta.map(c=>i.jsx("span",{className:"rounded-full bg-slate-800/80 px-2 py-0.5 text-[10px] font-mono text-slate-400",children:c},c))}),i.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[i.jsxs("button",{onClick:()=>w(r-1),disabled:r<=0,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:[i.jsx(I,{size:13})," Back"]}),i.jsxs("button",{onClick:q,disabled:r>=s.length-1,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-emerald-500/15 px-2 py-2 text-xs font-semibold text-emerald-300 ring-1 ring-emerald-500/30 disabled:opacity-30",children:[i.jsx(R,{size:13})," Play"]}),i.jsxs("button",{onClick:()=>w(r+1),disabled:r>=s.length-1,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:["Next ",i.jsx(z,{size:13})]})]}),i.jsxs("button",{onClick:()=>w(0),className:"mt-2 inline-flex w-full items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[i.jsx(A,{size:13})," Reset Steps"]})]}),i.jsx("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:i.jsxs("button",{onClick:()=>g(!p),className:`inline-flex w-full items-center justify-center gap-2 rounded-xl px-3 py-2 text-xs font-semibold ring-1 ${p?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[p?i.jsx(P,{size:14}):i.jsx(E,{size:14}),p?"Sound On":"Sound Off"]})})]})]})}function D({step:a,demo:n}){return a?a.grid?i.jsx(B,{step:a}):a.pegs?i.jsx(U,{pegs:a.pegs}):a.stacks||a.queues?i.jsx(O,{step:a}):i.jsx(V,{step:a,demo:n}):null}function V({step:a,demo:n}){const e=a.values??[],o=new Set(a.highlights??[]),s=(t,r)=>n==="dutch-national-flag"?t===0?"bg-sky-500/25 text-sky-200 ring-sky-500/40":t===1?"bg-white/15 text-white ring-white/30":"bg-rose-500/25 text-rose-200 ring-rose-500/40":o.has(r)?"bg-indigo-500/25 text-indigo-200 ring-indigo-500/50":"bg-slate-800/70 text-slate-200 ring-slate-700/50";return i.jsx("section",{className:"flex flex-1 flex-col items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5",children:i.jsx("div",{className:"flex max-w-full flex-wrap items-end justify-center gap-2",children:e.map((t,r)=>i.jsxs("div",{className:`relative flex h-16 min-w-12 items-center justify-center rounded-xl px-3 font-mono text-sm font-black ring-1 transition-all ${s(t,r)}`,children:[t,Object.entries(a.pointers??{}).filter(([,l])=>l===r).map(([l])=>i.jsx("span",{className:"absolute -bottom-5 text-[9px] uppercase tracking-wide text-amber-300",children:l},l))]},`${t}-${r}`))})})}function O({step:a}){const n=a.stacks??a.queues??{};return i.jsx("section",{className:"grid flex-1 gap-4 rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5 md:grid-cols-2",children:Object.entries(n).map(([e,o])=>i.jsxs("div",{className:"flex flex-col justify-end rounded-xl bg-slate-900/70 p-4 ring-1 ring-slate-700/50",children:[i.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:e}),i.jsx("div",{className:"flex min-h-64 flex-col-reverse gap-2",children:o.map((s,t)=>i.jsx("div",{className:"rounded-lg bg-indigo-500/15 px-3 py-2 text-center font-mono text-sm font-bold text-indigo-200 ring-1 ring-indigo-500/30",children:s},`${e}-${s}-${t}`))})]},e))})}function U({pegs:a}){return i.jsx("section",{className:"grid flex-1 items-end gap-4 rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5 md:grid-cols-3",children:a.map((n,e)=>i.jsxs("div",{className:"relative flex h-72 flex-col-reverse items-center justify-start gap-1 rounded-xl bg-slate-900/70 p-4 ring-1 ring-slate-700/50",children:[i.jsx("div",{className:"absolute bottom-4 h-56 w-2 rounded-full bg-slate-700"}),n.map(o=>i.jsx("div",{className:"z-10 h-6 rounded-md bg-gradient-to-r from-cyan-500 to-indigo-500 ring-1 ring-cyan-300/40",style:{width:`${o*34+34}px`}},`${e}-${o}`)),i.jsxs("span",{className:"absolute bottom-0 text-[10px] font-mono text-slate-500",children:["Peg ",e+1]})]},e))})}function B({step:a}){const n=new Set(a.visited??[]),e=new Set(a.path??[]);return i.jsx("section",{className:"flex flex-1 items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5",children:i.jsx("div",{className:"grid gap-1",style:{gridTemplateColumns:`repeat(${a.grid?.[0]?.length??0}, minmax(0, 1fr))`},children:a.grid?.flatMap((o,s)=>o.map((t,r)=>{const l=s*o.length+r,d=e.has(l),u=n.has(l),p=l===0,g=l===o.length*(a.grid?.length??1)-1,h=t===1?"bg-slate-800 ring-slate-700":d?"bg-emerald-400 ring-emerald-200":p?"bg-sky-400 ring-sky-200":g?"bg-orange-400 ring-orange-200":u?"bg-indigo-500/70 ring-indigo-300":"bg-slate-900 ring-slate-700";return i.jsx("div",{className:`h-9 w-9 rounded-md ring-1 ${h}`},l)}))})})}function j(a,n){switch(a){case"binary-search":return G(n);case"ternary-search":return _(n);case"dutch-national-flag":return K(n);case"top-k-frequent":return Q(n);case"queue-using-stacks":return H(n);case"stack-using-queues":return X(n);case"tower-of-hanoi":return J(n);case"rat-maze":return k(n,!0);case"grid-search":return k(n,!1);default:return[]}}function x(a){return a.split(",").map(n=>n.trim()).filter(Boolean).map(Number).filter(Number.isFinite)}function N(a){const[n,e]=a.split(";");return{values:x(n??"").sort((o,s)=>o-s),target:Number(e)}}function G(a){const{values:n,target:e}=N(a),o=[];let s=0,t=n.length-1;for(;s<=t;){const r=Math.floor((s+t)/2);if(o.push({description:`Compare target ${e} with middle value ${n[r]} at index ${r}.`,event:"compare",values:n,highlights:[r],pointers:{low:s,mid:r,high:t},codeLine:4}),n[r]===e)return o.push({description:`Found ${e} at index ${r}.`,event:"found",values:n,highlights:[r],pointers:{low:s,mid:r,high:t},codeLine:4}),o;n[r]n[d]?s=d+1:(s=l+1,t=d-1)}return[...o,{description:`${e} is not present in the sorted array.`,event:"not-found",values:n,codeLine:10}]}function K(a){const e=[...x(a).filter(l=>l===0||l===1||l===2)],o=[{description:"Start with low, mid, and high pointers.",event:"visit",values:[...e],pointers:{low:0,mid:0,high:e.length-1},codeLine:1}];let s=0,t=0,r=e.length-1;for(;t<=r;)e[t]===0?([e[s],e[t]]=[e[t],e[s]],o.push({description:`Swap 0 at mid ${t} with low ${s}.`,event:"swap",values:[...e],highlights:[s,t],pointers:{low:s,mid:t,high:r},codeLine:4}),s+=1,t+=1):e[t]===1?(o.push({description:`Value 1 at mid ${t} is already in the middle partition.`,event:"compare",values:[...e],highlights:[t],pointers:{low:s,mid:t,high:r},codeLine:6}),t+=1):([e[t],e[r]]=[e[r],e[t]],o.push({description:`Swap 2 at mid ${t} with high ${r}.`,event:"swap",values:[...e],highlights:[t,r],pointers:{low:s,mid:t,high:r},codeLine:8}),r-=1);return[...o,{description:"Colors are sorted: all 0s, then 1s, then 2s.",event:"complete",values:[...e],codeLine:9}]}function Q(a){const[n,e]=a.split(";"),o=x(n??""),s=Math.max(1,Number(e)||3),t=new Map,r=[];o.forEach((d,u)=>{t.set(d,(t.get(d)??0)+1),r.push({description:`Count ${d}: frequency is now ${t.get(d)}.`,event:"visit",values:o,highlights:[u],meta:[...t.entries()].map(([p,g])=>`${p}:${g}`),codeLine:3})});const l=[...t.entries()].sort((d,u)=>u[1]-d[1]).map(([d])=>d);return[...r,{description:`Top ${s} frequent elements: ${l.slice(0,s).join(", ")}.`,event:"complete",values:l,highlights:l.slice(0,s).map((d,u)=>u),meta:[...t.entries()].map(([d,u])=>`${d}:${u}`),codeLine:5}]}function H(a){const n=x(a),e=[],o=[],s=[];for(n.forEach(t=>{e.push(t),s.push({description:`Enqueue ${t}: push onto input stack.`,event:"push",stacks:{input:[...e],output:[...o]},codeLine:1})});e.length>0;){const t=e.pop();o.push(t),s.push({description:`Move ${t} from input to output stack to expose queue front.`,event:"pop",stacks:{input:[...e],output:[...o]},codeLine:6})}for(;o.length>0;){const t=o.pop();s.push({description:`Dequeue ${t} from output stack.`,event:"dequeue",stacks:{input:[...e],output:[...o]},codeLine:7})}return s}function X(a){const n=x(a);let e=[],o=[];const s=[];for(n.forEach(t=>{for(o.push(t),s.push({description:`Push ${t}: enqueue into helper queue.`,event:"enqueue",queues:{primary:[...e],helper:[...o]},codeLine:1});e.length>0;)o.push(e.shift());[e,o]=[o,[]],s.push({description:`Rotate queues so ${t} becomes the next pop.`,event:"visit",queues:{primary:[...e],helper:[...o]},codeLine:4})});e.length>0;){const t=e.shift();s.push({description:`Pop ${t} from primary queue front.`,event:"dequeue",queues:{primary:[...e],helper:[...o]},codeLine:7})}return s}function J(a){const n=Math.max(2,Math.min(5,Number(a)||4)),e=[Array.from({length:n},(t,r)=>n-r),[],[]],o=[{description:`Start with ${n} disks on peg 1.`,event:"recurse",pegs:v(e),codeLine:0}],s=(t,r,l,d)=>{if(t===0)return;o.push({description:`Solve subproblem: move ${t-1} disk(s) from peg ${r+1} to peg ${d+1}.`,event:"recurse",pegs:v(e),codeLine:2}),s(t-1,r,d,l);const u=e[r].pop();u&&e[l].push(u),o.push({description:`Move disk ${u} from peg ${r+1} to peg ${l+1}.`,event:"visit",pegs:v(e),codeLine:3}),s(t-1,d,l,r)};return s(n,0,2,1),[...o,{description:"Tower complete.",event:"complete",pegs:v(e),codeLine:4}]}function v(a){return a.map(n=>[...n])}const W=[[0,0,0,1,0,0,0],[1,1,0,1,0,1,0],[0,0,0,0,0,1,0],[0,1,1,1,0,0,0],[0,0,0,1,1,1,0],[0,1,0,0,0,0,0]];function k(a,n){const e=a.trim().toLowerCase()==="dfs"?"dfs":"bfs",o=W.map(h=>[...h]),s=o[0].length,t=o.length*s-1,r=new Set,l=new Map,d=[],u=[0];for(r.add(0);u.length>0;){const h=e==="dfs"?u.pop():u.shift();if(d.push({description:`${n?"Rat maze":"Grid search"} ${e.toUpperCase()}: visit cell (${Math.floor(h/s)}, ${h%s}).`,event:e==="dfs"?"recurse":"visit",grid:o,visited:[...r],path:[h],codeLine:3}),h===t)break;for(const m of Y(h,o))r.has(m)||(r.add(m),l.set(m,h),u.push(m),d.push({description:`Add allowed neighbor (${Math.floor(m/s)}, ${m%s}) to ${e==="dfs"?"stack":"queue"}.`,event:e==="dfs"?"push":"enqueue",grid:o,visited:[...r],path:[m],codeLine:8}))}const p=[];let g=t;for(;g!==void 0&&(g===0||l.has(g))&&(p.unshift(g),g!==0);)g=l.get(g);return[...d,{description:p[0]===0?`Found path with ${p.length} cells.`:"No path found.",event:p[0]===0?"found":"not-found",grid:o,visited:[...r],path:p,codeLine:9}]}function Y(a,n){const e=n[0].length,o=Math.floor(a/e),s=a%e;return[[o-1,s],[o+1,s],[o,s-1],[o,s+1]].filter(([t,r])=>t>=0&&r>=0&&tt*e+r)}function Z(a){const n=Array.from({length:9},()=>Math.floor(Math.random()*40)+1);switch(a){case"binary-search":case"ternary-search":{const e=[...n].sort((t,r)=>t-r),o=Math.floor(e.length/2);let s=Math.floor(Math.random()*e.length);return a==="binary-search"&&e.length>1&&s===o&&(s=(s+1)%e.length),`${e.join(",")};${e[s]}`}case"dutch-national-flag":return Array.from({length:10},()=>Math.floor(Math.random()*3)).join(",");case"top-k-frequent":return`${Array.from({length:12},()=>Math.floor(Math.random()*5)+1).join(",")};3`;case"tower-of-hanoi":return String(Math.floor(Math.random()*3)+3);case"rat-maze":return Math.random()>.5?"dfs":"bfs";case"grid-search":return Math.random()>.5?"dfs":"bfs";default:return n.slice(0,4).join(",")}}export{le as default}; +import{r as b,j as i}from"./index-DBkLeWDs.js";import{u as M,A as C}from"./AlgorithmCodePanel-CE3r0DXd.js";import{S as F}from"./shuffle-Dlr-c52A.js";import{C as I,a as z}from"./chevron-right-CFBAUJsk.js";import{P as R}from"./play-mcIZClKO.js";import{R as A}from"./rotate-ccw-7GTUOPy4.js";import{V as P,a as E}from"./volume-x-BSx9gxSg.js";import"./audioContext-NbgqvQGz.js";const T={"binary-search":{title:"Binary Search",subtitle:"Search a sorted array in logarithmic time",inputLabel:"Sorted numbers; target",defaultInput:"2,5,8,12,16,23,38,56,72;23",helper:"Format: sorted comma-separated numbers; target",pseudocode:["function binarySearch(arr, target):"," low = 0; high = arr.length - 1"," while low <= high:"," mid = (low + high) / 2"," if arr[mid] == target: return mid"," if arr[mid] < target: low = mid + 1"," else: high = mid - 1"," return -1 // not found"]},"ternary-search":{title:"Ternary Search",subtitle:"Split a sorted search range into thirds",inputLabel:"Sorted numbers; target",defaultInput:"1,4,8,11,15,19,23,27,31,35,39;31",helper:"Format: sorted comma-separated numbers; target",pseudocode:["function ternarySearch(arr, target):"," low = 0; high = arr.length - 1"," while low <= high:"," mid1 = low + (high - low) / 3"," mid2 = high - (high - low) / 3"," if arr[mid1] == target: return mid1"," if arr[mid2] == target: return mid2"," if target < arr[mid1]: high = mid1 - 1"," elif target > arr[mid2]: low = mid2 + 1"," else: low = mid1 + 1; high = mid2 - 1"," return -1 // not found"]},"dutch-national-flag":{title:"Sort Colors",subtitle:"Dutch national flag partitioning",inputLabel:"Colors as 0, 1, 2",defaultInput:"2,0,2,1,1,0,2,0,1",helper:"Use only 0, 1, and 2.",pseudocode:["function sortColors(arr):"," low = 0; mid = 0; high = arr.length - 1"," while mid <= high:"," if arr[mid] == 0:"," swap(arr[low], arr[mid]); low++; mid++"," elif arr[mid] == 1:"," mid++"," else: // arr[mid] == 2"," swap(arr[mid], arr[high]); high--"," return arr"]},"top-k-frequent":{title:"Top K Frequent Elements",subtitle:"Count, rank, and extract frequent values",inputLabel:"Numbers; k",defaultInput:"1,1,1,2,2,3,3,3,3,4,5,5;3",helper:"Format: comma-separated numbers; k",pseudocode:["function topKFrequent(arr, k):"," counts = {}"," for value in arr:"," counts[value] += 1 // tally frequency"," ranked = sortByCountDescending(counts)"," return ranked[0 .. k]"]},"queue-using-stacks":{title:"Queue Using Two Stacks",subtitle:"Build FIFO behavior from LIFO stacks",inputLabel:"Enqueue values",defaultInput:"10,20,30,40",helper:"Values are enqueued, then all are dequeued.",pseudocode:["enqueue(x):"," input.push(x)","","dequeue():"," if output.isEmpty():"," while not input.isEmpty():"," output.push(input.pop()) // reverse order"," return output.pop()"]},"stack-using-queues":{title:"Stack Using Two Queues",subtitle:"Build LIFO behavior from FIFO queues",inputLabel:"Push values",defaultInput:"10,20,30,40",helper:"Values are pushed, then all are popped.",pseudocode:["push(x):"," helper.enqueue(x)"," while not primary.isEmpty():"," helper.enqueue(primary.dequeue())"," swap(primary, helper) // x now at front","","pop():"," return primary.dequeue()"]},"tower-of-hanoi":{title:"Tower of Hanoi",subtitle:"Recursive disk movement",inputLabel:"Disk count",defaultInput:"4",helper:"Use 2 to 5 disks for readable playback.",pseudocode:["function hanoi(n, from, to, aux):"," if n == 0: return"," hanoi(n - 1, from, aux, to) // move top n-1 aside"," move disk n: from -> to"," hanoi(n - 1, aux, to, from) // move them onto target"]},"rat-maze":{title:"Rat in a Maze",subtitle:"Recursive DFS and BFS on blocked cells",inputLabel:"Mode",defaultInput:"dfs",helper:"Use dfs or bfs. The maze is generated in the visualizer.",pseudocode:["function solve(grid, mode):"," frontier = [start]; visited = {start}"," while frontier not empty:"," cell = mode == DFS ? frontier.pop() : frontier.shift()"," if cell == target: break"," for n in freeNeighbors(cell):"," if n not visited:"," visited.add(n); parent[n] = cell"," frontier.push(n)"," return reconstructPath(parent, target)"]},"grid-search":{title:"Grid Search",subtitle:"Search allowed positions from source to target",inputLabel:"Mode",defaultInput:"bfs",helper:"Use bfs or dfs over free/occupied grid cells.",pseudocode:["function search(grid, mode):"," frontier = [start]; visited = {start}"," while frontier not empty:"," cell = mode == DFS ? frontier.pop() : frontier.shift()"," if cell == target: break"," for n in freeNeighbors(cell):"," if n not visited:"," visited.add(n); parent[n] = cell"," frontier.push(n)"," return reconstructPath(parent, target)"]}};function le({demo:a}){const n=T[a],[e,o]=b.useState(n.defaultInput),[s,t]=b.useState(()=>j(a,n.defaultInput)),[r,l]=b.useState(0),[d,u]=b.useState(800),{soundEnabled:p,toggleSound:g,playEvent:h}=M(),m=s[r]??s[0],$=s.length>0?(r+1)/s.length*100:0,S=()=>{const c=j(a,e);t(c),l(0),h(c[0]?.event??"visit",0,c.length)},L=()=>{const c=Z(a);o(c);const f=j(a,c);t(f),l(0)},w=c=>{const f=Math.max(0,Math.min(s.length-1,c));l(f);const y=s[f];y&&h(y.event,f,s.length)},q=()=>{for(let c=r;c{l(c);const f=s[c];f&&h(f.event,c,s.length)},(c-r)*d)};return i.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[i.jsxs("main",{className:"order-last flex min-h-[520px] flex-1 flex-col gap-4 xl:order-first",children:[i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm",children:[i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-indigo-300",children:"Algorithms"}),i.jsx("h2",{className:"mt-1 text-xl font-bold text-white",children:n.title}),i.jsx("p",{className:"mt-1 text-sm text-slate-400",children:n.subtitle})]}),i.jsx(D,{step:m,demo:a}),i.jsx(C,{pseudocode:n.pseudocode,activeLine:m?.codeLine??null})]}),i.jsxs("aside",{className:"w-full space-y-4 xl:w-80 xl:shrink-0",children:[i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Input"}),i.jsx("label",{className:"text-[11px] text-slate-500",children:n.inputLabel}),i.jsx("textarea",{value:e,onChange:c=>o(c.target.value),rows:2,className:"mt-1 w-full resize-none rounded-xl bg-slate-950/70 px-3 py-2 text-xs font-mono text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-indigo-500/50"}),i.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:n.helper}),i.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[i.jsx("button",{onClick:S,className:"rounded-xl bg-indigo-500/20 px-3 py-2 text-xs font-semibold text-indigo-300 ring-1 ring-indigo-500/40 hover:bg-indigo-500/30",children:"Run"}),i.jsxs("button",{onClick:L,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[i.jsx(F,{size:13})," Random"]})]})]}),i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Step Playback"}),i.jsxs("span",{className:"font-mono text-xs text-indigo-300",children:[Math.min(r+1,s.length)," / ",s.length]})]}),i.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-slate-800",children:i.jsx("div",{className:"h-full rounded-full bg-indigo-400 transition-all",style:{width:`${$}%`}})}),i.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Animation Speed"}),i.jsxs("span",{className:"font-mono text-[10px] text-indigo-300",children:[(d/1e3).toFixed(2),"s"]})]}),i.jsx("input",{type:"range",min:120,max:3e3,step:20,value:3120-d,onChange:c=>u(3120-Number(c.target.value)),className:"w-full accent-indigo-400","aria-label":"Animation speed"}),i.jsxs("div",{className:"mt-1 flex justify-between text-[9px] uppercase tracking-wide text-slate-600",children:[i.jsx("span",{children:"Slow"}),i.jsx("span",{children:"Fast"})]})]}),i.jsx("p",{className:"mt-3 min-h-12 text-xs leading-relaxed text-slate-300",children:m?.description}),m?.meta&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:m.meta.map(c=>i.jsx("span",{className:"rounded-full bg-slate-800/80 px-2 py-0.5 text-[10px] font-mono text-slate-400",children:c},c))}),i.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[i.jsxs("button",{onClick:()=>w(r-1),disabled:r<=0,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:[i.jsx(I,{size:13})," Back"]}),i.jsxs("button",{onClick:q,disabled:r>=s.length-1,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-emerald-500/15 px-2 py-2 text-xs font-semibold text-emerald-300 ring-1 ring-emerald-500/30 disabled:opacity-30",children:[i.jsx(R,{size:13})," Play"]}),i.jsxs("button",{onClick:()=>w(r+1),disabled:r>=s.length-1,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:["Next ",i.jsx(z,{size:13})]})]}),i.jsxs("button",{onClick:()=>w(0),className:"mt-2 inline-flex w-full items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[i.jsx(A,{size:13})," Reset Steps"]})]}),i.jsx("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:i.jsxs("button",{onClick:()=>g(!p),className:`inline-flex w-full items-center justify-center gap-2 rounded-xl px-3 py-2 text-xs font-semibold ring-1 ${p?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[p?i.jsx(P,{size:14}):i.jsx(E,{size:14}),p?"Sound On":"Sound Off"]})})]})]})}function D({step:a,demo:n}){return a?a.grid?i.jsx(B,{step:a}):a.pegs?i.jsx(U,{pegs:a.pegs}):a.stacks||a.queues?i.jsx(O,{step:a}):i.jsx(V,{step:a,demo:n}):null}function V({step:a,demo:n}){const e=a.values??[],o=new Set(a.highlights??[]),s=(t,r)=>n==="dutch-national-flag"?t===0?"bg-sky-500/25 text-sky-200 ring-sky-500/40":t===1?"bg-white/15 text-white ring-white/30":"bg-rose-500/25 text-rose-200 ring-rose-500/40":o.has(r)?"bg-indigo-500/25 text-indigo-200 ring-indigo-500/50":"bg-slate-800/70 text-slate-200 ring-slate-700/50";return i.jsx("section",{className:"flex flex-1 flex-col items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5",children:i.jsx("div",{className:"flex max-w-full flex-wrap items-end justify-center gap-2",children:e.map((t,r)=>i.jsxs("div",{className:`relative flex h-16 min-w-12 items-center justify-center rounded-xl px-3 font-mono text-sm font-black ring-1 transition-all ${s(t,r)}`,children:[t,Object.entries(a.pointers??{}).filter(([,l])=>l===r).map(([l])=>i.jsx("span",{className:"absolute -bottom-5 text-[9px] uppercase tracking-wide text-amber-300",children:l},l))]},`${t}-${r}`))})})}function O({step:a}){const n=a.stacks??a.queues??{};return i.jsx("section",{className:"grid flex-1 gap-4 rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5 md:grid-cols-2",children:Object.entries(n).map(([e,o])=>i.jsxs("div",{className:"flex flex-col justify-end rounded-xl bg-slate-900/70 p-4 ring-1 ring-slate-700/50",children:[i.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:e}),i.jsx("div",{className:"flex min-h-64 flex-col-reverse gap-2",children:o.map((s,t)=>i.jsx("div",{className:"rounded-lg bg-indigo-500/15 px-3 py-2 text-center font-mono text-sm font-bold text-indigo-200 ring-1 ring-indigo-500/30",children:s},`${e}-${s}-${t}`))})]},e))})}function U({pegs:a}){return i.jsx("section",{className:"grid flex-1 items-end gap-4 rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5 md:grid-cols-3",children:a.map((n,e)=>i.jsxs("div",{className:"relative flex h-72 flex-col-reverse items-center justify-start gap-1 rounded-xl bg-slate-900/70 p-4 ring-1 ring-slate-700/50",children:[i.jsx("div",{className:"absolute bottom-4 h-56 w-2 rounded-full bg-slate-700"}),n.map(o=>i.jsx("div",{className:"z-10 h-6 rounded-md bg-gradient-to-r from-cyan-500 to-indigo-500 ring-1 ring-cyan-300/40",style:{width:`${o*34+34}px`}},`${e}-${o}`)),i.jsxs("span",{className:"absolute bottom-0 text-[10px] font-mono text-slate-500",children:["Peg ",e+1]})]},e))})}function B({step:a}){const n=new Set(a.visited??[]),e=new Set(a.path??[]);return i.jsx("section",{className:"flex flex-1 items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-950/60 p-5",children:i.jsx("div",{className:"grid gap-1",style:{gridTemplateColumns:`repeat(${a.grid?.[0]?.length??0}, minmax(0, 1fr))`},children:a.grid?.flatMap((o,s)=>o.map((t,r)=>{const l=s*o.length+r,d=e.has(l),u=n.has(l),p=l===0,g=l===o.length*(a.grid?.length??1)-1,h=t===1?"bg-slate-800 ring-slate-700":d?"bg-emerald-400 ring-emerald-200":p?"bg-sky-400 ring-sky-200":g?"bg-orange-400 ring-orange-200":u?"bg-indigo-500/70 ring-indigo-300":"bg-slate-900 ring-slate-700";return i.jsx("div",{className:`h-9 w-9 rounded-md ring-1 ${h}`},l)}))})})}function j(a,n){switch(a){case"binary-search":return G(n);case"ternary-search":return _(n);case"dutch-national-flag":return K(n);case"top-k-frequent":return Q(n);case"queue-using-stacks":return H(n);case"stack-using-queues":return X(n);case"tower-of-hanoi":return J(n);case"rat-maze":return k(n,!0);case"grid-search":return k(n,!1);default:return[]}}function x(a){return a.split(",").map(n=>n.trim()).filter(Boolean).map(Number).filter(Number.isFinite)}function N(a){const[n,e]=a.split(";");return{values:x(n??"").sort((o,s)=>o-s),target:Number(e)}}function G(a){const{values:n,target:e}=N(a),o=[];let s=0,t=n.length-1;for(;s<=t;){const r=Math.floor((s+t)/2);if(o.push({description:`Compare target ${e} with middle value ${n[r]} at index ${r}.`,event:"compare",values:n,highlights:[r],pointers:{low:s,mid:r,high:t},codeLine:4}),n[r]===e)return o.push({description:`Found ${e} at index ${r}.`,event:"found",values:n,highlights:[r],pointers:{low:s,mid:r,high:t},codeLine:4}),o;n[r]n[d]?s=d+1:(s=l+1,t=d-1)}return[...o,{description:`${e} is not present in the sorted array.`,event:"not-found",values:n,codeLine:10}]}function K(a){const e=[...x(a).filter(l=>l===0||l===1||l===2)],o=[{description:"Start with low, mid, and high pointers.",event:"visit",values:[...e],pointers:{low:0,mid:0,high:e.length-1},codeLine:1}];let s=0,t=0,r=e.length-1;for(;t<=r;)e[t]===0?([e[s],e[t]]=[e[t],e[s]],o.push({description:`Swap 0 at mid ${t} with low ${s}.`,event:"swap",values:[...e],highlights:[s,t],pointers:{low:s,mid:t,high:r},codeLine:4}),s+=1,t+=1):e[t]===1?(o.push({description:`Value 1 at mid ${t} is already in the middle partition.`,event:"compare",values:[...e],highlights:[t],pointers:{low:s,mid:t,high:r},codeLine:6}),t+=1):([e[t],e[r]]=[e[r],e[t]],o.push({description:`Swap 2 at mid ${t} with high ${r}.`,event:"swap",values:[...e],highlights:[t,r],pointers:{low:s,mid:t,high:r},codeLine:8}),r-=1);return[...o,{description:"Colors are sorted: all 0s, then 1s, then 2s.",event:"complete",values:[...e],codeLine:9}]}function Q(a){const[n,e]=a.split(";"),o=x(n??""),s=Math.max(1,Number(e)||3),t=new Map,r=[];o.forEach((d,u)=>{t.set(d,(t.get(d)??0)+1),r.push({description:`Count ${d}: frequency is now ${t.get(d)}.`,event:"visit",values:o,highlights:[u],meta:[...t.entries()].map(([p,g])=>`${p}:${g}`),codeLine:3})});const l=[...t.entries()].sort((d,u)=>u[1]-d[1]).map(([d])=>d);return[...r,{description:`Top ${s} frequent elements: ${l.slice(0,s).join(", ")}.`,event:"complete",values:l,highlights:l.slice(0,s).map((d,u)=>u),meta:[...t.entries()].map(([d,u])=>`${d}:${u}`),codeLine:5}]}function H(a){const n=x(a),e=[],o=[],s=[];for(n.forEach(t=>{e.push(t),s.push({description:`Enqueue ${t}: push onto input stack.`,event:"push",stacks:{input:[...e],output:[...o]},codeLine:1})});e.length>0;){const t=e.pop();o.push(t),s.push({description:`Move ${t} from input to output stack to expose queue front.`,event:"pop",stacks:{input:[...e],output:[...o]},codeLine:6})}for(;o.length>0;){const t=o.pop();s.push({description:`Dequeue ${t} from output stack.`,event:"dequeue",stacks:{input:[...e],output:[...o]},codeLine:7})}return s}function X(a){const n=x(a);let e=[],o=[];const s=[];for(n.forEach(t=>{for(o.push(t),s.push({description:`Push ${t}: enqueue into helper queue.`,event:"enqueue",queues:{primary:[...e],helper:[...o]},codeLine:1});e.length>0;)o.push(e.shift());[e,o]=[o,[]],s.push({description:`Rotate queues so ${t} becomes the next pop.`,event:"visit",queues:{primary:[...e],helper:[...o]},codeLine:4})});e.length>0;){const t=e.shift();s.push({description:`Pop ${t} from primary queue front.`,event:"dequeue",queues:{primary:[...e],helper:[...o]},codeLine:7})}return s}function J(a){const n=Math.max(2,Math.min(5,Number(a)||4)),e=[Array.from({length:n},(t,r)=>n-r),[],[]],o=[{description:`Start with ${n} disks on peg 1.`,event:"recurse",pegs:v(e),codeLine:0}],s=(t,r,l,d)=>{if(t===0)return;o.push({description:`Solve subproblem: move ${t-1} disk(s) from peg ${r+1} to peg ${d+1}.`,event:"recurse",pegs:v(e),codeLine:2}),s(t-1,r,d,l);const u=e[r].pop();u&&e[l].push(u),o.push({description:`Move disk ${u} from peg ${r+1} to peg ${l+1}.`,event:"visit",pegs:v(e),codeLine:3}),s(t-1,d,l,r)};return s(n,0,2,1),[...o,{description:"Tower complete.",event:"complete",pegs:v(e),codeLine:4}]}function v(a){return a.map(n=>[...n])}const W=[[0,0,0,1,0,0,0],[1,1,0,1,0,1,0],[0,0,0,0,0,1,0],[0,1,1,1,0,0,0],[0,0,0,1,1,1,0],[0,1,0,0,0,0,0]];function k(a,n){const e=a.trim().toLowerCase()==="dfs"?"dfs":"bfs",o=W.map(h=>[...h]),s=o[0].length,t=o.length*s-1,r=new Set,l=new Map,d=[],u=[0];for(r.add(0);u.length>0;){const h=e==="dfs"?u.pop():u.shift();if(d.push({description:`${n?"Rat maze":"Grid search"} ${e.toUpperCase()}: visit cell (${Math.floor(h/s)}, ${h%s}).`,event:e==="dfs"?"recurse":"visit",grid:o,visited:[...r],path:[h],codeLine:3}),h===t)break;for(const m of Y(h,o))r.has(m)||(r.add(m),l.set(m,h),u.push(m),d.push({description:`Add allowed neighbor (${Math.floor(m/s)}, ${m%s}) to ${e==="dfs"?"stack":"queue"}.`,event:e==="dfs"?"push":"enqueue",grid:o,visited:[...r],path:[m],codeLine:8}))}const p=[];let g=t;for(;g!==void 0&&(g===0||l.has(g))&&(p.unshift(g),g!==0);)g=l.get(g);return[...d,{description:p[0]===0?`Found path with ${p.length} cells.`:"No path found.",event:p[0]===0?"found":"not-found",grid:o,visited:[...r],path:p,codeLine:9}]}function Y(a,n){const e=n[0].length,o=Math.floor(a/e),s=a%e;return[[o-1,s],[o+1,s],[o,s-1],[o,s+1]].filter(([t,r])=>t>=0&&r>=0&&tt*e+r)}function Z(a){const n=Array.from({length:9},()=>Math.floor(Math.random()*40)+1);switch(a){case"binary-search":case"ternary-search":{const e=[...n].sort((t,r)=>t-r),o=Math.floor(e.length/2);let s=Math.floor(Math.random()*e.length);return a==="binary-search"&&e.length>1&&s===o&&(s=(s+1)%e.length),`${e.join(",")};${e[s]}`}case"dutch-national-flag":return Array.from({length:10},()=>Math.floor(Math.random()*3)).join(",");case"top-k-frequent":return`${Array.from({length:12},()=>Math.floor(Math.random()*5)+1).join(",")};3`;case"tower-of-hanoi":return String(Math.floor(Math.random()*3)+3);case"rat-maze":return Math.random()>.5?"dfs":"bfs";case"grid-search":return Math.random()>.5?"dfs":"bfs";default:return n.slice(0,4).join(",")}}export{le as default}; diff --git a/docs/assets/ArrayPage-Y8dJ1gfQ.js b/docs/assets/ArrayPage-CbscCeVa.js similarity index 97% rename from docs/assets/ArrayPage-Y8dJ1gfQ.js rename to docs/assets/ArrayPage-CbscCeVa.js index ce8d69d..6ea979d 100644 --- a/docs/assets/ArrayPage-Y8dJ1gfQ.js +++ b/docs/assets/ArrayPage-CbscCeVa.js @@ -1,4 +1,4 @@ -import{c as te,r as a,j as e,e as se}from"./index-eCXyAnHs.js";import{u as le}from"./useDSSound-CIDAFkgj.js";import{P as F}from"./plus-CffLiizr.js";import{T as ae}from"./trash-2-DQ8BZrIf.js";import{R as ne}from"./rotate-ccw-B8GZP3d7.js";import{S as re}from"./shuffle-CdKU4ZYx.js";import{V as ie,a as oe}from"./volume-x-CTbtCvt-.js";import{C as ce,a as de}from"./chevron-right-BZqZw4c2.js";import"./audioContext-NbgqvQGz.js";const he=[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]],xe=te("mouse-pointer",he);let O=1;const ue=[4,2,7,1,9,3,6].map(h=>({id:O++,value:h}));function ge(){const[h,x]=a.useState(ue),[r,g]=a.useState([]),[i,c]=a.useState(-1),[p,k]=a.useState(""),[R,T]=a.useState(""),[D,z]=a.useState([]),[f,E]=a.useState(400),[S,N]=a.useState(!1),m=a.useRef(null),I=a.useRef(f),b=a.useRef(!1),{soundEnabled:L,toggleSound:_,playInsert:v,playDelete:w,playAccess:j,playTraverse:A,playFound:C,playNotFound:P}=le(),V=a.useRef(()=>{});a.useEffect(()=>{I.current=f},[f]),a.useEffect(()=>{if(!b.current||r.length===0)return;b.current=!1,m.current&&clearTimeout(m.current),N(!0);let t=0;const s=()=>{if(t>=r.length-1){N(!1);return}t++,c(t),V.current(t,r),m.current=setTimeout(s,I.current)};m.current=setTimeout(s,I.current)},[r]);const y=a.useCallback((t,s)=>{const n=s[t];n&&(n.highlightColor==="green"?C():n.highlightColor==="red"?w():n.highlightColor==="blue"?j():(n.highlightColor==="yellow"||n.highlightColor==="orange")&&A(t,s.length))},[C,w,j,A]);a.useEffect(()=>{V.current=y},[y]);const W=i>=0&&r[i]?r[i].array:h,l=i>=0?r[i]:null,u=t=>z(s=>[t,...s].slice(0,20)),G=a.useCallback(t=>{x(s=>{if(t<0||t>=s.length)return s;const n=[{description:`Access index ${t}: going to position ${t}...`,array:s,highlightIndices:[],highlightColor:null},{description:`Found value ${s[t].value} at index ${t}.`,array:s,highlightIndices:[t],highlightColor:"blue"}];return g(n),c(0),b.current=!0,j(),u(`Access [${t}] → ${s[t].value}`),s})},[j]),H=a.useCallback((t,s)=>{const n={id:O++,value:t};x(d=>{if(s<0||s>d.length)return d;const o=[];o.push({description:`Insert ${t} at index ${s}: shifting elements right from index ${s}...`,array:d,highlightIndices:Array.from({length:d.length-s},(M,ee)=>s+ee),highlightColor:"orange"});const $=[...d.slice(0,s),n,...d.slice(s)];return o.push({description:`${t} inserted at index ${s}. Array size: ${$.length}`,array:$,highlightIndices:[s],highlightColor:"green"}),g(o),c(0),b.current=!0,v(),u(`Insert ${t} at [${s}]`),$})},[v]),X=a.useCallback(t=>{x(s=>{if(t<0||t>=s.length)return s;const n=s[t].value,d=[{description:`Delete at index ${t}: marking element ${n} for removal...`,array:s,highlightIndices:[t],highlightColor:"red"},{description:"Shifting elements left to fill the gap...",array:s,highlightIndices:Array.from({length:s.length-t-1},($,M)=>t+1+M),highlightColor:"orange"}],o=s.filter(($,M)=>M!==t);return d.push({description:`${n} deleted. Array size: ${o.length}`,array:o,highlightIndices:[],highlightColor:null}),g(d),c(0),b.current=!0,w(),u(`Delete [${t}] → ${n}`),o})},[w]),q=a.useCallback(t=>{x(s=>{const n=[];let d=-1;for(let o=0;o{const s={id:O++,value:t};x(n=>{const d=[...n,s],o=[{description:`Appending ${t} to the end of the array...`,array:n,highlightIndices:[],highlightColor:null},{description:`${t} added at index ${n.length}. Array size: ${d.length}`,array:d,highlightIndices:[d.length-1],highlightColor:"green"}];return g(o),c(0),b.current=!0,v(),u(`Push ${t}`),d})},[v]),J=a.useCallback(()=>{x([]),g([]),c(-1),u("Clear array")},[]),K=a.useCallback(()=>{const t=Math.floor(Math.random()*5)+5,s=Array.from({length:t},()=>({id:O++,value:Math.floor(Math.random()*90)+1}));x(s),g([]),c(-1),u("Random array")},[]),Q=a.useCallback(()=>{c(t=>{const s=Math.min(t+1,r.length-1);return y(s,r),s})},[r,y]),U=a.useCallback(()=>{c(t=>Math.max(t-1,0))},[]),Z=a.useCallback(()=>{if(S){N(!1),m.current&&clearTimeout(m.current);return}if(i>=r.length-1)return;N(!0);let t=i;const s=()=>{if(t>=r.length-1){N(!1);return}t++,c(t),y(t,r),m.current=setTimeout(s,f)};m.current=setTimeout(s,f)},[S,i,r,f,y]);return{array:h,displayArray:W,steps:r,stepIndex:i,currentStep:l,inputValue:p,setInputValue:k,indexValue:R,setIndexValue:T,history:D,speed:f,setSpeed:E,isPlaying:S,access:G,insertAt:H,deleteAt:X,search:q,pushBack:Y,clear:J,generateRandom:K,nextStep:Q,prevStep:U,autoPlay:Z,soundEnabled:L,toggleSound:_,canGoNext:i0}}const me={green:"border-emerald-400 bg-emerald-500/20 text-emerald-300",red:"border-rose-400 bg-rose-500/20 text-rose-300",yellow:"border-amber-400 bg-amber-500/20 text-amber-300",blue:"border-blue-400 bg-blue-500/20 text-blue-300",orange:"border-orange-400 bg-orange-500/20 text-orange-300"},B=12;function pe({array:h,currentStep:x}){const r=h.slice(0,B),g=new Set(x?.highlightIndices??[]),i=x?.highlightColor??null;return e.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full min-h-[300px] gap-6 px-4",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[h.length===0?e.jsx("div",{className:"flex items-center justify-center w-48 h-16 border-2 border-dashed border-slate-700 rounded-lg text-slate-600 text-xs",children:"Empty Array"}):e.jsxs("div",{className:"flex flex-wrap justify-center gap-1.5",children:[r.map((c,p)=>{const k=g.has(p);return e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:` +import{c as te,r as a,j as e,d as se}from"./index-DBkLeWDs.js";import{u as le}from"./useDSSound-KKipmh13.js";import{P as F}from"./plus-DVazsZHX.js";import{T as ae}from"./trash-2-C6_cMdiI.js";import{R as ne}from"./rotate-ccw-7GTUOPy4.js";import{S as re}from"./shuffle-Dlr-c52A.js";import{V as ie,a as oe}from"./volume-x-BSx9gxSg.js";import{C as ce,a as de}from"./chevron-right-CFBAUJsk.js";import"./audioContext-NbgqvQGz.js";const he=[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]],xe=te("mouse-pointer",he);let O=1;const ue=[4,2,7,1,9,3,6].map(h=>({id:O++,value:h}));function ge(){const[h,x]=a.useState(ue),[r,g]=a.useState([]),[i,c]=a.useState(-1),[p,k]=a.useState(""),[R,T]=a.useState(""),[D,z]=a.useState([]),[f,E]=a.useState(400),[S,N]=a.useState(!1),m=a.useRef(null),I=a.useRef(f),b=a.useRef(!1),{soundEnabled:L,toggleSound:_,playInsert:v,playDelete:w,playAccess:j,playTraverse:A,playFound:C,playNotFound:P}=le(),V=a.useRef(()=>{});a.useEffect(()=>{I.current=f},[f]),a.useEffect(()=>{if(!b.current||r.length===0)return;b.current=!1,m.current&&clearTimeout(m.current),N(!0);let t=0;const s=()=>{if(t>=r.length-1){N(!1);return}t++,c(t),V.current(t,r),m.current=setTimeout(s,I.current)};m.current=setTimeout(s,I.current)},[r]);const y=a.useCallback((t,s)=>{const n=s[t];n&&(n.highlightColor==="green"?C():n.highlightColor==="red"?w():n.highlightColor==="blue"?j():(n.highlightColor==="yellow"||n.highlightColor==="orange")&&A(t,s.length))},[C,w,j,A]);a.useEffect(()=>{V.current=y},[y]);const W=i>=0&&r[i]?r[i].array:h,l=i>=0?r[i]:null,u=t=>z(s=>[t,...s].slice(0,20)),G=a.useCallback(t=>{x(s=>{if(t<0||t>=s.length)return s;const n=[{description:`Access index ${t}: going to position ${t}...`,array:s,highlightIndices:[],highlightColor:null},{description:`Found value ${s[t].value} at index ${t}.`,array:s,highlightIndices:[t],highlightColor:"blue"}];return g(n),c(0),b.current=!0,j(),u(`Access [${t}] → ${s[t].value}`),s})},[j]),H=a.useCallback((t,s)=>{const n={id:O++,value:t};x(d=>{if(s<0||s>d.length)return d;const o=[];o.push({description:`Insert ${t} at index ${s}: shifting elements right from index ${s}...`,array:d,highlightIndices:Array.from({length:d.length-s},(M,ee)=>s+ee),highlightColor:"orange"});const $=[...d.slice(0,s),n,...d.slice(s)];return o.push({description:`${t} inserted at index ${s}. Array size: ${$.length}`,array:$,highlightIndices:[s],highlightColor:"green"}),g(o),c(0),b.current=!0,v(),u(`Insert ${t} at [${s}]`),$})},[v]),X=a.useCallback(t=>{x(s=>{if(t<0||t>=s.length)return s;const n=s[t].value,d=[{description:`Delete at index ${t}: marking element ${n} for removal...`,array:s,highlightIndices:[t],highlightColor:"red"},{description:"Shifting elements left to fill the gap...",array:s,highlightIndices:Array.from({length:s.length-t-1},($,M)=>t+1+M),highlightColor:"orange"}],o=s.filter(($,M)=>M!==t);return d.push({description:`${n} deleted. Array size: ${o.length}`,array:o,highlightIndices:[],highlightColor:null}),g(d),c(0),b.current=!0,w(),u(`Delete [${t}] → ${n}`),o})},[w]),q=a.useCallback(t=>{x(s=>{const n=[];let d=-1;for(let o=0;o{const s={id:O++,value:t};x(n=>{const d=[...n,s],o=[{description:`Appending ${t} to the end of the array...`,array:n,highlightIndices:[],highlightColor:null},{description:`${t} added at index ${n.length}. Array size: ${d.length}`,array:d,highlightIndices:[d.length-1],highlightColor:"green"}];return g(o),c(0),b.current=!0,v(),u(`Push ${t}`),d})},[v]),J=a.useCallback(()=>{x([]),g([]),c(-1),u("Clear array")},[]),K=a.useCallback(()=>{const t=Math.floor(Math.random()*5)+5,s=Array.from({length:t},()=>({id:O++,value:Math.floor(Math.random()*90)+1}));x(s),g([]),c(-1),u("Random array")},[]),Q=a.useCallback(()=>{c(t=>{const s=Math.min(t+1,r.length-1);return y(s,r),s})},[r,y]),U=a.useCallback(()=>{c(t=>Math.max(t-1,0))},[]),Z=a.useCallback(()=>{if(S){N(!1),m.current&&clearTimeout(m.current);return}if(i>=r.length-1)return;N(!0);let t=i;const s=()=>{if(t>=r.length-1){N(!1);return}t++,c(t),y(t,r),m.current=setTimeout(s,f)};m.current=setTimeout(s,f)},[S,i,r,f,y]);return{array:h,displayArray:W,steps:r,stepIndex:i,currentStep:l,inputValue:p,setInputValue:k,indexValue:R,setIndexValue:T,history:D,speed:f,setSpeed:E,isPlaying:S,access:G,insertAt:H,deleteAt:X,search:q,pushBack:Y,clear:J,generateRandom:K,nextStep:Q,prevStep:U,autoPlay:Z,soundEnabled:L,toggleSound:_,canGoNext:i0}}const me={green:"border-emerald-400 bg-emerald-500/20 text-emerald-300",red:"border-rose-400 bg-rose-500/20 text-rose-300",yellow:"border-amber-400 bg-amber-500/20 text-amber-300",blue:"border-blue-400 bg-blue-500/20 text-blue-300",orange:"border-orange-400 bg-orange-500/20 text-orange-300"},B=12;function pe({array:h,currentStep:x}){const r=h.slice(0,B),g=new Set(x?.highlightIndices??[]),i=x?.highlightColor??null;return e.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full min-h-[300px] gap-6 px-4",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[h.length===0?e.jsx("div",{className:"flex items-center justify-center w-48 h-16 border-2 border-dashed border-slate-700 rounded-lg text-slate-600 text-xs",children:"Empty Array"}):e.jsxs("div",{className:"flex flex-wrap justify-center gap-1.5",children:[r.map((c,p)=>{const k=g.has(p);return e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:` flex items-center justify-center rounded-lg border-2 w-12 h-12 md:w-14 md:h-14 font-bold text-sm md:text-base transition-all duration-300 ${k&&i?me[i]:"border-slate-600 bg-slate-800/60 text-slate-200"} diff --git a/docs/assets/BalancedTreePage-pB-O0xS6.js b/docs/assets/BalancedTreePage-2nu-ZXqQ.js similarity index 99% rename from docs/assets/BalancedTreePage-pB-O0xS6.js rename to docs/assets/BalancedTreePage-2nu-ZXqQ.js index 305fe21..b3caffd 100644 --- a/docs/assets/BalancedTreePage-pB-O0xS6.js +++ b/docs/assets/BalancedTreePage-2nu-ZXqQ.js @@ -1,4 +1,4 @@ -import{c as jt,r as p,j as a}from"./index-eCXyAnHs.js";import{P as Nt}from"./plus-CffLiizr.js";import{S as wt}from"./shuffle-CdKU4ZYx.js";import{C as $t,a as yt}from"./chevron-right-BZqZw4c2.js";const kt=[["path",{d:"M5 12h14",key:"1ays0h"}]],It=jt("minus",kt);function K(t){return t?[t,...K(t.left),...K(t.right)]:[]}function X(t){if(!t)return[];const e=[];return t.left&&(e.push({from:t,to:t.left}),e.push(...X(t.left))),t.right&&(e.push({from:t,to:t.right}),e.push(...X(t.right))),e}function Rt({root:t,treeType:e,highlightIds:r}){const s=p.useMemo(()=>K(t),[t]),n=p.useMemo(()=>X(t),[t]);if(!t)return a.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center rounded-xl border border-slate-700/50 bg-slate-950/80 text-slate-500",children:"No tree — insert a value to begin"});const l=Math.min(...s.map(u=>u.x),0)-40,i=Math.max(...s.map(u=>u.x),0)+40,c=Math.max(...s.map(u=>u.y),0)+40,h=i-l+80,m=c+80;return a.jsx("div",{className:"flex-1 w-full rounded-xl border border-slate-700/50 bg-slate-950/80 p-4 shadow-2xl backdrop-blur-sm overflow-auto",children:a.jsxs("svg",{viewBox:`${l-40} -20 ${h} ${m}`,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[n.map((u,g)=>a.jsx("line",{x1:u.from.x,y1:u.from.y,x2:u.to.x,y2:u.to.y,stroke:"#475569",strokeWidth:2,strokeOpacity:.5},g)),s.map(u=>{const g=r.includes(u.id),b=e==="rbtree";let N="#1e293b",w="#475569",v="#e2e8f0";return b?u.color==="red"?(N=g?"#f87171":"#dc2626",w="#fca5a5",v="#ffffff"):(N=g?"#475569":"#1e293b",w=g?"#94a3b8":"#64748b",v="#e2e8f0"):g&&(N="#fbbf24",w="#f59e0b",v="#1e293b"),a.jsxs("g",{children:[a.jsx("circle",{cx:u.x,cy:u.y,r:22,fill:N,stroke:w,strokeWidth:g?3:2,className:"transition-all duration-200"}),a.jsx("text",{x:u.x,y:u.y+1,textAnchor:"middle",dominantBaseline:"central",fill:v,fontSize:12,fontWeight:600,fontFamily:"ui-monospace, monospace",children:u.value}),e==="avl"&&a.jsxs("text",{x:u.x+20,y:u.y-18,textAnchor:"middle",dominantBaseline:"central",fill:"#94a3b8",fontSize:9,fontFamily:"ui-monospace, monospace",children:["h",u.height]})]},u.id)})]})})}const St={bst:{name:"Binary Search Tree",description:"A binary tree where left child < parent < right child. No self-balancing — can degenerate to a linked list.",properties:["Unbalanced","O(h) operations","Simple"]},avl:{name:"AVL Tree",description:"A self-balancing BST where the heights of left and right subtrees differ by at most 1. Uses rotations to maintain balance.",properties:["Height-balanced","O(log n)","Rotations"]},rbtree:{name:"Red-Black Tree",description:"A self-balancing BST using node coloring (red/black) and rules to ensure the tree stays approximately balanced.",properties:["Color-balanced","O(log n)","Recoloring"]}},Ct=[{label:"Slow",value:600},{label:"Medium",value:300},{label:"Fast",value:100}],Tt=["bst","avl","rbtree"];function Vt({treeType:t,changeTreeType:e,inputValue:r,setInputValue:s,description:n,stepIndex:l,totalSteps:i,canGoNext:c,canGoPrev:h,history:m,speed:u,setSpeed:g,isPlaying:b,onInsert:N,onDelete:w,onNextStep:v,onPrevStep:j,onGenerateRandom:F}){const I=St[t],R=()=>{const o=parseInt(r);!isNaN(o)&&o>0&&(N(o),s(""))},G=()=>{const o=parseInt(r);!isNaN(o)&&o>0&&(w(o),s(""))},W=o=>{o.key==="Enter"&&R()};return a.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[a.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[a.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Tree Type"}),a.jsx("div",{className:"flex gap-2",children:Tt.map(o=>a.jsx("button",{onClick:()=>e(o),className:` +import{c as jt,r as p,j as a}from"./index-DBkLeWDs.js";import{P as Nt}from"./plus-DVazsZHX.js";import{S as wt}from"./shuffle-Dlr-c52A.js";import{C as $t,a as yt}from"./chevron-right-CFBAUJsk.js";const kt=[["path",{d:"M5 12h14",key:"1ays0h"}]],It=jt("minus",kt);function K(t){return t?[t,...K(t.left),...K(t.right)]:[]}function X(t){if(!t)return[];const e=[];return t.left&&(e.push({from:t,to:t.left}),e.push(...X(t.left))),t.right&&(e.push({from:t,to:t.right}),e.push(...X(t.right))),e}function Rt({root:t,treeType:e,highlightIds:r}){const s=p.useMemo(()=>K(t),[t]),n=p.useMemo(()=>X(t),[t]);if(!t)return a.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center rounded-xl border border-slate-700/50 bg-slate-950/80 text-slate-500",children:"No tree — insert a value to begin"});const l=Math.min(...s.map(u=>u.x),0)-40,i=Math.max(...s.map(u=>u.x),0)+40,c=Math.max(...s.map(u=>u.y),0)+40,h=i-l+80,m=c+80;return a.jsx("div",{className:"flex-1 w-full rounded-xl border border-slate-700/50 bg-slate-950/80 p-4 shadow-2xl backdrop-blur-sm overflow-auto",children:a.jsxs("svg",{viewBox:`${l-40} -20 ${h} ${m}`,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[n.map((u,g)=>a.jsx("line",{x1:u.from.x,y1:u.from.y,x2:u.to.x,y2:u.to.y,stroke:"#475569",strokeWidth:2,strokeOpacity:.5},g)),s.map(u=>{const g=r.includes(u.id),b=e==="rbtree";let N="#1e293b",w="#475569",v="#e2e8f0";return b?u.color==="red"?(N=g?"#f87171":"#dc2626",w="#fca5a5",v="#ffffff"):(N=g?"#475569":"#1e293b",w=g?"#94a3b8":"#64748b",v="#e2e8f0"):g&&(N="#fbbf24",w="#f59e0b",v="#1e293b"),a.jsxs("g",{children:[a.jsx("circle",{cx:u.x,cy:u.y,r:22,fill:N,stroke:w,strokeWidth:g?3:2,className:"transition-all duration-200"}),a.jsx("text",{x:u.x,y:u.y+1,textAnchor:"middle",dominantBaseline:"central",fill:v,fontSize:12,fontWeight:600,fontFamily:"ui-monospace, monospace",children:u.value}),e==="avl"&&a.jsxs("text",{x:u.x+20,y:u.y-18,textAnchor:"middle",dominantBaseline:"central",fill:"#94a3b8",fontSize:9,fontFamily:"ui-monospace, monospace",children:["h",u.height]})]},u.id)})]})})}const St={bst:{name:"Binary Search Tree",description:"A binary tree where left child < parent < right child. No self-balancing — can degenerate to a linked list.",properties:["Unbalanced","O(h) operations","Simple"]},avl:{name:"AVL Tree",description:"A self-balancing BST where the heights of left and right subtrees differ by at most 1. Uses rotations to maintain balance.",properties:["Height-balanced","O(log n)","Rotations"]},rbtree:{name:"Red-Black Tree",description:"A self-balancing BST using node coloring (red/black) and rules to ensure the tree stays approximately balanced.",properties:["Color-balanced","O(log n)","Recoloring"]}},Ct=[{label:"Slow",value:600},{label:"Medium",value:300},{label:"Fast",value:100}],Tt=["bst","avl","rbtree"];function Vt({treeType:t,changeTreeType:e,inputValue:r,setInputValue:s,description:n,stepIndex:l,totalSteps:i,canGoNext:c,canGoPrev:h,history:m,speed:u,setSpeed:g,isPlaying:b,onInsert:N,onDelete:w,onNextStep:v,onPrevStep:j,onGenerateRandom:F}){const I=St[t],R=()=>{const o=parseInt(r);!isNaN(o)&&o>0&&(N(o),s(""))},G=()=>{const o=parseInt(r);!isNaN(o)&&o>0&&(w(o),s(""))},W=o=>{o.key==="Enter"&&R()};return a.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[a.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[a.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Tree Type"}),a.jsx("div",{className:"flex gap-2",children:Tt.map(o=>a.jsx("button",{onClick:()=>e(o),className:` flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-all duration-200 ${t===o?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 shadow-lg shadow-indigo-500/10":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} `,children:o==="rbtree"?"RB Tree":o.toUpperCase()},o))}),a.jsxs("div",{className:"mt-3 rounded-lg bg-slate-800/40 p-3",children:[a.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:I.description}),a.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:I.properties.map(o=>a.jsx("span",{className:"inline-flex items-center rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-400 ring-1 ring-violet-500/20",children:o},o))})]})]}),a.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[a.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Speed"}),a.jsx("div",{className:"flex gap-1",children:Ct.map(o=>a.jsx("button",{onClick:()=>g(o.value),className:` diff --git a/docs/assets/BattlePage-BlVnZaDx.js b/docs/assets/BattlePage-aVfnCuym.js similarity index 99% rename from docs/assets/BattlePage-BlVnZaDx.js rename to docs/assets/BattlePage-aVfnCuym.js index 4f8a8d2..d75cf9a 100644 --- a/docs/assets/BattlePage-BlVnZaDx.js +++ b/docs/assets/BattlePage-aVfnCuym.js @@ -1 +1 @@ -import{c as He,j as e,f as Le,r as u,g as Ve}from"./index-eCXyAnHs.js";import{V as ge,a as fe}from"./volume-x-CTbtCvt-.js";import{S as Ge}from"./shuffle-CdKU4ZYx.js";import{P as be}from"./play-BqZilH6N.js";import{T as je}from"./trophy-DkUzH7jB.js";import{R as xe}from"./rotate-ccw-B8GZP3d7.js";import{P as ve}from"./pause-nC-0zhw8.js";import{N as D,r as _e}from"./index-DrhCNtmA.js";import{r as Me}from"./index-iw_6MvvU.js";import{g as qe}from"./audioContext-NbgqvQGz.js";import{A as Ye}from"./arrow-left-DiyrXoev.js";import{M as Ee}from"./map-4vhpgcAJ.js";const Xe=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Ke=He("chart-column",Xe);const Qe=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],ye=He("equal",Qe),X=[{value:"bubble",label:"Bubble Sort"},{value:"selection",label:"Selection Sort"},{value:"insertion",label:"Insertion Sort"},{value:"quick",label:"Quick Sort"},{value:"heap",label:"Heap Sort"},{value:"merge",label:"Merge Sort"}],ze={bubble:{best:"O(n)",average:"O(n²)",worst:"O(n²)",space:"O(1)"},selection:{best:"O(n²)",average:"O(n²)",worst:"O(n²)",space:"O(1)"},insertion:{best:"O(n)",average:"O(n²)",worst:"O(n²)",space:"O(1)"},quick:{best:"O(n log n)",average:"O(n log n)",worst:"O(n²)",space:"O(log n)"},heap:{best:"O(n log n)",average:"O(n log n)",worst:"O(n log n)",space:"O(1)"},merge:{best:"O(n log n)",average:"O(n log n)",worst:"O(n log n)",space:"O(n)"}},me=[{label:"Slow",value:150},{label:"Medium",value:50},{label:"Fast",value:15},{label:"Turbo",value:1}];function Ue(t,a){const s=[];for(let l=0;ln-c);const l=Math.max(1,Math.floor(t*.05));for(let n=0;nn-l);return s}function Ze(t,a,s,l,n,c){const i=X.find(f=>f.value===a).label,o=X.find(f=>f.value===s).label;if(t==="tie")return`Both ${i} and ${o} completed in the same number of operations. This can happen with small inputs or similar-complexity algorithms.`;const r=t==="A"?i:o,d=t==="A"?o:i,m=t==="A"?l:n,x=t==="A"?n:l,g=(x.totalSteps/Math.max(m.totalSteps,1)).toFixed(1);let p=`${r} won with ${m.totalSteps} steps vs ${x.totalSteps} steps (${g}x fewer operations). `;return c==="nearly-sorted"?p+="On nearly-sorted data, algorithms like Insertion Sort have a natural advantage due to their O(n) best-case performance.":c==="reversed"?p+="Reversed input is the worst case for O(n²) algorithms, making the performance gap with O(n log n) algorithms very visible.":p+=`${d} performed more operations because its average-case complexity is higher for this input distribution.`,p}const Je=[{value:"random",label:"Random"},{value:"nearly-sorted",label:"Nearly Sorted"},{value:"reversed",label:"Reversed"}],et=[{value:"realtime",label:"Real-Time",desc:"Watch both algorithms animate step-by-step"},{value:"turbo",label:"Turbo",desc:"Instant execution, metrics only"},{value:"prediction",label:"Prediction",desc:"Predict the winner before starting"}];function tt({algorithmA:t,algorithmB:a,inputSize:s,inputType:l,gameMode:n,speed:c,soundEnabled:i,prediction:o,onSetAlgorithmA:r,onSetAlgorithmB:d,onSetInputSize:m,onSetInputType:x,onSetGameMode:g,onSetSpeed:p,onToggleSound:f,onSetPrediction:y,onStart:C}){const w=X.find(h=>h.value===t).label,S=X.find(h=>h.value===a).label;return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center justify-center px-6 pt-8 pb-4 text-center",children:[e.jsxs("div",{className:"mb-3 inline-flex items-center gap-2 rounded-full bg-rose-500/10 px-4 py-1.5 ring-1 ring-rose-500/20",children:[e.jsx(Le,{size:14,className:"text-rose-400"}),e.jsx("span",{className:"text-xs font-medium text-rose-300",children:"Algorithm Battles"})]}),e.jsxs("h2",{className:"text-2xl font-extrabold tracking-tight text-white",children:[e.jsx("span",{className:"bg-gradient-to-r from-rose-400 to-orange-400 bg-clip-text text-transparent",children:w})," ","vs"," ",e.jsx("span",{className:"bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent",children:S})]})]}),e.jsx("section",{className:"px-4 pb-8",children:e.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-rose-400 mb-3",children:"Algorithm A"}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:X.map(h=>e.jsx("button",{onClick:()=>r(h.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${t===h.value?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:h.label},h.value))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-cyan-400 mb-3",children:"Algorithm B"}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:X.map(h=>e.jsx("button",{onClick:()=>d(h.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${a===h.value?"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:h.label},h.value))})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Input Configuration"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Array Size"}),e.jsx("span",{className:"text-sm font-mono font-bold text-indigo-300",children:s})]}),e.jsx("input",{type:"range",min:10,max:200,step:10,value:s,onChange:h=>m(Number(h.target.value)),className:"w-full accent-indigo-500"})]}),e.jsx("div",{className:"flex gap-1.5",children:Je.map(h=>e.jsx("button",{onClick:()=>x(h.value),className:`flex-1 rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${l===h.value?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:h.label},h.value))})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Game Mode"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:et.map(h=>e.jsxs("button",{onClick:()=>g(h.value),className:`flex flex-col items-center rounded-lg px-2 py-2.5 text-[11px] font-medium transition-all ${n===h.value?"bg-violet-500/20 text-violet-300 ring-1 ring-violet-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:[e.jsx("span",{className:"font-semibold",children:h.label}),e.jsx("span",{className:"text-[9px] text-slate-500 mt-0.5 hidden sm:block",children:h.desc})]},h.value))})]}),n==="prediction"&&e.jsxs("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/5 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-amber-400 mb-3",children:"Your Prediction"}),e.jsx("p",{className:"text-[10px] text-amber-300/60 mb-3",children:"Who will win with fewer operations?"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>y("A"),className:`flex-1 rounded-lg px-3 py-2.5 text-sm font-medium transition-all ${o==="A"?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:w}),e.jsx("button",{onClick:()=>y("B"),className:`flex-1 rounded-lg px-3 py-2.5 text-sm font-medium transition-all ${o==="B"?"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:S})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex-1 rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Speed"}),e.jsx("div",{className:"flex gap-1.5",children:me.map(h=>e.jsx("button",{onClick:()=>p(h.value),className:`flex-1 rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${c===h.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:h.label},h.value))})]}),e.jsxs("button",{onClick:()=>f(!i),className:`shrink-0 flex flex-col items-center justify-center rounded-xl px-4 transition-all ${i?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-1 ring-slate-700/40"}`,children:[i?e.jsx(ge,{size:18}):e.jsx(fe,{size:18}),e.jsx("span",{className:"text-[10px] mt-1",children:i?"On":"Off"})]})]}),e.jsxs("button",{onClick:C,disabled:n==="prediction"&&!o,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500/20 to-cyan-500/20 px-6 py-4 text-base font-bold text-white ring-1 ring-white/10 transition-all hover:from-rose-500/30 hover:to-cyan-500/30 hover:ring-white/20 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Ge,{size:18,className:"text-rose-300"}),e.jsx(be,{size:18,className:"text-cyan-300"}),"Start Battle"]})]})})]})}function ke({state:t,color:a,maxVal:s}){const l=X.find(x=>x.value===t.algorithm).label,n=t.status==="finished",c=t.array.length,o={rose:{default:"bg-rose-500/60",comparing:"bg-amber-400",swapping:"bg-rose-300",sorted:"bg-emerald-500/70",border:n?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50",label:"text-rose-400",badge:"bg-rose-500/15 text-rose-300 ring-rose-500/30"},cyan:{default:"bg-cyan-500/60",comparing:"bg-amber-400",swapping:"bg-cyan-300",sorted:"bg-emerald-500/70",border:n?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50",label:"text-cyan-400",badge:"bg-cyan-500/15 text-cyan-300 ring-cyan-500/30"}}[a],r=new Set(t.comparing||[]),d=new Set(t.swapping||[]),m=new Set(t.sorted);return e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsx("span",{className:`text-xs font-bold ${o.label}`,children:l}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ring-1 ${o.badge}`,children:n?"Finished":"Running"})]}),e.jsx("div",{className:`rounded-xl border border-slate-700/50 bg-slate-950/80 p-2 ${o.border} transition-all overflow-hidden`,children:e.jsx("div",{className:"flex items-end gap-px h-32 sm:h-44 md:h-52",children:t.array.map((x,g)=>{const p=x/s*100;let f=o.default;return r.has(g)?f=o.comparing:d.has(g)?f=o.swapping:m.has(g)&&(f=o.sorted),e.jsx("div",{className:`flex-1 rounded-t-sm transition-all duration-75 ${f}`,style:{height:`${p}%`,minWidth:c>100?"1px":"2px"}},g)})})}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5 px-1",children:[e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Comparisons"}),e.jsx("div",{className:"text-xs font-mono font-bold text-white",children:t.metrics.comparisons})]}),e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Swaps"}),e.jsx("div",{className:"text-xs font-mono font-bold text-white",children:t.metrics.swaps})]}),e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Steps"}),e.jsxs("div",{className:"text-xs font-mono font-bold text-white",children:[t.metrics.stepsCompleted,"/",t.metrics.totalSteps]})]})]})]})}function st({history:t,nameA:a,nameB:s}){const{pathA:l,pathB:n,maxOps:c,maxTime:i}=u.useMemo(()=>{if(t.length<2)return{pathA:"",pathB:"",maxOps:1,maxTime:1};const o=Math.max(...t.map(g=>Math.max(g.opsA,g.opsB)),1),r=t.length-1,d=400,m=120,x=g=>t.map((p,f)=>{const y=f/r*d,C=m-p[g]/o*m;return`${f===0?"M":"L"}${y.toFixed(1)},${C.toFixed(1)}`}).join(" ");return{pathA:x("opsA"),pathB:x("opsB"),maxOps:o,maxTime:r}},[t]);return t.length<2?null:e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Live Performance"}),e.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"h-2 w-4 rounded-full bg-rose-400"}),e.jsx("span",{className:"text-[10px] text-slate-400",children:a})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"h-2 w-4 rounded-full bg-cyan-400"}),e.jsx("span",{className:"text-[10px] text-slate-400",children:s})]}),e.jsxs("span",{className:"ml-auto text-[10px] text-slate-500",children:["Max ops: ",c]})]}),e.jsxs("svg",{viewBox:"0 0 400 120",className:"w-full h-20 sm:h-28",preserveAspectRatio:"none",children:[e.jsx("path",{d:l,fill:"none",stroke:"#fb7185",strokeWidth:2,strokeLinecap:"round"}),e.jsx("path",{d:n,fill:"none",stroke:"#22d3ee",strokeWidth:2,strokeLinecap:"round"})]}),e.jsxs("div",{className:"flex justify-between mt-1",children:[e.jsx("span",{className:"text-[9px] text-slate-600",children:"0"}),e.jsxs("span",{className:"text-[9px] text-slate-600",children:["Steps → ",i]})]})]})}function nt({stateA:t,stateB:a,winner:s,prediction:l,predictionCorrect:n,inputType:c,onReset:i}){const o=X.find(g=>g.value===t.algorithm).label,r=X.find(g=>g.value===a.algorithm).label,d=ze[t.algorithm],m=ze[a.algorithm],x=Ze(s,t.algorithm,a.algorithm,t.metrics,a.metrics,c);return e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm space-y-4",children:[e.jsx("div",{className:"text-center",children:s==="tie"?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-500/10 px-5 py-2 ring-1 ring-amber-500/20",children:[e.jsx(ye,{size:18,className:"text-amber-400"}),e.jsx("span",{className:"text-sm font-bold text-amber-300",children:"It's a Tie!"})]}):e.jsxs("div",{className:`inline-flex items-center gap-2 rounded-full px-5 py-2 ring-1 ${s==="A"?"bg-rose-500/10 ring-rose-500/20":"bg-cyan-500/10 ring-cyan-500/20"}`,children:[e.jsx(je,{size:18,className:s==="A"?"text-rose-400":"text-cyan-400"}),e.jsxs("span",{className:`text-sm font-bold ${s==="A"?"text-rose-300":"text-cyan-300"}`,children:[s==="A"?o:r," Wins!"]})]})}),l&&n!==null&&e.jsx("div",{className:`rounded-lg px-4 py-2.5 text-center text-xs font-medium ${n?"bg-emerald-500/10 text-emerald-300 ring-1 ring-emerald-500/20":"bg-rose-500/10 text-rose-300 ring-1 ring-rose-500/20"}`,children:n?"🎯 Your prediction was correct!":"❌ Your prediction was wrong. Keep learning!"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-700/50",children:[e.jsx("th",{className:"py-2 text-left text-slate-500 font-medium",children:"Metric"}),e.jsx("th",{className:"py-2 text-center text-rose-400 font-semibold",children:o}),e.jsx("th",{className:"py-2 text-center text-cyan-400 font-semibold",children:r})]})}),e.jsx("tbody",{className:"font-mono",children:[{label:"Total Steps",a:t.metrics.totalSteps,b:a.metrics.totalSteps},{label:"Comparisons",a:t.metrics.comparisons,b:a.metrics.comparisons},{label:"Swaps",a:t.metrics.swaps,b:a.metrics.swaps},{label:"Array Accesses",a:t.metrics.arrayAccesses,b:a.metrics.arrayAccesses},{label:"Time (s)",a:t.metrics.timeElapsed.toFixed(2),b:a.metrics.timeElapsed.toFixed(2)}].map(({label:g,a:p,b:f})=>{const y=typeof p=="string"?parseFloat(p):p,C=typeof f=="string"?parseFloat(f):f;return e.jsxs("tr",{className:"border-b border-slate-800/50",children:[e.jsx("td",{className:"py-2 text-slate-400",children:g}),e.jsxs("td",{className:`py-2 text-center font-semibold ${y<=C?"text-emerald-300":"text-white"}`,children:[p,ye.jsxs("div",{className:"rounded-lg bg-slate-800/40 p-3",children:[e.jsx("h4",{className:`text-[10px] font-bold uppercase tracking-wider ${f==="rose"?"text-rose-400":"text-cyan-400"} mb-2`,children:g}),e.jsxs("div",{className:"space-y-1 text-[10px] font-mono",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Best"}),e.jsx("span",{className:"text-slate-300",children:p.best})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Average"}),e.jsx("span",{className:"text-slate-300",children:p.average})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Worst"}),e.jsx("span",{className:"text-slate-300",children:p.worst})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Space"}),e.jsx("span",{className:"text-slate-300",children:p.space})]})]})]},g))}),e.jsxs("div",{className:"rounded-lg bg-indigo-500/5 px-4 py-3 ring-1 ring-indigo-500/15",children:[e.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-wider text-indigo-400 mb-1",children:"Why?"}),e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:x})]}),e.jsxs("button",{onClick:i,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-slate-800/60 px-6 py-3 text-sm font-medium text-slate-300 ring-1 ring-slate-700/50 transition-all hover:bg-slate-700/60 active:scale-[0.98]",children:[e.jsx(xe,{size:14}),"New Battle"]})]})}function at({stateA:t,stateB:a,status:s,winner:l,prediction:n,predictionCorrect:c,inputType:i,speed:o,soundEnabled:r,metricsHistory:d,onPause:m,onResume:x,onReset:g,onSetSpeed:p,onToggleSound:f}){const y=X.find(h=>h.value===t.algorithm).label,C=X.find(h=>h.value===a.algorithm).label,w=Math.max(...t.array,...a.array,1),S=s==="running";return e.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-6",children:e.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s!=="finished"&&e.jsxs("button",{onClick:S?m:x,className:"flex items-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-300 ring-1 ring-slate-700/50 transition-all hover:bg-slate-700/60",children:[S?e.jsx(ve,{size:14}):e.jsx(be,{size:14}),S?"Pause":"Resume"]}),e.jsxs("button",{onClick:g,className:"flex items-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-300 ring-1 ring-slate-700/50 transition-all hover:bg-slate-700/60",children:[e.jsx(xe,{size:14}),"Reset"]}),e.jsx("button",{onClick:()=>f(!r),className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-medium transition-all ring-1 ${r?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-slate-700/40"}`,children:r?e.jsx(ge,{size:14}):e.jsx(fe,{size:14})})]}),s!=="finished"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Speed:"}),me.map(h=>e.jsx("button",{onClick:()=>p(h.value),className:`rounded px-2 py-1 text-[10px] font-medium transition-all ${o===h.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-500 hover:bg-slate-700/50"}`,children:h.label},h.value))]}),e.jsxs("div",{className:"text-xs text-slate-500 font-mono",children:[t.metrics.timeElapsed.toFixed(1),"s"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsx(ke,{state:t,color:"rose",maxVal:w}),e.jsx(ke,{state:a,color:"cyan",maxVal:w})]}),e.jsx(st,{history:d,nameA:y,nameB:C}),s==="finished"&&l&&e.jsx(nt,{stateA:t,stateB:a,winner:l,prediction:n,predictionCorrect:c,inputType:i,onReset:g})]})})}const ne=15,Z=25,lt=.25,rt=[{value:"random",label:"Random Scatter"},{value:"recursive-division",label:"Recursive Division"},{value:"dfs-maze",label:"DFS Maze"}];function Re(t,a){return`${t},${a}`}function it(){const t=[];for(let a=0;ac===a.row&&i===a.col||c===s.row&&i===s.col;function n(c,i,o,r,d){if(d){if(i-c<2)return;const m=[];for(let p=c+1;p.5)}function dt(t,a,s){for(let o=0;oMath.random()-.5);for(const[m,x]of d){const g=o+m,p=r+x;g>=0&&g=0&&p=0&&(t[s.row][s.col-1].type=D.EMPTY)}function ut(t="random"){const a=it(),s={row:Math.floor(ne/2),col:1},l={row:Math.floor(ne/2),col:Z-2};switch(t){case"recursive-division":ot(a,s,l);break;case"dfs-maze":dt(a,s,l);break;default:ct(a,s,l);break}return a[s.row][s.col].type=D.START,a[l.row][l.col].type=D.END,{grid:a,start:s,end:l}}function Te(t,a,s,l){const n=_e(l,t,a,s),c=n.visitedNodesInOrder,i=n.shortestPath,o=[],r=new Set;for(let d=0;d0){const d=new Set(r);for(let m=0;mRe(x.row,x.col)))})}return{steps:o,totalVisited:c.length,pathLength:i.length,found:i.length>0}}const de=[{value:"bfs",label:"BFS"},{value:"dfs",label:"DFS"},{value:"dijkstra",label:"Dijkstra"},{value:"astar",label:"A*"}],$e={bfs:{time:"O(V + E)",space:"O(V)",optimal:!0},dfs:{time:"O(V + E)",space:"O(V)",optimal:!1},dijkstra:{time:"O(V² / V+E log V)",space:"O(V)",optimal:!0},astar:{time:"O(E)",space:"O(V)",optimal:!0}};function Be({grid:t,step:a,algorithm:s,color:l,finished:n,totalVisited:c,pathLength:i,currentIndex:o,totalSteps:r}){const d=de.find(g=>g.value===s).label,x={rose:{visited:"bg-rose-500/40",path:"bg-rose-300",current:"bg-rose-400",label:"text-rose-400",badge:"bg-rose-500/15 text-rose-300 ring-rose-500/30",border:n?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50"},cyan:{visited:"bg-cyan-500/40",path:"bg-cyan-300",current:"bg-cyan-400",label:"text-cyan-400",badge:"bg-cyan-500/15 text-cyan-300 ring-cyan-500/30",border:n?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50"}}[l];return e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsx("span",{className:`text-xs font-bold ${x.label}`,children:d}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ring-1 ${x.badge}`,children:n?"Finished":"Running"})]}),e.jsx("div",{className:`rounded-xl border border-slate-700/50 bg-slate-950/80 p-1 ${x.border} transition-all overflow-hidden`,children:e.jsx("div",{className:"grid",style:{gridTemplateColumns:`repeat(${Z}, 1fr)`,gap:"1px"},children:t.map((g,p)=>g.map((f,y)=>{const C=`${p},${y}`;let w="bg-slate-800/40";return f.type===D.WALL?w="bg-slate-600":f.type===D.START?w="bg-emerald-500":f.type===D.END?w="bg-amber-500":a&&(a.pathNodes.has(C)?w=x.path:a.currentNode&&a.currentNode.row===p&&a.currentNode.col===y?w=x.current:a.visitedSoFar.has(C)&&(w=x.visited)),e.jsx("div",{className:`aspect-square rounded-[1px] ${w} transition-colors duration-75`},C)}))})}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5 px-1",children:[e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Visited"}),e.jsx("div",{className:"text-xs font-mono font-bold text-white",children:c})]}),e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Path"}),e.jsx("div",{className:"text-xs font-mono font-bold text-white",children:i})]}),e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Steps"}),e.jsxs("div",{className:"text-xs font-mono font-bold text-white",children:[o,"/",r]})]})]})]})}function xt({grid:t,stateA:a,stateB:s,status:l,winner:n,prediction:c,predictionCorrect:i,speed:o,soundEnabled:r,onPause:d,onResume:m,onReset:x,onSetSpeed:g,onToggleSound:p}){const f=l==="running",y=de.find(h=>h.value===a.algorithm).label,C=de.find(h=>h.value===s.algorithm).label,w=a.currentIndexp(!r),className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-medium ring-1 ${r?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-slate-700/40"}`,children:r?e.jsx(ge,{size:14}):e.jsx(fe,{size:14})})]}),l!=="finished"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Speed:"}),me.map(h=>e.jsx("button",{onClick:()=>g(h.value),className:`rounded px-2 py-1 text-[10px] font-medium ${o===h.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-500 hover:bg-slate-700/50"}`,children:h.label},h.value))]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsx(Be,{grid:t,step:w,algorithm:a.algorithm,color:"rose",finished:a.finished,totalVisited:a.totalVisited,pathLength:a.pathLength,currentIndex:a.currentIndex,totalSteps:a.steps.length}),e.jsx(Be,{grid:t,step:S,algorithm:s.algorithm,color:"cyan",finished:s.finished,totalVisited:s.totalVisited,pathLength:s.pathLength,currentIndex:s.currentIndex,totalSteps:s.steps.length})]}),l==="finished"&&n&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm space-y-4",children:[e.jsx("div",{className:"text-center",children:n==="tie"?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-500/10 px-5 py-2 ring-1 ring-amber-500/20",children:[e.jsx(ye,{size:18,className:"text-amber-400"}),e.jsx("span",{className:"text-sm font-bold text-amber-300",children:"It's a Tie!"})]}):e.jsxs("div",{className:`inline-flex items-center gap-2 rounded-full px-5 py-2 ring-1 ${n==="A"?"bg-rose-500/10 ring-rose-500/20":"bg-cyan-500/10 ring-cyan-500/20"}`,children:[e.jsx(je,{size:18,className:n==="A"?"text-rose-400":"text-cyan-400"}),e.jsxs("span",{className:`text-sm font-bold ${n==="A"?"text-rose-300":"text-cyan-300"}`,children:[n==="A"?y:C," Wins!"]})]})}),c&&i!==null&&e.jsx("div",{className:`rounded-lg px-4 py-2.5 text-center text-xs font-medium ${i?"bg-emerald-500/10 text-emerald-300 ring-1 ring-emerald-500/20":"bg-rose-500/10 text-rose-300 ring-1 ring-rose-500/20"}`,children:i?"🎯 Correct prediction!":"❌ Wrong prediction. Keep learning!"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-700/50",children:[e.jsx("th",{className:"py-2 text-left text-slate-500",children:"Metric"}),e.jsx("th",{className:"py-2 text-center text-rose-400 font-semibold",children:y}),e.jsx("th",{className:"py-2 text-center text-cyan-400 font-semibold",children:C})]})}),e.jsx("tbody",{className:"font-mono",children:[{label:"Nodes Visited",a:a.totalVisited,b:s.totalVisited},{label:"Path Length",a:a.pathLength,b:s.pathLength},{label:"Total Steps",a:a.steps.length,b:s.steps.length}].map(({label:h,a:z,b:B})=>e.jsxs("tr",{className:"border-b border-slate-800/50",children:[e.jsx("td",{className:"py-2 text-slate-400",children:h}),e.jsxs("td",{className:`py-2 text-center font-semibold ${z<=B?"text-emerald-300":"text-white"}`,children:[z,ze.jsxs("div",{className:"rounded-lg bg-slate-800/40 p-3",children:[e.jsx("h4",{className:`text-[10px] font-bold uppercase tracking-wider ${B==="rose"?"text-rose-400":"text-cyan-400"} mb-2`,children:h}),e.jsxs("div",{className:"space-y-1 text-[10px] font-mono",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Time"}),e.jsx("span",{className:"text-slate-300",children:z.time})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Space"}),e.jsx("span",{className:"text-slate-300",children:z.space})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Optimal"}),e.jsx("span",{className:z.optimal?"text-emerald-300":"text-rose-300",children:z.optimal?"Yes":"No"})]})]})]},h))}),e.jsxs("button",{onClick:x,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-slate-800/60 px-6 py-3 text-sm font-medium text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/60 active:scale-[0.98]",children:[e.jsx(xe,{size:14})," New Battle"]})]})]})})}const Ne=[{value:"fibonacci",label:"Fibonacci",desc:"Compute the Nth Fibonacci number",inputLabel:"N",inputMin:5,inputMax:25,defaultN:15},{value:"factorial",label:"Factorial",desc:"Compute N! (N factorial)",inputLabel:"N",inputMin:3,inputMax:20,defaultN:10},{value:"staircase",label:"Staircase",desc:"Ways to climb N stairs (1 or 2 steps)",inputLabel:"Stairs",inputMin:5,inputMax:25,defaultN:15},{value:"coin-change",label:"Coin Change",desc:"Min coins to make amount N (coins: 1,3,5)",inputLabel:"Amount",inputMin:5,inputMax:30,defaultN:15}];function Ie(t){const a=[];let s=0,l=0;function n(i,o){if(s++,l=Math.max(l,o),a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:null,cacheSize:0}),i<=1)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:i,cacheSize:0}),i;const r=n(i-1,o+1)+n(i-2,o+1);return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:r,cacheSize:0}),r}const c=n(t,0);return{steps:a,finalResult:c,totalCalls:s,totalCacheHits:0,maxDepth:l}}function mt(t){const a=[];let s=0,l=0,n=0;const c=new Map;function i(r,d){if(s++,n=Math.max(n,d),c.has(r)){l++;const x=c.get(r);return a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:x,cacheSize:c.size}),x}if(a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:null,cacheSize:c.size}),r<=1)return c.set(r,r),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:r,cacheSize:c.size}),r;const m=i(r-1,d+1)+i(r-2,d+1);return c.set(r,m),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:m,cacheSize:c.size}),m}const o=i(t,0);return{steps:a,finalResult:o,totalCalls:s,totalCacheHits:l,maxDepth:n}}function pt(t){const a=[];let s=0;if(t<=1)return s=1,a.push({callCount:s,cacheHits:0,currentDepth:0,maxDepth:0,currentN:t,result:t,cacheSize:0}),{steps:a,finalResult:t,totalCalls:1,totalCacheHits:0,maxDepth:0};let l=0,n=1;for(let c=2;c<=t;c++){s++;const i=l+n;l=n,n=i,a.push({callCount:s,cacheHits:0,currentDepth:0,maxDepth:0,currentN:c,result:n,cacheSize:0})}return{steps:a,finalResult:n,totalCalls:s,totalCacheHits:0,maxDepth:0}}const ue=[{value:"naive",label:"Naive Recursive"},{value:"memoized",label:"Memoized"},{value:"iterative",label:"Iterative"}],De={naive:{time:"O(2ⁿ)",space:"O(n)"},memoized:{time:"O(n)",space:"O(n)"},iterative:{time:"O(n)",space:"O(1)"}};function ht(t){const a=[];let s=0,l=0;function n(i,o){if(s++,l=Math.max(l,o),a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:null,cacheSize:0}),i<=1)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:1,cacheSize:0}),1;const r=i*n(i-1,o+1);return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:r,cacheSize:0}),r}const c=n(t,0);return{steps:a,finalResult:c,totalCalls:s,totalCacheHits:0,maxDepth:l}}function gt(t){const a=[];let s=0,l=0,n=0;const c=new Map;function i(r,d){if(s++,n=Math.max(n,d),c.has(r)){l++;const x=c.get(r);return a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:x,cacheSize:c.size}),x}if(a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:null,cacheSize:c.size}),r<=1)return c.set(r,1),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:1,cacheSize:c.size}),1;const m=r*i(r-1,d+1);return c.set(r,m),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:m,cacheSize:c.size}),m}const o=i(t,0);return{steps:a,finalResult:o,totalCalls:s,totalCacheHits:l,maxDepth:n}}function ft(t){const a=[];let s=1;for(let l=2;l<=t;l++)s*=l,a.push({callCount:l-1,cacheHits:0,currentDepth:0,maxDepth:0,currentN:l,result:s,cacheSize:0});return a.length===0&&a.push({callCount:1,cacheHits:0,currentDepth:0,maxDepth:0,currentN:t,result:1,cacheSize:0}),{steps:a,finalResult:s,totalCalls:Math.max(t-1,1),totalCacheHits:0,maxDepth:0}}function bt(t){const a=[];let s=0,l=0;function n(i,o){if(s++,l=Math.max(l,o),a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:null,cacheSize:0}),i<=1)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:1,cacheSize:0}),1;const r=n(i-1,o+1)+n(i-2,o+1);return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:r,cacheSize:0}),r}const c=n(t,0);return{steps:a,finalResult:c,totalCalls:s,totalCacheHits:0,maxDepth:l}}function Nt(t){const a=[];let s=0,l=0,n=0;const c=new Map;function i(r,d){if(s++,n=Math.max(n,d),c.has(r)){l++;const x=c.get(r);return a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:x,cacheSize:c.size}),x}if(a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:null,cacheSize:c.size}),r<=1)return c.set(r,1),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:1,cacheSize:c.size}),1;const m=i(r-1,d+1)+i(r-2,d+1);return c.set(r,m),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:m,cacheSize:c.size}),m}const o=i(t,0);return{steps:a,finalResult:o,totalCalls:s,totalCacheHits:l,maxDepth:n}}function jt(t){const a=[];if(t<=1)return a.push({callCount:1,cacheHits:0,currentDepth:0,maxDepth:0,currentN:t,result:1,cacheSize:0}),{steps:a,finalResult:1,totalCalls:1,totalCacheHits:0,maxDepth:0};let s=1,l=1;for(let n=2;n<=t;n++){const c=s+l;s=l,l=c,a.push({callCount:n-1,cacheHits:0,currentDepth:0,maxDepth:0,currentN:n,result:l,cacheSize:0})}return{steps:a,finalResult:l,totalCalls:t-1,totalCacheHits:0,maxDepth:0}}const Se=[1,3,5];function vt(t){const a=[];let s=0,l=0;function n(i,o){if(s++,l=Math.max(l,o),a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:null,cacheSize:0}),i===0)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:0,cacheSize:0}),0;if(i<0)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:1/0,cacheSize:0}),1/0;let r=1/0;for(const d of Se){const m=n(i-d,o+1);m!==1/0&&(r=Math.min(r,m+1))}return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:r===1/0?-1:r,cacheSize:0}),r}const c=n(t,0);return{steps:a,finalResult:c===1/0?-1:c,totalCalls:s,totalCacheHits:0,maxDepth:l}}function yt(t){const a=[];let s=0,l=0,n=0;const c=new Map;function i(r,d){if(s++,n=Math.max(n,d),c.has(r)){l++;const x=c.get(r);return a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:x===1/0?-1:x,cacheSize:c.size}),x}if(a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:null,cacheSize:c.size}),r===0)return c.set(0,0),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:0,cacheSize:c.size}),0;if(r<0)return 1/0;let m=1/0;for(const x of Se){const g=i(r-x,d+1);g!==1/0&&(m=Math.min(m,g+1))}return c.set(r,m),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:m===1/0?-1:m,cacheSize:c.size}),m}const o=i(t,0);return{steps:a,finalResult:o===1/0?-1:o,totalCalls:s,totalCacheHits:l,maxDepth:n}}function St(t){const a=[],s=new Array(t+1).fill(1/0);s[0]=0;let l=0;for(let n=1;n<=t;n++){for(const c of Se)n>=c&&s[n-c]+1r.value===t.algorithm).label,n=t.currentIndex0?t.currentIndex/c*100:0,o=a==="rose"?{label:"text-rose-400",badge:"bg-rose-500/15 text-rose-300 ring-rose-500/30",bar:"bg-rose-500",border:t.finished?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50"}:{label:"text-cyan-400",badge:"bg-cyan-500/15 text-cyan-300 ring-cyan-500/30",bar:"bg-cyan-500",border:t.finished?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50"};return e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsx("span",{className:`text-xs font-bold ${o.label}`,children:l}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ring-1 ${o.badge}`,children:t.finished?"Finished":"Running"})]}),e.jsxs("div",{className:`rounded-xl border border-slate-700/50 bg-slate-950/80 p-3 ${o.border} transition-all`,children:[e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{className:"flex justify-between mb-1",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Function Calls"}),e.jsxs("span",{className:"text-[10px] font-mono text-slate-400",children:[n?n.callCount:0," / ",t.totalCalls]})]}),e.jsx("div",{className:"h-4 rounded-full bg-slate-800/60 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${o.bar} transition-all duration-75`,style:{width:`${i}%`}})})]}),e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"text-[10px] text-slate-500 block mb-1",children:"Stack Depth"}),e.jsx("div",{className:"flex items-end gap-px h-16",children:Array.from({length:Math.max(n?.maxDepth||1,1)},(r,d)=>{const m=n?dS.value===t.algorithm).label,C=ue.find(S=>S.value===a.algorithm).label,w=wt[r];return e.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-6",children:e.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s!=="finished"&&e.jsxs("button",{onClick:f?d:m,className:"flex items-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/60",children:[f?e.jsx(ve,{size:14}):e.jsx(be,{size:14}),f?"Pause":"Resume"]}),e.jsxs("button",{onClick:x,className:"flex items-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/60",children:[e.jsx(xe,{size:14})," Reset"]}),e.jsx("button",{onClick:()=>p(!o),className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-medium ring-1 ${o?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-slate-700/40"}`,children:o?e.jsx(ge,{size:14}):e.jsx(fe,{size:14})})]}),s!=="finished"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Speed:"}),me.map(S=>e.jsx("button",{onClick:()=>g(S.value),className:`rounded px-2 py-1 text-[10px] font-medium ${i===S.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-500 hover:bg-slate-700/50"}`,children:S.label},S.value))]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsx(Pe,{state:t,color:"rose",funcName:w}),e.jsx(Pe,{state:a,color:"cyan",funcName:w})]}),s==="finished"&&l&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm space-y-4",children:[e.jsx("div",{className:"text-center",children:l==="tie"?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-500/10 px-5 py-2 ring-1 ring-amber-500/20",children:[e.jsx(ye,{size:18,className:"text-amber-400"}),e.jsx("span",{className:"text-sm font-bold text-amber-300",children:"It's a Tie!"})]}):e.jsxs("div",{className:`inline-flex items-center gap-2 rounded-full px-5 py-2 ring-1 ${l==="A"?"bg-rose-500/10 ring-rose-500/20":"bg-cyan-500/10 ring-cyan-500/20"}`,children:[e.jsx(je,{size:18,className:l==="A"?"text-rose-400":"text-cyan-400"}),e.jsxs("span",{className:`text-sm font-bold ${l==="A"?"text-rose-300":"text-cyan-300"}`,children:[l==="A"?y:C," Wins!"]})]})}),n&&c!==null&&e.jsx("div",{className:`rounded-lg px-4 py-2.5 text-center text-xs font-medium ${c?"bg-emerald-500/10 text-emerald-300 ring-1 ring-emerald-500/20":"bg-rose-500/10 text-rose-300 ring-1 ring-rose-500/20"}`,children:c?"🎯 Correct prediction!":"❌ Wrong prediction. Keep learning!"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-700/50",children:[e.jsx("th",{className:"py-2 text-left text-slate-500",children:"Metric"}),e.jsx("th",{className:"py-2 text-center text-rose-400 font-semibold",children:y}),e.jsx("th",{className:"py-2 text-center text-cyan-400 font-semibold",children:C})]})}),e.jsx("tbody",{className:"font-mono",children:[{label:"Total Calls",a:t.totalCalls,b:a.totalCalls},{label:"Cache Hits",a:t.totalCacheHits,b:a.totalCacheHits},{label:"Max Stack Depth",a:t.maxDepth,b:a.maxDepth},{label:"Total Steps",a:t.steps.length,b:a.steps.length}].map(({label:S,a:h,b:z})=>e.jsxs("tr",{className:"border-b border-slate-800/50",children:[e.jsx("td",{className:"py-2 text-slate-400",children:S}),e.jsxs("td",{className:`py-2 text-center font-semibold ${h<=z?"text-emerald-300":"text-white"}`,children:[h,he.jsxs("div",{className:"rounded-lg bg-slate-800/40 p-3",children:[e.jsx("h4",{className:`text-[10px] font-bold uppercase tracking-wider ${z==="rose"?"text-rose-400":"text-cyan-400"} mb-2`,children:S}),e.jsxs("div",{className:"space-y-1 text-[10px] font-mono",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Time"}),e.jsx("span",{className:"text-slate-300",children:h.time})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Space"}),e.jsx("span",{className:"text-slate-300",children:h.space})]})]})]},S))}),e.jsxs("div",{className:"rounded-lg bg-indigo-500/5 px-4 py-3 ring-1 ring-indigo-500/15",children:[e.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-wider text-indigo-400 mb-1",children:"Why?"}),e.jsxs("p",{className:"text-xs text-slate-400 leading-relaxed",children:[t.totalCalls>a.totalCalls?`${y} made ${t.totalCalls} function calls compared to ${C}'s ${a.totalCalls}. `:a.totalCalls>t.totalCalls?`${C} made ${a.totalCalls} function calls compared to ${y}'s ${t.totalCalls}. `:`Both made ${t.totalCalls} calls. `,r==="factorial"?"Factorial is inherently linear — naive and memoized perform similarly. The iterative version avoids stack overhead.":r==="coin-change"?"Naive coin change explores all combinations (branching factor 3), while memoization caches sub-amounts to avoid redundant work. Iterative DP builds the table bottom-up.":"Naive recursion recalculates the same subproblems exponentially (O(2ⁿ)), while memoization caches results reducing to O(n). The iterative approach avoids recursion overhead entirely with O(1) space."]})]}),e.jsxs("button",{onClick:x,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-slate-800/60 px-6 py-3 text-sm font-medium text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/60 active:scale-[0.98]",children:[e.jsx(xe,{size:14})," New Battle"]})]})]})})}const Fe=[261.63,293.66,329.63,392,440,523.25,587.33,659.25,783.99,880];function we(){const t=u.useRef(!0),a=u.useCallback(()=>qe(),[]),s=u.useCallback(i=>{t.current=i},[]),l=u.useCallback((i,o,r)=>{if(!t.current)return;const d=a();if(!d)return;const m=i/Math.max(o-1,1),x=Fe[Math.floor(m*(Fe.length-1))],g=d.createOscillator(),p=d.createGain(),f=d.createStereoPanner();g.type="sine",g.frequency.value=x,p.gain.setValueAtTime(.04,d.currentTime),p.gain.exponentialRampToValueAtTime(.001,d.currentTime+.08),f.pan.value=r,g.connect(p),p.connect(f),f.connect(d.destination),g.start(),g.stop(d.currentTime+.08)},[a]),n=u.useCallback((i,o,r)=>{if(!t.current)return;const d=a();if(!d)return;const x=200+i/Math.max(o-1,1)*600,g=d.createOscillator(),p=d.createGain(),f=d.createStereoPanner();g.type="triangle",g.frequency.value=x,p.gain.setValueAtTime(.06,d.currentTime),p.gain.exponentialRampToValueAtTime(.001,d.currentTime+.1),f.pan.value=r,g.connect(p),p.connect(f),f.connect(d.destination),g.start(),g.stop(d.currentTime+.1)},[a]),c=u.useCallback(()=>{if(!t.current)return;const i=a();i&&[523.25,659.25,783.99].forEach((o,r)=>{const d=i.createOscillator(),m=i.createGain();d.type="sine",d.frequency.value=o,m.gain.setValueAtTime(.1,i.currentTime+r*.12),m.gain.exponentialRampToValueAtTime(.001,i.currentTime+r*.12+.2),d.connect(m),m.connect(i.destination),d.start(i.currentTime+r*.12),d.stop(i.currentTime+r*.12+.2)})},[a]);return{playCompareTone:l,playSwapTone:n,playWinTone:c,setEnabled:s}}function te(t,a){let s=0,l=0,n=0;for(let c=0;c<=a&&c{y(j),ie(j)},[ie]),Q=u.useCallback(()=>{L.current&&(cancelAnimationFrame(L.current),L.current=null)},[]),A=u.useCallback(()=>{const j=Ue(n,i);ae(j);const b=Me(t,[...j]),v=Me(s,[...j]);P.current=b,F.current=v,E.current=0,H.current=0;const T=te(b,0),V=te(v,0);if(w(se(t,b[0],T,0,b.length,!1)),h(se(s,v[0],V,0,v.length,!1)),B(null),G(null),_([{stepA:0,stepB:0,opsA:0,opsB:0}]),ee.current=performance.now(),r==="turbo"){const le=te(b,b.length-1),U=te(v,v.length-1);le.timeElapsed=0,U.timeElapsed=0;const oe=b[b.length-1],pe=v[v.length-1];w(se(t,oe,le,b.length-1,b.length,!0)),h(se(s,pe,U,v.length-1,v.length,!0));let I="tie";le.totalSteps{const j=P.current,b=F.current;let v=E.current,T=H.current;const V=v>=j.length-1,le=T>=b.length-1;if(V&&le){const I=te(j,v),Ce=te(b,T),Ae=(performance.now()-ee.current)/1e3;I.timeElapsed=Ae,Ce.timeElapsed=Ae,w(se(t,j[v],I,v,j.length,!0)),h(se(s,b[T],Ce,T,b.length,!0));let he="tie";j.length=j.length-1)),h(se(s,b[T],oe,T,b.length,T>=b.length-1)),_(I=>[...I,{stepA:U.stepsCompleted,stepB:oe.stepsCompleted,opsA:U.totalOperations,opsB:oe.totalOperations}])},[t,s,n,f,$,q,Y,W]);u.useEffect(()=>{if(g!=="running"){Q();return}let j=0;const b=v=>{v-j>=m&&(j=v,k()),L.current=requestAnimationFrame(b)};return L.current=requestAnimationFrame(b),Q},[g,m,k,Q]);const N=u.useCallback(()=>{g==="running"&&p("paused")},[g]),M=u.useCallback(()=>{g==="paused"&&p("running")},[g]),R=u.useCallback(()=>{Q(),P.current=[],F.current=[],E.current=0,H.current=0,w(null),h(null),B(null),O(null),G(null),_([]),p("setup")},[Q]);return{algorithmA:t,setAlgorithmA:a,algorithmB:s,setAlgorithmB:l,inputSize:n,setInputSize:c,inputType:i,setInputType:o,gameMode:r,setGameMode:d,speed:m,setSpeed:x,status:g,soundEnabled:f,toggleSound:ce,stateA:C,stateB:S,winner:z,prediction:$,setPrediction:O,predictionCorrect:re,inputData:K,metricsHistory:J,startBattle:A,pause:N,resume:M,reset:R}}function Mt(){const[t,a]=u.useState("bfs"),[s,l]=u.useState("dfs"),[n,c]=u.useState("random"),[i,o]=u.useState("realtime"),[r,d]=u.useState(50),[m,x]=u.useState("setup"),[g,p]=u.useState(!0),[f,y]=u.useState(null),[C,w]=u.useState(null),[S,h]=u.useState(null),[z,B]=u.useState(null),[$,O]=u.useState(null),[re,G]=u.useState(null),K=u.useRef([]),ae=u.useRef([]),J=u.useRef(0),_=u.useRef(0),P=u.useRef(null),F=u.useRef({totalVisited:0,pathLength:0,found:!1}),E=u.useRef({totalVisited:0,pathLength:0,found:!1}),{playCompareTone:H,playWinTone:L,setEnabled:ee}=we(),q=u.useCallback(N=>{p(N),ee(N)},[ee]),Y=u.useCallback(()=>{P.current&&(cancelAnimationFrame(P.current),P.current=null)},[]),W=u.useCallback((N,M)=>{let R="tie";return N.found&&!M.found?R="A":!N.found&&M.found?R="B":N.found&&M.found&&(N.totalVisited{const{grid:N,start:M,end:R}=ut(n);y(N);const j=Te(N,M,R,t),b=Te(N,M,R,s);K.current=j.steps,ae.current=b.steps,J.current=0,_.current=0,F.current={totalVisited:j.totalVisited,pathLength:j.pathLength,found:j.found},E.current={totalVisited:b.totalVisited,pathLength:b.pathLength,found:b.found};const v={algorithm:t,steps:j.steps,currentIndex:0,totalVisited:j.totalVisited,pathLength:j.pathLength,found:j.found,finished:!1},T={algorithm:s,steps:b.steps,currentIndex:0,totalVisited:b.totalVisited,pathLength:b.pathLength,found:b.found,finished:!1};if(i==="turbo"){w({...v,currentIndex:j.steps.length-1,finished:!0}),h({...T,currentIndex:b.steps.length-1,finished:!0});const V=W(F.current,E.current);B(V),$&&G($===V),x("finished"),L();return}w(v),h(T),B(null),G(null),x("running")},[t,s,n,i,$,W,L]),ce=u.useCallback(()=>{let N=J.current,M=_.current;const R=K.current,j=ae.current,b=N>=R.length-1,v=M>=j.length-1;if(b&&v){w(V=>V?{...V,currentIndex:N,finished:!0}:null),h(V=>V?{...V,currentIndex:M,finished:!0}:null);const T=W(F.current,E.current);B(T),$&&G($===T),x("finished"),L();return}b||(N++,J.current=N,g&&H(N,R.length,-.8)),v||(M++,_.current=M,g&&H(M,j.length,.8)),w(T=>T?{...T,currentIndex:N,finished:N>=R.length-1}:null),h(T=>T?{...T,currentIndex:M,finished:M>=j.length-1}:null)},[g,$,W,H,L]);u.useEffect(()=>{if(m!=="running"){Y();return}let N=0;const M=R=>{R-N>=r&&(N=R,ce()),P.current=requestAnimationFrame(M)};return P.current=requestAnimationFrame(M),Y},[m,r,ce,Y]);const Q=u.useCallback(()=>{m==="running"&&x("paused")},[m]),A=u.useCallback(()=>{m==="paused"&&x("running")},[m]),k=u.useCallback(()=>{Y(),y(null),w(null),h(null),B(null),O(null),G(null),x("setup")},[Y]);return{algorithmA:t,setAlgorithmA:a,algorithmB:s,setAlgorithmB:l,mazeType:n,setMazeType:c,gameMode:i,setGameMode:o,speed:r,setSpeed:d,status:m,soundEnabled:g,toggleSound:q,grid:f,stateA:C,stateB:S,winner:z,prediction:$,setPrediction:O,predictionCorrect:re,startBattle:ie,pause:Q,resume:A,reset:k}}function zt(){const[t,a]=u.useState("naive"),[s,l]=u.useState("memoized"),[n,c]=u.useState("fibonacci"),[i,o]=u.useState(15),r=u.useCallback(A=>{c(A);const k=Ne.find(N=>N.value===A);k&&o(k.defaultN)},[]),[d,m]=u.useState("realtime"),[x,g]=u.useState(50),[p,f]=u.useState("setup"),[y,C]=u.useState(!0),[w,S]=u.useState(null),[h,z]=u.useState(null),[B,$]=u.useState(null),[O,re]=u.useState(null),[G,K]=u.useState(null),ae=u.useRef([]),J=u.useRef([]),_=u.useRef(0),P=u.useRef(0),F=u.useRef(null),{playCompareTone:E,playWinTone:H,setEnabled:L}=we(),ee=u.useCallback(A=>{C(A),L(A)},[L]),q=u.useCallback(()=>{F.current&&(cancelAnimationFrame(F.current),F.current=null)},[]),Y=u.useCallback(()=>{const A=Oe(t,i,n),k=Oe(s,i,n);ae.current=A.steps,J.current=k.steps,_.current=0,P.current=0;const N={algorithm:t,steps:A.steps,currentIndex:0,totalCalls:A.totalCalls,totalCacheHits:A.totalCacheHits,maxDepth:A.maxDepth,finalResult:A.finalResult,finished:!1},M={algorithm:s,steps:k.steps,currentIndex:0,totalCalls:k.totalCalls,totalCacheHits:k.totalCacheHits,maxDepth:k.maxDepth,finalResult:k.finalResult,finished:!1};if(d==="turbo"){S({...N,currentIndex:A.steps.length-1,finished:!0}),z({...M,currentIndex:k.steps.length-1,finished:!0});let R="tie";A.totalCalls{let A=_.current,k=P.current;const N=ae.current,M=J.current,R=A>=N.length-1,j=k>=M.length-1;if(R&&j){S(v=>v?{...v,currentIndex:A,finished:!0}:null),z(v=>v?{...v,currentIndex:k,finished:!0}:null);let b="tie";N.lengthb?{...b,currentIndex:A,finished:A>=N.length-1}:null),z(b=>b?{...b,currentIndex:k,finished:k>=M.length-1}:null)},[y,O,E,H]);u.useEffect(()=>{if(p!=="running"){q();return}let A=0;const k=N=>{N-A>=x&&(A=N,W()),F.current=requestAnimationFrame(k)};return F.current=requestAnimationFrame(k),q},[p,x,W,q]);const ie=u.useCallback(()=>{p==="running"&&f("paused")},[p]),ce=u.useCallback(()=>{p==="paused"&&f("running")},[p]),Q=u.useCallback(()=>{q(),S(null),z(null),$(null),re(null),K(null),f("setup")},[q]);return{algorithmA:t,setAlgorithmA:a,algorithmB:s,setAlgorithmB:l,problem:n,changeProblem:r,inputN:i,setInputN:o,gameMode:d,setGameMode:m,speed:x,setSpeed:g,status:p,soundEnabled:y,toggleSound:ee,stateA:w,stateB:h,winner:B,prediction:O,setPrediction:re,predictionCorrect:G,startBattle:Y,pause:ie,resume:ce,reset:Q}}const kt=[{value:"sorting",label:"Sorting",desc:"Bubble, Quick, Merge & more",icon:Ke},{value:"pathfinding",label:"Pathfinding",desc:"BFS, DFS, Dijkstra, A*",icon:Ee},{value:"recursion",label:"Recursion",desc:"Fibonacci, Factorial, Staircase & more",icon:Ve}];function Rt({onSelect:t}){return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center justify-center px-6 pt-10 pb-6 text-center",children:[e.jsxs("div",{className:"mb-3 inline-flex items-center gap-2 rounded-full bg-rose-500/10 px-4 py-1.5 ring-1 ring-rose-500/20",children:[e.jsx(Le,{size:14,className:"text-rose-400"}),e.jsx("span",{className:"text-xs font-medium text-rose-300",children:"Algorithm Battles"})]}),e.jsxs("h2",{className:"text-2xl font-extrabold tracking-tight text-white",children:["Choose Your ",e.jsx("span",{className:"bg-gradient-to-r from-rose-400 to-cyan-400 bg-clip-text text-transparent",children:"Arena"})]}),e.jsx("p",{className:"mt-2 max-w-md text-sm text-slate-400",children:"Pick a battle category to pit two algorithms head-to-head."})]}),e.jsx("section",{className:"px-4 pb-10",children:e.jsx("div",{className:"mx-auto max-w-lg grid grid-cols-1 gap-3",children:kt.map(({value:a,label:s,desc:l,icon:n})=>e.jsxs("button",{onClick:()=>t(a),className:"group flex items-center gap-4 rounded-xl border border-slate-700/50 bg-slate-900/60 p-5 text-left backdrop-blur-sm transition-all hover:border-slate-600/60 hover:bg-slate-900/80 hover:scale-[1.01] active:scale-[0.99]",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br from-rose-500/20 to-cyan-500/20 ring-1 ring-white/10",children:e.jsx(n,{size:22,className:"text-white"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white",children:[s," Battles"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:l})]})]},a))})})]})}function Tt({battle:t}){const a=de.find(l=>l.value===t.algorithmA).label,s=de.find(l=>l.value===t.algorithmB).label;return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center px-6 pt-8 pb-4 text-center",children:[e.jsxs("h2",{className:"text-2xl font-extrabold text-white",children:[e.jsx("span",{className:"bg-gradient-to-r from-rose-400 to-orange-400 bg-clip-text text-transparent",children:a})," ","vs"," ",e.jsx("span",{className:"bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent",children:s})]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Race to find a path on the same random grid"})]}),e.jsx("section",{className:"px-4 pb-8",children:e.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:["A","B"].map(l=>e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wider ${l==="A"?"text-rose-400":"text-cyan-400"} mb-3`,children:["Algorithm ",l]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:de.map(n=>e.jsx("button",{onClick:()=>l==="A"?t.setAlgorithmA(n.value):t.setAlgorithmB(n.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${(l==="A"?t.algorithmA:t.algorithmB)===n.value?l==="A"?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:n.label},n.value))})]},l))}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Maze Type"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:rt.map(l=>e.jsx("button",{onClick:()=>t.setMazeType(l.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${t.mazeType===l.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:l.label},l.value))})]}),e.jsx(We,{gameMode:t.gameMode,setGameMode:t.setGameMode,speed:t.speed,setSpeed:t.setSpeed,soundEnabled:t.soundEnabled,toggleSound:t.toggleSound,prediction:t.prediction,setPrediction:t.setPrediction,nameA:a,nameB:s}),e.jsxs("button",{onClick:t.startBattle,disabled:t.gameMode==="prediction"&&!t.prediction,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500/20 to-cyan-500/20 px-6 py-4 text-base font-bold text-white ring-1 ring-white/10 transition-all hover:from-rose-500/30 hover:to-cyan-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Ee,{size:18,className:"text-rose-300"})," Start Battle"]})]})})]})}function $t({battle:t}){const a=ue.find(n=>n.value===t.algorithmA).label,s=ue.find(n=>n.value===t.algorithmB).label,l=Ne.find(n=>n.value===t.problem);return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center px-6 pt-8 pb-4 text-center",children:[e.jsxs("h2",{className:"text-2xl font-extrabold text-white",children:[e.jsx("span",{className:"bg-gradient-to-r from-rose-400 to-orange-400 bg-clip-text text-transparent",children:a})," ","vs"," ",e.jsx("span",{className:"bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent",children:s})]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:l.desc})]}),e.jsx("section",{className:"px-4 pb-8",children:e.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Problem"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-1.5",children:Ne.map(n=>e.jsxs("button",{onClick:()=>t.changeProblem(n.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${t.problem===n.value?"bg-amber-500/20 text-amber-300 ring-1 ring-amber-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:[e.jsx("span",{className:"block font-semibold",children:n.label}),e.jsx("span",{className:"block text-[9px] text-slate-500 mt-0.5",children:n.desc})]},n.value))})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:["A","B"].map(n=>e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wider ${n==="A"?"text-rose-400":"text-cyan-400"} mb-3`,children:["Algorithm ",n]}),e.jsx("div",{className:"space-y-1.5",children:ue.map(c=>e.jsx("button",{onClick:()=>n==="A"?t.setAlgorithmA(c.value):t.setAlgorithmB(c.value),className:`w-full rounded-lg px-3 py-2 text-[11px] font-medium transition-all text-left ${(n==="A"?t.algorithmA:t.algorithmB)===c.value?n==="A"?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:c.label},c.value))})]},n))}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Input"}),e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-slate-500",children:l.inputLabel}),e.jsx("span",{className:"text-sm font-mono font-bold text-indigo-300",children:t.inputN})]}),e.jsx("input",{type:"range",min:l.inputMin,max:l.inputMax,value:t.inputN,onChange:n=>t.setInputN(Number(n.target.value)),className:"w-full accent-indigo-500"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:t.problem==="fibonacci"||t.problem==="staircase"?"⚠️ Naive recursive is exponential — large N generates many steps":t.problem==="coin-change"?"⚠️ Naive coin change branches 3 ways per call — grows very fast":"⚠️ Factorial is linear — naive and memoized are similar here"})]}),e.jsx(We,{gameMode:t.gameMode,setGameMode:t.setGameMode,speed:t.speed,setSpeed:t.setSpeed,soundEnabled:t.soundEnabled,toggleSound:t.toggleSound,prediction:t.prediction,setPrediction:t.setPrediction,nameA:a,nameB:s}),e.jsxs("button",{onClick:t.startBattle,disabled:t.gameMode==="prediction"&&!t.prediction,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500/20 to-cyan-500/20 px-6 py-4 text-base font-bold text-white ring-1 ring-white/10 transition-all hover:from-rose-500/30 hover:to-cyan-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Ve,{size:18,className:"text-rose-300"})," Start Battle"]})]})})]})}function We({gameMode:t,setGameMode:a,speed:s,setSpeed:l,soundEnabled:n,toggleSound:c,prediction:i,setPrediction:o,nameA:r,nameB:d}){const m=[{value:"realtime",label:"Real-Time"},{value:"turbo",label:"Turbo"},{value:"prediction",label:"Prediction"}];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Game Mode"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:m.map(x=>e.jsx("button",{onClick:()=>a(x.value),className:`rounded-lg px-2 py-2 text-[11px] font-semibold transition-all ${t===x.value?"bg-violet-500/20 text-violet-300 ring-1 ring-violet-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:x.label},x.value))})]}),t==="prediction"&&e.jsxs("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/5 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-amber-400 mb-3",children:"Your Prediction"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>o("A"),className:`flex-1 rounded-lg px-3 py-2.5 text-sm font-medium transition-all ${i==="A"?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:r}),e.jsx("button",{onClick:()=>o("B"),className:`flex-1 rounded-lg px-3 py-2.5 text-sm font-medium transition-all ${i==="B"?"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:d})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex-1 rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Speed"}),e.jsx("div",{className:"flex gap-1.5",children:me.map(x=>e.jsx("button",{onClick:()=>l(x.value),className:`flex-1 rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${s===x.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:x.label},x.value))})]}),e.jsxs("button",{onClick:()=>c(!n),className:`shrink-0 flex flex-col items-center justify-center rounded-xl px-4 transition-all ${n?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-1 ring-slate-700/40"}`,children:[n?"🔊":"🔇",e.jsx("span",{className:"text-[10px] mt-1",children:n?"On":"Off"})]})]})]})}function _t(){const[t,a]=u.useState(null),s=At(),l=Mt(),n=zt(),c=()=>{s.reset(),l.reset(),n.reset(),a(null)};if(!t)return e.jsx(Rt,{onSelect:a});const i=e.jsxs("button",{onClick:c,className:"fixed top-16 left-4 z-10 flex items-center gap-1 rounded-lg bg-slate-800/80 px-3 py-1.5 text-xs font-medium text-slate-400 ring-1 ring-slate-700/50 backdrop-blur-sm hover:bg-slate-700/80 hover:text-slate-300",children:[e.jsx(Ye,{size:12})," Back"]});if(t==="sorting"){if(s.status==="setup")return e.jsxs(e.Fragment,{children:[i,e.jsx(tt,{algorithmA:s.algorithmA,algorithmB:s.algorithmB,inputSize:s.inputSize,inputType:s.inputType,gameMode:s.gameMode,speed:s.speed,soundEnabled:s.soundEnabled,prediction:s.prediction,onSetAlgorithmA:s.setAlgorithmA,onSetAlgorithmB:s.setAlgorithmB,onSetInputSize:s.setInputSize,onSetInputType:s.setInputType,onSetGameMode:s.setGameMode,onSetSpeed:s.setSpeed,onToggleSound:s.toggleSound,onSetPrediction:s.setPrediction,onStart:s.startBattle})]});if(s.stateA&&s.stateB)return e.jsxs(e.Fragment,{children:[i,e.jsx(at,{stateA:s.stateA,stateB:s.stateB,status:s.status,winner:s.winner,prediction:s.prediction,predictionCorrect:s.predictionCorrect,inputType:s.inputType,speed:s.speed,soundEnabled:s.soundEnabled,metricsHistory:s.metricsHistory,onPause:s.pause,onResume:s.resume,onReset:s.reset,onSetSpeed:s.setSpeed,onToggleSound:s.toggleSound})]})}if(t==="pathfinding"){if(l.status==="setup")return e.jsxs(e.Fragment,{children:[i,e.jsx(Tt,{battle:l})]});if(l.stateA&&l.stateB&&l.grid)return e.jsxs(e.Fragment,{children:[i,e.jsx(xt,{grid:l.grid,stateA:l.stateA,stateB:l.stateB,status:l.status,winner:l.winner,prediction:l.prediction,predictionCorrect:l.predictionCorrect,speed:l.speed,soundEnabled:l.soundEnabled,onPause:l.pause,onResume:l.resume,onReset:l.reset,onSetSpeed:l.setSpeed,onToggleSound:l.toggleSound})]})}if(t==="recursion"){if(n.status==="setup")return e.jsxs(e.Fragment,{children:[i,e.jsx($t,{battle:n})]});if(n.stateA&&n.stateB)return e.jsxs(e.Fragment,{children:[i,e.jsx(Ct,{stateA:n.stateA,stateB:n.stateB,status:n.status,winner:n.winner,prediction:n.prediction,predictionCorrect:n.predictionCorrect,speed:n.speed,soundEnabled:n.soundEnabled,problem:n.problem,onPause:n.pause,onResume:n.resume,onReset:n.reset,onSetSpeed:n.setSpeed,onToggleSound:n.toggleSound})]})}return null}export{_t as default}; +import{c as He,j as e,e as Le,r as u,f as Ve}from"./index-DBkLeWDs.js";import{V as ge,a as fe}from"./volume-x-BSx9gxSg.js";import{S as Ge}from"./shuffle-Dlr-c52A.js";import{P as be}from"./play-mcIZClKO.js";import{T as je}from"./trophy-C1QWh03u.js";import{R as xe}from"./rotate-ccw-7GTUOPy4.js";import{P as ve}from"./pause-CG1snUW9.js";import{N as D,r as _e}from"./index-DrhCNtmA.js";import{r as Me}from"./index-iw_6MvvU.js";import{g as qe}from"./audioContext-NbgqvQGz.js";import{A as Ye}from"./arrow-left-CTMPG6pL.js";import{M as Ee}from"./map-9j6oGOs_.js";const Xe=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Ke=He("chart-column",Xe);const Qe=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],ye=He("equal",Qe),X=[{value:"bubble",label:"Bubble Sort"},{value:"selection",label:"Selection Sort"},{value:"insertion",label:"Insertion Sort"},{value:"quick",label:"Quick Sort"},{value:"heap",label:"Heap Sort"},{value:"merge",label:"Merge Sort"}],ze={bubble:{best:"O(n)",average:"O(n²)",worst:"O(n²)",space:"O(1)"},selection:{best:"O(n²)",average:"O(n²)",worst:"O(n²)",space:"O(1)"},insertion:{best:"O(n)",average:"O(n²)",worst:"O(n²)",space:"O(1)"},quick:{best:"O(n log n)",average:"O(n log n)",worst:"O(n²)",space:"O(log n)"},heap:{best:"O(n log n)",average:"O(n log n)",worst:"O(n log n)",space:"O(1)"},merge:{best:"O(n log n)",average:"O(n log n)",worst:"O(n log n)",space:"O(n)"}},me=[{label:"Slow",value:150},{label:"Medium",value:50},{label:"Fast",value:15},{label:"Turbo",value:1}];function Ue(t,a){const s=[];for(let l=0;ln-c);const l=Math.max(1,Math.floor(t*.05));for(let n=0;nn-l);return s}function Ze(t,a,s,l,n,c){const i=X.find(f=>f.value===a).label,o=X.find(f=>f.value===s).label;if(t==="tie")return`Both ${i} and ${o} completed in the same number of operations. This can happen with small inputs or similar-complexity algorithms.`;const r=t==="A"?i:o,d=t==="A"?o:i,m=t==="A"?l:n,x=t==="A"?n:l,g=(x.totalSteps/Math.max(m.totalSteps,1)).toFixed(1);let p=`${r} won with ${m.totalSteps} steps vs ${x.totalSteps} steps (${g}x fewer operations). `;return c==="nearly-sorted"?p+="On nearly-sorted data, algorithms like Insertion Sort have a natural advantage due to their O(n) best-case performance.":c==="reversed"?p+="Reversed input is the worst case for O(n²) algorithms, making the performance gap with O(n log n) algorithms very visible.":p+=`${d} performed more operations because its average-case complexity is higher for this input distribution.`,p}const Je=[{value:"random",label:"Random"},{value:"nearly-sorted",label:"Nearly Sorted"},{value:"reversed",label:"Reversed"}],et=[{value:"realtime",label:"Real-Time",desc:"Watch both algorithms animate step-by-step"},{value:"turbo",label:"Turbo",desc:"Instant execution, metrics only"},{value:"prediction",label:"Prediction",desc:"Predict the winner before starting"}];function tt({algorithmA:t,algorithmB:a,inputSize:s,inputType:l,gameMode:n,speed:c,soundEnabled:i,prediction:o,onSetAlgorithmA:r,onSetAlgorithmB:d,onSetInputSize:m,onSetInputType:x,onSetGameMode:g,onSetSpeed:p,onToggleSound:f,onSetPrediction:y,onStart:C}){const w=X.find(h=>h.value===t).label,S=X.find(h=>h.value===a).label;return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center justify-center px-6 pt-8 pb-4 text-center",children:[e.jsxs("div",{className:"mb-3 inline-flex items-center gap-2 rounded-full bg-rose-500/10 px-4 py-1.5 ring-1 ring-rose-500/20",children:[e.jsx(Le,{size:14,className:"text-rose-400"}),e.jsx("span",{className:"text-xs font-medium text-rose-300",children:"Algorithm Battles"})]}),e.jsxs("h2",{className:"text-2xl font-extrabold tracking-tight text-white",children:[e.jsx("span",{className:"bg-gradient-to-r from-rose-400 to-orange-400 bg-clip-text text-transparent",children:w})," ","vs"," ",e.jsx("span",{className:"bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent",children:S})]})]}),e.jsx("section",{className:"px-4 pb-8",children:e.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-rose-400 mb-3",children:"Algorithm A"}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:X.map(h=>e.jsx("button",{onClick:()=>r(h.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${t===h.value?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:h.label},h.value))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-cyan-400 mb-3",children:"Algorithm B"}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:X.map(h=>e.jsx("button",{onClick:()=>d(h.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${a===h.value?"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:h.label},h.value))})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Input Configuration"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Array Size"}),e.jsx("span",{className:"text-sm font-mono font-bold text-indigo-300",children:s})]}),e.jsx("input",{type:"range",min:10,max:200,step:10,value:s,onChange:h=>m(Number(h.target.value)),className:"w-full accent-indigo-500"})]}),e.jsx("div",{className:"flex gap-1.5",children:Je.map(h=>e.jsx("button",{onClick:()=>x(h.value),className:`flex-1 rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${l===h.value?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:h.label},h.value))})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Game Mode"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:et.map(h=>e.jsxs("button",{onClick:()=>g(h.value),className:`flex flex-col items-center rounded-lg px-2 py-2.5 text-[11px] font-medium transition-all ${n===h.value?"bg-violet-500/20 text-violet-300 ring-1 ring-violet-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:[e.jsx("span",{className:"font-semibold",children:h.label}),e.jsx("span",{className:"text-[9px] text-slate-500 mt-0.5 hidden sm:block",children:h.desc})]},h.value))})]}),n==="prediction"&&e.jsxs("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/5 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-amber-400 mb-3",children:"Your Prediction"}),e.jsx("p",{className:"text-[10px] text-amber-300/60 mb-3",children:"Who will win with fewer operations?"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>y("A"),className:`flex-1 rounded-lg px-3 py-2.5 text-sm font-medium transition-all ${o==="A"?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:w}),e.jsx("button",{onClick:()=>y("B"),className:`flex-1 rounded-lg px-3 py-2.5 text-sm font-medium transition-all ${o==="B"?"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:S})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex-1 rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Speed"}),e.jsx("div",{className:"flex gap-1.5",children:me.map(h=>e.jsx("button",{onClick:()=>p(h.value),className:`flex-1 rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${c===h.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:h.label},h.value))})]}),e.jsxs("button",{onClick:()=>f(!i),className:`shrink-0 flex flex-col items-center justify-center rounded-xl px-4 transition-all ${i?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-1 ring-slate-700/40"}`,children:[i?e.jsx(ge,{size:18}):e.jsx(fe,{size:18}),e.jsx("span",{className:"text-[10px] mt-1",children:i?"On":"Off"})]})]}),e.jsxs("button",{onClick:C,disabled:n==="prediction"&&!o,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500/20 to-cyan-500/20 px-6 py-4 text-base font-bold text-white ring-1 ring-white/10 transition-all hover:from-rose-500/30 hover:to-cyan-500/30 hover:ring-white/20 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Ge,{size:18,className:"text-rose-300"}),e.jsx(be,{size:18,className:"text-cyan-300"}),"Start Battle"]})]})})]})}function ke({state:t,color:a,maxVal:s}){const l=X.find(x=>x.value===t.algorithm).label,n=t.status==="finished",c=t.array.length,o={rose:{default:"bg-rose-500/60",comparing:"bg-amber-400",swapping:"bg-rose-300",sorted:"bg-emerald-500/70",border:n?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50",label:"text-rose-400",badge:"bg-rose-500/15 text-rose-300 ring-rose-500/30"},cyan:{default:"bg-cyan-500/60",comparing:"bg-amber-400",swapping:"bg-cyan-300",sorted:"bg-emerald-500/70",border:n?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50",label:"text-cyan-400",badge:"bg-cyan-500/15 text-cyan-300 ring-cyan-500/30"}}[a],r=new Set(t.comparing||[]),d=new Set(t.swapping||[]),m=new Set(t.sorted);return e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsx("span",{className:`text-xs font-bold ${o.label}`,children:l}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ring-1 ${o.badge}`,children:n?"Finished":"Running"})]}),e.jsx("div",{className:`rounded-xl border border-slate-700/50 bg-slate-950/80 p-2 ${o.border} transition-all overflow-hidden`,children:e.jsx("div",{className:"flex items-end gap-px h-32 sm:h-44 md:h-52",children:t.array.map((x,g)=>{const p=x/s*100;let f=o.default;return r.has(g)?f=o.comparing:d.has(g)?f=o.swapping:m.has(g)&&(f=o.sorted),e.jsx("div",{className:`flex-1 rounded-t-sm transition-all duration-75 ${f}`,style:{height:`${p}%`,minWidth:c>100?"1px":"2px"}},g)})})}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5 px-1",children:[e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Comparisons"}),e.jsx("div",{className:"text-xs font-mono font-bold text-white",children:t.metrics.comparisons})]}),e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Swaps"}),e.jsx("div",{className:"text-xs font-mono font-bold text-white",children:t.metrics.swaps})]}),e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Steps"}),e.jsxs("div",{className:"text-xs font-mono font-bold text-white",children:[t.metrics.stepsCompleted,"/",t.metrics.totalSteps]})]})]})]})}function st({history:t,nameA:a,nameB:s}){const{pathA:l,pathB:n,maxOps:c,maxTime:i}=u.useMemo(()=>{if(t.length<2)return{pathA:"",pathB:"",maxOps:1,maxTime:1};const o=Math.max(...t.map(g=>Math.max(g.opsA,g.opsB)),1),r=t.length-1,d=400,m=120,x=g=>t.map((p,f)=>{const y=f/r*d,C=m-p[g]/o*m;return`${f===0?"M":"L"}${y.toFixed(1)},${C.toFixed(1)}`}).join(" ");return{pathA:x("opsA"),pathB:x("opsB"),maxOps:o,maxTime:r}},[t]);return t.length<2?null:e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Live Performance"}),e.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"h-2 w-4 rounded-full bg-rose-400"}),e.jsx("span",{className:"text-[10px] text-slate-400",children:a})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"h-2 w-4 rounded-full bg-cyan-400"}),e.jsx("span",{className:"text-[10px] text-slate-400",children:s})]}),e.jsxs("span",{className:"ml-auto text-[10px] text-slate-500",children:["Max ops: ",c]})]}),e.jsxs("svg",{viewBox:"0 0 400 120",className:"w-full h-20 sm:h-28",preserveAspectRatio:"none",children:[e.jsx("path",{d:l,fill:"none",stroke:"#fb7185",strokeWidth:2,strokeLinecap:"round"}),e.jsx("path",{d:n,fill:"none",stroke:"#22d3ee",strokeWidth:2,strokeLinecap:"round"})]}),e.jsxs("div",{className:"flex justify-between mt-1",children:[e.jsx("span",{className:"text-[9px] text-slate-600",children:"0"}),e.jsxs("span",{className:"text-[9px] text-slate-600",children:["Steps → ",i]})]})]})}function nt({stateA:t,stateB:a,winner:s,prediction:l,predictionCorrect:n,inputType:c,onReset:i}){const o=X.find(g=>g.value===t.algorithm).label,r=X.find(g=>g.value===a.algorithm).label,d=ze[t.algorithm],m=ze[a.algorithm],x=Ze(s,t.algorithm,a.algorithm,t.metrics,a.metrics,c);return e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm space-y-4",children:[e.jsx("div",{className:"text-center",children:s==="tie"?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-500/10 px-5 py-2 ring-1 ring-amber-500/20",children:[e.jsx(ye,{size:18,className:"text-amber-400"}),e.jsx("span",{className:"text-sm font-bold text-amber-300",children:"It's a Tie!"})]}):e.jsxs("div",{className:`inline-flex items-center gap-2 rounded-full px-5 py-2 ring-1 ${s==="A"?"bg-rose-500/10 ring-rose-500/20":"bg-cyan-500/10 ring-cyan-500/20"}`,children:[e.jsx(je,{size:18,className:s==="A"?"text-rose-400":"text-cyan-400"}),e.jsxs("span",{className:`text-sm font-bold ${s==="A"?"text-rose-300":"text-cyan-300"}`,children:[s==="A"?o:r," Wins!"]})]})}),l&&n!==null&&e.jsx("div",{className:`rounded-lg px-4 py-2.5 text-center text-xs font-medium ${n?"bg-emerald-500/10 text-emerald-300 ring-1 ring-emerald-500/20":"bg-rose-500/10 text-rose-300 ring-1 ring-rose-500/20"}`,children:n?"🎯 Your prediction was correct!":"❌ Your prediction was wrong. Keep learning!"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-700/50",children:[e.jsx("th",{className:"py-2 text-left text-slate-500 font-medium",children:"Metric"}),e.jsx("th",{className:"py-2 text-center text-rose-400 font-semibold",children:o}),e.jsx("th",{className:"py-2 text-center text-cyan-400 font-semibold",children:r})]})}),e.jsx("tbody",{className:"font-mono",children:[{label:"Total Steps",a:t.metrics.totalSteps,b:a.metrics.totalSteps},{label:"Comparisons",a:t.metrics.comparisons,b:a.metrics.comparisons},{label:"Swaps",a:t.metrics.swaps,b:a.metrics.swaps},{label:"Array Accesses",a:t.metrics.arrayAccesses,b:a.metrics.arrayAccesses},{label:"Time (s)",a:t.metrics.timeElapsed.toFixed(2),b:a.metrics.timeElapsed.toFixed(2)}].map(({label:g,a:p,b:f})=>{const y=typeof p=="string"?parseFloat(p):p,C=typeof f=="string"?parseFloat(f):f;return e.jsxs("tr",{className:"border-b border-slate-800/50",children:[e.jsx("td",{className:"py-2 text-slate-400",children:g}),e.jsxs("td",{className:`py-2 text-center font-semibold ${y<=C?"text-emerald-300":"text-white"}`,children:[p,ye.jsxs("div",{className:"rounded-lg bg-slate-800/40 p-3",children:[e.jsx("h4",{className:`text-[10px] font-bold uppercase tracking-wider ${f==="rose"?"text-rose-400":"text-cyan-400"} mb-2`,children:g}),e.jsxs("div",{className:"space-y-1 text-[10px] font-mono",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Best"}),e.jsx("span",{className:"text-slate-300",children:p.best})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Average"}),e.jsx("span",{className:"text-slate-300",children:p.average})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Worst"}),e.jsx("span",{className:"text-slate-300",children:p.worst})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Space"}),e.jsx("span",{className:"text-slate-300",children:p.space})]})]})]},g))}),e.jsxs("div",{className:"rounded-lg bg-indigo-500/5 px-4 py-3 ring-1 ring-indigo-500/15",children:[e.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-wider text-indigo-400 mb-1",children:"Why?"}),e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:x})]}),e.jsxs("button",{onClick:i,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-slate-800/60 px-6 py-3 text-sm font-medium text-slate-300 ring-1 ring-slate-700/50 transition-all hover:bg-slate-700/60 active:scale-[0.98]",children:[e.jsx(xe,{size:14}),"New Battle"]})]})}function at({stateA:t,stateB:a,status:s,winner:l,prediction:n,predictionCorrect:c,inputType:i,speed:o,soundEnabled:r,metricsHistory:d,onPause:m,onResume:x,onReset:g,onSetSpeed:p,onToggleSound:f}){const y=X.find(h=>h.value===t.algorithm).label,C=X.find(h=>h.value===a.algorithm).label,w=Math.max(...t.array,...a.array,1),S=s==="running";return e.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-6",children:e.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s!=="finished"&&e.jsxs("button",{onClick:S?m:x,className:"flex items-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-300 ring-1 ring-slate-700/50 transition-all hover:bg-slate-700/60",children:[S?e.jsx(ve,{size:14}):e.jsx(be,{size:14}),S?"Pause":"Resume"]}),e.jsxs("button",{onClick:g,className:"flex items-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-300 ring-1 ring-slate-700/50 transition-all hover:bg-slate-700/60",children:[e.jsx(xe,{size:14}),"Reset"]}),e.jsx("button",{onClick:()=>f(!r),className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-medium transition-all ring-1 ${r?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-slate-700/40"}`,children:r?e.jsx(ge,{size:14}):e.jsx(fe,{size:14})})]}),s!=="finished"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Speed:"}),me.map(h=>e.jsx("button",{onClick:()=>p(h.value),className:`rounded px-2 py-1 text-[10px] font-medium transition-all ${o===h.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-500 hover:bg-slate-700/50"}`,children:h.label},h.value))]}),e.jsxs("div",{className:"text-xs text-slate-500 font-mono",children:[t.metrics.timeElapsed.toFixed(1),"s"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsx(ke,{state:t,color:"rose",maxVal:w}),e.jsx(ke,{state:a,color:"cyan",maxVal:w})]}),e.jsx(st,{history:d,nameA:y,nameB:C}),s==="finished"&&l&&e.jsx(nt,{stateA:t,stateB:a,winner:l,prediction:n,predictionCorrect:c,inputType:i,onReset:g})]})})}const ne=15,Z=25,lt=.25,rt=[{value:"random",label:"Random Scatter"},{value:"recursive-division",label:"Recursive Division"},{value:"dfs-maze",label:"DFS Maze"}];function Re(t,a){return`${t},${a}`}function it(){const t=[];for(let a=0;ac===a.row&&i===a.col||c===s.row&&i===s.col;function n(c,i,o,r,d){if(d){if(i-c<2)return;const m=[];for(let p=c+1;p.5)}function dt(t,a,s){for(let o=0;oMath.random()-.5);for(const[m,x]of d){const g=o+m,p=r+x;g>=0&&g=0&&p=0&&(t[s.row][s.col-1].type=D.EMPTY)}function ut(t="random"){const a=it(),s={row:Math.floor(ne/2),col:1},l={row:Math.floor(ne/2),col:Z-2};switch(t){case"recursive-division":ot(a,s,l);break;case"dfs-maze":dt(a,s,l);break;default:ct(a,s,l);break}return a[s.row][s.col].type=D.START,a[l.row][l.col].type=D.END,{grid:a,start:s,end:l}}function Te(t,a,s,l){const n=_e(l,t,a,s),c=n.visitedNodesInOrder,i=n.shortestPath,o=[],r=new Set;for(let d=0;d0){const d=new Set(r);for(let m=0;mRe(x.row,x.col)))})}return{steps:o,totalVisited:c.length,pathLength:i.length,found:i.length>0}}const de=[{value:"bfs",label:"BFS"},{value:"dfs",label:"DFS"},{value:"dijkstra",label:"Dijkstra"},{value:"astar",label:"A*"}],$e={bfs:{time:"O(V + E)",space:"O(V)",optimal:!0},dfs:{time:"O(V + E)",space:"O(V)",optimal:!1},dijkstra:{time:"O(V² / V+E log V)",space:"O(V)",optimal:!0},astar:{time:"O(E)",space:"O(V)",optimal:!0}};function Be({grid:t,step:a,algorithm:s,color:l,finished:n,totalVisited:c,pathLength:i,currentIndex:o,totalSteps:r}){const d=de.find(g=>g.value===s).label,x={rose:{visited:"bg-rose-500/40",path:"bg-rose-300",current:"bg-rose-400",label:"text-rose-400",badge:"bg-rose-500/15 text-rose-300 ring-rose-500/30",border:n?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50"},cyan:{visited:"bg-cyan-500/40",path:"bg-cyan-300",current:"bg-cyan-400",label:"text-cyan-400",badge:"bg-cyan-500/15 text-cyan-300 ring-cyan-500/30",border:n?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50"}}[l];return e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsx("span",{className:`text-xs font-bold ${x.label}`,children:d}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ring-1 ${x.badge}`,children:n?"Finished":"Running"})]}),e.jsx("div",{className:`rounded-xl border border-slate-700/50 bg-slate-950/80 p-1 ${x.border} transition-all overflow-hidden`,children:e.jsx("div",{className:"grid",style:{gridTemplateColumns:`repeat(${Z}, 1fr)`,gap:"1px"},children:t.map((g,p)=>g.map((f,y)=>{const C=`${p},${y}`;let w="bg-slate-800/40";return f.type===D.WALL?w="bg-slate-600":f.type===D.START?w="bg-emerald-500":f.type===D.END?w="bg-amber-500":a&&(a.pathNodes.has(C)?w=x.path:a.currentNode&&a.currentNode.row===p&&a.currentNode.col===y?w=x.current:a.visitedSoFar.has(C)&&(w=x.visited)),e.jsx("div",{className:`aspect-square rounded-[1px] ${w} transition-colors duration-75`},C)}))})}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5 px-1",children:[e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Visited"}),e.jsx("div",{className:"text-xs font-mono font-bold text-white",children:c})]}),e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Path"}),e.jsx("div",{className:"text-xs font-mono font-bold text-white",children:i})]}),e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2 py-1.5 text-center",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:"Steps"}),e.jsxs("div",{className:"text-xs font-mono font-bold text-white",children:[o,"/",r]})]})]})]})}function xt({grid:t,stateA:a,stateB:s,status:l,winner:n,prediction:c,predictionCorrect:i,speed:o,soundEnabled:r,onPause:d,onResume:m,onReset:x,onSetSpeed:g,onToggleSound:p}){const f=l==="running",y=de.find(h=>h.value===a.algorithm).label,C=de.find(h=>h.value===s.algorithm).label,w=a.currentIndexp(!r),className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-medium ring-1 ${r?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-slate-700/40"}`,children:r?e.jsx(ge,{size:14}):e.jsx(fe,{size:14})})]}),l!=="finished"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Speed:"}),me.map(h=>e.jsx("button",{onClick:()=>g(h.value),className:`rounded px-2 py-1 text-[10px] font-medium ${o===h.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-500 hover:bg-slate-700/50"}`,children:h.label},h.value))]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsx(Be,{grid:t,step:w,algorithm:a.algorithm,color:"rose",finished:a.finished,totalVisited:a.totalVisited,pathLength:a.pathLength,currentIndex:a.currentIndex,totalSteps:a.steps.length}),e.jsx(Be,{grid:t,step:S,algorithm:s.algorithm,color:"cyan",finished:s.finished,totalVisited:s.totalVisited,pathLength:s.pathLength,currentIndex:s.currentIndex,totalSteps:s.steps.length})]}),l==="finished"&&n&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm space-y-4",children:[e.jsx("div",{className:"text-center",children:n==="tie"?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-500/10 px-5 py-2 ring-1 ring-amber-500/20",children:[e.jsx(ye,{size:18,className:"text-amber-400"}),e.jsx("span",{className:"text-sm font-bold text-amber-300",children:"It's a Tie!"})]}):e.jsxs("div",{className:`inline-flex items-center gap-2 rounded-full px-5 py-2 ring-1 ${n==="A"?"bg-rose-500/10 ring-rose-500/20":"bg-cyan-500/10 ring-cyan-500/20"}`,children:[e.jsx(je,{size:18,className:n==="A"?"text-rose-400":"text-cyan-400"}),e.jsxs("span",{className:`text-sm font-bold ${n==="A"?"text-rose-300":"text-cyan-300"}`,children:[n==="A"?y:C," Wins!"]})]})}),c&&i!==null&&e.jsx("div",{className:`rounded-lg px-4 py-2.5 text-center text-xs font-medium ${i?"bg-emerald-500/10 text-emerald-300 ring-1 ring-emerald-500/20":"bg-rose-500/10 text-rose-300 ring-1 ring-rose-500/20"}`,children:i?"🎯 Correct prediction!":"❌ Wrong prediction. Keep learning!"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-700/50",children:[e.jsx("th",{className:"py-2 text-left text-slate-500",children:"Metric"}),e.jsx("th",{className:"py-2 text-center text-rose-400 font-semibold",children:y}),e.jsx("th",{className:"py-2 text-center text-cyan-400 font-semibold",children:C})]})}),e.jsx("tbody",{className:"font-mono",children:[{label:"Nodes Visited",a:a.totalVisited,b:s.totalVisited},{label:"Path Length",a:a.pathLength,b:s.pathLength},{label:"Total Steps",a:a.steps.length,b:s.steps.length}].map(({label:h,a:z,b:B})=>e.jsxs("tr",{className:"border-b border-slate-800/50",children:[e.jsx("td",{className:"py-2 text-slate-400",children:h}),e.jsxs("td",{className:`py-2 text-center font-semibold ${z<=B?"text-emerald-300":"text-white"}`,children:[z,ze.jsxs("div",{className:"rounded-lg bg-slate-800/40 p-3",children:[e.jsx("h4",{className:`text-[10px] font-bold uppercase tracking-wider ${B==="rose"?"text-rose-400":"text-cyan-400"} mb-2`,children:h}),e.jsxs("div",{className:"space-y-1 text-[10px] font-mono",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Time"}),e.jsx("span",{className:"text-slate-300",children:z.time})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Space"}),e.jsx("span",{className:"text-slate-300",children:z.space})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Optimal"}),e.jsx("span",{className:z.optimal?"text-emerald-300":"text-rose-300",children:z.optimal?"Yes":"No"})]})]})]},h))}),e.jsxs("button",{onClick:x,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-slate-800/60 px-6 py-3 text-sm font-medium text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/60 active:scale-[0.98]",children:[e.jsx(xe,{size:14})," New Battle"]})]})]})})}const Ne=[{value:"fibonacci",label:"Fibonacci",desc:"Compute the Nth Fibonacci number",inputLabel:"N",inputMin:5,inputMax:25,defaultN:15},{value:"factorial",label:"Factorial",desc:"Compute N! (N factorial)",inputLabel:"N",inputMin:3,inputMax:20,defaultN:10},{value:"staircase",label:"Staircase",desc:"Ways to climb N stairs (1 or 2 steps)",inputLabel:"Stairs",inputMin:5,inputMax:25,defaultN:15},{value:"coin-change",label:"Coin Change",desc:"Min coins to make amount N (coins: 1,3,5)",inputLabel:"Amount",inputMin:5,inputMax:30,defaultN:15}];function Ie(t){const a=[];let s=0,l=0;function n(i,o){if(s++,l=Math.max(l,o),a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:null,cacheSize:0}),i<=1)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:i,cacheSize:0}),i;const r=n(i-1,o+1)+n(i-2,o+1);return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:r,cacheSize:0}),r}const c=n(t,0);return{steps:a,finalResult:c,totalCalls:s,totalCacheHits:0,maxDepth:l}}function mt(t){const a=[];let s=0,l=0,n=0;const c=new Map;function i(r,d){if(s++,n=Math.max(n,d),c.has(r)){l++;const x=c.get(r);return a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:x,cacheSize:c.size}),x}if(a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:null,cacheSize:c.size}),r<=1)return c.set(r,r),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:r,cacheSize:c.size}),r;const m=i(r-1,d+1)+i(r-2,d+1);return c.set(r,m),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:m,cacheSize:c.size}),m}const o=i(t,0);return{steps:a,finalResult:o,totalCalls:s,totalCacheHits:l,maxDepth:n}}function pt(t){const a=[];let s=0;if(t<=1)return s=1,a.push({callCount:s,cacheHits:0,currentDepth:0,maxDepth:0,currentN:t,result:t,cacheSize:0}),{steps:a,finalResult:t,totalCalls:1,totalCacheHits:0,maxDepth:0};let l=0,n=1;for(let c=2;c<=t;c++){s++;const i=l+n;l=n,n=i,a.push({callCount:s,cacheHits:0,currentDepth:0,maxDepth:0,currentN:c,result:n,cacheSize:0})}return{steps:a,finalResult:n,totalCalls:s,totalCacheHits:0,maxDepth:0}}const ue=[{value:"naive",label:"Naive Recursive"},{value:"memoized",label:"Memoized"},{value:"iterative",label:"Iterative"}],De={naive:{time:"O(2ⁿ)",space:"O(n)"},memoized:{time:"O(n)",space:"O(n)"},iterative:{time:"O(n)",space:"O(1)"}};function ht(t){const a=[];let s=0,l=0;function n(i,o){if(s++,l=Math.max(l,o),a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:null,cacheSize:0}),i<=1)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:1,cacheSize:0}),1;const r=i*n(i-1,o+1);return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:r,cacheSize:0}),r}const c=n(t,0);return{steps:a,finalResult:c,totalCalls:s,totalCacheHits:0,maxDepth:l}}function gt(t){const a=[];let s=0,l=0,n=0;const c=new Map;function i(r,d){if(s++,n=Math.max(n,d),c.has(r)){l++;const x=c.get(r);return a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:x,cacheSize:c.size}),x}if(a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:null,cacheSize:c.size}),r<=1)return c.set(r,1),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:1,cacheSize:c.size}),1;const m=r*i(r-1,d+1);return c.set(r,m),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:m,cacheSize:c.size}),m}const o=i(t,0);return{steps:a,finalResult:o,totalCalls:s,totalCacheHits:l,maxDepth:n}}function ft(t){const a=[];let s=1;for(let l=2;l<=t;l++)s*=l,a.push({callCount:l-1,cacheHits:0,currentDepth:0,maxDepth:0,currentN:l,result:s,cacheSize:0});return a.length===0&&a.push({callCount:1,cacheHits:0,currentDepth:0,maxDepth:0,currentN:t,result:1,cacheSize:0}),{steps:a,finalResult:s,totalCalls:Math.max(t-1,1),totalCacheHits:0,maxDepth:0}}function bt(t){const a=[];let s=0,l=0;function n(i,o){if(s++,l=Math.max(l,o),a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:null,cacheSize:0}),i<=1)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:1,cacheSize:0}),1;const r=n(i-1,o+1)+n(i-2,o+1);return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:r,cacheSize:0}),r}const c=n(t,0);return{steps:a,finalResult:c,totalCalls:s,totalCacheHits:0,maxDepth:l}}function Nt(t){const a=[];let s=0,l=0,n=0;const c=new Map;function i(r,d){if(s++,n=Math.max(n,d),c.has(r)){l++;const x=c.get(r);return a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:x,cacheSize:c.size}),x}if(a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:null,cacheSize:c.size}),r<=1)return c.set(r,1),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:1,cacheSize:c.size}),1;const m=i(r-1,d+1)+i(r-2,d+1);return c.set(r,m),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:m,cacheSize:c.size}),m}const o=i(t,0);return{steps:a,finalResult:o,totalCalls:s,totalCacheHits:l,maxDepth:n}}function jt(t){const a=[];if(t<=1)return a.push({callCount:1,cacheHits:0,currentDepth:0,maxDepth:0,currentN:t,result:1,cacheSize:0}),{steps:a,finalResult:1,totalCalls:1,totalCacheHits:0,maxDepth:0};let s=1,l=1;for(let n=2;n<=t;n++){const c=s+l;s=l,l=c,a.push({callCount:n-1,cacheHits:0,currentDepth:0,maxDepth:0,currentN:n,result:l,cacheSize:0})}return{steps:a,finalResult:l,totalCalls:t-1,totalCacheHits:0,maxDepth:0}}const Se=[1,3,5];function vt(t){const a=[];let s=0,l=0;function n(i,o){if(s++,l=Math.max(l,o),a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:null,cacheSize:0}),i===0)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:0,cacheSize:0}),0;if(i<0)return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:1/0,cacheSize:0}),1/0;let r=1/0;for(const d of Se){const m=n(i-d,o+1);m!==1/0&&(r=Math.min(r,m+1))}return a.push({callCount:s,cacheHits:0,currentDepth:o,maxDepth:l,currentN:i,result:r===1/0?-1:r,cacheSize:0}),r}const c=n(t,0);return{steps:a,finalResult:c===1/0?-1:c,totalCalls:s,totalCacheHits:0,maxDepth:l}}function yt(t){const a=[];let s=0,l=0,n=0;const c=new Map;function i(r,d){if(s++,n=Math.max(n,d),c.has(r)){l++;const x=c.get(r);return a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:x===1/0?-1:x,cacheSize:c.size}),x}if(a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:null,cacheSize:c.size}),r===0)return c.set(0,0),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:0,cacheSize:c.size}),0;if(r<0)return 1/0;let m=1/0;for(const x of Se){const g=i(r-x,d+1);g!==1/0&&(m=Math.min(m,g+1))}return c.set(r,m),a.push({callCount:s,cacheHits:l,currentDepth:d,maxDepth:n,currentN:r,result:m===1/0?-1:m,cacheSize:c.size}),m}const o=i(t,0);return{steps:a,finalResult:o===1/0?-1:o,totalCalls:s,totalCacheHits:l,maxDepth:n}}function St(t){const a=[],s=new Array(t+1).fill(1/0);s[0]=0;let l=0;for(let n=1;n<=t;n++){for(const c of Se)n>=c&&s[n-c]+1r.value===t.algorithm).label,n=t.currentIndex0?t.currentIndex/c*100:0,o=a==="rose"?{label:"text-rose-400",badge:"bg-rose-500/15 text-rose-300 ring-rose-500/30",bar:"bg-rose-500",border:t.finished?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50"}:{label:"text-cyan-400",badge:"bg-cyan-500/15 text-cyan-300 ring-cyan-500/30",bar:"bg-cyan-500",border:t.finished?"ring-2 ring-emerald-500/50":"ring-1 ring-slate-700/50"};return e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-1",children:[e.jsx("span",{className:`text-xs font-bold ${o.label}`,children:l}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ring-1 ${o.badge}`,children:t.finished?"Finished":"Running"})]}),e.jsxs("div",{className:`rounded-xl border border-slate-700/50 bg-slate-950/80 p-3 ${o.border} transition-all`,children:[e.jsxs("div",{className:"mb-2",children:[e.jsxs("div",{className:"flex justify-between mb-1",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Function Calls"}),e.jsxs("span",{className:"text-[10px] font-mono text-slate-400",children:[n?n.callCount:0," / ",t.totalCalls]})]}),e.jsx("div",{className:"h-4 rounded-full bg-slate-800/60 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${o.bar} transition-all duration-75`,style:{width:`${i}%`}})})]}),e.jsxs("div",{className:"mb-2",children:[e.jsx("span",{className:"text-[10px] text-slate-500 block mb-1",children:"Stack Depth"}),e.jsx("div",{className:"flex items-end gap-px h-16",children:Array.from({length:Math.max(n?.maxDepth||1,1)},(r,d)=>{const m=n?dS.value===t.algorithm).label,C=ue.find(S=>S.value===a.algorithm).label,w=wt[r];return e.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-6",children:e.jsxs("div",{className:"mx-auto max-w-5xl space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s!=="finished"&&e.jsxs("button",{onClick:f?d:m,className:"flex items-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/60",children:[f?e.jsx(ve,{size:14}):e.jsx(be,{size:14}),f?"Pause":"Resume"]}),e.jsxs("button",{onClick:x,className:"flex items-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/60",children:[e.jsx(xe,{size:14})," Reset"]}),e.jsx("button",{onClick:()=>p(!o),className:`flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-medium ring-1 ${o?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-slate-700/40"}`,children:o?e.jsx(ge,{size:14}):e.jsx(fe,{size:14})})]}),s!=="finished"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-slate-500",children:"Speed:"}),me.map(S=>e.jsx("button",{onClick:()=>g(S.value),className:`rounded px-2 py-1 text-[10px] font-medium ${i===S.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-500 hover:bg-slate-700/50"}`,children:S.label},S.value))]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsx(Pe,{state:t,color:"rose",funcName:w}),e.jsx(Pe,{state:a,color:"cyan",funcName:w})]}),s==="finished"&&l&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm space-y-4",children:[e.jsx("div",{className:"text-center",children:l==="tie"?e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full bg-amber-500/10 px-5 py-2 ring-1 ring-amber-500/20",children:[e.jsx(ye,{size:18,className:"text-amber-400"}),e.jsx("span",{className:"text-sm font-bold text-amber-300",children:"It's a Tie!"})]}):e.jsxs("div",{className:`inline-flex items-center gap-2 rounded-full px-5 py-2 ring-1 ${l==="A"?"bg-rose-500/10 ring-rose-500/20":"bg-cyan-500/10 ring-cyan-500/20"}`,children:[e.jsx(je,{size:18,className:l==="A"?"text-rose-400":"text-cyan-400"}),e.jsxs("span",{className:`text-sm font-bold ${l==="A"?"text-rose-300":"text-cyan-300"}`,children:[l==="A"?y:C," Wins!"]})]})}),n&&c!==null&&e.jsx("div",{className:`rounded-lg px-4 py-2.5 text-center text-xs font-medium ${c?"bg-emerald-500/10 text-emerald-300 ring-1 ring-emerald-500/20":"bg-rose-500/10 text-rose-300 ring-1 ring-rose-500/20"}`,children:c?"🎯 Correct prediction!":"❌ Wrong prediction. Keep learning!"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-700/50",children:[e.jsx("th",{className:"py-2 text-left text-slate-500",children:"Metric"}),e.jsx("th",{className:"py-2 text-center text-rose-400 font-semibold",children:y}),e.jsx("th",{className:"py-2 text-center text-cyan-400 font-semibold",children:C})]})}),e.jsx("tbody",{className:"font-mono",children:[{label:"Total Calls",a:t.totalCalls,b:a.totalCalls},{label:"Cache Hits",a:t.totalCacheHits,b:a.totalCacheHits},{label:"Max Stack Depth",a:t.maxDepth,b:a.maxDepth},{label:"Total Steps",a:t.steps.length,b:a.steps.length}].map(({label:S,a:h,b:z})=>e.jsxs("tr",{className:"border-b border-slate-800/50",children:[e.jsx("td",{className:"py-2 text-slate-400",children:S}),e.jsxs("td",{className:`py-2 text-center font-semibold ${h<=z?"text-emerald-300":"text-white"}`,children:[h,he.jsxs("div",{className:"rounded-lg bg-slate-800/40 p-3",children:[e.jsx("h4",{className:`text-[10px] font-bold uppercase tracking-wider ${z==="rose"?"text-rose-400":"text-cyan-400"} mb-2`,children:S}),e.jsxs("div",{className:"space-y-1 text-[10px] font-mono",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Time"}),e.jsx("span",{className:"text-slate-300",children:h.time})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-500",children:"Space"}),e.jsx("span",{className:"text-slate-300",children:h.space})]})]})]},S))}),e.jsxs("div",{className:"rounded-lg bg-indigo-500/5 px-4 py-3 ring-1 ring-indigo-500/15",children:[e.jsx("h4",{className:"text-[10px] font-bold uppercase tracking-wider text-indigo-400 mb-1",children:"Why?"}),e.jsxs("p",{className:"text-xs text-slate-400 leading-relaxed",children:[t.totalCalls>a.totalCalls?`${y} made ${t.totalCalls} function calls compared to ${C}'s ${a.totalCalls}. `:a.totalCalls>t.totalCalls?`${C} made ${a.totalCalls} function calls compared to ${y}'s ${t.totalCalls}. `:`Both made ${t.totalCalls} calls. `,r==="factorial"?"Factorial is inherently linear — naive and memoized perform similarly. The iterative version avoids stack overhead.":r==="coin-change"?"Naive coin change explores all combinations (branching factor 3), while memoization caches sub-amounts to avoid redundant work. Iterative DP builds the table bottom-up.":"Naive recursion recalculates the same subproblems exponentially (O(2ⁿ)), while memoization caches results reducing to O(n). The iterative approach avoids recursion overhead entirely with O(1) space."]})]}),e.jsxs("button",{onClick:x,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-slate-800/60 px-6 py-3 text-sm font-medium text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/60 active:scale-[0.98]",children:[e.jsx(xe,{size:14})," New Battle"]})]})]})})}const Fe=[261.63,293.66,329.63,392,440,523.25,587.33,659.25,783.99,880];function we(){const t=u.useRef(!0),a=u.useCallback(()=>qe(),[]),s=u.useCallback(i=>{t.current=i},[]),l=u.useCallback((i,o,r)=>{if(!t.current)return;const d=a();if(!d)return;const m=i/Math.max(o-1,1),x=Fe[Math.floor(m*(Fe.length-1))],g=d.createOscillator(),p=d.createGain(),f=d.createStereoPanner();g.type="sine",g.frequency.value=x,p.gain.setValueAtTime(.04,d.currentTime),p.gain.exponentialRampToValueAtTime(.001,d.currentTime+.08),f.pan.value=r,g.connect(p),p.connect(f),f.connect(d.destination),g.start(),g.stop(d.currentTime+.08)},[a]),n=u.useCallback((i,o,r)=>{if(!t.current)return;const d=a();if(!d)return;const x=200+i/Math.max(o-1,1)*600,g=d.createOscillator(),p=d.createGain(),f=d.createStereoPanner();g.type="triangle",g.frequency.value=x,p.gain.setValueAtTime(.06,d.currentTime),p.gain.exponentialRampToValueAtTime(.001,d.currentTime+.1),f.pan.value=r,g.connect(p),p.connect(f),f.connect(d.destination),g.start(),g.stop(d.currentTime+.1)},[a]),c=u.useCallback(()=>{if(!t.current)return;const i=a();i&&[523.25,659.25,783.99].forEach((o,r)=>{const d=i.createOscillator(),m=i.createGain();d.type="sine",d.frequency.value=o,m.gain.setValueAtTime(.1,i.currentTime+r*.12),m.gain.exponentialRampToValueAtTime(.001,i.currentTime+r*.12+.2),d.connect(m),m.connect(i.destination),d.start(i.currentTime+r*.12),d.stop(i.currentTime+r*.12+.2)})},[a]);return{playCompareTone:l,playSwapTone:n,playWinTone:c,setEnabled:s}}function te(t,a){let s=0,l=0,n=0;for(let c=0;c<=a&&c{y(j),ie(j)},[ie]),Q=u.useCallback(()=>{L.current&&(cancelAnimationFrame(L.current),L.current=null)},[]),A=u.useCallback(()=>{const j=Ue(n,i);ae(j);const b=Me(t,[...j]),v=Me(s,[...j]);P.current=b,F.current=v,E.current=0,H.current=0;const T=te(b,0),V=te(v,0);if(w(se(t,b[0],T,0,b.length,!1)),h(se(s,v[0],V,0,v.length,!1)),B(null),G(null),_([{stepA:0,stepB:0,opsA:0,opsB:0}]),ee.current=performance.now(),r==="turbo"){const le=te(b,b.length-1),U=te(v,v.length-1);le.timeElapsed=0,U.timeElapsed=0;const oe=b[b.length-1],pe=v[v.length-1];w(se(t,oe,le,b.length-1,b.length,!0)),h(se(s,pe,U,v.length-1,v.length,!0));let I="tie";le.totalSteps{const j=P.current,b=F.current;let v=E.current,T=H.current;const V=v>=j.length-1,le=T>=b.length-1;if(V&&le){const I=te(j,v),Ce=te(b,T),Ae=(performance.now()-ee.current)/1e3;I.timeElapsed=Ae,Ce.timeElapsed=Ae,w(se(t,j[v],I,v,j.length,!0)),h(se(s,b[T],Ce,T,b.length,!0));let he="tie";j.length=j.length-1)),h(se(s,b[T],oe,T,b.length,T>=b.length-1)),_(I=>[...I,{stepA:U.stepsCompleted,stepB:oe.stepsCompleted,opsA:U.totalOperations,opsB:oe.totalOperations}])},[t,s,n,f,$,q,Y,W]);u.useEffect(()=>{if(g!=="running"){Q();return}let j=0;const b=v=>{v-j>=m&&(j=v,k()),L.current=requestAnimationFrame(b)};return L.current=requestAnimationFrame(b),Q},[g,m,k,Q]);const N=u.useCallback(()=>{g==="running"&&p("paused")},[g]),M=u.useCallback(()=>{g==="paused"&&p("running")},[g]),R=u.useCallback(()=>{Q(),P.current=[],F.current=[],E.current=0,H.current=0,w(null),h(null),B(null),O(null),G(null),_([]),p("setup")},[Q]);return{algorithmA:t,setAlgorithmA:a,algorithmB:s,setAlgorithmB:l,inputSize:n,setInputSize:c,inputType:i,setInputType:o,gameMode:r,setGameMode:d,speed:m,setSpeed:x,status:g,soundEnabled:f,toggleSound:ce,stateA:C,stateB:S,winner:z,prediction:$,setPrediction:O,predictionCorrect:re,inputData:K,metricsHistory:J,startBattle:A,pause:N,resume:M,reset:R}}function Mt(){const[t,a]=u.useState("bfs"),[s,l]=u.useState("dfs"),[n,c]=u.useState("random"),[i,o]=u.useState("realtime"),[r,d]=u.useState(50),[m,x]=u.useState("setup"),[g,p]=u.useState(!0),[f,y]=u.useState(null),[C,w]=u.useState(null),[S,h]=u.useState(null),[z,B]=u.useState(null),[$,O]=u.useState(null),[re,G]=u.useState(null),K=u.useRef([]),ae=u.useRef([]),J=u.useRef(0),_=u.useRef(0),P=u.useRef(null),F=u.useRef({totalVisited:0,pathLength:0,found:!1}),E=u.useRef({totalVisited:0,pathLength:0,found:!1}),{playCompareTone:H,playWinTone:L,setEnabled:ee}=we(),q=u.useCallback(N=>{p(N),ee(N)},[ee]),Y=u.useCallback(()=>{P.current&&(cancelAnimationFrame(P.current),P.current=null)},[]),W=u.useCallback((N,M)=>{let R="tie";return N.found&&!M.found?R="A":!N.found&&M.found?R="B":N.found&&M.found&&(N.totalVisited{const{grid:N,start:M,end:R}=ut(n);y(N);const j=Te(N,M,R,t),b=Te(N,M,R,s);K.current=j.steps,ae.current=b.steps,J.current=0,_.current=0,F.current={totalVisited:j.totalVisited,pathLength:j.pathLength,found:j.found},E.current={totalVisited:b.totalVisited,pathLength:b.pathLength,found:b.found};const v={algorithm:t,steps:j.steps,currentIndex:0,totalVisited:j.totalVisited,pathLength:j.pathLength,found:j.found,finished:!1},T={algorithm:s,steps:b.steps,currentIndex:0,totalVisited:b.totalVisited,pathLength:b.pathLength,found:b.found,finished:!1};if(i==="turbo"){w({...v,currentIndex:j.steps.length-1,finished:!0}),h({...T,currentIndex:b.steps.length-1,finished:!0});const V=W(F.current,E.current);B(V),$&&G($===V),x("finished"),L();return}w(v),h(T),B(null),G(null),x("running")},[t,s,n,i,$,W,L]),ce=u.useCallback(()=>{let N=J.current,M=_.current;const R=K.current,j=ae.current,b=N>=R.length-1,v=M>=j.length-1;if(b&&v){w(V=>V?{...V,currentIndex:N,finished:!0}:null),h(V=>V?{...V,currentIndex:M,finished:!0}:null);const T=W(F.current,E.current);B(T),$&&G($===T),x("finished"),L();return}b||(N++,J.current=N,g&&H(N,R.length,-.8)),v||(M++,_.current=M,g&&H(M,j.length,.8)),w(T=>T?{...T,currentIndex:N,finished:N>=R.length-1}:null),h(T=>T?{...T,currentIndex:M,finished:M>=j.length-1}:null)},[g,$,W,H,L]);u.useEffect(()=>{if(m!=="running"){Y();return}let N=0;const M=R=>{R-N>=r&&(N=R,ce()),P.current=requestAnimationFrame(M)};return P.current=requestAnimationFrame(M),Y},[m,r,ce,Y]);const Q=u.useCallback(()=>{m==="running"&&x("paused")},[m]),A=u.useCallback(()=>{m==="paused"&&x("running")},[m]),k=u.useCallback(()=>{Y(),y(null),w(null),h(null),B(null),O(null),G(null),x("setup")},[Y]);return{algorithmA:t,setAlgorithmA:a,algorithmB:s,setAlgorithmB:l,mazeType:n,setMazeType:c,gameMode:i,setGameMode:o,speed:r,setSpeed:d,status:m,soundEnabled:g,toggleSound:q,grid:f,stateA:C,stateB:S,winner:z,prediction:$,setPrediction:O,predictionCorrect:re,startBattle:ie,pause:Q,resume:A,reset:k}}function zt(){const[t,a]=u.useState("naive"),[s,l]=u.useState("memoized"),[n,c]=u.useState("fibonacci"),[i,o]=u.useState(15),r=u.useCallback(A=>{c(A);const k=Ne.find(N=>N.value===A);k&&o(k.defaultN)},[]),[d,m]=u.useState("realtime"),[x,g]=u.useState(50),[p,f]=u.useState("setup"),[y,C]=u.useState(!0),[w,S]=u.useState(null),[h,z]=u.useState(null),[B,$]=u.useState(null),[O,re]=u.useState(null),[G,K]=u.useState(null),ae=u.useRef([]),J=u.useRef([]),_=u.useRef(0),P=u.useRef(0),F=u.useRef(null),{playCompareTone:E,playWinTone:H,setEnabled:L}=we(),ee=u.useCallback(A=>{C(A),L(A)},[L]),q=u.useCallback(()=>{F.current&&(cancelAnimationFrame(F.current),F.current=null)},[]),Y=u.useCallback(()=>{const A=Oe(t,i,n),k=Oe(s,i,n);ae.current=A.steps,J.current=k.steps,_.current=0,P.current=0;const N={algorithm:t,steps:A.steps,currentIndex:0,totalCalls:A.totalCalls,totalCacheHits:A.totalCacheHits,maxDepth:A.maxDepth,finalResult:A.finalResult,finished:!1},M={algorithm:s,steps:k.steps,currentIndex:0,totalCalls:k.totalCalls,totalCacheHits:k.totalCacheHits,maxDepth:k.maxDepth,finalResult:k.finalResult,finished:!1};if(d==="turbo"){S({...N,currentIndex:A.steps.length-1,finished:!0}),z({...M,currentIndex:k.steps.length-1,finished:!0});let R="tie";A.totalCalls{let A=_.current,k=P.current;const N=ae.current,M=J.current,R=A>=N.length-1,j=k>=M.length-1;if(R&&j){S(v=>v?{...v,currentIndex:A,finished:!0}:null),z(v=>v?{...v,currentIndex:k,finished:!0}:null);let b="tie";N.lengthb?{...b,currentIndex:A,finished:A>=N.length-1}:null),z(b=>b?{...b,currentIndex:k,finished:k>=M.length-1}:null)},[y,O,E,H]);u.useEffect(()=>{if(p!=="running"){q();return}let A=0;const k=N=>{N-A>=x&&(A=N,W()),F.current=requestAnimationFrame(k)};return F.current=requestAnimationFrame(k),q},[p,x,W,q]);const ie=u.useCallback(()=>{p==="running"&&f("paused")},[p]),ce=u.useCallback(()=>{p==="paused"&&f("running")},[p]),Q=u.useCallback(()=>{q(),S(null),z(null),$(null),re(null),K(null),f("setup")},[q]);return{algorithmA:t,setAlgorithmA:a,algorithmB:s,setAlgorithmB:l,problem:n,changeProblem:r,inputN:i,setInputN:o,gameMode:d,setGameMode:m,speed:x,setSpeed:g,status:p,soundEnabled:y,toggleSound:ee,stateA:w,stateB:h,winner:B,prediction:O,setPrediction:re,predictionCorrect:G,startBattle:Y,pause:ie,resume:ce,reset:Q}}const kt=[{value:"sorting",label:"Sorting",desc:"Bubble, Quick, Merge & more",icon:Ke},{value:"pathfinding",label:"Pathfinding",desc:"BFS, DFS, Dijkstra, A*",icon:Ee},{value:"recursion",label:"Recursion",desc:"Fibonacci, Factorial, Staircase & more",icon:Ve}];function Rt({onSelect:t}){return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center justify-center px-6 pt-10 pb-6 text-center",children:[e.jsxs("div",{className:"mb-3 inline-flex items-center gap-2 rounded-full bg-rose-500/10 px-4 py-1.5 ring-1 ring-rose-500/20",children:[e.jsx(Le,{size:14,className:"text-rose-400"}),e.jsx("span",{className:"text-xs font-medium text-rose-300",children:"Algorithm Battles"})]}),e.jsxs("h2",{className:"text-2xl font-extrabold tracking-tight text-white",children:["Choose Your ",e.jsx("span",{className:"bg-gradient-to-r from-rose-400 to-cyan-400 bg-clip-text text-transparent",children:"Arena"})]}),e.jsx("p",{className:"mt-2 max-w-md text-sm text-slate-400",children:"Pick a battle category to pit two algorithms head-to-head."})]}),e.jsx("section",{className:"px-4 pb-10",children:e.jsx("div",{className:"mx-auto max-w-lg grid grid-cols-1 gap-3",children:kt.map(({value:a,label:s,desc:l,icon:n})=>e.jsxs("button",{onClick:()=>t(a),className:"group flex items-center gap-4 rounded-xl border border-slate-700/50 bg-slate-900/60 p-5 text-left backdrop-blur-sm transition-all hover:border-slate-600/60 hover:bg-slate-900/80 hover:scale-[1.01] active:scale-[0.99]",children:[e.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br from-rose-500/20 to-cyan-500/20 ring-1 ring-white/10",children:e.jsx(n,{size:22,className:"text-white"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-white",children:[s," Battles"]}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:l})]})]},a))})})]})}function Tt({battle:t}){const a=de.find(l=>l.value===t.algorithmA).label,s=de.find(l=>l.value===t.algorithmB).label;return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center px-6 pt-8 pb-4 text-center",children:[e.jsxs("h2",{className:"text-2xl font-extrabold text-white",children:[e.jsx("span",{className:"bg-gradient-to-r from-rose-400 to-orange-400 bg-clip-text text-transparent",children:a})," ","vs"," ",e.jsx("span",{className:"bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent",children:s})]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Race to find a path on the same random grid"})]}),e.jsx("section",{className:"px-4 pb-8",children:e.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:["A","B"].map(l=>e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wider ${l==="A"?"text-rose-400":"text-cyan-400"} mb-3`,children:["Algorithm ",l]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:de.map(n=>e.jsx("button",{onClick:()=>l==="A"?t.setAlgorithmA(n.value):t.setAlgorithmB(n.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${(l==="A"?t.algorithmA:t.algorithmB)===n.value?l==="A"?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:n.label},n.value))})]},l))}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Maze Type"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:rt.map(l=>e.jsx("button",{onClick:()=>t.setMazeType(l.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${t.mazeType===l.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:l.label},l.value))})]}),e.jsx(We,{gameMode:t.gameMode,setGameMode:t.setGameMode,speed:t.speed,setSpeed:t.setSpeed,soundEnabled:t.soundEnabled,toggleSound:t.toggleSound,prediction:t.prediction,setPrediction:t.setPrediction,nameA:a,nameB:s}),e.jsxs("button",{onClick:t.startBattle,disabled:t.gameMode==="prediction"&&!t.prediction,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500/20 to-cyan-500/20 px-6 py-4 text-base font-bold text-white ring-1 ring-white/10 transition-all hover:from-rose-500/30 hover:to-cyan-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Ee,{size:18,className:"text-rose-300"})," Start Battle"]})]})})]})}function $t({battle:t}){const a=ue.find(n=>n.value===t.algorithmA).label,s=ue.find(n=>n.value===t.algorithmB).label,l=Ne.find(n=>n.value===t.problem);return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center px-6 pt-8 pb-4 text-center",children:[e.jsxs("h2",{className:"text-2xl font-extrabold text-white",children:[e.jsx("span",{className:"bg-gradient-to-r from-rose-400 to-orange-400 bg-clip-text text-transparent",children:a})," ","vs"," ",e.jsx("span",{className:"bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent",children:s})]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:l.desc})]}),e.jsx("section",{className:"px-4 pb-8",children:e.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Problem"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-1.5",children:Ne.map(n=>e.jsxs("button",{onClick:()=>t.changeProblem(n.value),className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${t.problem===n.value?"bg-amber-500/20 text-amber-300 ring-1 ring-amber-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:[e.jsx("span",{className:"block font-semibold",children:n.label}),e.jsx("span",{className:"block text-[9px] text-slate-500 mt-0.5",children:n.desc})]},n.value))})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:["A","B"].map(n=>e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("h3",{className:`text-xs font-semibold uppercase tracking-wider ${n==="A"?"text-rose-400":"text-cyan-400"} mb-3`,children:["Algorithm ",n]}),e.jsx("div",{className:"space-y-1.5",children:ue.map(c=>e.jsx("button",{onClick:()=>n==="A"?t.setAlgorithmA(c.value):t.setAlgorithmB(c.value),className:`w-full rounded-lg px-3 py-2 text-[11px] font-medium transition-all text-left ${(n==="A"?t.algorithmA:t.algorithmB)===c.value?n==="A"?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:c.label},c.value))})]},n))}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Input"}),e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-slate-500",children:l.inputLabel}),e.jsx("span",{className:"text-sm font-mono font-bold text-indigo-300",children:t.inputN})]}),e.jsx("input",{type:"range",min:l.inputMin,max:l.inputMax,value:t.inputN,onChange:n=>t.setInputN(Number(n.target.value)),className:"w-full accent-indigo-500"}),e.jsx("p",{className:"text-[10px] text-slate-500 mt-1",children:t.problem==="fibonacci"||t.problem==="staircase"?"⚠️ Naive recursive is exponential — large N generates many steps":t.problem==="coin-change"?"⚠️ Naive coin change branches 3 ways per call — grows very fast":"⚠️ Factorial is linear — naive and memoized are similar here"})]}),e.jsx(We,{gameMode:t.gameMode,setGameMode:t.setGameMode,speed:t.speed,setSpeed:t.setSpeed,soundEnabled:t.soundEnabled,toggleSound:t.toggleSound,prediction:t.prediction,setPrediction:t.setPrediction,nameA:a,nameB:s}),e.jsxs("button",{onClick:t.startBattle,disabled:t.gameMode==="prediction"&&!t.prediction,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500/20 to-cyan-500/20 px-6 py-4 text-base font-bold text-white ring-1 ring-white/10 transition-all hover:from-rose-500/30 hover:to-cyan-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Ve,{size:18,className:"text-rose-300"})," Start Battle"]})]})})]})}function We({gameMode:t,setGameMode:a,speed:s,setSpeed:l,soundEnabled:n,toggleSound:c,prediction:i,setPrediction:o,nameA:r,nameB:d}){const m=[{value:"realtime",label:"Real-Time"},{value:"turbo",label:"Turbo"},{value:"prediction",label:"Prediction"}];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Game Mode"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:m.map(x=>e.jsx("button",{onClick:()=>a(x.value),className:`rounded-lg px-2 py-2 text-[11px] font-semibold transition-all ${t===x.value?"bg-violet-500/20 text-violet-300 ring-1 ring-violet-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:x.label},x.value))})]}),t==="prediction"&&e.jsxs("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/5 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-amber-400 mb-3",children:"Your Prediction"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>o("A"),className:`flex-1 rounded-lg px-3 py-2.5 text-sm font-medium transition-all ${i==="A"?"bg-rose-500/20 text-rose-300 ring-1 ring-rose-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:r}),e.jsx("button",{onClick:()=>o("B"),className:`flex-1 rounded-lg px-3 py-2.5 text-sm font-medium transition-all ${i==="B"?"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:d})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex-1 rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Speed"}),e.jsx("div",{className:"flex gap-1.5",children:me.map(x=>e.jsx("button",{onClick:()=>l(x.value),className:`flex-1 rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${s===x.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50"}`,children:x.label},x.value))})]}),e.jsxs("button",{onClick:()=>c(!n),className:`shrink-0 flex flex-col items-center justify-center rounded-xl px-4 transition-all ${n?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-500 ring-1 ring-slate-700/40"}`,children:[n?"🔊":"🔇",e.jsx("span",{className:"text-[10px] mt-1",children:n?"On":"Off"})]})]})]})}function _t(){const[t,a]=u.useState(null),s=At(),l=Mt(),n=zt(),c=()=>{s.reset(),l.reset(),n.reset(),a(null)};if(!t)return e.jsx(Rt,{onSelect:a});const i=e.jsxs("button",{onClick:c,className:"fixed top-16 left-4 z-10 flex items-center gap-1 rounded-lg bg-slate-800/80 px-3 py-1.5 text-xs font-medium text-slate-400 ring-1 ring-slate-700/50 backdrop-blur-sm hover:bg-slate-700/80 hover:text-slate-300",children:[e.jsx(Ye,{size:12})," Back"]});if(t==="sorting"){if(s.status==="setup")return e.jsxs(e.Fragment,{children:[i,e.jsx(tt,{algorithmA:s.algorithmA,algorithmB:s.algorithmB,inputSize:s.inputSize,inputType:s.inputType,gameMode:s.gameMode,speed:s.speed,soundEnabled:s.soundEnabled,prediction:s.prediction,onSetAlgorithmA:s.setAlgorithmA,onSetAlgorithmB:s.setAlgorithmB,onSetInputSize:s.setInputSize,onSetInputType:s.setInputType,onSetGameMode:s.setGameMode,onSetSpeed:s.setSpeed,onToggleSound:s.toggleSound,onSetPrediction:s.setPrediction,onStart:s.startBattle})]});if(s.stateA&&s.stateB)return e.jsxs(e.Fragment,{children:[i,e.jsx(at,{stateA:s.stateA,stateB:s.stateB,status:s.status,winner:s.winner,prediction:s.prediction,predictionCorrect:s.predictionCorrect,inputType:s.inputType,speed:s.speed,soundEnabled:s.soundEnabled,metricsHistory:s.metricsHistory,onPause:s.pause,onResume:s.resume,onReset:s.reset,onSetSpeed:s.setSpeed,onToggleSound:s.toggleSound})]})}if(t==="pathfinding"){if(l.status==="setup")return e.jsxs(e.Fragment,{children:[i,e.jsx(Tt,{battle:l})]});if(l.stateA&&l.stateB&&l.grid)return e.jsxs(e.Fragment,{children:[i,e.jsx(xt,{grid:l.grid,stateA:l.stateA,stateB:l.stateB,status:l.status,winner:l.winner,prediction:l.prediction,predictionCorrect:l.predictionCorrect,speed:l.speed,soundEnabled:l.soundEnabled,onPause:l.pause,onResume:l.resume,onReset:l.reset,onSetSpeed:l.setSpeed,onToggleSound:l.toggleSound})]})}if(t==="recursion"){if(n.status==="setup")return e.jsxs(e.Fragment,{children:[i,e.jsx($t,{battle:n})]});if(n.stateA&&n.stateB)return e.jsxs(e.Fragment,{children:[i,e.jsx(Ct,{stateA:n.stateA,stateB:n.stateB,status:n.status,winner:n.winner,prediction:n.prediction,predictionCorrect:n.predictionCorrect,speed:n.speed,soundEnabled:n.soundEnabled,problem:n.problem,onPause:n.pause,onResume:n.resume,onReset:n.reset,onSetSpeed:n.setSpeed,onToggleSound:n.toggleSound})]})}return null}export{_t as default}; diff --git a/docs/assets/CodeVisualizerPage-CGESrDz0.js b/docs/assets/CodeVisualizerPage-CGESrDz0.js new file mode 100644 index 0000000..7dfc6b7 --- /dev/null +++ b/docs/assets/CodeVisualizerPage-CGESrDz0.js @@ -0,0 +1,44 @@ +import{c as Se,r as Z,j as h,T as Qt,A as Yt,C as Xt,h as Zt}from"./index-DBkLeWDs.js";import{S as Jt}from"./sparkles-3Zw4K66N.js";import{R as ei}from"./rotate-ccw-7GTUOPy4.js";import{A as ti}from"./arrow-left-CTMPG6pL.js";import{P as ii}from"./pause-CG1snUW9.js";import{P as si}from"./play-mcIZClKO.js";const ai=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],ri=Se("circle-stop",ai);const ni=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],oi=Se("gauge",ni);const ui=[["path",{d:"M12 12v-2",key:"fwoke6"}],["path",{d:"M12 18v-2",key:"qj6yno"}],["path",{d:"M16 12v-2",key:"heuere"}],["path",{d:"M16 18v-2",key:"s1ct0w"}],["path",{d:"M2 11h1.5",key:"15p63e"}],["path",{d:"M20 18v-2",key:"12ehxp"}],["path",{d:"M20.5 11H22",key:"khsy7a"}],["path",{d:"M4 18v-2",key:"1c3oqr"}],["path",{d:"M8 12v-2",key:"1mwtfd"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["rect",{x:"2",y:"6",width:"20",height:"10",rx:"2",key:"1qcswk"}]],hi=Se("memory-stick",ui);const li=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ye=Se("shield-check",li);var ci=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],nt=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],pi="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-᫝᫠-᫫ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",ot="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-࢏ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚ౜ౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ೜-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ƛ꟱-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Pe={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},Ve="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",fi={5:Ve,"5module":Ve+" export import",6:Ve+" const class extends export import super"},ut=/^in(stanceof)?$/,di=new RegExp("["+ot+"]"),xi=new RegExp("["+ot+pi+"]");function je(e,t){for(var i=65536,s=0;se)return!1;if(i+=t[s+1],i>=e)return!0}return!1}function U(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&di.test(String.fromCharCode(e)):t===!1?!1:je(e,nt)}function Y(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&xi.test(String.fromCharCode(e)):t===!1?!1:je(e,nt)||je(e,ci)}var y=function(t,i){i===void 0&&(i={}),this.label=t,this.keyword=i.keyword,this.beforeExpr=!!i.beforeExpr,this.startsExpr=!!i.startsExpr,this.isLoop=!!i.isLoop,this.isAssign=!!i.isAssign,this.prefix=!!i.prefix,this.postfix=!!i.postfix,this.binop=i.binop||null,this.updateContext=null};function R(e,t){return new y(e,{beforeExpr:!0,binop:t})}var j={beforeExpr:!0},L={startsExpr:!0},De={};function b(e,t){return t===void 0&&(t={}),t.keyword=e,De[e]=new y(e,t)}var a={num:new y("num",L),regexp:new y("regexp",L),string:new y("string",L),name:new y("name",L),privateId:new y("privateId",L),eof:new y("eof"),bracketL:new y("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new y("]"),braceL:new y("{",{beforeExpr:!0,startsExpr:!0}),braceR:new y("}"),parenL:new y("(",{beforeExpr:!0,startsExpr:!0}),parenR:new y(")"),comma:new y(",",j),semi:new y(";",j),colon:new y(":",j),dot:new y("."),question:new y("?",j),questionDot:new y("?."),arrow:new y("=>",j),template:new y("template"),invalidTemplate:new y("invalidTemplate"),ellipsis:new y("...",j),backQuote:new y("`",L),dollarBraceL:new y("${",{beforeExpr:!0,startsExpr:!0}),eq:new y("=",{beforeExpr:!0,isAssign:!0}),assign:new y("_=",{beforeExpr:!0,isAssign:!0}),incDec:new y("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new y("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:R("||",1),logicalAND:R("&&",2),bitwiseOR:R("|",3),bitwiseXOR:R("^",4),bitwiseAND:R("&",5),equality:R("==/!=/===/!==",6),relational:R("/<=/>=",7),bitShift:R("<>/>>>",8),plusMin:new y("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:R("%",10),star:R("*",10),slash:R("/",10),starstar:new y("**",{beforeExpr:!0}),coalesce:R("??",1),_break:b("break"),_case:b("case",j),_catch:b("catch"),_continue:b("continue"),_debugger:b("debugger"),_default:b("default",j),_do:b("do",{isLoop:!0,beforeExpr:!0}),_else:b("else",j),_finally:b("finally"),_for:b("for",{isLoop:!0}),_function:b("function",L),_if:b("if"),_return:b("return",j),_switch:b("switch"),_throw:b("throw",j),_try:b("try"),_var:b("var"),_const:b("const"),_while:b("while",{isLoop:!0}),_with:b("with"),_new:b("new",{beforeExpr:!0,startsExpr:!0}),_this:b("this",L),_super:b("super",L),_class:b("class",L),_extends:b("extends",j),_export:b("export"),_import:b("import",L),_null:b("null",L),_true:b("true",L),_false:b("false",L),_in:b("in",{beforeExpr:!0,binop:7}),_instanceof:b("instanceof",{beforeExpr:!0,binop:7}),_typeof:b("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:b("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:b("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},T=/\r\n?|\n|\u2028|\u2029/,mi=new RegExp(T.source,"g");function ne(e){return e===10||e===13||e===8232||e===8233}function ht(e,t,i){i===void 0&&(i=e.length);for(var s=t;s>10)+55296,(e&1023)+56320))}var bi=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,ce=function(t,i){this.line=t,this.column=i};ce.prototype.offset=function(t){return new ce(this.line,this.column+t)};var _e=function(t,i,s){this.start=i,this.end=s,t.sourceFile!==null&&(this.source=t.sourceFile)};function pt(e,t){for(var i=1,s=0;;){var r=ht(e,s,t);if(r<0)return new ce(i,t-s);++i,s=r}}var Oe={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Je=!1;function yi(e){var t={};for(var i in Oe)t[i]=e&&oe(e,i)?e[i]:Oe[i];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!Je&&typeof console=="object"&&console.warn&&(Je=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required. +Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),Xe(t.onToken)){var s=t.onToken;t.onToken=function(r){return s.push(r)}}if(Xe(t.onComment)&&(t.onComment=Ci(t,t.onComment)),t.sourceType==="commonjs"&&t.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return t}function Ci(e,t){return function(i,s,r,n,o,u){var l={type:i?"Block":"Line",value:s,start:r,end:n};e.locations&&(l.loc=new _e(this,o,u)),e.ranges&&(l.range=[r,n]),t.push(l)}}var ee=1,te=2,Ue=4,ft=8,qe=16,dt=32,we=64,xt=128,ie=256,pe=512,mt=1024,Ae=ee|te|ie;function ze(e,t){return te|(e?Ue:0)|(t?ft:0)}var ge=0,Ge=1,H=2,gt=3,vt=4,bt=5,E=function(t,i,s){this.options=t=yi(t),this.sourceFile=t.sourceFile,this.keywords=Q(fi[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var r="";t.allowReserved!==!0&&(r=Pe[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(r+=" await")),this.reservedWords=Q(r);var n=(r?r+" ":"")+Pe.strict;this.reservedWordsStrict=Q(n),this.reservedWordsStrictBind=Q(n+" "+Pe.strictBind),this.input=String(i),this.containsEsc=!1,s?(this.pos=s,this.lineStart=this.input.lastIndexOf(` +`,s-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(T).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=a.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?te:ee),this.regexpState=null,this.privateNameStack=[]},B={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};E.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)};B.inFunction.get=function(){return(this.currentVarScope().flags&te)>0};B.inGenerator.get=function(){return(this.currentVarScope().flags&ft)>0};B.inAsync.get=function(){return(this.currentVarScope().flags&Ue)>0};B.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],i=t.flags;if(i&(ie|pe))return!1;if(i&te)return(i&Ue)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};B.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&ee)};B.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&we)>0||this.options.allowSuperOutsideMethod};B.allowDirectSuper.get=function(){return(this.currentThisScope().flags&xt)>0};B.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};B.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],i=t.flags;if(i&(ie|pe)||i&te&&!(i&qe))return!0}return!1};B.allowUsing.get=function(){var e=this.currentScope(),t=e.flags;return!(t&mt||!this.inModule&&t&ee)};B.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ie)>0};E.extend=function(){for(var t=[],i=arguments.length;i--;)t[i]=arguments[i];for(var s=this,r=0;r=,?^&]/.test(r)||r==="!"&&this.input.charAt(s+1)==="=")}e+=t[0].length,P.lastIndex=e,e+=P.exec(this.input)[0].length,this.input[e]===";"&&e++}};V.eat=function(e){return this.type===e?(this.next(),!0):!1};V.isContextual=function(e){return this.type===a.name&&this.value===e&&!this.containsEsc};V.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1};V.expectContextual=function(e){this.eatContextual(e)||this.unexpected()};V.canInsertSemicolon=function(){return this.type===a.eof||this.type===a.braceR||T.test(this.input.slice(this.lastTokEnd,this.start))};V.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};V.semicolon=function(){!this.eat(a.semi)&&!this.insertSemicolon()&&this.unexpected()};V.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0};V.expect=function(e){this.eat(e)||this.unexpected()};V.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var Ie=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};V.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var i=t?e.parenthesizedAssign:e.parenthesizedBind;i>-1&&this.raiseRecoverable(i,t?"Assigning to rvalue":"Parenthesized pattern")}};V.checkExpressionErrors=function(e,t){if(!e)return!1;var i=e.shorthandAssign,s=e.doubleProto;if(!t)return i>=0||s>=0;i>=0&&this.raise(i,"Shorthand property assignments are valid only in destructuring patterns"),s>=0&&this.raiseRecoverable(s,"Redefinition of __proto__ property")};V.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&this.unexpected(),this.parseFunctionStatement(r,!1,!e);case a._class:return e&&this.unexpected(),this.parseClass(r,!0);case a._if:return this.parseIfStatement(r);case a._return:return this.parseReturnStatement(r);case a._switch:return this.parseSwitchStatement(r);case a._throw:return this.parseThrowStatement(r);case a._try:return this.parseTryStatement(r);case a._const:case a._var:return n=n||this.value,e&&n!=="var"&&this.unexpected(),this.parseVarStatement(r,n);case a._while:return this.parseWhileStatement(r);case a._with:return this.parseWithStatement(r);case a.braceL:return this.parseBlock(!0,r);case a.semi:return this.parseEmptyStatement(r);case a._export:case a._import:if(this.options.ecmaVersion>10&&s===a._import){P.lastIndex=this.pos;var o=P.exec(this.input),u=this.pos+o[0].length,l=this.input.charCodeAt(u);if(l===40||l===46)return this.parseExpressionStatement(r,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),s===a._import?this.parseImport(r):this.parseExport(r,i);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(r,!0,!e);var d=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(d)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),d==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(r,!1,d),this.semicolon(),this.finishNode(r,"VariableDeclaration");var f=this.value,S=this.parseExpression();return s===a.name&&S.type==="Identifier"&&this.eat(a.colon)?this.parseLabeledStatement(r,f,S,e):this.parseExpressionStatement(r,S)}};p.parseBreakContinueStatement=function(e,t){var i=t==="break";this.next(),this.eat(a.semi)||this.insertSemicolon()?e.label=null:this.type!==a.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var s=0;s=6?this.eat(a.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")};p.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(We),this.enterScope(0),this.expect(a.parenL),this.type===a.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var i=this.isLet();if(this.type===a._var||this.type===a._const||i){var s=this.startNode(),r=i?"let":this.value;return this.next(),this.parseVar(s,!0,r),this.finishNode(s,"VariableDeclaration"),this.parseForAfterInit(e,s,t)}var n=this.isContextual("let"),o=!1,u=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(u){var l=this.startNode();return this.next(),u==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(l,!0,u),this.finishNode(l,"VariableDeclaration"),this.parseForAfterInit(e,l,t)}var d=this.containsEsc,f=new Ie,S=this.start,I=t>-1?this.parseExprSubscripts(f,"await"):this.parseExpression(!0,f);return this.type===a._in||(o=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===a._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(I.start===S&&!d&&I.type==="Identifier"&&I.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),n&&o&&this.raise(I.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(I,!1,f),this.checkLValPattern(I),this.parseForIn(e,I)):(this.checkExpressionErrors(f,!0),t>-1&&this.unexpected(t),this.parseFor(e,I))};p.parseForAfterInit=function(e,t,i){return(this.type===a._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===a._in?i>-1&&this.unexpected(i):e.await=i>-1),this.parseForIn(e,t)):(i>-1&&this.unexpected(i),this.parseFor(e,t))};p.parseFunctionStatement=function(e,t,i){return this.next(),this.parseFunction(e,le|(i?0:Be),!1,t)};p.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(a._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")};p.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(a.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")};p.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(a.braceL),this.labels.push(Si),this.enterScope(mt);for(var t,i=!1;this.type!==a.braceR;)if(this.type===a._case||this.type===a._default){var s=this.type===a._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),s?t.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,t.test=null),this.expect(a.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")};p.parseThrowStatement=function(e){return this.next(),T.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var _i=[];p.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?dt:0),this.checkLValPattern(e,t?vt:H),this.expect(a.parenR),e};p.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===a._catch){var t=this.startNode();this.next(),this.eat(a.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(a._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")};p.parseVarStatement=function(e,t,i){return this.next(),this.parseVar(e,!1,t,i),this.semicolon(),this.finishNode(e,"VariableDeclaration")};p.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(We),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")};p.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")};p.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")};p.parseLabeledStatement=function(e,t,i,s){for(var r=0,n=this.labels;r=0;l--){var d=this.labels[l];if(d.statementStart===e.start)d.statementStart=this.start,d.kind=u;else break}return this.labels.push({name:t,kind:u,statementStart:this.start}),e.body=this.parseStatement(s?s.indexOf("label")===-1?s+"label":s:"label"),this.labels.pop(),e.label=i,this.finishNode(e,"LabeledStatement")};p.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")};p.parseBlock=function(e,t,i){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(a.braceL),e&&this.enterScope(0);this.type!==a.braceR;){var s=this.parseStatement(null);t.body.push(s)}return i&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")};p.parseFor=function(e,t){return e.init=t,this.expect(a.semi),e.test=this.type===a.semi?null:this.parseExpression(),this.expect(a.semi),e.update=this.type===a.parenR?null:this.parseExpression(),this.expect(a.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")};p.parseForIn=function(e,t){var i=this.type===a._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!i||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(i?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=i?this.parseExpression():this.parseMaybeAssign(),this.expect(a.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,i?"ForInStatement":"ForOfStatement")};p.parseVar=function(e,t,i,s){for(e.declarations=[],e.kind=i;;){var r=this.startNode();if(this.parseVarId(r,i),this.eat(a.eq)?r.init=this.parseMaybeAssign(t):!s&&i==="const"&&!(this.type===a._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!s&&(i==="using"||i==="await using")&&this.options.ecmaVersion>=17&&this.type!==a._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+i+" declaration"):!s&&r.id.type!=="Identifier"&&!(t&&(this.type===a._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):r.init=null,e.declarations.push(this.finishNode(r,"VariableDeclarator")),!this.eat(a.comma))break}return e};p.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?Ge:H,!1)};var le=1,Be=2,yt=4;p.parseFunction=function(e,t,i,s,r){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!s)&&(this.type===a.star&&t&Be&&this.unexpected(),e.generator=this.eat(a.star)),this.options.ecmaVersion>=8&&(e.async=!!s),t&le&&(e.id=t&yt&&this.type!==a.name?null:this.parseIdent(),e.id&&!(t&Be)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Ge:H:gt));var n=this.yieldPos,o=this.awaitPos,u=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(ze(e.async,e.generator)),t&le||(e.id=this.type===a.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,i,!1,r),this.yieldPos=n,this.awaitPos=o,this.awaitIdentPos=u,this.finishNode(e,t&le?"FunctionDeclaration":"FunctionExpression")};p.parseFunctionParams=function(e){this.expect(a.parenL),e.params=this.parseBindingList(a.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};p.parseClass=function(e,t){this.next();var i=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var s=this.enterClassBody(),r=this.startNode(),n=!1;for(r.body=[],this.expect(a.braceL);this.type!==a.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(r.body.push(o),o.type==="MethodDefinition"&&o.kind==="constructor"?(n&&this.raiseRecoverable(o.start,"Duplicate constructor in the same class"),n=!0):o.key&&o.key.type==="PrivateIdentifier"&&wi(s,o)&&this.raiseRecoverable(o.key.start,"Identifier '#"+o.key.name+"' has already been declared"))}return this.strict=i,this.next(),e.body=this.finishNode(r,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")};p.parseClassElement=function(e){if(this.eat(a.semi))return null;var t=this.options.ecmaVersion,i=this.startNode(),s="",r=!1,n=!1,o="method",u=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(a.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===a.star?u=!0:s="static"}if(i.static=u,!s&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===a.star)&&!this.canInsertSemicolon()?n=!0:s="async"),!s&&(t>=9||!n)&&this.eat(a.star)&&(r=!0),!s&&!n&&!r){var l=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?o=l:s=l)}if(s?(i.computed=!1,i.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),i.key.name=s,this.finishNode(i.key,"Identifier")):this.parseClassElementName(i),t<13||this.type===a.parenL||o!=="method"||r||n){var d=!i.static&&ve(i,"constructor"),f=d&&e;d&&o!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=d?"constructor":o,this.parseClassMethod(i,r,n,f)}else this.parseClassField(i);return i};p.isClassElementNameStart=function(){return this.type===a.name||this.type===a.privateId||this.type===a.num||this.type===a.string||this.type===a.bracketL||this.type.keyword};p.parseClassElementName=function(e){this.type===a.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)};p.parseClassMethod=function(e,t,i,s){var r=e.key;e.kind==="constructor"?(t&&this.raise(r.start,"Constructor can't be a generator"),i&&this.raise(r.start,"Constructor can't be an async method")):e.static&&ve(e,"prototype")&&this.raise(r.start,"Classes may not have a static property named prototype");var n=e.value=this.parseMethod(t,i,s);return e.kind==="get"&&n.params.length!==0&&this.raiseRecoverable(n.start,"getter should have no params"),e.kind==="set"&&n.params.length!==1&&this.raiseRecoverable(n.start,"setter should have exactly one param"),e.kind==="set"&&n.params[0].type==="RestElement"&&this.raiseRecoverable(n.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")};p.parseClassField=function(e){return ve(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&ve(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(a.eq)?(this.enterScope(pe|we),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")};p.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(ie|we);this.type!==a.braceR;){var i=this.parseStatement(null);e.body.push(i)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")};p.parseClassId=function(e,t){this.type===a.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,H,!1)):(t===!0&&this.unexpected(),e.id=null)};p.parseClassSuper=function(e){e.superClass=this.eat(a._extends)?this.parseExprSubscripts(null,!1):null};p.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared};p.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,i=e.used;if(this.options.checkPrivateFields)for(var s=this.privateNameStack.length,r=s===0?null:this.privateNameStack[s-1],n=0;n=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==a.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")};p.parseExport=function(e,t){if(this.next(),this.eat(a.star))return this.parseExportAllDeclaration(e,t);if(this.eat(a._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==a.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var i=0,s=e.specifiers;i=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")};p.parseExportDeclaration=function(e){return this.parseStatement(null)};p.parseExportDefaultDeclaration=function(){var e;if(this.type===a._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,le|yt,!1,e)}else if(this.type===a._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var s=this.parseMaybeAssign();return this.semicolon(),s}};p.checkExport=function(e,t,i){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),oe(e,t)&&this.raiseRecoverable(i,"Duplicate export '"+t+"'"),e[t]=!0)};p.checkPatternExport=function(e,t){var i=t.type;if(i==="Identifier")this.checkExport(e,t,t.start);else if(i==="ObjectPattern")for(var s=0,r=t.properties;s=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")};p.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,H),this.finishNode(e,"ImportSpecifier")};p.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,H),this.finishNode(e,"ImportDefaultSpecifier")};p.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,H),this.finishNode(e,"ImportNamespaceSpecifier")};p.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===a.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(a.comma)))return e;if(this.type===a.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(a.braceL);!this.eat(a.braceR);){if(t)t=!1;else if(this.expect(a.comma),this.afterTrailingComma(a.braceR))break;e.push(this.parseImportSpecifier())}return e};p.parseWithClause=function(){var e=[];if(!this.eat(a._with))return e;this.expect(a.braceL);for(var t={},i=!0;!this.eat(a.braceR);){if(i)i=!1;else if(this.expect(a.comma),this.afterTrailingComma(a.braceR))break;var s=this.parseImportAttribute(),r=s.key.type==="Identifier"?s.key.name:s.key.value;oe(t,r)&&this.raiseRecoverable(s.key.start,"Duplicate attribute key '"+r+"'"),t[r]=!0,e.push(s)}return e};p.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===a.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(a.colon),this.type!==a.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")};p.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===a.string){var e=this.parseLiteral(this.value);return bi.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)};p.adaptDirectivePrologue=function(e){for(var t=0;t=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var M=E.prototype;M.toAssignable=function(e,t,i){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",i&&this.checkPatternErrors(i,!0);for(var s=0,r=e.properties;s=8&&!u&&l.name==="async"&&!this.canInsertSemicolon()&&this.eat(a._function))return this.overrideContext(A.f_expr),this.parseFunction(this.startNodeAt(n,o),0,!1,!0,t);if(r&&!this.canInsertSemicolon()){if(this.eat(a.arrow))return this.parseArrowExpression(this.startNodeAt(n,o),[l],!1,t);if(this.options.ecmaVersion>=8&&l.name==="async"&&this.type===a.name&&!u&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return l=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(a.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(n,o),[l],!0,t)}return l;case a.regexp:var d=this.value;return s=this.parseLiteral(d.value),s.regex={pattern:d.pattern,flags:d.flags},s;case a.num:case a.string:return this.parseLiteral(this.value);case a._null:case a._true:case a._false:return s=this.startNode(),s.value=this.type===a._null?null:this.type===a._true,s.raw=this.type.keyword,this.next(),this.finishNode(s,"Literal");case a.parenL:var f=this.start,S=this.parseParenAndDistinguishExpression(r,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(S)&&(e.parenthesizedAssign=f),e.parenthesizedBind<0&&(e.parenthesizedBind=f)),S;case a.bracketL:return s=this.startNode(),this.next(),s.elements=this.parseExprList(a.bracketR,!0,!0,e),this.finishNode(s,"ArrayExpression");case a.braceL:return this.overrideContext(A.b_expr),this.parseObj(!1,e);case a._function:return s=this.startNode(),this.next(),this.parseFunction(s,0);case a._class:return this.parseClass(this.startNode(),!1);case a._new:return this.parseNew();case a.backQuote:return this.parseTemplate();case a._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};x.parseExprAtomDefault=function(){this.unexpected()};x.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===a.parenL&&!e)return this.parseDynamicImport(t);if(this.type===a.dot){var i=this.startNodeAt(t.start,t.loc&&t.loc.start);return i.name="import",t.meta=this.finishNode(i,"Identifier"),this.parseImportMeta(t)}else this.unexpected()};x.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(a.parenR)?e.options=null:(this.expect(a.comma),this.afterTrailingComma(a.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(a.parenR)||(this.expect(a.comma),this.afterTrailingComma(a.parenR)||this.unexpected())));else if(!this.eat(a.parenR)){var t=this.start;this.eat(a.comma)&&this.eat(a.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")};x.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")};x.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")};x.parseParenExpression=function(){this.expect(a.parenL);var e=this.parseExpression();return this.expect(a.parenR),e};x.shouldParseArrow=function(e){return!this.canInsertSemicolon()};x.parseParenAndDistinguishExpression=function(e,t){var i=this.start,s=this.startLoc,r,n=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,u=this.startLoc,l=[],d=!0,f=!1,S=new Ie,I=this.yieldPos,K=this.awaitPos,z;for(this.yieldPos=0,this.awaitPos=0;this.type!==a.parenR;)if(d?d=!1:this.expect(a.comma),n&&this.afterTrailingComma(a.parenR,!0)){f=!0;break}else if(this.type===a.ellipsis){z=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===a.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else l.push(this.parseMaybeAssign(!1,S,this.parseParenItem));var se=this.lastTokEnd,F=this.lastTokEndLoc;if(this.expect(a.parenR),e&&this.shouldParseArrow(l)&&this.eat(a.arrow))return this.checkPatternErrors(S,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=I,this.awaitPos=K,this.parseParenArrowList(i,s,l,t);(!l.length||f)&&this.unexpected(this.lastTokStart),z&&this.unexpected(z),this.checkExpressionErrors(S,!0),this.yieldPos=I||this.yieldPos,this.awaitPos=K||this.awaitPos,l.length>1?(r=this.startNodeAt(o,u),r.expressions=l,this.finishNodeAt(r,"SequenceExpression",se,F)):r=l[0]}else r=this.parseParenExpression();if(this.options.preserveParens){var g=this.startNodeAt(i,s);return g.expression=r,this.finishNode(g,"ParenthesizedExpression")}else return r};x.parseParenItem=function(e){return e};x.parseParenArrowList=function(e,t,i,s){return this.parseArrowExpression(this.startNodeAt(e,t),i,!1,s)};var Ai=[];x.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===a.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var i=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var s=this.start,r=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),s,r,!0,!1),this.eat(a.parenL)?e.arguments=this.parseExprList(a.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Ai,this.finishNode(e,"NewExpression")};x.parseTemplateElement=function(e){var t=e.isTagged,i=this.startNode();return this.type===a.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,` +`),cooked:null}):i.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,` +`),cooked:this.value},this.next(),i.tail=this.type===a.backQuote,this.finishNode(i,"TemplateElement")};x.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var i=this.startNode();this.next(),i.expressions=[];var s=this.parseTemplateElement({isTagged:t});for(i.quasis=[s];!s.tail;)this.type===a.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(a.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(a.braceR),i.quasis.push(s=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(i,"TemplateLiteral")};x.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===a.name||this.type===a.num||this.type===a.string||this.type===a.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===a.star)&&!T.test(this.input.slice(this.lastTokEnd,this.start))};x.parseObj=function(e,t){var i=this.startNode(),s=!0,r={};for(i.properties=[],this.next();!this.eat(a.braceR);){if(s)s=!1;else if(this.expect(a.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(a.braceR))break;var n=this.parseProperty(e,t);e||this.checkPropClash(n,r,t),i.properties.push(n)}return this.finishNode(i,e?"ObjectPattern":"ObjectExpression")};x.parseProperty=function(e,t){var i=this.startNode(),s,r,n,o;if(this.options.ecmaVersion>=9&&this.eat(a.ellipsis))return e?(i.argument=this.parseIdent(!1),this.type===a.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(i,"RestElement")):(i.argument=this.parseMaybeAssign(!1,t),this.type===a.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(i,"SpreadElement"));this.options.ecmaVersion>=6&&(i.method=!1,i.shorthand=!1,(e||t)&&(n=this.start,o=this.startLoc),e||(s=this.eat(a.star)));var u=this.containsEsc;return this.parsePropertyName(i),!e&&!u&&this.options.ecmaVersion>=8&&!s&&this.isAsyncProp(i)?(r=!0,s=this.options.ecmaVersion>=9&&this.eat(a.star),this.parsePropertyName(i)):r=!1,this.parsePropertyValue(i,e,s,r,n,o,t,u),this.finishNode(i,"Property")};x.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var i=e.kind==="get"?0:1;if(e.value.params.length!==i){var s=e.value.start;e.kind==="get"?this.raiseRecoverable(s,"getter should have no params"):this.raiseRecoverable(s,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")};x.parsePropertyValue=function(e,t,i,s,r,n,o,u){(i||s)&&this.type===a.colon&&this.unexpected(),this.eat(a.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind="init"):this.options.ecmaVersion>=6&&this.type===a.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(i,s),e.kind="init"):!t&&!u&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==a.comma&&this.type!==a.braceR&&this.type!==a.eq?((i||s)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((i||s)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=r),t?e.value=this.parseMaybeDefault(r,n,this.copyNode(e.key)):this.type===a.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(r,n,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()};x.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(a.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(a.bracketR),e.key;e.computed=!1}return e.key=this.type===a.num||this.type===a.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};x.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)};x.parseMethod=function(e,t,i){var s=this.startNode(),r=this.yieldPos,n=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(s),this.options.ecmaVersion>=6&&(s.generator=e),this.options.ecmaVersion>=8&&(s.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(ze(t,s.generator)|we|(i?xt:0)),this.expect(a.parenL),s.params=this.parseBindingList(a.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(s,!1,!0,!1),this.yieldPos=r,this.awaitPos=n,this.awaitIdentPos=o,this.finishNode(s,"FunctionExpression")};x.parseArrowExpression=function(e,t,i,s){var r=this.yieldPos,n=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(ze(i,!1)|qe),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!i),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,s),this.yieldPos=r,this.awaitPos=n,this.awaitIdentPos=o,this.finishNode(e,"ArrowFunctionExpression")};x.parseFunctionBody=function(e,t,i,s){var r=t&&this.type!==a.braceL,n=this.strict,o=!1;if(r)e.body=this.parseMaybeAssign(s),e.expression=!0,this.checkParams(e,!1);else{var u=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!n||u)&&(o=this.strictDirective(this.end),o&&u&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var l=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!n&&!o&&!t&&!i&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,bt),e.body=this.parseBlock(!1,void 0,o&&!n),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=l}this.exitScope()};x.isSimpleParamList=function(e){for(var t=0,i=e;t-1||r.functions.indexOf(e)>-1||r.var.indexOf(e)>-1,r.lexical.push(e),this.inModule&&r.flags&ee&&delete this.undefinedExports[e]}else if(t===vt){var n=this.currentScope();n.lexical.push(e)}else if(t===gt){var o=this.currentScope();this.treatFunctionsAsVar?s=o.lexical.indexOf(e)>-1:s=o.lexical.indexOf(e)>-1||o.var.indexOf(e)>-1,o.functions.push(e)}else for(var u=this.scopeStack.length-1;u>=0;--u){var l=this.scopeStack[u];if(l.lexical.indexOf(e)>-1&&!(l.flags&dt&&l.lexical[0]===e)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(e)>-1){s=!0;break}if(l.var.push(e),this.inModule&&l.flags&ee&&delete this.undefinedExports[e],l.flags&Ae)break}s&&this.raiseRecoverable(i,"Identifier '"+e+"' has already been declared")};X.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)};X.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};X.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ae|pe|ie))return t}};X.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Ae|pe|ie)&&!(t.flags&qe))return t}};var Ee=function(t,i,s){this.type="",this.start=i,this.end=0,t.options.locations&&(this.loc=new _e(t,s)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[i,0])},fe=E.prototype;fe.startNode=function(){return new Ee(this,this.start,this.startLoc)};fe.startNodeAt=function(e,t){return new Ee(this,e,t)};function kt(e,t,i,s){return e.type=t,e.end=i,this.options.locations&&(e.loc.end=s),this.options.ranges&&(e.range[1]=i),e}fe.finishNode=function(e,t){return kt.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)};fe.finishNodeAt=function(e,t,i,s){return kt.call(this,e,t,i,s)};fe.copyNode=function(e){var t=new Ee(this,e.start,this.startLoc);for(var i in e)t[i]=e[i];return t};var Ei="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",St="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",_t=St+" Extended_Pictographic",wt=_t,At=wt+" EBase EComp EMod EPres ExtPict",It=At,Ni=It,Pi={9:St,10:_t,11:wt,12:At,13:It,14:Ni},Vi="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Li={9:"",10:"",11:"",12:"",13:"",14:Vi},et="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",Et="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Nt=Et+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Pt=Nt+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Vt=Pt+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Lt=Vt+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Ti=Lt+" "+Ei,Ri={9:Et,10:Nt,11:Pt,12:Vt,13:Lt,14:Ti},Tt={};function ji(e){var t=Tt[e]={binary:Q(Pi[e]+" "+et),binaryOfStrings:Q(Li[e]),nonBinary:{General_Category:Q(et),Script:Q(Ri[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var Le=0,tt=[9,10,11,12,13,14];Le=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Tt[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};q.prototype.reset=function(t,i,s){var r=s.indexOf("v")!==-1,n=s.indexOf("u")!==-1;this.start=t|0,this.source=i+"",this.flags=s,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=n&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=n&&this.parser.options.ecmaVersion>=9)};q.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)};q.prototype.at=function(t,i){i===void 0&&(i=!1);var s=this.source,r=s.length;if(t>=r)return-1;var n=s.charCodeAt(t);if(!(i||this.switchU)||n<=55295||n>=57344||t+1>=r)return n;var o=s.charCodeAt(t+1);return o>=56320&&o<=57343?(n<<10)+o-56613888:n};q.prototype.nextIndex=function(t,i){i===void 0&&(i=!1);var s=this.source,r=s.length;if(t>=r)return r;var n=s.charCodeAt(t),o;return!(i||this.switchU)||n<=55295||n>=57344||t+1>=r||(o=s.charCodeAt(t+1))<56320||o>57343?t+1:t+2};q.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)};q.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)};q.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)};q.prototype.eat=function(t,i){return i===void 0&&(i=!1),this.current(i)===t?(this.advance(i),!0):!1};q.prototype.eatChars=function(t,i){i===void 0&&(i=!1);for(var s=this.pos,r=0,n=t;r-1&&this.raise(e.start,"Duplicate regular expression flag"),o==="u"&&(s=!0),o==="v"&&(r=!0)}this.options.ecmaVersion>=15&&s&&r&&this.raise(e.start,"Invalid regular expression flag")};function Bi(e){for(var t in e)return!0;return!1}c.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Bi(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))};c.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,i=e.backReferenceNames;t=16;for(t&&(e.branchID=new ye(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")};c.regexp_alternative=function(e){for(;e.pos=9&&(i=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!i,!0}return e.pos=t,!1};c.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1};c.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)};c.regexp_eatBracedQuantifier=function(e,t){var i=e.pos;if(e.eat(123)){var s=0,r=-1;if(this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue),e.eat(125)))return r!==-1&&r=16){var i=this.regexp_eatModifiers(e),s=e.eat(45);if(i||s){for(var r=0;r-1&&e.raise("Duplicate regular expression modifiers")}if(s){var o=this.regexp_eatModifiers(e);!i&&!o&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var u=0;u-1||i.indexOf(l)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1};c.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1};c.regexp_eatModifiers=function(e){for(var t="",i=0;(i=e.current())!==-1&&Mi(i);)t+=G(i),e.advance();return t};function Mi(e){return e===105||e===109||e===115}c.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)};c.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1};c.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Rt(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Rt(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}c.regexp_eatPatternCharacters=function(e){for(var t=e.pos,i=0;(i=e.current())!==-1&&!Rt(i);)e.advance();return e.pos!==t};c.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1};c.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,i=e.groupNames[e.lastStringValue];if(i)if(t)for(var s=0,r=i;s=11,s=e.current(i);return e.advance(i),s===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,i)&&(s=e.lastIntValue),Fi(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)};function Fi(e){return U(e,!0)||e===36||e===95}c.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,i=this.options.ecmaVersion>=11,s=e.current(i);return e.advance(i),s===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,i)&&(s=e.lastIntValue),Di(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)};function Di(e){return Y(e,!0)||e===36||e===95||e===8204||e===8205}c.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)};c.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var i=e.lastIntValue;if(e.switchU)return i>e.maxBackReference&&(e.maxBackReference=i),!0;if(i<=e.numCapturingParens)return!0;e.pos=t}return!1};c.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1};c.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)};c.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1};c.regexp_eatZero=function(e){return e.current()===48&&!Ne(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1};c.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1};c.regexp_eatControlLetter=function(e){var t=e.current();return jt(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function jt(e){return e>=65&&e<=90||e>=97&&e<=122}c.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var i=e.pos,s=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var r=e.lastIntValue;if(s&&r>=55296&&r<=56319){var n=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(r-55296)*1024+(o-56320)+65536,!0}e.pos=n,e.lastIntValue=r}return!0}if(s&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Ui(e.lastIntValue))return!0;s&&e.raise("Invalid unicode escape"),e.pos=i}return!1};function Ui(e){return e>=0&&e<=1114111}c.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1};c.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Ot=0,W=1,O=2;c.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(qi(t))return e.lastIntValue=-1,e.advance(),W;var i=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((i=t===80)||t===112)){e.lastIntValue=-1,e.advance();var s;if(e.eat(123)&&(s=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return i&&s===O&&e.raise("Invalid property name"),s;e.raise("Invalid property name")}return Ot};function qi(e){return e===100||e===68||e===115||e===83||e===119||e===87}c.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var i=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,i,s),W}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,r)}return Ot};c.regexp_validateUnicodePropertyNameAndValue=function(e,t,i){oe(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(i)||e.raise("Invalid property value")};c.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return W;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return O;e.raise("Invalid property name")};c.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Bt(t=e.current());)e.lastStringValue+=G(t),e.advance();return e.lastStringValue!==""};function Bt(e){return jt(e)||e===95}c.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";zi(t=e.current());)e.lastStringValue+=G(t),e.advance();return e.lastStringValue!==""};function zi(e){return Bt(e)||Ne(e)}c.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)};c.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),i=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&i===O&&e.raise("Negated character class may contain strings"),!0}return!1};c.regexp_classContents=function(e){return e.current()===93?W:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),W)};c.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var i=e.lastIntValue;e.switchU&&(t===-1||i===-1)&&e.raise("Invalid character class"),t!==-1&&i!==-1&&t>i&&e.raise("Range out of order in character class")}}};c.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var i=e.current();(i===99||Dt(i))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var s=e.current();return s!==93?(e.lastIntValue=s,e.advance(),!0):!1};c.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)};c.regexp_classSetExpression=function(e){var t=W,i;if(!this.regexp_eatClassSetRange(e))if(i=this.regexp_eatClassSetOperand(e)){i===O&&(t=O);for(var s=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(i=this.regexp_eatClassSetOperand(e))){i!==O&&(t=W);continue}e.raise("Invalid character in character class")}if(s!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(s!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(i=this.regexp_eatClassSetOperand(e),!i)return t;i===O&&(t=O)}};c.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var i=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var s=e.lastIntValue;return i!==-1&&s!==-1&&i>s&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1};c.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?W:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)};c.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var i=e.eat(94),s=this.regexp_classContents(e);if(e.eat(93))return i&&s===O&&e.raise("Negated character class may contain strings"),s;e.pos=t}if(e.eat(92)){var r=this.regexp_eatCharacterClassEscape(e);if(r)return r;e.pos=t}return null};c.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var i=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return i}else e.raise("Invalid escape");e.pos=t}return null};c.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===O&&(t=O);return t};c.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?W:O};c.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var i=e.current();return i<0||i===e.lookahead()&&Gi(i)||Wi(i)?!1:(e.advance(),e.lastIntValue=i,!0)};function Gi(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Wi(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}c.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Hi(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Hi(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}c.regexp_eatClassControlLetter=function(e){var t=e.current();return Ne(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1};c.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1};c.regexp_eatDecimalDigits=function(e){var t=e.pos,i=0;for(e.lastIntValue=0;Ne(i=e.current());)e.lastIntValue=10*e.lastIntValue+(i-48),e.advance();return e.pos!==t};function Ne(e){return e>=48&&e<=57}c.regexp_eatHexDigits=function(e){var t=e.pos,i=0;for(e.lastIntValue=0;Mt(i=e.current());)e.lastIntValue=16*e.lastIntValue+Ft(i),e.advance();return e.pos!==t};function Mt(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Ft(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}c.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var i=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+i*8+e.lastIntValue:e.lastIntValue=t*8+i}else e.lastIntValue=t;return!0}return!1};c.regexp_eatOctalDigit=function(e){var t=e.current();return Dt(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Dt(e){return e>=48&&e<=55}c.regexp_eatFixedHexDigits=function(e,t){var i=e.pos;e.lastIntValue=0;for(var s=0;s=this.input.length)return this.finishToken(a.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())};v.readToken=function(e){return U(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)};v.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var i=this.input.charCodeAt(e+1);return i<=56319||i>=57344?t:(t<<10)+i-56613888};v.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};v.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,i=this.input.indexOf("*/",this.pos+=2);if(i===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=i+2,this.options.locations)for(var s=void 0,r=t;(s=ht(this.input,r,this.pos))>-1;)++this.curLine,r=this.lineStart=s;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,i),t,this.pos,e,this.curPosition())};v.skipLineComment=function(e){for(var t=this.pos,i=this.options.onComment&&this.curPosition(),s=this.input.charCodeAt(this.pos+=e);this.pos8&&e<14||e>=5760&<.test(String.fromCharCode(e)))++this.pos;else break e}}};v.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var i=this.type;this.type=e,this.value=t,this.updateContext(i)};v.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(a.ellipsis)):(++this.pos,this.finishToken(a.dot))};v.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(a.assign,2):this.finishOp(a.slash,1)};v.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),i=1,s=e===42?a.star:a.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++i,s=a.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(a.assign,i+1):this.finishOp(s,i)};v.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(a.assign,3)}return this.finishOp(e===124?a.logicalOR:a.logicalAND,2)}return t===61?this.finishOp(a.assign,2):this.finishOp(e===124?a.bitwiseOR:a.bitwiseAND,1)};v.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(a.assign,2):this.finishOp(a.bitwiseXOR,1)};v.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||T.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(a.incDec,2):t===61?this.finishOp(a.assign,2):this.finishOp(a.plusMin,1)};v.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),i=1;return t===e?(i=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+i)===61?this.finishOp(a.assign,i+1):this.finishOp(a.bitShift,i)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(i=2),this.finishOp(a.relational,i))};v.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(a.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(a.arrow)):this.finishOp(e===61?a.eq:a.prefix,1)};v.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var i=this.input.charCodeAt(this.pos+2);if(i<48||i>57)return this.finishOp(a.questionDot,2)}if(t===63){if(e>=12){var s=this.input.charCodeAt(this.pos+2);if(s===61)return this.finishOp(a.assign,3)}return this.finishOp(a.coalesce,2)}}return this.finishOp(a.question,1)};v.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),U(t,!0)||t===92))return this.finishToken(a.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+G(t)+"'")};v.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(a.parenL);case 41:return++this.pos,this.finishToken(a.parenR);case 59:return++this.pos,this.finishToken(a.semi);case 44:return++this.pos,this.finishToken(a.comma);case 91:return++this.pos,this.finishToken(a.bracketL);case 93:return++this.pos,this.finishToken(a.bracketR);case 123:return++this.pos,this.finishToken(a.braceL);case 125:return++this.pos,this.finishToken(a.braceR);case 58:return++this.pos,this.finishToken(a.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(a.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(a.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+G(e)+"'")};v.finishOp=function(e,t){var i=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,i)};v.readRegexp=function(){for(var e,t,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var s=this.input.charAt(this.pos);if(T.test(s)&&this.raise(i,"Unterminated regular expression"),e)e=!1;else{if(s==="[")t=!0;else if(s==="]"&&t)t=!1;else if(s==="/"&&!t)break;e=s==="\\"}++this.pos}var r=this.input.slice(i,this.pos);++this.pos;var n=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(n);var u=this.regexpState||(this.regexpState=new q(this));u.reset(i,r,o),this.validateRegExpFlags(u),this.validateRegExpPattern(u);var l=null;try{l=new RegExp(r,o)}catch{}return this.finishToken(a.regexp,{pattern:r,flags:o,value:l})};v.readInt=function(e,t,i){for(var s=this.options.ecmaVersion>=12&&t===void 0,r=i&&this.input.charCodeAt(this.pos)===48,n=this.pos,o=0,u=0,l=0,d=t??1/0;l=97?S=f-97+10:f>=65?S=f-65+10:f>=48&&f<=57?S=f-48:S=1/0,S>=e)break;u=f,o=o*e+S}return s&&u===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===n||t!=null&&this.pos-n!==t?null:o};function Ki(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Ut(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}v.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var i=this.readInt(e);return i==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(i=Ut(this.input.slice(t,this.pos)),++this.pos):U(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(a.num,i)};v.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var i=this.pos-t>=2&&this.input.charCodeAt(t)===48;i&&this.strict&&this.raise(t,"Invalid number");var s=this.input.charCodeAt(this.pos);if(!i&&!e&&this.options.ecmaVersion>=11&&s===110){var r=Ut(this.input.slice(t,this.pos));return++this.pos,U(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(a.num,r)}i&&/[89]/.test(this.input.slice(t,this.pos))&&(i=!1),s===46&&!i&&(++this.pos,this.readInt(10),s=this.input.charCodeAt(this.pos)),(s===69||s===101)&&!i&&(s=this.input.charCodeAt(++this.pos),(s===43||s===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),U(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var n=Ki(this.input.slice(t,this.pos),i);return this.finishToken(a.num,n)};v.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var i=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(i,"Code point out of bounds")}else t=this.readHexChar(4);return t};v.readString=function(e){for(var t="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var s=this.input.charCodeAt(this.pos);if(s===e)break;s===92?(t+=this.input.slice(i,this.pos),t+=this.readEscapedChar(!1),i=this.pos):s===8232||s===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(ne(s)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(i,this.pos++),this.finishToken(a.string,t)};var qt={};v.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===qt)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1};v.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw qt;this.raise(e,t)};v.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var i=this.input.charCodeAt(this.pos);if(i===96||i===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===a.template||this.type===a.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(a.dollarBraceL)):(++this.pos,this.finishToken(a.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(a.template,e));if(i===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(ne(i)){switch(e+=this.input.slice(t,this.pos),++this.pos,i){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=` +`;break;default:e+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}};v.readInvalidTemplateToken=function(){for(;this.pos=48&&t<=55){var s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(s,8);return r>255&&(s=s.slice(0,-1),r=parseInt(s,8)),this.pos+=s.length-1,t=this.input.charCodeAt(this.pos),(s!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-s.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(r)}return ne(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}};v.readHexChar=function(e){var t=this.pos,i=this.readInt(16,e);return i===null&&this.invalidStringToken(t,"Bad character escape sequence"),i};v.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,i=this.pos,s=this.options.ecmaVersion>=6;this.pos3&&_("memory","Nested collections are limited to three levels."),!Array.isArray(e))return typeof e=="string"&&e.length>m.stringCharacters&&_("memory",`Strings are limited to ${m.stringCharacters} characters.`),typeof e=="number"&&!Number.isFinite(e)&&_("complexity","Calculations must produce finite numbers."),1;e.length>m.collectionItems&&_("memory",`Collections are limited to ${m.collectionItems} items.`);let i=1;for(const s of e)i+=re(s,t+1);return i}function Ke(e){e.operations+=1,e.operations>m.operations&&_("complexity",`Execution exceeded ${m.operations.toLocaleString()} operations.`),performance.now()-e.startedAt>m.runtimeMs&&_("complexity",`Execution exceeded the ${m.runtimeMs}ms time budget.`)}function Yi(e){let t=0;for(const i of e.environment.values())t+=re(i);e.peakCells=Math.max(e.peakCells,t),t>m.totalCells&&_("memory",`Live state exceeded the ${m.totalCells}-cell memory budget.`)}function Xi(e){return Object.fromEntries([...e.environment.entries()].map(([t,i])=>[t,Gt(i)]))}function $(e,t,i){e.frames.length>=m.traceFrames&&_("complexity",`Visualization exceeded ${m.traceFrames} trace steps.`),Yi(e),e.frames.push({line:he(t),description:i,source:e.source.slice(t.start,t.end).split(` +`)[0]?.trim()??"",variables:Xi(e),output:[...e.output]})}function $e(e,t,i){return re(i),!e.environment.has(t)&&e.environment.size>=m.variables&&_("memory",`Programs may use at most ${m.variables} variables.`),e.environment.set(t,i),i}function xe(e,t,i){return e.environment.has(t)||_("syntax",`Unknown variable “${t}” on line ${he(i)}.`),e.environment.get(t)??null}function w(e,t){return typeof e!="number"&&k(t,"This operation requires numbers"),e}function Wt(e,t){const i=w(e,t);return(!Number.isInteger(i)||i<0)&&_("syntax",`Array indexes must be non-negative integers on line ${he(t)}.`),i}function J(e){return Array.isArray(e)?!0:!!e}function Ce(e,t){return e===t}function ke(e){return Array.isArray(e)?`[${e.map(ke).join(", ")}]`:String(e)}function it(e,t,i,s){switch(e){case"+":return typeof t=="string"||typeof i=="string"?`${ke(t)}${ke(i)}`:w(t,s)+w(i,s);case"-":return w(t,s)-w(i,s);case"*":return w(t,s)*w(i,s);case"/":return w(t,s)/w(i,s);case"%":return w(t,s)%w(i,s);case"**":return w(t,s)**w(i,s);case"<":return w(t,s)":return w(t,s)>w(i,s);case">=":return w(t,s)>=w(i,s);case"==":case"===":return Ce(t,i);case"!=":case"!==":return!Ce(t,i);default:return k(s,`Operator ${e}`)}}function Ht(e){return!e.computed&&e.property.type==="Identifier"?e.property.name:null}function me(e,t){e.object.type==="Super"&&k(e,"Super");const i=C(e.object,t);if(e.computed){e.property.type==="PrivateIdentifier"&&k(e.property,"Private properties"),Array.isArray(i)||k(e,"Only arrays can be indexed");const r=Wt(C(e.property,t),e);return r>=i.length&&_("syntax",`Index ${r} is outside the array on line ${he(e)}.`),i[r]??null}const s=Ht(e);return s!=="length"&&k(e,`Property .${s??"?"}`),!Array.isArray(i)&&typeof i!="string"&&k(e,"Only arrays and strings have a readable length"),i.length}function Fe(e,t,i){if(re(t),e.type==="Identifier")return $e(i,e.name,t);if(e.type==="MemberExpression"){e.object.type==="Super"&&k(e,"Super"),(!e.computed||e.property.type==="PrivateIdentifier")&&k(e,"Only array elements can be assigned");const s=C(e.object,i);Array.isArray(s)||k(e,"Only array elements can be assigned");const r=Wt(C(e.property,i),e);return r>=s.length&&_("memory","Sparse arrays and implicit array growth are not supported."),s[r]=t,re(s),t}return k(e,"Assignment target")}function Zi(e,t,i){const s=e.type==="Identifier"?xe(i,e.name,e):e.type==="MemberExpression"?me(e,i):k(e,"Increment target"),r=w(s,e)+t;return Fe(e,r,i),r}function Ji(e,t){e.callee.type!=="MemberExpression"&&k(e,"Function calls");const i=e.callee;i.object.type==="Super"&&k(e,"Function calls");const s=i.object,r=Ht(i);r||k(e,"Computed method calls"),e.arguments.some(l=>l.type==="SpreadElement")&&k(e,"Spread arguments");const n=e.arguments;if(s.type==="Identifier"&&s.name==="console"&&r==="log"){const l=n.map(d=>ke(C(d,t))).join(" ");return l.length>m.stringCharacters&&_("memory","Console output line is too long."),t.output.length>=m.outputLines&&_("memory",`Console output is limited to ${m.outputLines} lines.`),t.output.push(l),null}if(s.type==="Identifier"&&s.name==="Math"){const d={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt}[r];return d||k(e,`Math.${r}`),d(...n.map(f=>w(C(f,t),f)))}const o=C(s,t);Array.isArray(o)||k(e,"Method calls");const u=n.map(l=>C(l,t));switch(r){case"push":return o.length+u.length>m.collectionItems&&_("memory",`Collections are limited to ${m.collectionItems} items.`),o.push(...u),o.length;case"pop":return o.pop()??null;case"shift":return o.shift()??null;case"unshift":return o.length+u.length>m.collectionItems&&_("memory",`Collections are limited to ${m.collectionItems} items.`),o.unshift(...u),o.length;case"includes":return u.length===1&&o.some(l=>Ce(l,u[0]??null));case"indexOf":return u.length===1?o.findIndex(l=>Ce(l,u[0]??null)):-1;default:return k(e,`Array.${r}`)}}function C(e,t){switch(Ke(t),e.type){case"Literal":return typeof e.value=="bigint"||e.value instanceof RegExp||e.value===void 0?k(e,"This literal"):e.value;case"Identifier":return xe(t,e.name,e);case"ArrayExpression":{const i=e.elements.map(s=>s?s.type==="SpreadElement"?k(s,"Array spread"):C(s,t):null);return re(i),i}case"MemberExpression":return me(e,t);case"ConditionalExpression":return J(C(e.test,t))?C(e.consequent,t):C(e.alternate,t);case"UnaryExpression":return e.operator==="!"?!J(C(e.argument,t)):e.operator==="-"?-w(C(e.argument,t),e):e.operator==="+"?w(C(e.argument,t),e):k(e,`Unary operator ${e.operator}`);case"UpdateExpression":{const i=e.argument.type==="Identifier"?xe(t,e.argument.name,e.argument):e.argument.type==="MemberExpression"?me(e.argument,t):k(e,"Increment target"),s=Zi(e.argument,e.operator==="++"?1:-1,t);return e.prefix?s:i}case"LogicalExpression":{const i=C(e.left,t);return e.operator==="&&"?J(i)?C(e.right,t):i:e.operator==="||"?J(i)?i:C(e.right,t):i??C(e.right,t)}case"AssignmentExpression":{const i=C(e.right,t);if(e.operator==="=")return Fe(e.left,i,t);const s=e.operator.slice(0,-1),r=e.left.type==="Identifier"?xe(t,e.left.name,e.left):e.left.type==="MemberExpression"?me(e.left,t):k(e.left,"Assignment target");return Fe(e.left,it(s,r,i,e),t)}case"BinaryExpression":return e.left.type==="PrivateIdentifier"&&k(e.left,"Private identifiers"),it(e.operator,C(e.left,t),C(e.right,t),e);case"CallExpression":return Ji(e,t);case"ParenthesizedExpression":return C(e.expression,t);default:return k(e)}}function st(e,t){for(const i of e.declarations)i.id.type!=="Identifier"&&k(i,"Destructuring"),$e(t,i.id.name,i.init?C(i.init,t):null)}function Kt(e,t){for(const i of e){const s=ae(i,t);if(s!=="normal")return s}return"normal"}function Te(e,t){e.loopIterations+=1,e.loopIterations>m.loopIterations&&_("complexity",`Loops exceeded ${m.loopIterations.toLocaleString()} iterations near line ${he(t)}.`),Ke(e)}function ae(e,t){switch(Ke(t),e.type){case"BlockStatement":return Kt(e.body,t);case"VariableDeclaration":return st(e,t),$(t,e,"Declared variables"),"normal";case"ExpressionStatement":return C(e.expression,t),$(t,e,"Updated state"),"normal";case"IfStatement":{const i=J(C(e.test,t));return $(t,e,i?"Condition matched":"Condition skipped"),i?ae(e.consequent,t):e.alternate?ae(e.alternate,t):"normal"}case"ForStatement":{e.init&&(e.init.type==="VariableDeclaration"?st(e.init,t):C(e.init,t));let i=0;for(;(!e.test||J(C(e.test,t)))&&(Te(t,e),i+=1,$(t,e,`For loop · iteration ${i}`),ae(e.body,t)!=="break");)e.update&&C(e.update,t);return $(t,e,`For loop complete · ${i} iterations`),"normal"}case"WhileStatement":{let i=0;for(;J(C(e.test,t))&&(Te(t,e),i+=1,$(t,e,`While loop · iteration ${i}`),ae(e.body,t)!=="break"););return $(t,e,`While loop complete · ${i} iterations`),"normal"}case"ForOfStatement":{(e.left.type!=="VariableDeclaration"||e.left.declarations.length!==1)&&k(e,"For-of initializer");const i=e.left.declarations[0];(!i||i.id.type!=="Identifier")&&k(e,"For-of destructuring");const s=C(e.right,t);Array.isArray(s)||k(e.right,"For-of requires an array");for(let r=0;r{t+=1,t>m.astNodes&&_("complexity",`Code is limited to ${m.astNodes} syntax nodes.`);for(const r of Object.values(s))if(Array.isArray(r))for(const n of r)at(n)&&i(n);else at(r)&&i(r)};return i(e),t}function ts(e){e.trim()||_("source","Enter a small JavaScript algorithm to visualize."),e.length>m.sourceCharacters&&_("source",`Code is limited to ${m.sourceCharacters.toLocaleString()} characters.`),e.split(/\r?\n/).length>m.sourceLines&&_("source",`Code is limited to ${m.sourceLines} lines.`);try{const t=Qi(e,{ecmaVersion:2022,sourceType:"script",locations:!0});return{program:t,astNodes:es(t)}}catch(t){return _("syntax",t instanceof Error?t.message:"The code could not be parsed.")}}function rt(e){const{program:t,astNodes:i}=ts(e),s={source:e,environment:new Map,frames:[],output:[],operations:0,loopIterations:0,peakCells:0,startedAt:performance.now()},r=Kt(t.body,s);return r!=="normal"&&_("syntax",`${r} can only be used inside a loop.`),s.frames.length===0&&_("source","Add at least one variable, condition, loop, or expression."),{frames:s.frames,metrics:{characters:e.length,lines:e.split(/\r?\n/).length,astNodes:i,operations:s.operations,loopIterations:s.loopIterations,peakCells:s.peakCells}}}const Re=[{name:"Bubble sort",code:`const numbers = [7, 3, 9, 1, 5]; + +for (let pass = 0; pass < numbers.length; pass++) { + for (let i = 0; i < numbers.length - pass - 1; i++) { + if (numbers[i] > numbers[i + 1]) { + const temp = numbers[i]; + numbers[i] = numbers[i + 1]; + numbers[i + 1] = temp; + } + } +} + +console.log("sorted", numbers);`},{name:"Binary search",code:`const numbers = [2, 5, 8, 12, 16, 23, 38]; +const target = 23; +let low = 0; +let high = numbers.length - 1; +let found = -1; + +while (low <= high) { + const middle = Math.floor((low + high) / 2); + if (numbers[middle] === target) { + found = middle; + break; + } + if (numbers[middle] < target) low = middle + 1; + else high = middle - 1; +} + +console.log("index", found);`},{name:"Fibonacci",code:`const sequence = [0, 1]; + +for (let i = 2; i < 10; i++) { + sequence.push(sequence[i - 1] + sequence[i - 2]); +} + +console.log(sequence);`}];function $t(e){return Array.isArray(e)?`[${e.map($t).join(", ")}]`:typeof e=="string"?`“${e}”`:String(e)}function de({icon:e,title:t,value:i}){return h.jsxs("div",{className:"rounded-xl border border-white/[0.07] bg-black/15 p-3",children:[h.jsx(e,{size:14,className:"text-emerald-300"}),h.jsx("p",{className:"mt-2 text-[9px] font-bold uppercase tracking-[0.16em] text-slate-600",children:t}),h.jsx("p",{className:"mt-1 text-xs font-medium text-slate-300",children:i})]})}function is({frame:e}){const t=Object.entries(e.variables).find(n=>Array.isArray(n[1])&&n[1].length>0&&n[1].every(o=>typeof o=="number"));if(!t)return h.jsx("div",{className:"flex min-h-52 items-center justify-center rounded-xl border border-dashed border-white/10 bg-black/10 p-6 text-center",children:h.jsxs("div",{children:[h.jsx(Zt,{size:24,className:"mx-auto text-slate-700"}),h.jsx("p",{className:"mt-3 text-xs text-slate-500",children:"Add a numeric array to see a bar visualization."})]})});const[i,s]=t,r=Math.max(...s.map(n=>Math.abs(n)),1);return h.jsxs("div",{className:"rounded-xl border border-white/[0.07] bg-black/15 p-4",children:[h.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[h.jsx("p",{className:"font-mono text-xs font-semibold text-emerald-200",children:i}),h.jsxs("p",{className:"text-[9px] font-bold uppercase tracking-[0.16em] text-slate-600",children:[s.length," items"]})]}),h.jsx("div",{className:"flex h-48 items-end gap-1.5 sm:gap-2",role:"img","aria-label":`${i} array values: ${s.join(", ")}`,children:s.map((n,o)=>h.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col items-center justify-end gap-2",children:[h.jsx("span",{className:"font-mono text-[9px] text-slate-500",children:n}),h.jsx("span",{className:"w-full rounded-t-md bg-gradient-to-t from-emerald-500/70 to-teal-300 shadow-[0_0_18px_rgb(52_211_153_/_0.12)] transition-[height] duration-300",style:{height:`${Math.max(8,Math.abs(n)/r*100)}%`}}),h.jsx("span",{className:"font-mono text-[8px] text-slate-700",children:o})]},o))})]})}function hs(){const[e,t]=Z.useState(Re[0].code),[i,s]=Z.useState(()=>rt(Re[0].code)),[r,n]=Z.useState(0),[o,u]=Z.useState(!1),[l,d]=Z.useState(null),f=i.frames[r]??i.frames[0],S=i.frames[Math.max(0,r-1)],I=e.split(/\r?\n/),K=Z.useMemo(()=>!f||!S||r===0?new Set(Object.keys(f?.variables??{})):new Set(Object.keys(f.variables).filter(g=>JSON.stringify(f.variables[g])!==JSON.stringify(S.variables[g]))),[f,r,S]);Z.useEffect(()=>{if(!o)return;const g=window.setInterval(()=>{n(N=>N>=i.frames.length-1?(u(!1),N):N+1)},650);return()=>window.clearInterval(g)},[o,i.frames.length]);const z=(g=e)=>{try{const N=rt(g);s(N),n(0),u(!1),d(null)}catch(N){u(!1),d(N instanceof zt?N.message:"The visualizer could not read this code.")}},se=g=>{t(g.code),z(g.code)},F=g=>{u(!1),n(Math.max(0,Math.min(i.frames.length-1,g)))};return h.jsx("div",{className:"book-page flex-1 overflow-y-auto",children:h.jsxs("main",{className:"mx-auto max-w-[1500px] px-4 py-8 sm:px-6 lg:px-8 lg:py-10",children:[h.jsxs("header",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_460px] lg:items-end",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-emerald-300/20 bg-emerald-300/8 px-3 py-1.5 text-[10px] font-bold uppercase tracking-[0.2em] text-emerald-200",children:[h.jsx(Ye,{size:13})," Safe code lab"]}),h.jsx("h1",{className:"font-display mt-5 text-4xl font-semibold tracking-tight text-white sm:text-5xl",children:"Visualize your code"}),h.jsx("p",{className:"mt-3 max-w-2xl text-sm leading-7 text-slate-400",children:"Enter a small JavaScript algorithm, then play through every state change. The interpreter supports variables, arrays, conditions, and bounded loops without executing arbitrary browser code."})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[h.jsx(de,{icon:ri,title:"Source",value:`${m.sourceLines} lines`}),h.jsx(de,{icon:oi,title:"Trace",value:`${m.traceFrames} steps`}),h.jsx(de,{icon:hi,title:"Memory",value:`${m.totalCells} cells`}),h.jsx(de,{icon:Ye,title:"Runtime",value:"No eval"})]})]}),h.jsxs("div",{className:"mt-8 grid gap-5 xl:grid-cols-[minmax(360px,0.82fr)_minmax(0,1.18fr)]",children:[h.jsxs("section",{className:"book-panel overflow-hidden","aria-labelledby":"editor-title",children:[h.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-white/[0.07] px-4 py-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-emerald-300",children:"Input"}),h.jsx("h2",{id:"editor-title",className:"mt-0.5 text-sm font-semibold text-white",children:"JavaScript subset"})]}),h.jsx("div",{className:"flex flex-wrap gap-1.5",children:Re.map(g=>h.jsx("button",{type:"button",onClick:()=>se(g),className:"rounded-lg bg-white/[0.045] px-2.5 py-1.5 text-[10px] font-medium text-slate-400 ring-1 ring-white/[0.07] hover:text-white",children:g.name},g.name))})]}),h.jsxs("div",{className:"relative bg-[#080d18]",children:[h.jsx("textarea",{value:e,onChange:g=>t(g.target.value),spellCheck:!1,"aria-label":"Code to visualize",className:"h-[500px] w-full resize-y bg-transparent p-4 font-mono text-[12px] leading-6 text-slate-300 outline-none placeholder:text-slate-700 sm:p-5"}),h.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 rounded-md bg-slate-950/90 px-2 py-1 font-mono text-[9px] text-slate-600 ring-1 ring-white/[0.06]",children:[I.length,"/",m.sourceLines," lines · ",e.length,"/",m.sourceCharacters," chars"]})]}),h.jsxs("div",{className:"border-t border-white/[0.07] p-4",children:[l&&h.jsxs("div",{role:"alert",className:"mb-3 flex items-start gap-2 rounded-xl border border-rose-400/20 bg-rose-400/8 p-3 text-xs leading-5 text-rose-200",children:[h.jsx(Qt,{size:15,className:"mt-0.5 shrink-0"})," ",l]}),h.jsxs("button",{type:"button",onClick:()=>z(),className:"flex h-11 w-full items-center justify-center gap-2 rounded-xl bg-emerald-300 text-sm font-bold text-slate-950 transition-colors hover:bg-emerald-200",children:[h.jsx(Jt,{size:16})," Build visualization"]}),h.jsx("p",{className:"mt-3 text-[10px] leading-5 text-slate-600",children:"Supported: declarations, assignment, arrays, if/else, for, for…of, while, break/continue, console.log, basic Math, and safe array methods. Functions, objects, imports, network access, DOM access, recursion, and dynamic evaluation are rejected."})]})]}),h.jsxs("section",{className:"space-y-5","aria-label":"Code visualization",children:[h.jsxs("div",{className:"book-panel overflow-hidden",children:[h.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-white/[0.07] px-4 py-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-emerald-300",children:"Execution trace"}),h.jsxs("h2",{className:"mt-0.5 text-sm font-semibold text-white",children:["Step ",r+1," of ",i.frames.length]})]}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("button",{type:"button",onClick:()=>F(0),"aria-label":"Restart visualization",className:"trace-control",children:h.jsx(ei,{size:14})}),h.jsx("button",{type:"button",onClick:()=>F(r-1),"aria-label":"Previous step",disabled:r===0,className:"trace-control",children:h.jsx(ti,{size:14})}),h.jsx("button",{type:"button",onClick:()=>u(g=>!g),"aria-label":o?"Pause visualization":"Play visualization",className:"trace-control trace-control-primary",children:o?h.jsx(ii,{size:14}):h.jsx(si,{size:14})}),h.jsx("button",{type:"button",onClick:()=>F(r+1),"aria-label":"Next step",disabled:r===i.frames.length-1,className:"trace-control",children:h.jsx(Yt,{size:14})})]})]}),h.jsx("div",{className:"px-4 py-3",children:h.jsx("input",{type:"range",min:0,max:Math.max(0,i.frames.length-1),value:r,onChange:g=>F(Number(g.target.value)),className:"w-full accent-emerald-300","aria-label":"Visualization step"})})]}),f&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_280px]",children:[h.jsxs("div",{className:"book-panel p-4 sm:p-5",children:[h.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-slate-600",children:"Current action"}),h.jsx("p",{className:"mt-1 text-sm font-semibold text-white",children:f.description})]}),h.jsxs("span",{className:"rounded-lg bg-emerald-300/10 px-2.5 py-1 font-mono text-[10px] text-emerald-200 ring-1 ring-emerald-300/20",children:["line ",f.line]})]}),h.jsx(is,{frame:f})]}),h.jsxs("div",{className:"book-panel p-4",children:[h.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-slate-600",children:"Variables"}),h.jsx("div",{className:"mt-3 max-h-[315px] space-y-2 overflow-auto",children:Object.entries(f.variables).map(([g,N])=>h.jsxs("div",{className:`rounded-xl border p-3 transition-colors ${K.has(g)?"border-emerald-300/20 bg-emerald-300/[0.06]":"border-white/[0.06] bg-black/10"}`,children:[h.jsxs("div",{className:"flex items-center justify-between gap-2",children:[h.jsx("span",{className:"font-mono text-[10px] font-semibold text-slate-400",children:g}),K.has(g)&&h.jsx(Xt,{size:11,className:"text-emerald-300"})]}),h.jsx("p",{className:"mt-1 break-all font-mono text-[11px] leading-5 text-slate-200",children:$t(N)})]},g))})]})]}),h.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_280px]",children:[h.jsxs("div",{className:"book-panel overflow-hidden",children:[h.jsx("div",{className:"border-b border-white/[0.07] px-4 py-3 text-[9px] font-bold uppercase tracking-[0.18em] text-slate-600",children:"Source playback"}),h.jsx("pre",{className:"max-h-80 overflow-auto bg-[#080d18] p-3 font-mono text-[11px] leading-6",children:I.map((g,N)=>{const Qe=N+1===f.line;return h.jsxs("div",{className:`flex rounded-md px-2 ${Qe?"bg-emerald-300/12 text-emerald-100 ring-1 ring-emerald-300/20":"text-slate-500"}`,children:[h.jsx("span",{className:`mr-4 w-6 shrink-0 select-none text-right ${Qe?"text-emerald-300":"text-slate-700"}`,children:N+1}),h.jsx("code",{children:g||" "})]},N)})})]}),h.jsxs("div",{className:"space-y-5",children:[h.jsxs("div",{className:"book-panel p-4",children:[h.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-slate-600",children:"Run budget"}),h.jsxs("dl",{className:"mt-3 space-y-2 text-[10px]",children:[h.jsxs("div",{className:"flex justify-between gap-3",children:[h.jsx("dt",{className:"text-slate-500",children:"Operations"}),h.jsxs("dd",{className:"font-mono text-slate-300",children:[i.metrics.operations,"/",m.operations]})]}),h.jsxs("div",{className:"flex justify-between gap-3",children:[h.jsx("dt",{className:"text-slate-500",children:"Loop iterations"}),h.jsxs("dd",{className:"font-mono text-slate-300",children:[i.metrics.loopIterations,"/",m.loopIterations]})]}),h.jsxs("div",{className:"flex justify-between gap-3",children:[h.jsx("dt",{className:"text-slate-500",children:"Peak cells"}),h.jsxs("dd",{className:"font-mono text-slate-300",children:[i.metrics.peakCells,"/",m.totalCells]})]}),h.jsxs("div",{className:"flex justify-between gap-3",children:[h.jsx("dt",{className:"text-slate-500",children:"Syntax nodes"}),h.jsxs("dd",{className:"font-mono text-slate-300",children:[i.metrics.astNodes,"/",m.astNodes]})]})]})]}),h.jsxs("div",{className:"book-panel p-4",children:[h.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.18em] text-slate-600",children:"Console"}),h.jsx("div",{className:"mt-3 min-h-16 font-mono text-[10px] leading-5 text-slate-400",children:f.output.length?f.output.map((g,N)=>h.jsxs("p",{children:["> ",g]},N)):h.jsx("p",{className:"text-slate-700",children:"No output yet"})})]})]})]})]})]})]})]})})}export{hs as default}; diff --git a/docs/assets/DijkstraGamePage-BLLSsKgV.js b/docs/assets/DijkstraGamePage-DovdEQ8Y.js similarity index 98% rename from docs/assets/DijkstraGamePage-BLLSsKgV.js rename to docs/assets/DijkstraGamePage-DovdEQ8Y.js index 340ee2c..c9e9014 100644 --- a/docs/assets/DijkstraGamePage-BLLSsKgV.js +++ b/docs/assets/DijkstraGamePage-DovdEQ8Y.js @@ -1 +1 @@ -import{c as Ge,r as x,j as e,E as Ve}from"./index-eCXyAnHs.js";import{M as Be}from"./map-4vhpgcAJ.js";import{S as Fe}from"./shuffle-CdKU4ZYx.js";import{C as Oe,a as _e}from"./chevron-right-BZqZw4c2.js";import{P as Le}from"./pause-nC-0zhw8.js";import{P as Pe}from"./play-BqZilH6N.js";import{R as ue}from"./route-CjoQmFsM.js";import{T as qe}from"./timer-DSbfy6P3.js";import{T as We}from"./trophy-DkUzH7jB.js";import{R as He}from"./rotate-ccw-B8GZP3d7.js";import{E as Ue}from"./eye-off-EsCpy5pU.js";import{V as Ye,a as Qe}from"./volume-x-CTbtCvt-.js";import{g as Ze}from"./audioContext-NbgqvQGz.js";const Xe=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Je=Ge("undo-2",Xe),L=20,Ke=["#1e293b","#0f3b3f","#312e81","#3b2416","#064e3b"];function et({graph:s,startNode:n,endNode:d,playerPath:r,optimalPath:f,showOptimal:l,currentAlgoStep:p,selectingPhase:j,onClickNode:a}){const i=x.useMemo(()=>{const t=new Set;for(let o=0;o{const t=new Set;if(l)for(let o=0;o{const t={};for(const o of s.nodes)t[o.id]={x:o.x,y:o.y};return t},[s.nodes]),A=j==="start"||j==="end"?"cursor-crosshair":"cursor-pointer",z=j==="start"?"Click an intersection to set START DEPOT":j==="end"?"Click an intersection to set DELIVERY DESTINATION":null,$=[...p?.queue??[]].sort((t,o)=>t.distance-o.distance).slice(0,5),C={intersections:s.nodes.length,roads:s.edges.length,avgTraffic:s.edges.length?Math.round(s.edges.reduce((t,o)=>t+o.weight,0)/s.edges.length):0};return e.jsxs("div",{className:`relative flex-1 w-full overflow-hidden rounded-[1.5rem] border border-slate-700/50 bg-slate-950/90 p-3 shadow-2xl shadow-black/40 backdrop-blur-sm ${A}`,children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_20%_10%,rgba(56,189,248,0.14),transparent_28%),radial-gradient(circle_at_80%_80%,rgba(34,197,94,0.1),transparent_30%)]"}),z&&e.jsx("div",{className:"absolute top-5 left-1/2 z-20 -translate-x-1/2 rounded-full bg-slate-950/90 px-4 py-2 text-xs font-semibold uppercase tracking-wide text-sky-200 ring-1 ring-sky-500/30 shadow-xl shadow-sky-950/40 animate-pulse",children:z}),e.jsxs("div",{className:"absolute left-5 top-5 z-10 rounded-2xl border border-slate-700/60 bg-slate-950/85 px-4 py-3 shadow-xl shadow-black/30 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-slate-500",children:"City Routing Map"}),e.jsxs("div",{className:"mt-2 flex gap-3 text-[11px] text-slate-300",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"font-mono text-white",children:C.intersections})," intersections"]}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-mono text-white",children:C.roads})," roads"]}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-mono text-white",children:C.avgTraffic})," avg min"]})]})]}),e.jsxs("div",{className:"absolute right-5 top-5 z-10 hidden rounded-2xl border border-slate-700/60 bg-slate-950/85 px-4 py-3 shadow-xl shadow-black/30 backdrop-blur-sm sm:block",children:[e.jsx("div",{className:"mb-2 text-[10px] font-semibold uppercase tracking-[0.24em] text-slate-500",children:"Legend"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1.5 text-[10px] text-slate-400",children:[e.jsx(F,{color:"bg-yellow-300",label:"Depot"}),e.jsx(F,{color:"bg-orange-400",label:"Dropoff"}),e.jsx(F,{color:"bg-indigo-400",label:"Your route"}),e.jsx(F,{color:"bg-emerald-400",label:"Best route"}),e.jsx(F,{color:"bg-sky-400",label:"Scanning"}),e.jsx(F,{color:"bg-slate-500",label:"Unvisited"})]})]}),p&&e.jsxs("div",{className:"absolute bottom-5 left-5 z-10 max-w-sm rounded-2xl border border-slate-700/60 bg-slate-950/90 p-4 shadow-xl shadow-black/35 backdrop-blur-sm",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-[0.24em] text-sky-300",children:"Dijkstra Live Scan"}),e.jsx("p",{className:"text-xs leading-relaxed text-slate-300",children:p.description}),$.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:$.map(t=>e.jsxs("span",{className:"rounded-full bg-sky-500/10 px-2 py-1 text-[10px] font-mono font-semibold text-sky-300 ring-1 ring-sky-500/25",children:[t.id,": ",t.distance]},t.id))})]}),e.jsxs("svg",{viewBox:"0 0 820 400",className:"relative z-0 h-full w-full rounded-[1.15rem]",preserveAspectRatio:"xMidYMid meet",children:[e.jsxs("defs",{children:[e.jsx("pattern",{id:"dijkstra-grid",width:"32",height:"32",patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:"M32 0H0V32",fill:"none",stroke:"#334155",strokeWidth:"0.7",opacity:"0.24"})}),e.jsxs("filter",{id:"soft-glow",x:"-40%",y:"-40%",width:"180%",height:"180%",children:[e.jsx("feGaussianBlur",{stdDeviation:"4",result:"blur"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{in:"blur"}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),e.jsx("filter",{id:"pin-shadow",x:"-60%",y:"-60%",width:"220%",height:"220%",children:e.jsx("feDropShadow",{dx:"0",dy:"7",stdDeviation:"5",floodColor:"#020617",floodOpacity:"0.65"})})]}),e.jsx("rect",{x:"0",y:"0",width:"820",height:"400",rx:"24",fill:"#020617"}),e.jsx("rect",{x:"0",y:"0",width:"820",height:"400",rx:"24",fill:"url(#dijkstra-grid)"}),[0,1,2,3,4].map(t=>e.jsx("rect",{x:30+t*155,y:t%2===0?38:238,width:112+t%2*34,height:78,rx:18,fill:Ke[t],opacity:"0.26"},t)),e.jsx("path",{d:"M612 40C690 68 760 70 800 42V132C744 154 684 146 612 118Z",fill:"#075985",opacity:"0.18"}),e.jsx("path",{d:"M38 336C96 302 150 306 206 338C154 374 91 382 38 356Z",fill:"#166534",opacity:"0.22"}),s.edges.map(t=>{const o=N[t.source],h=N[t.destination];if(!o||!h)return null;const T=S(t.source,t.destination),E=M(t.source,t.destination);return e.jsxs("g",{children:[e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:"#020617",strokeWidth:17,strokeLinecap:"round",opacity:.7}),e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:"#1e293b",strokeWidth:13,strokeLinecap:"round"}),e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:"#475569",strokeWidth:8,strokeLinecap:"round",opacity:.78}),e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:"#cbd5e1",strokeWidth:1.2,strokeLinecap:"round",strokeDasharray:"5 8",opacity:.34}),(i.has([t.source,t.destination].sort().join("-"))||m.has([t.source,t.destination].sort().join("-"))||u&&[u.from,u.to].sort().join("-")===[t.source,t.destination].sort().join("-"))&&e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:T,strokeWidth:E+6,strokeLinecap:"round",opacity:.34,filter:"url(#soft-glow)"})]},`${t.id}-road-base`)}),s.edges.map(t=>{const o=N[t.source],h=N[t.destination];if(!o||!h)return null;const T=S(t.source,t.destination),E=M(t.source,t.destination),k=(o.x+h.x)/2,I=(o.y+h.y)/2,b=[t.source,t.destination].sort().join("-"),R=i.has(b)||m.has(b)||u&&[u.from,u.to].sort().join("-")===b;return e.jsxs("g",{children:[e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:T,strokeWidth:R?E+2:1.4,strokeLinecap:"round",opacity:R?.96:.18,strokeDasharray:m.has(b)&&!i.has(b)?"9 6":void 0}),e.jsx("rect",{x:k-17,y:I-11,width:34,height:22,rx:8,fill:"#020617",fillOpacity:.92,stroke:R?T:"#475569",strokeWidth:.8,filter:"url(#pin-shadow)"}),e.jsxs("text",{x:k,y:I+.5,textAnchor:"middle",dominantBaseline:"central",fontSize:9,fontWeight:800,fontFamily:"ui-monospace, monospace",fill:R?T:"#cbd5e1",fillOpacity:.95,children:[t.weight,"m"]})]},t.id)}),s.nodes.map(t=>{const o=y(t.id),h=v(t.id),T=p?.distances[t.id],E=T!==void 0&&T!==1/0?T.toString():"",k=t.id===n,I=t.id===d,b=p&&t.id===c,R=p&&w.includes(t.id);return e.jsxs("g",{onClick:()=>a(t.id),className:"cursor-pointer",children:[e.jsx("circle",{cx:t.x,cy:t.y,r:L+12,fill:o,fillOpacity:b?.22:.08,filter:b?"url(#soft-glow)":void 0}),e.jsx("circle",{cx:t.x,cy:t.y,r:L+5,fill:"#020617",stroke:"#0f172a",strokeWidth:7,filter:"url(#pin-shadow)"}),e.jsx("circle",{cx:t.x,cy:t.y,r:L,fill:o,fillOpacity:k||I||b||R?.32:.16,stroke:h,strokeWidth:k||I?4:2.5}),e.jsx("text",{x:t.x,y:t.y+1,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fontWeight:900,fontFamily:"ui-monospace, monospace",fill:o,children:t.id}),(k||I)&&e.jsxs("g",{children:[e.jsx("path",{d:`M${t.x-8} ${t.y-41}h16a7 7 0 0 1 7 7v12a7 7 0 0 1-7 7h-16a7 7 0 0 1-7-7v-12a7 7 0 0 1 7-7Z`,fill:k?"#eab308":"#f97316",opacity:"0.95",filter:"url(#pin-shadow)"}),e.jsx("text",{x:t.x,y:t.y-28,textAnchor:"middle",dominantBaseline:"central",fontSize:9,fontWeight:900,fontFamily:"ui-monospace, monospace",fill:"#020617",children:k?"START":"END"})]}),E&&e.jsxs("g",{children:[e.jsx("rect",{x:t.x-20,y:t.y+L+8,width:40,height:16,rx:8,fill:"#020617",stroke:"#334155"}),e.jsxs("text",{x:t.x,y:t.y+L+16.5,textAnchor:"middle",dominantBaseline:"central",fontSize:8,fontWeight:700,fontFamily:"ui-monospace, monospace",fill:"#94a3b8",children:["ETA ",E]})]})]},t.id)})]})]})}function F({color:s,label:n}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${s}`}),n]})}const xe={explore:{name:"Free Explore",description:"Pick any route and compare your cost to the optimal Dijkstra path."},visualize:{name:"Visualizer",description:"Watch Dijkstra's algorithm run step-by-step with priority queue updates."},race:{name:"Race Mode",description:"Beat the algorithm! Find the shortest path as fast as you can."}},J={title:"Dijkstra Delivery Simulator",subtitle:"Based on Edsger W. Dijkstra's shortest-path algorithm",what:"You're a delivery driver navigating a city. Intersections are nodes, roads are edges, and traffic time is the weight. Find the shortest route from start to destination — then see how your path compares to Dijkstra's optimal solution.",skills:["Graph Theory","Shortest Path","Greedy Algorithms","Priority Queues"]},tt=["explore","visualize","race"],st=[{label:"Slow",value:800},{label:"Med",value:400},{label:"Fast",value:150}];function it(s){const n=Math.floor(s/60),d=s%60;return`${n}:${d.toString().padStart(2,"0")}`}function nt({mode:s,mapType:n,startNode:d,endNode:r,playerPath:f,playerCost:l,optimalCost:p,showOptimal:j,currentAlgoStep:a,algoStepIndex:i,algoStepsTotal:m,isAlgoRunning:w,algoSpeed:c,score:u,timer:y,isComplete:v,lastError:S,soundEnabled:M,selectingPhase:N,onChangeMode:A,onNewMap:z,onReset:$,onToggleOptimal:C,onUndoLastStep:t,onStepForward:o,onStepBack:h,onAutoPlay:T,onSetAlgoSpeed:E,onToggleSound:k}){const I=N==="start"?"Choose depot":N==="end"?"Choose destination":s==="visualize"?"Run algorithm scan":"Build delivery route";return e.jsxs("div",{className:"flex w-full shrink-0 flex-col gap-4 overflow-y-auto pr-1 xl:w-80",children:[e.jsxs("div",{className:"rounded-2xl border border-sky-500/20 bg-slate-950/75 p-4 shadow-2xl shadow-black/30 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-sky-200",children:J.title}),e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:J.subtitle})]}),e.jsx("span",{className:"rounded-full bg-sky-500/10 px-2 py-1 text-[9px] font-bold uppercase tracking-wider text-sky-300 ring-1 ring-sky-500/25",children:"Dispatch"})]}),e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:J.what}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:J.skills.map(b=>e.jsx("span",{className:"inline-flex items-center rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-400 ring-1 ring-violet-500/20",children:b},b))})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Game Mode"}),e.jsx("div",{className:"grid gap-2",children:tt.map(b=>e.jsxs("button",{onClick:()=>A(b),className:`rounded-xl px-3 py-2 text-left transition-all duration-200 ${s===b?"bg-indigo-500/20 text-indigo-200 ring-1 ring-indigo-500/40":"bg-slate-900/70 text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[e.jsx("span",{className:"block text-xs font-bold",children:xe[b].name}),e.jsx("span",{className:"mt-0.5 block text-[10px] leading-snug opacity-70",children:xe[b].description})]},b))})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Map"}),e.jsx("span",{className:"rounded-full bg-slate-900 px-2 py-0.5 text-[9px] font-mono uppercase text-slate-400 ring-1 ring-slate-800",children:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:()=>z("predefined"),className:`flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-medium transition-all ${n==="predefined"?"bg-sky-500/15 text-sky-300 ring-1 ring-sky-500/30":"bg-slate-900/70 text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[e.jsx(Be,{size:12})," Preset"]}),e.jsxs("button",{onClick:()=>z("random"),className:`flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-medium transition-all ${n==="random"?"bg-sky-500/15 text-sky-300 ring-1 ring-sky-500/30":"bg-slate-900/70 text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[e.jsx(Fe,{size:12})," Random"]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-emerald-500/20 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Mission"}),e.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[9px] font-bold uppercase tracking-wider text-emerald-300 ring-1 ring-emerald-500/25",children:I})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(fe,{label:"Depot",value:d??"unset",tone:"yellow"}),e.jsx(fe,{label:"Dropoff",value:r??"unset",tone:"orange"})]}),f.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl bg-slate-900/70 p-3 ring-1 ring-slate-800/80",children:[e.jsx("p",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Route manifest"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:f.map((b,R)=>e.jsx("span",{className:"inline-flex items-center rounded-md bg-indigo-500/15 px-1.5 py-0.5 text-[10px] font-mono font-semibold text-indigo-300 ring-1 ring-indigo-500/20",children:b},`${b}-${R}`))})]})]}),s==="visualize"&&d&&r&&e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Algorithm"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("button",{onClick:h,disabled:i<=0,className:"flex-1 flex items-center justify-center gap-1 rounded-xl bg-slate-900/70 px-2 py-2 text-xs font-medium text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(Oe,{size:14})," Prev"]}),e.jsx("button",{onClick:T,className:`flex-1 flex items-center justify-center gap-1 rounded-xl px-2 py-2 text-xs font-medium transition-all ${w?"bg-amber-500/20 text-amber-300 ring-1 ring-amber-500/30":"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/30 hover:bg-indigo-500/30"}`,children:w?e.jsxs(e.Fragment,{children:[e.jsx(Le,{size:14})," Pause"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{size:14})," Play"]})}),e.jsxs("button",{onClick:o,disabled:i>=m-1,className:"flex-1 flex items-center justify-center gap-1 rounded-xl bg-slate-900/70 px-2 py-2 text-xs font-medium text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:["Next ",e.jsx(_e,{size:14})]})]}),e.jsx("div",{className:"flex gap-1 mb-2",children:st.map(b=>e.jsx("button",{onClick:()=>E(b.value),className:`flex-1 rounded-md px-2 py-1 text-[10px] font-medium transition-all ${c===b.value?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/50 text-slate-500 hover:text-slate-400"}`,children:b.label},b.value))}),m>0&&e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-500",children:[e.jsx("span",{children:"Step"}),e.jsxs("span",{className:"font-mono font-semibold text-indigo-300",children:[Math.max(0,i+1)," / ",m]})]})]}),d&&r&&e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Route Info"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(ue,{size:11})," Your Cost"]}),e.jsx("span",{className:"text-sm font-mono font-bold text-indigo-300",children:l>0||v?l:"—"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(ue,{size:11})," Optimal"]}),e.jsx("span",{className:`text-sm font-mono font-bold ${j?"text-emerald-300":"text-slate-600"}`,children:j?p:"???"})]}),v&&l>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Difference"}),e.jsx("span",{className:`text-sm font-mono font-bold ${l===p?"text-emerald-400":"text-amber-400"}`,children:l===p?"Perfect!":`+${l-p}`})]}),s==="race"&&v&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(qe,{size:11})," Time"]}),e.jsx("span",{className:"text-sm font-mono font-bold text-sky-300",children:it(y)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(We,{size:11})," Score"]}),e.jsx("span",{className:"text-sm font-mono font-bold text-amber-300",children:u})]})]})]})]}),s==="visualize"&&a&&e.jsxs("div",{className:`rounded-2xl border p-4 shadow-xl shadow-black/20 backdrop-blur-sm ${a.type==="relax"?"border-amber-500/30 bg-amber-500/5":a.type==="done"?"border-emerald-500/30 bg-emerald-500/5":"border-slate-700/50 bg-slate-950/75"}`,children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-2",children:"Current Step"}),e.jsx("p",{className:"text-xs text-slate-300 leading-relaxed",children:a.description}),a.queue.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1",children:"Priority Queue:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:[...a.queue].sort((b,R)=>b.distance-R.distance).map(b=>e.jsxs("span",{className:"inline-flex items-center rounded-md bg-sky-500/10 px-1.5 py-0.5 text-[10px] font-mono text-sky-300 ring-1 ring-sky-500/20",children:[b.id,":",b.distance]},b.id))})]})]}),S&&e.jsx("div",{className:"rounded-xl border border-red-500/30 bg-red-500/5 px-3 py-2 text-center text-xs font-medium text-red-400 shadow-xl shadow-red-950/20 animate-pulse",children:S}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:$,className:"flex items-center justify-center gap-1.5 rounded-xl bg-slate-950/80 px-3 py-2 text-xs font-medium text-slate-400 ring-1 ring-slate-800 transition-all hover:bg-slate-800/80 hover:text-slate-300",children:[e.jsx(He,{size:12})," Reset"]}),s!=="visualize"&&e.jsxs("button",{onClick:t,disabled:f.length<=1||v,className:"flex items-center justify-center gap-1.5 rounded-xl bg-slate-950/80 px-3 py-2 text-xs font-medium text-slate-400 ring-1 ring-slate-800 transition-all hover:bg-slate-800/80 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(Je,{size:12})," Undo"]}),s!=="visualize"&&d&&r&&e.jsxs("button",{onClick:C,className:`flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-medium transition-all ${j?"bg-emerald-500/15 text-emerald-300 ring-1 ring-emerald-500/30":"bg-slate-950/80 text-slate-400 ring-1 ring-slate-800 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[j?e.jsx(Ve,{size:12}):e.jsx(Ue,{size:12})," Best"]}),e.jsxs("button",{onClick:()=>k(!M),className:`flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-medium transition-all ${M?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-950/80 text-slate-400 ring-1 ring-slate-800 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[M?e.jsx(Ye,{size:12}):e.jsx(Qe,{size:12})," Sound"]})]})]})}function fe({label:s,value:n,tone:d}){const r={yellow:"text-yellow-300 ring-yellow-500/25 bg-yellow-500/10",orange:"text-orange-300 ring-orange-500/25 bg-orange-500/10"};return e.jsxs("div",{className:`rounded-xl p-3 ring-1 ${r[d]}`,children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider opacity-65",children:s}),e.jsx("div",{className:"mt-1 font-mono text-lg font-black",children:n})]})}let P=0,q=0;function at(){return String.fromCharCode(65+P++%26)}function ge(){P=0,q=0}function me(){return`e${q++}`}function re(s,n){return Math.sqrt((s.x-n.x)**2+(s.y-n.y)**2)}function pe(s){ge();const n=[rt,ot,lt];return n[s%n.length]()}function rt(){const s=[{id:"A",x:80,y:200,distance:1/0,visited:!1,previous:null},{id:"B",x:220,y:80,distance:1/0,visited:!1,previous:null},{id:"C",x:220,y:320,distance:1/0,visited:!1,previous:null},{id:"D",x:400,y:80,distance:1/0,visited:!1,previous:null},{id:"E",x:400,y:200,distance:1/0,visited:!1,previous:null},{id:"F",x:400,y:320,distance:1/0,visited:!1,previous:null},{id:"G",x:560,y:200,distance:1/0,visited:!1,previous:null},{id:"H",x:700,y:200,distance:1/0,visited:!1,previous:null}];P=8;const n=[{id:"e0",source:"A",destination:"B",weight:4},{id:"e1",source:"A",destination:"C",weight:2},{id:"e2",source:"B",destination:"D",weight:5},{id:"e3",source:"B",destination:"E",weight:10},{id:"e4",source:"C",destination:"E",weight:3},{id:"e5",source:"C",destination:"F",weight:8},{id:"e6",source:"D",destination:"G",weight:2},{id:"e7",source:"E",destination:"G",weight:6},{id:"e8",source:"F",destination:"G",weight:1},{id:"e9",source:"G",destination:"H",weight:3},{id:"e10",source:"D",destination:"E",weight:1}];return q=11,{nodes:s,edges:n}}function ot(){const s=[{id:"A",x:100,y:150,distance:1/0,visited:!1,previous:null},{id:"B",x:250,y:50,distance:1/0,visited:!1,previous:null},{id:"C",x:250,y:250,distance:1/0,visited:!1,previous:null},{id:"D",x:400,y:150,distance:1/0,visited:!1,previous:null},{id:"E",x:550,y:50,distance:1/0,visited:!1,previous:null},{id:"F",x:550,y:250,distance:1/0,visited:!1,previous:null},{id:"G",x:700,y:150,distance:1/0,visited:!1,previous:null}];P=7;const n=[{id:"e0",source:"A",destination:"B",weight:7},{id:"e1",source:"A",destination:"C",weight:3},{id:"e2",source:"B",destination:"D",weight:2},{id:"e3",source:"C",destination:"D",weight:5},{id:"e4",source:"C",destination:"F",weight:12},{id:"e5",source:"D",destination:"E",weight:4},{id:"e6",source:"D",destination:"F",weight:3},{id:"e7",source:"E",destination:"G",weight:1},{id:"e8",source:"F",destination:"G",weight:2},{id:"e9",source:"B",destination:"E",weight:9}];return q=10,{nodes:s,edges:n}}function lt(){const s=[{id:"A",x:80,y:180,distance:1/0,visited:!1,previous:null},{id:"B",x:200,y:60,distance:1/0,visited:!1,previous:null},{id:"C",x:200,y:300,distance:1/0,visited:!1,previous:null},{id:"D",x:350,y:180,distance:1/0,visited:!1,previous:null},{id:"E",x:500,y:60,distance:1/0,visited:!1,previous:null},{id:"F",x:500,y:300,distance:1/0,visited:!1,previous:null},{id:"G",x:650,y:120,distance:1/0,visited:!1,previous:null},{id:"H",x:650,y:240,distance:1/0,visited:!1,previous:null},{id:"I",x:780,y:180,distance:1/0,visited:!1,previous:null}];P=9;const n=[{id:"e0",source:"A",destination:"B",weight:3},{id:"e1",source:"A",destination:"C",weight:6},{id:"e2",source:"A",destination:"D",weight:7},{id:"e3",source:"B",destination:"D",weight:2},{id:"e4",source:"B",destination:"E",weight:8},{id:"e5",source:"C",destination:"D",weight:3},{id:"e6",source:"C",destination:"F",weight:4},{id:"e7",source:"D",destination:"E",weight:2},{id:"e8",source:"D",destination:"F",weight:5},{id:"e9",source:"E",destination:"G",weight:1},{id:"e10",source:"F",destination:"H",weight:2},{id:"e11",source:"G",destination:"I",weight:4},{id:"e12",source:"H",destination:"I",weight:3},{id:"e13",source:"G",destination:"H",weight:2}];return q=14,{nodes:s,edges:n}}function ct(s=12){ge();const n=750,d=360,r=60,f=80,l=[];let p=0;for(;l.lengthre(v,{x:c,y:u})u).filter(c=>c>0));for(;m.size>0;){let c=1/0,u=0,y=0;for(const M of i)for(const N of m){const A=re(l[M],l[N]);A0;){j.sort((c,u)=>c.distance-u.distance);const i=j.shift();if(p.has(i.id))continue;p.add(i.id);const m=[...p];if(r.push({type:"visit",currentNodeId:i.id,description:`Visit node ${i.id} (distance = ${f[i.id]})`,distances:{...f},visited:m,previous:{...l},queue:[...j]}),i.id===d)break;const w=be(s,i.id);for(const c of w){if(p.has(c.id))continue;const u=f[i.id]+c.weight,y=f[c.id];if(uS.id===c.id);v>=0?j[v].distance=u:j.push({id:c.id,distance:u}),r.push({type:"relax",currentNodeId:i.id,description:`Relax edge ${i.id} → ${c.id}: distance updated from ${y===1/0?"∞":y} to ${u}`,distances:{...f},visited:[...p],previous:{...l},queue:[...j],relaxedEdge:{from:i.id,to:c.id,oldDist:y,newDist:u}})}}}const a=je(l,n,d);return r.push({type:"done",currentNodeId:d,description:a.length>0?`Done! Shortest path: ${a.join(" → ")} (cost: ${f[d]})`:`No path found from ${n} to ${d}`,distances:{...f},visited:[...p],previous:{...l},queue:[]}),r}function je(s,n,d){const r=[];let f=d;for(;f!==null&&(r.unshift(f),f!==n);)f=s[f];return r[0]!==n?[]:r}function dt(s,n,d){const r=ye(s,n,d),f=r[r.length-1],l=je(f.previous,n,d),p=f.distances[d]??1/0;return{path:l,cost:p===1/0?-1:p}}function ut(s,n){let d=0;for(let r=0;rl.source===n[r]&&l.destination===n[r+1]||l.destination===n[r]&&l.source===n[r+1]);if(!f)return-1;d+=f.weight}return d}function xt(s,n,d){if(n<=0||s<0)return 0;const r=100,f=(s-n)*5,l=Math.floor(d/3),p=s===n?50:0;return Math.max(0,r-f-l+p)}const he=[329.63,392,440,493.88,523.25,587.33,659.25,783.99];function ft(){const s=x.useRef(!0),n=x.useCallback(()=>Ze(),[]),d=x.useCallback(a=>{s.current=a},[]),r=x.useCallback(a=>{if(!s.current)return;const i=n();if(!i)return;const m=he[a%he.length],w=i.createOscillator(),c=i.createGain();w.type="sine",w.frequency.setValueAtTime(m,i.currentTime),c.gain.setValueAtTime(.1,i.currentTime),c.gain.exponentialRampToValueAtTime(.001,i.currentTime+.25),w.connect(c),c.connect(i.destination),w.start(),w.stop(i.currentTime+.25)},[n]),f=x.useCallback(()=>{if(!s.current)return;const a=n();if(!a)return;const i=a.createOscillator(),m=a.createGain();i.type="triangle",i.frequency.setValueAtTime(600,a.currentTime),i.frequency.setValueAtTime(800,a.currentTime+.08),m.gain.setValueAtTime(.06,a.currentTime),m.gain.exponentialRampToValueAtTime(.001,a.currentTime+.15),i.connect(m),m.connect(a.destination),i.start(),i.stop(a.currentTime+.15)},[n]),l=x.useCallback(()=>{if(!s.current)return;const a=n();if(!a)return;const i=a.createOscillator(),m=a.createGain();i.type="sine",i.frequency.setValueAtTime(520,a.currentTime),m.gain.setValueAtTime(.08,a.currentTime),m.gain.exponentialRampToValueAtTime(.001,a.currentTime+.1),i.connect(m),m.connect(a.destination),i.start(),i.stop(a.currentTime+.1)},[n]),p=x.useCallback(()=>{if(!s.current)return;const a=n();if(!a)return;const i=a.createOscillator(),m=a.createGain();i.type="sawtooth",i.frequency.setValueAtTime(200,a.currentTime),i.frequency.setValueAtTime(140,a.currentTime+.12),m.gain.setValueAtTime(.07,a.currentTime),m.gain.exponentialRampToValueAtTime(.001,a.currentTime+.25),i.connect(m),m.connect(a.destination),i.start(),i.stop(a.currentTime+.25)},[n]),j=x.useCallback(a=>{if(!s.current)return;const i=n();if(!i)return;(a?[523.25,587.33,659.25,783.99,880,1046.5]:[400,350,300]).forEach((w,c)=>{const u=i.createOscillator(),y=i.createGain();u.type="sine",u.frequency.value=w,y.gain.setValueAtTime(.07,i.currentTime+c*.08),y.gain.exponentialRampToValueAtTime(.001,i.currentTime+c*.08+.18),u.connect(y),y.connect(i.destination),u.start(i.currentTime+c*.08),u.stop(i.currentTime+c*.08+.18)})},[n]);return{playVisitTone:r,playRelaxTone:f,playClickTone:l,playErrorTone:p,playCompleteSweep:j,setEnabled:d}}function mt(){const[s,n]=x.useState("explore"),[d,r]=x.useState(()=>pe(0)),[f,l]=x.useState("predefined"),[p,j]=x.useState(0),[a,i]=x.useState(null),[m,w]=x.useState(null),[c,u]=x.useState([]),[y,v]=x.useState(0),[S,M]=x.useState([]),[N,A]=x.useState(0),[z,$]=x.useState(!1),[C,t]=x.useState([]),[o,h]=x.useState(-1),[T,E]=x.useState(!1),k=x.useRef(null),[I,b]=x.useState(500),[R,W]=x.useState(0),[ee,te]=x.useState(0),[oe,se]=x.useState(!1),O=x.useRef(null),[ve,we]=x.useState(!0),[ke,V]=x.useState(null),[ie,le]=x.useState(!1),[H,U]=x.useState("start"),{playVisitTone:Y,playRelaxTone:Q,playClickTone:Z,playErrorTone:ne,playCompleteSweep:G,setEnabled:ce}=ft(),Ne=x.useCallback(g=>{we(g),ce(g)},[ce]);x.useEffect(()=>(oe&&(O.current=window.setInterval(()=>te(g=>g+1),1e3)),()=>{O.current&&clearInterval(O.current)}),[oe]);const Ce=o>=0&&o{if(V(null),H==="start"){i(g),U("end"),Z();return}if(H==="end"){if(g===a){V("Destination must be different from start"),ne();return}w(g),Z();const B=dt(d,a,g);if(M(B.path),A(B.cost),s==="visualize"){const ze=ye(d,a,g);t(ze),h(-1),U("path")}else u([a]),v(0),U("path"),s==="race"&&(se(!0),te(0));return}if(s==="visualize"||c.length===0)return;const D=c[c.length-1];if(g===D)return;const de=be(d,D).find(B=>B.id===g);if(!de){V(`${g} is not adjacent to ${D}`),ne(),setTimeout(()=>V(null),1500);return}Z();const $e=[...c,g],ae=y+de.weight;if(u($e),v(ae),g===m)if(le(!0),se(!1),$(!0),s==="race"){const B=xt(ae,N,ee);W(B),G(ae===N)}else G(!0)},[H,a,m,d,s,c,y,N,ee,Z,ne,G]),Se=x.useCallback(()=>{if(c.length<=1||ie)return;const g=c.slice(0,-1);u(g),v(ut(d,g)),V(null)},[c,d,ie]),Me=x.useCallback(()=>{C.length!==0&&h(g=>{const D=Math.min(g+1,C.length-1),X=C[D];return X.type==="visit"&&Y(D),X.type==="relax"&&Q(),X.type==="done"&&G(!0),D})},[C,Y,Q,G]),De=x.useCallback(()=>{h(g=>Math.max(g-1,0))},[]),Ee=x.useCallback(()=>{if(T){k.current&&clearInterval(k.current),E(!1);return}E(!0);let g=o<0?0:o;k.current=window.setInterval(()=>{if(g>=C.length-1){k.current&&clearInterval(k.current),E(!1);return}g++,h(g);const D=C[g];D.type==="visit"&&Y(g),D.type==="relax"&&Q(),D.type==="done"&&G(!0)},I)},[T,o,C,I,Y,Q,G]),_=x.useCallback(()=>{i(null),w(null),u([]),v(0),M([]),A(0),$(!1),t([]),h(-1),E(!1),W(0),te(0),se(!1),le(!1),V(null),U("start"),k.current&&clearInterval(k.current),O.current&&clearInterval(O.current),r(g=>({...g,nodes:g.nodes.map(D=>({...D,distance:1/0,visited:!1,previous:null}))}))},[]),Ie=x.useCallback(g=>{n(g),_()},[_]),Re=x.useCallback(g=>{if(l(g),g==="predefined"){const D=(p+1)%3;j(D),r(pe(D))}else r(ct(12));_()},[p,_]),Ae=x.useCallback(()=>{!a||!m||$(g=>!g)},[a,m]);return{mode:s,graph:d,mapType:f,startNode:a,endNode:m,playerPath:c,playerCost:y,optimalPath:S,optimalCost:N,showOptimal:z,algoSteps:C,algoStepIndex:o,currentAlgoStep:Ce,isAlgoRunning:T,algoSpeed:I,setAlgoSpeed:b,score:R,timer:ee,isComplete:ie,lastError:ke,soundEnabled:ve,selectingPhase:H,clickNode:Te,undoLastStep:Se,stepAlgoForward:Me,stepAlgoBack:De,autoPlayAlgo:Ee,resetGame:_,changeMode:Ie,newMap:Re,toggleOptimal:Ae,toggleSound:Ne}}function Mt(){const{mode:s,graph:n,mapType:d,startNode:r,endNode:f,playerPath:l,playerCost:p,optimalPath:j,optimalCost:a,showOptimal:i,algoSteps:m,algoStepIndex:w,currentAlgoStep:c,isAlgoRunning:u,algoSpeed:y,setAlgoSpeed:v,score:S,timer:M,isComplete:N,lastError:A,soundEnabled:z,selectingPhase:$,clickNode:C,undoLastStep:t,stepAlgoForward:o,stepAlgoBack:h,autoPlayAlgo:T,resetGame:E,changeMode:k,newMap:I,toggleOptimal:b,toggleSound:R}=mt(),W=r&&f?`${r} -> ${f}`:"Select depot and destination";return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_30%),radial-gradient(circle_at_bottom_right,rgba(34,197,94,0.12),transparent_28%)]",children:[e.jsx("div",{className:"border-b border-slate-800/70 bg-slate-950/75 px-4 py-3 shadow-lg shadow-black/20 backdrop-blur-sm md:px-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-sky-400",children:"Shortest Path Command Center"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Dijkstra Delivery Simulator"})]}),e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[e.jsx(K,{label:"Mode",value:s,tone:"indigo"}),e.jsx(K,{label:"Map",value:d,tone:"sky"}),e.jsx(K,{label:"Route",value:W,tone:"emerald"}),N&&e.jsx(K,{label:"Result",value:p===a?"optimal":`+${p-a} min`,tone:p===a?"emerald":"amber"})]})]})}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[e.jsx("div",{className:"order-last flex min-h-[620px] flex-1 flex-col gap-4 xl:order-first xl:min-h-0",children:e.jsx(et,{graph:n,startNode:r,endNode:f,playerPath:l,optimalPath:j,showOptimal:i,currentAlgoStep:c,selectingPhase:$,onClickNode:C})}),e.jsx(nt,{mode:s,mapType:d,startNode:r,endNode:f,playerPath:l,playerCost:p,optimalCost:a,showOptimal:i,currentAlgoStep:c,algoStepIndex:w,algoStepsTotal:m.length,isAlgoRunning:u,algoSpeed:y,score:S,timer:M,isComplete:N,lastError:A,soundEnabled:z,selectingPhase:$,onChangeMode:k,onNewMap:I,onReset:E,onToggleOptimal:b,onUndoLastStep:t,onStepForward:o,onStepBack:h,onAutoPlay:T,onSetAlgoSpeed:v,onToggleSound:R})]})]})}function K({label:s,value:n,tone:d}){const r={indigo:"bg-indigo-500/10 text-indigo-200 ring-indigo-500/25",sky:"bg-sky-500/10 text-sky-200 ring-sky-500/25",emerald:"bg-emerald-500/10 text-emerald-200 ring-emerald-500/25",amber:"bg-amber-500/10 text-amber-200 ring-amber-500/25"};return e.jsxs("div",{className:`rounded-full px-3 py-1.5 text-[10px] ring-1 ${r[d]}`,children:[e.jsx("span",{className:"mr-1 uppercase tracking-wider opacity-60",children:s}),e.jsx("span",{className:"font-mono font-bold",children:n})]})}export{Mt as default}; +import{c as Ge,r as x,j as e,E as Ve}from"./index-DBkLeWDs.js";import{M as Be}from"./map-9j6oGOs_.js";import{S as Fe}from"./shuffle-Dlr-c52A.js";import{C as Oe,a as _e}from"./chevron-right-CFBAUJsk.js";import{P as Le}from"./pause-CG1snUW9.js";import{P as Pe}from"./play-mcIZClKO.js";import{R as ue}from"./route-C4zDL9m7.js";import{T as qe}from"./timer-e0gb0oZa.js";import{T as We}from"./trophy-C1QWh03u.js";import{R as He}from"./rotate-ccw-7GTUOPy4.js";import{E as Ue}from"./eye-off-BfEKGZbc.js";import{V as Ye,a as Qe}from"./volume-x-BSx9gxSg.js";import{g as Ze}from"./audioContext-NbgqvQGz.js";const Xe=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Je=Ge("undo-2",Xe),L=20,Ke=["#1e293b","#0f3b3f","#312e81","#3b2416","#064e3b"];function et({graph:s,startNode:n,endNode:d,playerPath:r,optimalPath:f,showOptimal:l,currentAlgoStep:p,selectingPhase:j,onClickNode:a}){const i=x.useMemo(()=>{const t=new Set;for(let o=0;o{const t=new Set;if(l)for(let o=0;o{const t={};for(const o of s.nodes)t[o.id]={x:o.x,y:o.y};return t},[s.nodes]),A=j==="start"||j==="end"?"cursor-crosshair":"cursor-pointer",z=j==="start"?"Click an intersection to set START DEPOT":j==="end"?"Click an intersection to set DELIVERY DESTINATION":null,$=[...p?.queue??[]].sort((t,o)=>t.distance-o.distance).slice(0,5),C={intersections:s.nodes.length,roads:s.edges.length,avgTraffic:s.edges.length?Math.round(s.edges.reduce((t,o)=>t+o.weight,0)/s.edges.length):0};return e.jsxs("div",{className:`relative flex-1 w-full overflow-hidden rounded-[1.5rem] border border-slate-700/50 bg-slate-950/90 p-3 shadow-2xl shadow-black/40 backdrop-blur-sm ${A}`,children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_20%_10%,rgba(56,189,248,0.14),transparent_28%),radial-gradient(circle_at_80%_80%,rgba(34,197,94,0.1),transparent_30%)]"}),z&&e.jsx("div",{className:"absolute top-5 left-1/2 z-20 -translate-x-1/2 rounded-full bg-slate-950/90 px-4 py-2 text-xs font-semibold uppercase tracking-wide text-sky-200 ring-1 ring-sky-500/30 shadow-xl shadow-sky-950/40 animate-pulse",children:z}),e.jsxs("div",{className:"absolute left-5 top-5 z-10 rounded-2xl border border-slate-700/60 bg-slate-950/85 px-4 py-3 shadow-xl shadow-black/30 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-slate-500",children:"City Routing Map"}),e.jsxs("div",{className:"mt-2 flex gap-3 text-[11px] text-slate-300",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"font-mono text-white",children:C.intersections})," intersections"]}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-mono text-white",children:C.roads})," roads"]}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-mono text-white",children:C.avgTraffic})," avg min"]})]})]}),e.jsxs("div",{className:"absolute right-5 top-5 z-10 hidden rounded-2xl border border-slate-700/60 bg-slate-950/85 px-4 py-3 shadow-xl shadow-black/30 backdrop-blur-sm sm:block",children:[e.jsx("div",{className:"mb-2 text-[10px] font-semibold uppercase tracking-[0.24em] text-slate-500",children:"Legend"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1.5 text-[10px] text-slate-400",children:[e.jsx(F,{color:"bg-yellow-300",label:"Depot"}),e.jsx(F,{color:"bg-orange-400",label:"Dropoff"}),e.jsx(F,{color:"bg-indigo-400",label:"Your route"}),e.jsx(F,{color:"bg-emerald-400",label:"Best route"}),e.jsx(F,{color:"bg-sky-400",label:"Scanning"}),e.jsx(F,{color:"bg-slate-500",label:"Unvisited"})]})]}),p&&e.jsxs("div",{className:"absolute bottom-5 left-5 z-10 max-w-sm rounded-2xl border border-slate-700/60 bg-slate-950/90 p-4 shadow-xl shadow-black/35 backdrop-blur-sm",children:[e.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-[0.24em] text-sky-300",children:"Dijkstra Live Scan"}),e.jsx("p",{className:"text-xs leading-relaxed text-slate-300",children:p.description}),$.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:$.map(t=>e.jsxs("span",{className:"rounded-full bg-sky-500/10 px-2 py-1 text-[10px] font-mono font-semibold text-sky-300 ring-1 ring-sky-500/25",children:[t.id,": ",t.distance]},t.id))})]}),e.jsxs("svg",{viewBox:"0 0 820 400",className:"relative z-0 h-full w-full rounded-[1.15rem]",preserveAspectRatio:"xMidYMid meet",children:[e.jsxs("defs",{children:[e.jsx("pattern",{id:"dijkstra-grid",width:"32",height:"32",patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:"M32 0H0V32",fill:"none",stroke:"#334155",strokeWidth:"0.7",opacity:"0.24"})}),e.jsxs("filter",{id:"soft-glow",x:"-40%",y:"-40%",width:"180%",height:"180%",children:[e.jsx("feGaussianBlur",{stdDeviation:"4",result:"blur"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{in:"blur"}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),e.jsx("filter",{id:"pin-shadow",x:"-60%",y:"-60%",width:"220%",height:"220%",children:e.jsx("feDropShadow",{dx:"0",dy:"7",stdDeviation:"5",floodColor:"#020617",floodOpacity:"0.65"})})]}),e.jsx("rect",{x:"0",y:"0",width:"820",height:"400",rx:"24",fill:"#020617"}),e.jsx("rect",{x:"0",y:"0",width:"820",height:"400",rx:"24",fill:"url(#dijkstra-grid)"}),[0,1,2,3,4].map(t=>e.jsx("rect",{x:30+t*155,y:t%2===0?38:238,width:112+t%2*34,height:78,rx:18,fill:Ke[t],opacity:"0.26"},t)),e.jsx("path",{d:"M612 40C690 68 760 70 800 42V132C744 154 684 146 612 118Z",fill:"#075985",opacity:"0.18"}),e.jsx("path",{d:"M38 336C96 302 150 306 206 338C154 374 91 382 38 356Z",fill:"#166534",opacity:"0.22"}),s.edges.map(t=>{const o=N[t.source],h=N[t.destination];if(!o||!h)return null;const T=S(t.source,t.destination),E=M(t.source,t.destination);return e.jsxs("g",{children:[e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:"#020617",strokeWidth:17,strokeLinecap:"round",opacity:.7}),e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:"#1e293b",strokeWidth:13,strokeLinecap:"round"}),e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:"#475569",strokeWidth:8,strokeLinecap:"round",opacity:.78}),e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:"#cbd5e1",strokeWidth:1.2,strokeLinecap:"round",strokeDasharray:"5 8",opacity:.34}),(i.has([t.source,t.destination].sort().join("-"))||m.has([t.source,t.destination].sort().join("-"))||u&&[u.from,u.to].sort().join("-")===[t.source,t.destination].sort().join("-"))&&e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:T,strokeWidth:E+6,strokeLinecap:"round",opacity:.34,filter:"url(#soft-glow)"})]},`${t.id}-road-base`)}),s.edges.map(t=>{const o=N[t.source],h=N[t.destination];if(!o||!h)return null;const T=S(t.source,t.destination),E=M(t.source,t.destination),k=(o.x+h.x)/2,I=(o.y+h.y)/2,b=[t.source,t.destination].sort().join("-"),R=i.has(b)||m.has(b)||u&&[u.from,u.to].sort().join("-")===b;return e.jsxs("g",{children:[e.jsx("line",{x1:o.x,y1:o.y,x2:h.x,y2:h.y,stroke:T,strokeWidth:R?E+2:1.4,strokeLinecap:"round",opacity:R?.96:.18,strokeDasharray:m.has(b)&&!i.has(b)?"9 6":void 0}),e.jsx("rect",{x:k-17,y:I-11,width:34,height:22,rx:8,fill:"#020617",fillOpacity:.92,stroke:R?T:"#475569",strokeWidth:.8,filter:"url(#pin-shadow)"}),e.jsxs("text",{x:k,y:I+.5,textAnchor:"middle",dominantBaseline:"central",fontSize:9,fontWeight:800,fontFamily:"ui-monospace, monospace",fill:R?T:"#cbd5e1",fillOpacity:.95,children:[t.weight,"m"]})]},t.id)}),s.nodes.map(t=>{const o=y(t.id),h=v(t.id),T=p?.distances[t.id],E=T!==void 0&&T!==1/0?T.toString():"",k=t.id===n,I=t.id===d,b=p&&t.id===c,R=p&&w.includes(t.id);return e.jsxs("g",{onClick:()=>a(t.id),className:"cursor-pointer",children:[e.jsx("circle",{cx:t.x,cy:t.y,r:L+12,fill:o,fillOpacity:b?.22:.08,filter:b?"url(#soft-glow)":void 0}),e.jsx("circle",{cx:t.x,cy:t.y,r:L+5,fill:"#020617",stroke:"#0f172a",strokeWidth:7,filter:"url(#pin-shadow)"}),e.jsx("circle",{cx:t.x,cy:t.y,r:L,fill:o,fillOpacity:k||I||b||R?.32:.16,stroke:h,strokeWidth:k||I?4:2.5}),e.jsx("text",{x:t.x,y:t.y+1,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fontWeight:900,fontFamily:"ui-monospace, monospace",fill:o,children:t.id}),(k||I)&&e.jsxs("g",{children:[e.jsx("path",{d:`M${t.x-8} ${t.y-41}h16a7 7 0 0 1 7 7v12a7 7 0 0 1-7 7h-16a7 7 0 0 1-7-7v-12a7 7 0 0 1 7-7Z`,fill:k?"#eab308":"#f97316",opacity:"0.95",filter:"url(#pin-shadow)"}),e.jsx("text",{x:t.x,y:t.y-28,textAnchor:"middle",dominantBaseline:"central",fontSize:9,fontWeight:900,fontFamily:"ui-monospace, monospace",fill:"#020617",children:k?"START":"END"})]}),E&&e.jsxs("g",{children:[e.jsx("rect",{x:t.x-20,y:t.y+L+8,width:40,height:16,rx:8,fill:"#020617",stroke:"#334155"}),e.jsxs("text",{x:t.x,y:t.y+L+16.5,textAnchor:"middle",dominantBaseline:"central",fontSize:8,fontWeight:700,fontFamily:"ui-monospace, monospace",fill:"#94a3b8",children:["ETA ",E]})]})]},t.id)})]})]})}function F({color:s,label:n}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${s}`}),n]})}const xe={explore:{name:"Free Explore",description:"Pick any route and compare your cost to the optimal Dijkstra path."},visualize:{name:"Visualizer",description:"Watch Dijkstra's algorithm run step-by-step with priority queue updates."},race:{name:"Race Mode",description:"Beat the algorithm! Find the shortest path as fast as you can."}},J={title:"Dijkstra Delivery Simulator",subtitle:"Based on Edsger W. Dijkstra's shortest-path algorithm",what:"You're a delivery driver navigating a city. Intersections are nodes, roads are edges, and traffic time is the weight. Find the shortest route from start to destination — then see how your path compares to Dijkstra's optimal solution.",skills:["Graph Theory","Shortest Path","Greedy Algorithms","Priority Queues"]},tt=["explore","visualize","race"],st=[{label:"Slow",value:800},{label:"Med",value:400},{label:"Fast",value:150}];function it(s){const n=Math.floor(s/60),d=s%60;return`${n}:${d.toString().padStart(2,"0")}`}function nt({mode:s,mapType:n,startNode:d,endNode:r,playerPath:f,playerCost:l,optimalCost:p,showOptimal:j,currentAlgoStep:a,algoStepIndex:i,algoStepsTotal:m,isAlgoRunning:w,algoSpeed:c,score:u,timer:y,isComplete:v,lastError:S,soundEnabled:M,selectingPhase:N,onChangeMode:A,onNewMap:z,onReset:$,onToggleOptimal:C,onUndoLastStep:t,onStepForward:o,onStepBack:h,onAutoPlay:T,onSetAlgoSpeed:E,onToggleSound:k}){const I=N==="start"?"Choose depot":N==="end"?"Choose destination":s==="visualize"?"Run algorithm scan":"Build delivery route";return e.jsxs("div",{className:"flex w-full shrink-0 flex-col gap-4 overflow-y-auto pr-1 xl:w-80",children:[e.jsxs("div",{className:"rounded-2xl border border-sky-500/20 bg-slate-950/75 p-4 shadow-2xl shadow-black/30 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-sky-200",children:J.title}),e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:J.subtitle})]}),e.jsx("span",{className:"rounded-full bg-sky-500/10 px-2 py-1 text-[9px] font-bold uppercase tracking-wider text-sky-300 ring-1 ring-sky-500/25",children:"Dispatch"})]}),e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:J.what}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:J.skills.map(b=>e.jsx("span",{className:"inline-flex items-center rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-400 ring-1 ring-violet-500/20",children:b},b))})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Game Mode"}),e.jsx("div",{className:"grid gap-2",children:tt.map(b=>e.jsxs("button",{onClick:()=>A(b),className:`rounded-xl px-3 py-2 text-left transition-all duration-200 ${s===b?"bg-indigo-500/20 text-indigo-200 ring-1 ring-indigo-500/40":"bg-slate-900/70 text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[e.jsx("span",{className:"block text-xs font-bold",children:xe[b].name}),e.jsx("span",{className:"mt-0.5 block text-[10px] leading-snug opacity-70",children:xe[b].description})]},b))})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Map"}),e.jsx("span",{className:"rounded-full bg-slate-900 px-2 py-0.5 text-[9px] font-mono uppercase text-slate-400 ring-1 ring-slate-800",children:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:()=>z("predefined"),className:`flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-medium transition-all ${n==="predefined"?"bg-sky-500/15 text-sky-300 ring-1 ring-sky-500/30":"bg-slate-900/70 text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[e.jsx(Be,{size:12})," Preset"]}),e.jsxs("button",{onClick:()=>z("random"),className:`flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-medium transition-all ${n==="random"?"bg-sky-500/15 text-sky-300 ring-1 ring-sky-500/30":"bg-slate-900/70 text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[e.jsx(Fe,{size:12})," Random"]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-emerald-500/20 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Mission"}),e.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[9px] font-bold uppercase tracking-wider text-emerald-300 ring-1 ring-emerald-500/25",children:I})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(fe,{label:"Depot",value:d??"unset",tone:"yellow"}),e.jsx(fe,{label:"Dropoff",value:r??"unset",tone:"orange"})]}),f.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl bg-slate-900/70 p-3 ring-1 ring-slate-800/80",children:[e.jsx("p",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Route manifest"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:f.map((b,R)=>e.jsx("span",{className:"inline-flex items-center rounded-md bg-indigo-500/15 px-1.5 py-0.5 text-[10px] font-mono font-semibold text-indigo-300 ring-1 ring-indigo-500/20",children:b},`${b}-${R}`))})]})]}),s==="visualize"&&d&&r&&e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Algorithm"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("button",{onClick:h,disabled:i<=0,className:"flex-1 flex items-center justify-center gap-1 rounded-xl bg-slate-900/70 px-2 py-2 text-xs font-medium text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(Oe,{size:14})," Prev"]}),e.jsx("button",{onClick:T,className:`flex-1 flex items-center justify-center gap-1 rounded-xl px-2 py-2 text-xs font-medium transition-all ${w?"bg-amber-500/20 text-amber-300 ring-1 ring-amber-500/30":"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/30 hover:bg-indigo-500/30"}`,children:w?e.jsxs(e.Fragment,{children:[e.jsx(Le,{size:14})," Pause"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{size:14})," Play"]})}),e.jsxs("button",{onClick:o,disabled:i>=m-1,className:"flex-1 flex items-center justify-center gap-1 rounded-xl bg-slate-900/70 px-2 py-2 text-xs font-medium text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:["Next ",e.jsx(_e,{size:14})]})]}),e.jsx("div",{className:"flex gap-1 mb-2",children:st.map(b=>e.jsx("button",{onClick:()=>E(b.value),className:`flex-1 rounded-md px-2 py-1 text-[10px] font-medium transition-all ${c===b.value?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/50 text-slate-500 hover:text-slate-400"}`,children:b.label},b.value))}),m>0&&e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-500",children:[e.jsx("span",{children:"Step"}),e.jsxs("span",{className:"font-mono font-semibold text-indigo-300",children:[Math.max(0,i+1)," / ",m]})]})]}),d&&r&&e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Route Info"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(ue,{size:11})," Your Cost"]}),e.jsx("span",{className:"text-sm font-mono font-bold text-indigo-300",children:l>0||v?l:"—"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(ue,{size:11})," Optimal"]}),e.jsx("span",{className:`text-sm font-mono font-bold ${j?"text-emerald-300":"text-slate-600"}`,children:j?p:"???"})]}),v&&l>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Difference"}),e.jsx("span",{className:`text-sm font-mono font-bold ${l===p?"text-emerald-400":"text-amber-400"}`,children:l===p?"Perfect!":`+${l-p}`})]}),s==="race"&&v&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(qe,{size:11})," Time"]}),e.jsx("span",{className:"text-sm font-mono font-bold text-sky-300",children:it(y)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-slate-500",children:[e.jsx(We,{size:11})," Score"]}),e.jsx("span",{className:"text-sm font-mono font-bold text-amber-300",children:u})]})]})]})]}),s==="visualize"&&a&&e.jsxs("div",{className:`rounded-2xl border p-4 shadow-xl shadow-black/20 backdrop-blur-sm ${a.type==="relax"?"border-amber-500/30 bg-amber-500/5":a.type==="done"?"border-emerald-500/30 bg-emerald-500/5":"border-slate-700/50 bg-slate-950/75"}`,children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-2",children:"Current Step"}),e.jsx("p",{className:"text-xs text-slate-300 leading-relaxed",children:a.description}),a.queue.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-[10px] text-slate-500 mb-1",children:"Priority Queue:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:[...a.queue].sort((b,R)=>b.distance-R.distance).map(b=>e.jsxs("span",{className:"inline-flex items-center rounded-md bg-sky-500/10 px-1.5 py-0.5 text-[10px] font-mono text-sky-300 ring-1 ring-sky-500/20",children:[b.id,":",b.distance]},b.id))})]})]}),S&&e.jsx("div",{className:"rounded-xl border border-red-500/30 bg-red-500/5 px-3 py-2 text-center text-xs font-medium text-red-400 shadow-xl shadow-red-950/20 animate-pulse",children:S}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:$,className:"flex items-center justify-center gap-1.5 rounded-xl bg-slate-950/80 px-3 py-2 text-xs font-medium text-slate-400 ring-1 ring-slate-800 transition-all hover:bg-slate-800/80 hover:text-slate-300",children:[e.jsx(He,{size:12})," Reset"]}),s!=="visualize"&&e.jsxs("button",{onClick:t,disabled:f.length<=1||v,className:"flex items-center justify-center gap-1.5 rounded-xl bg-slate-950/80 px-3 py-2 text-xs font-medium text-slate-400 ring-1 ring-slate-800 transition-all hover:bg-slate-800/80 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(Je,{size:12})," Undo"]}),s!=="visualize"&&d&&r&&e.jsxs("button",{onClick:C,className:`flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-medium transition-all ${j?"bg-emerald-500/15 text-emerald-300 ring-1 ring-emerald-500/30":"bg-slate-950/80 text-slate-400 ring-1 ring-slate-800 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[j?e.jsx(Ve,{size:12}):e.jsx(Ue,{size:12})," Best"]}),e.jsxs("button",{onClick:()=>k(!M),className:`flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-xs font-medium transition-all ${M?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-950/80 text-slate-400 ring-1 ring-slate-800 hover:bg-slate-800/80 hover:text-slate-300"}`,children:[M?e.jsx(Ye,{size:12}):e.jsx(Qe,{size:12})," Sound"]})]})]})}function fe({label:s,value:n,tone:d}){const r={yellow:"text-yellow-300 ring-yellow-500/25 bg-yellow-500/10",orange:"text-orange-300 ring-orange-500/25 bg-orange-500/10"};return e.jsxs("div",{className:`rounded-xl p-3 ring-1 ${r[d]}`,children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider opacity-65",children:s}),e.jsx("div",{className:"mt-1 font-mono text-lg font-black",children:n})]})}let P=0,q=0;function at(){return String.fromCharCode(65+P++%26)}function ge(){P=0,q=0}function me(){return`e${q++}`}function re(s,n){return Math.sqrt((s.x-n.x)**2+(s.y-n.y)**2)}function pe(s){ge();const n=[rt,ot,lt];return n[s%n.length]()}function rt(){const s=[{id:"A",x:80,y:200,distance:1/0,visited:!1,previous:null},{id:"B",x:220,y:80,distance:1/0,visited:!1,previous:null},{id:"C",x:220,y:320,distance:1/0,visited:!1,previous:null},{id:"D",x:400,y:80,distance:1/0,visited:!1,previous:null},{id:"E",x:400,y:200,distance:1/0,visited:!1,previous:null},{id:"F",x:400,y:320,distance:1/0,visited:!1,previous:null},{id:"G",x:560,y:200,distance:1/0,visited:!1,previous:null},{id:"H",x:700,y:200,distance:1/0,visited:!1,previous:null}];P=8;const n=[{id:"e0",source:"A",destination:"B",weight:4},{id:"e1",source:"A",destination:"C",weight:2},{id:"e2",source:"B",destination:"D",weight:5},{id:"e3",source:"B",destination:"E",weight:10},{id:"e4",source:"C",destination:"E",weight:3},{id:"e5",source:"C",destination:"F",weight:8},{id:"e6",source:"D",destination:"G",weight:2},{id:"e7",source:"E",destination:"G",weight:6},{id:"e8",source:"F",destination:"G",weight:1},{id:"e9",source:"G",destination:"H",weight:3},{id:"e10",source:"D",destination:"E",weight:1}];return q=11,{nodes:s,edges:n}}function ot(){const s=[{id:"A",x:100,y:150,distance:1/0,visited:!1,previous:null},{id:"B",x:250,y:50,distance:1/0,visited:!1,previous:null},{id:"C",x:250,y:250,distance:1/0,visited:!1,previous:null},{id:"D",x:400,y:150,distance:1/0,visited:!1,previous:null},{id:"E",x:550,y:50,distance:1/0,visited:!1,previous:null},{id:"F",x:550,y:250,distance:1/0,visited:!1,previous:null},{id:"G",x:700,y:150,distance:1/0,visited:!1,previous:null}];P=7;const n=[{id:"e0",source:"A",destination:"B",weight:7},{id:"e1",source:"A",destination:"C",weight:3},{id:"e2",source:"B",destination:"D",weight:2},{id:"e3",source:"C",destination:"D",weight:5},{id:"e4",source:"C",destination:"F",weight:12},{id:"e5",source:"D",destination:"E",weight:4},{id:"e6",source:"D",destination:"F",weight:3},{id:"e7",source:"E",destination:"G",weight:1},{id:"e8",source:"F",destination:"G",weight:2},{id:"e9",source:"B",destination:"E",weight:9}];return q=10,{nodes:s,edges:n}}function lt(){const s=[{id:"A",x:80,y:180,distance:1/0,visited:!1,previous:null},{id:"B",x:200,y:60,distance:1/0,visited:!1,previous:null},{id:"C",x:200,y:300,distance:1/0,visited:!1,previous:null},{id:"D",x:350,y:180,distance:1/0,visited:!1,previous:null},{id:"E",x:500,y:60,distance:1/0,visited:!1,previous:null},{id:"F",x:500,y:300,distance:1/0,visited:!1,previous:null},{id:"G",x:650,y:120,distance:1/0,visited:!1,previous:null},{id:"H",x:650,y:240,distance:1/0,visited:!1,previous:null},{id:"I",x:780,y:180,distance:1/0,visited:!1,previous:null}];P=9;const n=[{id:"e0",source:"A",destination:"B",weight:3},{id:"e1",source:"A",destination:"C",weight:6},{id:"e2",source:"A",destination:"D",weight:7},{id:"e3",source:"B",destination:"D",weight:2},{id:"e4",source:"B",destination:"E",weight:8},{id:"e5",source:"C",destination:"D",weight:3},{id:"e6",source:"C",destination:"F",weight:4},{id:"e7",source:"D",destination:"E",weight:2},{id:"e8",source:"D",destination:"F",weight:5},{id:"e9",source:"E",destination:"G",weight:1},{id:"e10",source:"F",destination:"H",weight:2},{id:"e11",source:"G",destination:"I",weight:4},{id:"e12",source:"H",destination:"I",weight:3},{id:"e13",source:"G",destination:"H",weight:2}];return q=14,{nodes:s,edges:n}}function ct(s=12){ge();const n=750,d=360,r=60,f=80,l=[];let p=0;for(;l.lengthre(v,{x:c,y:u})u).filter(c=>c>0));for(;m.size>0;){let c=1/0,u=0,y=0;for(const M of i)for(const N of m){const A=re(l[M],l[N]);A0;){j.sort((c,u)=>c.distance-u.distance);const i=j.shift();if(p.has(i.id))continue;p.add(i.id);const m=[...p];if(r.push({type:"visit",currentNodeId:i.id,description:`Visit node ${i.id} (distance = ${f[i.id]})`,distances:{...f},visited:m,previous:{...l},queue:[...j]}),i.id===d)break;const w=be(s,i.id);for(const c of w){if(p.has(c.id))continue;const u=f[i.id]+c.weight,y=f[c.id];if(uS.id===c.id);v>=0?j[v].distance=u:j.push({id:c.id,distance:u}),r.push({type:"relax",currentNodeId:i.id,description:`Relax edge ${i.id} → ${c.id}: distance updated from ${y===1/0?"∞":y} to ${u}`,distances:{...f},visited:[...p],previous:{...l},queue:[...j],relaxedEdge:{from:i.id,to:c.id,oldDist:y,newDist:u}})}}}const a=je(l,n,d);return r.push({type:"done",currentNodeId:d,description:a.length>0?`Done! Shortest path: ${a.join(" → ")} (cost: ${f[d]})`:`No path found from ${n} to ${d}`,distances:{...f},visited:[...p],previous:{...l},queue:[]}),r}function je(s,n,d){const r=[];let f=d;for(;f!==null&&(r.unshift(f),f!==n);)f=s[f];return r[0]!==n?[]:r}function dt(s,n,d){const r=ye(s,n,d),f=r[r.length-1],l=je(f.previous,n,d),p=f.distances[d]??1/0;return{path:l,cost:p===1/0?-1:p}}function ut(s,n){let d=0;for(let r=0;rl.source===n[r]&&l.destination===n[r+1]||l.destination===n[r]&&l.source===n[r+1]);if(!f)return-1;d+=f.weight}return d}function xt(s,n,d){if(n<=0||s<0)return 0;const r=100,f=(s-n)*5,l=Math.floor(d/3),p=s===n?50:0;return Math.max(0,r-f-l+p)}const he=[329.63,392,440,493.88,523.25,587.33,659.25,783.99];function ft(){const s=x.useRef(!0),n=x.useCallback(()=>Ze(),[]),d=x.useCallback(a=>{s.current=a},[]),r=x.useCallback(a=>{if(!s.current)return;const i=n();if(!i)return;const m=he[a%he.length],w=i.createOscillator(),c=i.createGain();w.type="sine",w.frequency.setValueAtTime(m,i.currentTime),c.gain.setValueAtTime(.1,i.currentTime),c.gain.exponentialRampToValueAtTime(.001,i.currentTime+.25),w.connect(c),c.connect(i.destination),w.start(),w.stop(i.currentTime+.25)},[n]),f=x.useCallback(()=>{if(!s.current)return;const a=n();if(!a)return;const i=a.createOscillator(),m=a.createGain();i.type="triangle",i.frequency.setValueAtTime(600,a.currentTime),i.frequency.setValueAtTime(800,a.currentTime+.08),m.gain.setValueAtTime(.06,a.currentTime),m.gain.exponentialRampToValueAtTime(.001,a.currentTime+.15),i.connect(m),m.connect(a.destination),i.start(),i.stop(a.currentTime+.15)},[n]),l=x.useCallback(()=>{if(!s.current)return;const a=n();if(!a)return;const i=a.createOscillator(),m=a.createGain();i.type="sine",i.frequency.setValueAtTime(520,a.currentTime),m.gain.setValueAtTime(.08,a.currentTime),m.gain.exponentialRampToValueAtTime(.001,a.currentTime+.1),i.connect(m),m.connect(a.destination),i.start(),i.stop(a.currentTime+.1)},[n]),p=x.useCallback(()=>{if(!s.current)return;const a=n();if(!a)return;const i=a.createOscillator(),m=a.createGain();i.type="sawtooth",i.frequency.setValueAtTime(200,a.currentTime),i.frequency.setValueAtTime(140,a.currentTime+.12),m.gain.setValueAtTime(.07,a.currentTime),m.gain.exponentialRampToValueAtTime(.001,a.currentTime+.25),i.connect(m),m.connect(a.destination),i.start(),i.stop(a.currentTime+.25)},[n]),j=x.useCallback(a=>{if(!s.current)return;const i=n();if(!i)return;(a?[523.25,587.33,659.25,783.99,880,1046.5]:[400,350,300]).forEach((w,c)=>{const u=i.createOscillator(),y=i.createGain();u.type="sine",u.frequency.value=w,y.gain.setValueAtTime(.07,i.currentTime+c*.08),y.gain.exponentialRampToValueAtTime(.001,i.currentTime+c*.08+.18),u.connect(y),y.connect(i.destination),u.start(i.currentTime+c*.08),u.stop(i.currentTime+c*.08+.18)})},[n]);return{playVisitTone:r,playRelaxTone:f,playClickTone:l,playErrorTone:p,playCompleteSweep:j,setEnabled:d}}function mt(){const[s,n]=x.useState("explore"),[d,r]=x.useState(()=>pe(0)),[f,l]=x.useState("predefined"),[p,j]=x.useState(0),[a,i]=x.useState(null),[m,w]=x.useState(null),[c,u]=x.useState([]),[y,v]=x.useState(0),[S,M]=x.useState([]),[N,A]=x.useState(0),[z,$]=x.useState(!1),[C,t]=x.useState([]),[o,h]=x.useState(-1),[T,E]=x.useState(!1),k=x.useRef(null),[I,b]=x.useState(500),[R,W]=x.useState(0),[ee,te]=x.useState(0),[oe,se]=x.useState(!1),O=x.useRef(null),[ve,we]=x.useState(!0),[ke,V]=x.useState(null),[ie,le]=x.useState(!1),[H,U]=x.useState("start"),{playVisitTone:Y,playRelaxTone:Q,playClickTone:Z,playErrorTone:ne,playCompleteSweep:G,setEnabled:ce}=ft(),Ne=x.useCallback(g=>{we(g),ce(g)},[ce]);x.useEffect(()=>(oe&&(O.current=window.setInterval(()=>te(g=>g+1),1e3)),()=>{O.current&&clearInterval(O.current)}),[oe]);const Ce=o>=0&&o{if(V(null),H==="start"){i(g),U("end"),Z();return}if(H==="end"){if(g===a){V("Destination must be different from start"),ne();return}w(g),Z();const B=dt(d,a,g);if(M(B.path),A(B.cost),s==="visualize"){const ze=ye(d,a,g);t(ze),h(-1),U("path")}else u([a]),v(0),U("path"),s==="race"&&(se(!0),te(0));return}if(s==="visualize"||c.length===0)return;const D=c[c.length-1];if(g===D)return;const de=be(d,D).find(B=>B.id===g);if(!de){V(`${g} is not adjacent to ${D}`),ne(),setTimeout(()=>V(null),1500);return}Z();const $e=[...c,g],ae=y+de.weight;if(u($e),v(ae),g===m)if(le(!0),se(!1),$(!0),s==="race"){const B=xt(ae,N,ee);W(B),G(ae===N)}else G(!0)},[H,a,m,d,s,c,y,N,ee,Z,ne,G]),Se=x.useCallback(()=>{if(c.length<=1||ie)return;const g=c.slice(0,-1);u(g),v(ut(d,g)),V(null)},[c,d,ie]),Me=x.useCallback(()=>{C.length!==0&&h(g=>{const D=Math.min(g+1,C.length-1),X=C[D];return X.type==="visit"&&Y(D),X.type==="relax"&&Q(),X.type==="done"&&G(!0),D})},[C,Y,Q,G]),De=x.useCallback(()=>{h(g=>Math.max(g-1,0))},[]),Ee=x.useCallback(()=>{if(T){k.current&&clearInterval(k.current),E(!1);return}E(!0);let g=o<0?0:o;k.current=window.setInterval(()=>{if(g>=C.length-1){k.current&&clearInterval(k.current),E(!1);return}g++,h(g);const D=C[g];D.type==="visit"&&Y(g),D.type==="relax"&&Q(),D.type==="done"&&G(!0)},I)},[T,o,C,I,Y,Q,G]),_=x.useCallback(()=>{i(null),w(null),u([]),v(0),M([]),A(0),$(!1),t([]),h(-1),E(!1),W(0),te(0),se(!1),le(!1),V(null),U("start"),k.current&&clearInterval(k.current),O.current&&clearInterval(O.current),r(g=>({...g,nodes:g.nodes.map(D=>({...D,distance:1/0,visited:!1,previous:null}))}))},[]),Ie=x.useCallback(g=>{n(g),_()},[_]),Re=x.useCallback(g=>{if(l(g),g==="predefined"){const D=(p+1)%3;j(D),r(pe(D))}else r(ct(12));_()},[p,_]),Ae=x.useCallback(()=>{!a||!m||$(g=>!g)},[a,m]);return{mode:s,graph:d,mapType:f,startNode:a,endNode:m,playerPath:c,playerCost:y,optimalPath:S,optimalCost:N,showOptimal:z,algoSteps:C,algoStepIndex:o,currentAlgoStep:Ce,isAlgoRunning:T,algoSpeed:I,setAlgoSpeed:b,score:R,timer:ee,isComplete:ie,lastError:ke,soundEnabled:ve,selectingPhase:H,clickNode:Te,undoLastStep:Se,stepAlgoForward:Me,stepAlgoBack:De,autoPlayAlgo:Ee,resetGame:_,changeMode:Ie,newMap:Re,toggleOptimal:Ae,toggleSound:Ne}}function Mt(){const{mode:s,graph:n,mapType:d,startNode:r,endNode:f,playerPath:l,playerCost:p,optimalPath:j,optimalCost:a,showOptimal:i,algoSteps:m,algoStepIndex:w,currentAlgoStep:c,isAlgoRunning:u,algoSpeed:y,setAlgoSpeed:v,score:S,timer:M,isComplete:N,lastError:A,soundEnabled:z,selectingPhase:$,clickNode:C,undoLastStep:t,stepAlgoForward:o,stepAlgoBack:h,autoPlayAlgo:T,resetGame:E,changeMode:k,newMap:I,toggleOptimal:b,toggleSound:R}=mt(),W=r&&f?`${r} -> ${f}`:"Select depot and destination";return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_30%),radial-gradient(circle_at_bottom_right,rgba(34,197,94,0.12),transparent_28%)]",children:[e.jsx("div",{className:"border-b border-slate-800/70 bg-slate-950/75 px-4 py-3 shadow-lg shadow-black/20 backdrop-blur-sm md:px-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-sky-400",children:"Shortest Path Command Center"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Dijkstra Delivery Simulator"})]}),e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[e.jsx(K,{label:"Mode",value:s,tone:"indigo"}),e.jsx(K,{label:"Map",value:d,tone:"sky"}),e.jsx(K,{label:"Route",value:W,tone:"emerald"}),N&&e.jsx(K,{label:"Result",value:p===a?"optimal":`+${p-a} min`,tone:p===a?"emerald":"amber"})]})]})}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[e.jsx("div",{className:"order-last flex min-h-[620px] flex-1 flex-col gap-4 xl:order-first xl:min-h-0",children:e.jsx(et,{graph:n,startNode:r,endNode:f,playerPath:l,optimalPath:j,showOptimal:i,currentAlgoStep:c,selectingPhase:$,onClickNode:C})}),e.jsx(nt,{mode:s,mapType:d,startNode:r,endNode:f,playerPath:l,playerCost:p,optimalCost:a,showOptimal:i,currentAlgoStep:c,algoStepIndex:w,algoStepsTotal:m.length,isAlgoRunning:u,algoSpeed:y,score:S,timer:M,isComplete:N,lastError:A,soundEnabled:z,selectingPhase:$,onChangeMode:k,onNewMap:I,onReset:E,onToggleOptimal:b,onUndoLastStep:t,onStepForward:o,onStepBack:h,onAutoPlay:T,onSetAlgoSpeed:v,onToggleSound:R})]})]})}function K({label:s,value:n,tone:d}){const r={indigo:"bg-indigo-500/10 text-indigo-200 ring-indigo-500/25",sky:"bg-sky-500/10 text-sky-200 ring-sky-500/25",emerald:"bg-emerald-500/10 text-emerald-200 ring-emerald-500/25",amber:"bg-amber-500/10 text-amber-200 ring-amber-500/25"};return e.jsxs("div",{className:`rounded-full px-3 py-1.5 text-[10px] ring-1 ${r[d]}`,children:[e.jsx("span",{className:"mr-1 uppercase tracking-wider opacity-60",children:s}),e.jsx("span",{className:"font-mono font-bold",children:n})]})}export{Mt as default}; diff --git a/docs/assets/EvolutionSimulatorPage-AYe0wg-1.js b/docs/assets/EvolutionSimulatorPage-C1Me-6kF.js similarity index 98% rename from docs/assets/EvolutionSimulatorPage-AYe0wg-1.js rename to docs/assets/EvolutionSimulatorPage-C1Me-6kF.js index 37f23d3..de8f66f 100644 --- a/docs/assets/EvolutionSimulatorPage-AYe0wg-1.js +++ b/docs/assets/EvolutionSimulatorPage-C1Me-6kF.js @@ -1 +1 @@ -import{j as e,r as i}from"./index-eCXyAnHs.js";import{g as de}from"./audioContext-NbgqvQGz.js";import{S as ue}from"./shuffle-CdKU4ZYx.js";import{P as B}from"./play-BqZilH6N.js";import{P as xe}from"./pause-nC-0zhw8.js";import{R as me}from"./rotate-ccw-B8GZP3d7.js";import{V as ge,a as he}from"./volume-x-CTbtCvt-.js";function U(t,n,s,a){return t.length===0?"":t.length===1?`0,${s}`:t.map((r,l)=>{const o=l/(t.length-1)*n,c=s-Math.max(0,r)/Math.max(1,a)*s;return`${o},${c}`}).join(" ")}function pe({best:t,avg:n,targetLength:s}){const l=Math.max(s,...t,...n,1);return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-300",children:"Fitness Monitor"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-500",children:"Lab readout for best and average population health"})]}),e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("svg",{viewBox:"0 0 640 220",className:"w-full min-w-[560px] h-56 rounded-xl bg-slate-950/80 ring-1 ring-slate-700/50",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"fitnessGlow",x1:"0",x2:"1",y1:"0",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(244 63 94)"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(52 211 153)"})]})}),e.jsx("line",{x1:"0",y1:220,x2:640,y2:220,stroke:"rgb(71 85 105 / 0.7)",strokeWidth:"1"}),e.jsx("line",{x1:"0",y1:"0",x2:"0",y2:220,stroke:"rgb(71 85 105 / 0.7)",strokeWidth:"1"}),s>0&&e.jsx("line",{x1:"0",y1:220-s/l*220,x2:640,y2:220-s/l*220,stroke:"rgb(74 222 128 / 0.35)",strokeDasharray:"4 4",strokeWidth:"1"}),e.jsx("polyline",{fill:"none",stroke:"url(#fitnessGlow)",strokeWidth:"3",points:U(t,640,220,l)}),e.jsx("polyline",{fill:"none",stroke:"rgb(56 189 248)",strokeWidth:"2",points:U(n,640,220,l)})]})}),e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-[10px] text-slate-400",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-rose-500"})," Best Fitness"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-sky-400"})," Average Fitness"]})]})]})}function be({population:t,target:n}){return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-300",children:"Candidate Profiles"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-500",children:"The strongest survivors in this generation"})]}),e.jsxs("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-semibold text-emerald-300 ring-1 ring-emerald-500/25",children:["Top ",t.length||0]})]}),e.jsx("div",{className:"space-y-1.5 max-h-72 overflow-auto pr-1",children:t.map((s,a)=>e.jsxs("div",{className:`rounded-xl px-3 py-2 ring-1 transition-all ${a===0?"bg-emerald-500/10 ring-emerald-500/30 shadow-lg shadow-emerald-950/20":"bg-slate-800/50 ring-slate-700/40"}`,children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-500",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${a===0?"bg-emerald-400":"bg-slate-600"}`}),"Subject #",a+1]}),e.jsxs("span",{className:"font-mono",children:[s.fitness," / ",n.length]})]}),e.jsx("div",{className:"mt-1 font-mono text-xs text-slate-200 tracking-wide break-all",children:s.genes}),e.jsx("div",{className:"mt-2 h-1 overflow-hidden rounded-full bg-slate-950/70",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-emerald-400 to-cyan-300",style:{width:`${s.fitness/Math.max(1,n.length)*100}%`}})})]},`${s.genes}-${a}`))})]})}function fe({target:t,bestGenes:n}){return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-300",children:"DNA Match Board"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-500",children:"Green cells already match the target phrase"})]}),e.jsxs("div",{className:"space-y-3 font-mono text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-slate-500 mb-1",children:"Target"}),e.jsx("div",{className:"rounded-xl bg-slate-950/70 ring-1 ring-slate-700/40 px-3 py-2 break-all tracking-wide text-slate-200",children:t||"(empty)"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-slate-500 mb-1",children:"Best Individual"}),e.jsxs("div",{className:"rounded-xl bg-slate-950/70 ring-1 ring-slate-700/40 px-3 py-2 break-all tracking-wide",children:[(n||"").split("").map((s,a)=>{const r=t[a]===s;return e.jsx("span",{className:`mx-0.5 inline-flex min-w-5 justify-center rounded px-1 py-0.5 ${r?"bg-emerald-500/20 text-emerald-200 ring-1 ring-emerald-500/30":"bg-slate-800/60 text-slate-300 ring-1 ring-slate-700/40"}`,children:s},`${s}-${a}`)}),!n&&e.jsx("span",{className:"text-slate-500",children:"Start the simulator to see candidate DNA."})]})]})]})]})}const q=["#f8c9a5","#d99b6c","#8d5524","#f1b982","#c68642"],K=["#22c55e","#38bdf8","#a78bfa","#fb7185","#facc15","#2dd4bf"];function ve({population:t,target:n,generation:s,convergence:a,status:r}){const l=t.length>0?t.slice(0,12):Array.from({length:12},(c,d)=>({genes:"????",fitness:Math.max(0,12-d)})),o=Math.max(1,n.length);return e.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-emerald-700/30 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.18),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.42))] p-4 shadow-2xl shadow-black/30 md:p-5",children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-28 bg-gradient-to-t from-emerald-950/50 to-transparent"}),e.jsxs("div",{className:"relative z-10 flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-white md:text-lg",children:"Population Habitat"}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-emerald-100/65",children:"Each person is a candidate solution. Brighter badges mean more matching genes survived selection."})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsx(_,{label:"Gen",value:s}),e.jsx(_,{label:"Fit",value:`${a.toFixed(0)}%`}),e.jsx(_,{label:"State",value:r})]})]}),e.jsxs("div",{className:"relative z-10 mt-5 rounded-2xl border border-emerald-950/50 bg-emerald-950/25 p-4 shadow-inner",children:[e.jsx("div",{className:"absolute inset-x-6 bottom-3 h-10 rounded-[50%] bg-black/20 blur-xl"}),e.jsx("div",{className:"relative grid grid-cols-3 gap-x-3 gap-y-5 sm:grid-cols-4 lg:grid-cols-6",children:l.map((c,d)=>{const p=c.fitness/o,m=d===0&&t.length>0;return e.jsx(je,{rank:d+1,genes:c.genes,fitnessRatio:p,isElite:m,skin:q[d%q.length],shirt:K[d%K.length]},`${c.genes}-${d}`)})})]})]})}function je({rank:t,genes:n,fitnessRatio:s,isElite:a,skin:r,shirt:l}){const o=Math.max(0,Math.min(1,s)),c=a?"shadow-[0_0_26px_rgba(52,211,153,0.45)]":"",d=.4+o*.6;return e.jsxs("div",{className:`group relative flex flex-col items-center rounded-2xl border px-2 py-3 transition-all hover:-translate-y-1 ${a?"border-emerald-300/50 bg-emerald-400/10":"border-emerald-900/30 bg-slate-950/25"} ${c}`,children:[e.jsxs("div",{className:"absolute right-1.5 top-1.5 rounded-full bg-slate-950/70 px-1.5 py-0.5 text-[9px] font-bold text-slate-400 ring-1 ring-slate-700/50",children:["#",t]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsxs("div",{className:"h-9 w-9 rounded-full border border-black/15 shadow-inner",style:{backgroundColor:r,opacity:d},children:[e.jsxs("div",{className:"mx-auto mt-3 flex w-4 justify-between",children:[e.jsx("span",{className:"h-1 w-1 rounded-full bg-slate-950/70"}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-slate-950/70"})]}),e.jsx("div",{className:"mx-auto mt-1 h-1 w-3 rounded-full bg-slate-950/40"})]}),e.jsx("div",{className:"mx-auto -mt-1 h-10 w-12 rounded-t-2xl rounded-b-lg border border-black/15 shadow-lg",style:{backgroundColor:l,opacity:d}})]}),e.jsx("div",{className:"mt-2 h-1.5 w-full overflow-hidden rounded-full bg-slate-950/70",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-emerald-400 to-cyan-300 transition-all",style:{width:`${o*100}%`}})}),e.jsx("div",{className:"mt-1 max-w-full truncate font-mono text-[9px] text-emerald-100/70",children:n||"waiting"})]})}function _({label:t,value:n}){return e.jsxs("div",{className:"rounded-xl bg-slate-950/45 px-3 py-2 ring-1 ring-emerald-500/20",children:[e.jsx("div",{className:"text-[9px] uppercase tracking-wider text-emerald-100/45",children:t}),e.jsx("div",{className:"mt-0.5 text-xs font-bold capitalize text-emerald-100",children:n})]})}const J="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,!?-",$={target:"HELLO WORLD",populationSize:300,mutationRate:.03,crossoverRate:.75,maxGenerations:500,selectionStrategy:"roulette"},X=["HELLO WORLD","GENETIC ALGORITHM","EVOLUTION IN ACTION","SURVIVAL OF THE FITTEST","OPTIMIZE THE GENES"];function Q(t){let n=t>>>0;const s=()=>(n=1664525*n+1013904223>>>0,n/4294967296);return{next:s,int:(r,l)=>l<=r?r:Math.floor(s()*(l-r+1))+r}}function Ne(t,n,s){let a="";for(let r=0;r({...s,fitness:we(s.genes,n)}))}function ee(t){return t.length===0?0:t.reduce((s,a)=>s+a.fitness,0)/t.length}function Se(t,n){const s=t.reduce((l,o)=>l+o.fitness,0);if(s<=0)return t[n.int(0,t.length-1)];const a=n.next()*s;let r=0;for(let l=0;l=a)return t[l];return t[t.length-1]}function ke(t,n,s){let a=t[s.int(0,t.length-1)];const r=Math.max(1,n);for(let l=1;la.fitness&&(a=o)}return a}function Y(t,n,s,a){return n==="tournament"?ke(t,s,a):Se(t,a)}function Ce(t,n,s,a){const r=t.genes.length;if(r<=1||a.next()>s)return t.genes;const l=a.int(1,r-1);return t.genes.slice(0,l)+n.genes.slice(l)}function Te(t,n,s,a){if(t.length===0)return t;let r="";for(let l=0;ls.fitness-n.fitness)}function te(t,n,s,a){return n===0?"Target is empty. Enter a target to evolve.":t>=n?`Solution found in ${s} generations`:s>=a?"Max generations reached without full match":"Evolving..."}function Re(t,n){const s=t.target.length,a=Q(n),r=ye(t.populationSize,s,t.allowedChars,a),l=V(D(r,t.target)),o=l[0]??{genes:"",fitness:0},c=ee(l),d=s===0||o.fitness>=s;return{generation:0,population:l,bestIndividual:W(o),averageFitness:c,bestFitnessHistory:[o.fitness],averageFitnessHistory:[c],rngSeed:n,done:d,message:te(o.fitness,s,0,t.maxGenerations)}}function Me(t,n){if(n.done)return n;const s=t.target.length,a=Q(n.rngSeed+n.generation+1),r=V(D(n.population,t.target)),l=r[0]?W(r[0]):{genes:"",fitness:0},o=[l];for(;o.length=s||d>=t.maxGenerations;return{generation:d,population:c,bestIndividual:W(p),averageFitness:m,bestFitnessHistory:[...n.bestFitnessHistory,p.fitness],averageFitnessHistory:[...n.averageFitnessHistory,m],rngSeed:n.rngSeed,done:x,message:te(p.fitness,s,d,t.maxGenerations)}}const H=[220,261.63,293.66,329.63,392,440,523.25,659.25,783.99];function Ee(){const t=i.useRef(!0),n=i.useCallback(()=>de(),[]),s=i.useCallback(c=>{t.current=c},[]),a=i.useCallback((c,d,p,m=.05)=>{if(!t.current)return;const x=n();if(!x)return;const h=x.createOscillator(),v=x.createGain();h.type=d,h.frequency.setValueAtTime(c,x.currentTime),v.gain.setValueAtTime(m,x.currentTime),v.gain.exponentialRampToValueAtTime(.001,x.currentTime+p),h.connect(v),v.connect(x.destination),h.start(x.currentTime),h.stop(x.currentTime+p)},[n]),r=i.useCallback((c,d)=>{const p=d>0?c/d:0,m=Math.max(0,Math.min(H.length-1,Math.floor(p*(H.length-1))));a(H[m],"sine",.06,.03)},[a]),l=i.useCallback(()=>{a(523.25,"triangle",.08,.05)},[a]),o=i.useCallback(()=>{if(!t.current)return;const c=n();c&&[523.25,659.25,783.99].forEach((d,p)=>{const m=c.createOscillator(),x=c.createGain(),h=c.currentTime+p*.1;m.type="sine",m.frequency.setValueAtTime(d,h),x.gain.setValueAtTime(.06,h),x.gain.exponentialRampToValueAtTime(.001,h+.16),m.connect(x),x.connect(c.destination),m.start(h),m.stop(h+.16)})},[n]);return{setEnabled:s,playGenerationTick:r,playImprove:l,playComplete:o}}function Z(t){const n=t.toUpperCase();let s="";for(let a=0;a{n(g),g==="guided"&&(a("HELLO WORLD"),l(300),c(3),p(75),x(500),v("roulette"),M(35))},[]);i.useEffect(()=>{O(S)},[S,O]);const C=i.useCallback(()=>{k.current&&(clearTimeout(k.current),k.current=null)},[]),z=i.useCallback(()=>({target:Z(s),populationSize:Math.max(1,r),mutationRate:Math.min(1,Math.max(0,o/100)),crossoverRate:Math.min(1,Math.max(0,d/100)),maxGenerations:Math.max(1,m),selectionStrategy:h,tournamentSize:5,allowedChars:J}),[s,r,o,d,m,h]),u=i.useCallback(()=>{N(g=>{if(!g||!E.current)return g;const T=Me(E.current,g),R=E.current.target.length;return G(T.bestIndividual.fitness,R),T.bestIndividual.fitness>F.current&&P(),F.current=T.bestIndividual.fitness,T.done&&(f(),y("finished")),T})},[G,P,f]);i.useEffect(()=>{if(j!=="running"){C();return}const g=()=>{u(),k.current=setTimeout(g,w)};return k.current=setTimeout(g,w),C},[j,w,u,C]);const se=i.useCallback(()=>{const g=z();E.current=g;const R=Re(g,1337);F.current=R.bestIndividual.fitness,N(R),R.bestIndividual.fitness>0&&G(R.bestIndividual.fitness,g.target.length),y(R.done?"finished":"running")},[z,G]),ne=i.useCallback(()=>{j==="running"&&y("paused")},[j]),ae=i.useCallback(()=>{j==="paused"&&y("running")},[j]),re=i.useCallback(()=>{C(),N(null),y("idle"),F.current=0},[C]),le=i.useCallback(g=>{A(g)},[]),ie=i.useCallback(()=>{const g=Math.floor(Math.random()*X.length);a(X[g])},[]),oe=i.useMemo(()=>b?.population?b.population.slice(0,10):[],[b]),ce=i.useMemo(()=>{const g=Math.max(1,Z(s).length);return(b?.bestIndividual.fitness??0)/g*100},[b,s]);return{mode:t,setMode:L,target:s,setTarget:a,populationSize:r,setPopulationSize:l,mutationRatePercent:o,setMutationRatePercent:c,crossoverRatePercent:d,setCrossoverRatePercent:p,maxGenerations:m,setMaxGenerations:x,selectionStrategy:h,setSelectionStrategy:v,speedMs:w,setSpeedMs:M,soundEnabled:S,toggleSound:le,state:b,status:j,topIndividuals:oe,convergence:ce,start:se,pause:ne,resume:ae,reset:re,randomTarget:ie}}const Ge=[{label:"Slow",value:120},{label:"Med",value:35},{label:"Fast",value:8}];function He(){const{mode:t,setMode:n,target:s,setTarget:a,populationSize:r,setPopulationSize:l,mutationRatePercent:o,setMutationRatePercent:c,crossoverRatePercent:d,setCrossoverRatePercent:p,maxGenerations:m,setMaxGenerations:x,selectionStrategy:h,setSelectionStrategy:v,speedMs:w,setSpeedMs:M,soundEnabled:S,toggleSound:A,state:b,status:N,topIndividuals:j,convergence:y,start:k,pause:E,resume:F,reset:O,randomTarget:G}=Fe(),P=N==="running",f=t==="guided",L=b?.bestIndividual,C=b?.averageFitness??0,z=Pe({status:N,generation:b?.generation??0,bestFitness:L?.fitness??0,targetLength:s.length,convergence:y});return e.jsx("div",{className:"flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top,rgba(16,185,129,0.12),transparent_34%),linear-gradient(180deg,rgba(15,23,42,0),rgba(6,78,59,0.16))] p-4 md:p-6",children:e.jsxs("div",{className:"mx-auto max-w-6xl space-y-4",children:[e.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-emerald-700/30 bg-[radial-gradient(circle_at_top_left,rgba(34,197,94,0.18),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.36))] p-4 shadow-2xl shadow-black/30 backdrop-blur-sm md:p-5",children:[e.jsx("div",{className:"pointer-events-none absolute right-6 top-4 text-7xl opacity-10",children:"🧬"}),e.jsx("h2",{className:"text-lg md:text-xl font-bold text-white",children:"Evolution Lab — Genetic Algorithm"}),e.jsx("p",{className:"text-xs text-emerald-100/65 mt-1",children:"Evolve a population of digital people toward a target phrase using selection, crossover, and mutation."}),e.jsx("div",{className:"mt-3 rounded-xl bg-emerald-500/10 ring-1 ring-emerald-500/20 px-3 py-2",children:e.jsx("p",{className:"text-[11px] text-emerald-50/80 leading-relaxed",children:"Each generation is a lab cycle: evaluate every person → select stronger parents → combine DNA → mutate a few genes → keep the elite survivor."})}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 md:max-w-sm",children:[e.jsx("button",{onClick:()=>n("guided"),className:`rounded-lg px-3 py-2 text-xs font-semibold ring-1 transition-all ${f?"bg-amber-500/20 text-amber-300 ring-amber-500/40":"bg-slate-800/60 text-slate-400 ring-slate-700/40 hover:bg-slate-700/60"}`,children:"Guided Mode"}),e.jsx("button",{onClick:()=>n("free-play"),className:`rounded-lg px-3 py-2 text-xs font-semibold ring-1 transition-all ${f?"bg-slate-800/60 text-slate-400 ring-slate-700/40 hover:bg-slate-700/60":"bg-cyan-500/20 text-cyan-300 ring-cyan-500/40"}`,children:"Free-play Mode"})]}),f&&e.jsx("p",{className:"mt-2 text-[10px] text-amber-300/80",children:"Guided mode uses recommended settings (HELLO WORLD, pop 300, mutation 3%, crossover 75%) for stable learning."}),f&&e.jsxs("div",{className:"mt-3 rounded-xl border border-amber-500/20 bg-amber-500/5 p-3",children:[e.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-300",children:"Guided Walkthrough"}),e.jsx("p",{className:"mt-1 text-xs text-slate-300 leading-relaxed",children:z.main}),e.jsx("ul",{className:"mt-2 space-y-1 text-[11px] text-slate-400 list-disc pl-4",children:z.points.map(u=>e.jsx("li",{children:u},u))})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Target String"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("input",{value:s,onChange:u=>a(u.target.value),placeholder:"HELLO WORLD",disabled:f,className:"flex-1 rounded-lg bg-slate-950/70 px-3 py-2 text-sm text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-cyan-500/50"}),e.jsx("button",{onClick:G,disabled:f,className:"rounded-lg bg-slate-800/70 px-3 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:e.jsx(ue,{size:14})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Population Size"}),e.jsx("input",{type:"number",min:1,max:2e3,value:r,disabled:f,onChange:u=>l(Number(u.target.value)||1),className:"mt-1 w-full rounded-lg bg-slate-950/70 px-3 py-2 text-sm text-slate-200 ring-1 ring-slate-700/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Max Generations"}),e.jsx("input",{type:"number",min:1,max:2e4,value:m,disabled:f,onChange:u=>x(Number(u.target.value)||1),className:"mt-1 w-full rounded-lg bg-slate-950/70 px-3 py-2 text-sm text-slate-200 ring-1 ring-slate-700/50"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-slate-400 mb-1",children:[e.jsx("span",{children:"Mutation Rate"}),e.jsxs("span",{children:[o,"%"]})]}),e.jsx("input",{type:"range",min:0,max:100,value:o,disabled:f,onChange:u=>c(Number(u.target.value)),className:"w-full accent-rose-500"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-slate-400 mb-1",children:[e.jsx("span",{children:"Crossover Rate"}),e.jsxs("span",{children:[d,"%"]})]}),e.jsx("input",{type:"range",min:0,max:100,value:d,disabled:f,onChange:u=>p(Number(u.target.value)),className:"w-full accent-sky-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Selection Strategy"}),e.jsx("div",{className:"mt-1 grid grid-cols-2 gap-2",children:["roulette","tournament"].map(u=>e.jsx("button",{disabled:f,onClick:()=>v(u),className:`rounded-lg px-3 py-2 text-xs font-medium ring-1 transition-all ${h===u?"bg-emerald-500/20 text-emerald-300 ring-emerald-500/40":"bg-slate-800/60 text-slate-400 ring-slate-700/40 hover:bg-slate-700/60"}`,children:u==="roulette"?"Roulette Wheel":"Tournament"},u))})]})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:k,className:"inline-flex items-center gap-1.5 rounded-lg bg-cyan-500/20 px-3 py-2 text-xs font-semibold text-cyan-300 ring-1 ring-cyan-500/40 hover:bg-cyan-500/30",children:[e.jsx(B,{size:14})," Start"]}),e.jsxs("button",{onClick:P?E:F,disabled:N==="idle"||N==="finished",className:"inline-flex items-center gap-1.5 rounded-lg bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70 disabled:opacity-40",children:[P?e.jsx(xe,{size:14}):e.jsx(B,{size:14}),P?"Pause":"Resume"]}),e.jsxs("button",{onClick:O,className:"inline-flex items-center gap-1.5 rounded-lg bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[e.jsx(me,{size:14})," Reset"]}),e.jsxs("button",{onClick:()=>A(!S),className:`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-semibold ring-1 ${S?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[S?e.jsx(ge,{size:14}):e.jsx(he,{size:14}),S?"Sound On":"Sound Off"]}),e.jsxs("div",{className:"ml-auto inline-flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-slate-500",children:"Speed"}),Ge.map(u=>e.jsx("button",{onClick:()=>M(u.value),className:`rounded px-2 py-1 text-[10px] font-medium ${w===u.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/60 text-slate-400 ring-1 ring-slate-700/40"}`,children:u.label},u.value))]})]})]}),e.jsx(ve,{population:j,target:s.toUpperCase(),generation:b?.generation??0,convergence:y,status:N}),e.jsxs("section",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Statistics"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsx(I,{label:"Generation",value:b?.generation??0}),e.jsx(I,{label:"Best Fitness",value:`${L?.fitness??0} / ${s.length}`}),e.jsx(I,{label:"Avg Fitness",value:C.toFixed(2)}),e.jsx(I,{label:"Convergence",value:`${y.toFixed(1)}%`}),e.jsx(I,{label:"Mutation",value:`${o}%`}),e.jsx(I,{label:"Population",value:r})]}),e.jsx("p",{className:"mt-3 text-[11px] text-slate-400",children:b?.message??"Ready to evolve."})]}),e.jsx("div",{className:"lg:col-span-2",children:e.jsx(fe,{target:s.toUpperCase(),bestGenes:L?.genes??""})})]}),e.jsxs("section",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsx(pe,{best:b?.bestFitnessHistory??[],avg:b?.averageFitnessHistory??[],targetLength:s.length})}),e.jsx(be,{population:j,target:s.toUpperCase()})]})]})})}function I({label:t,value:n}){return e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2.5 py-2 ring-1 ring-slate-700/40",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:t}),e.jsx("div",{className:"text-sm font-mono text-slate-100",children:n})]})}function Pe({status:t,generation:n,bestFitness:s,targetLength:a,convergence:r}){if(t==="idle")return{main:"Start the simulator to create the initial random population. Every individual has the same length as the target string.",points:["Fitness = number of correct characters in correct positions.","Roulette selection gives fitter strings higher chance to reproduce.","Elitism keeps the best individual every generation."]};if(t==="paused")return{main:"Simulation is paused. Compare the best and average fitness lines before continuing.",points:[`Current convergence is ${r.toFixed(1)}%.`,"If average fitness is catching best fitness, population is stabilizing.","Resume to observe further crossover + mutation effects."]};if(t==="finished"){const l=a>0&&s>=a;return{main:l?`Solved in ${n} generations. The best individual now exactly matches the target.`:`Reached max generations at ${r.toFixed(1)}% convergence without full match.`,points:l?["Notice how best fitness rose in steps when useful mutations appeared.","Average fitness should trend upward as good genes spread.","Try Free-play to test lower mutation or alternate selection strategy."]:["Try increasing max generations or population size.","Slightly higher mutation can help escape local plateaus.","Free-play mode lets you experiment with these trade-offs."]}}return n<10?{main:"Early phase: selection pressure is starting to amplify better character matches.",points:["Watch the best-fitness line jump when a useful mutation appears.","Average fitness may rise slowly at first—this is normal.","Crossover recombines partial matches from different parents."]}:r<60?{main:"Middle phase: the population is accumulating correct characters in more positions.",points:["Best fitness reflects the strongest candidate so far.","Average fitness indicates overall population quality.","Gap between best and average shows remaining diversity."]}:{main:"Late phase: convergence is high; progress often comes from rare beneficial mutations.",points:["Near the end, single-character improvements become more important.","If progress stalls, Free-play can help you tune mutation and generation budget.","Use Gene Comparison to see exactly which positions remain incorrect."]}}export{He as default}; +import{j as e,r as i}from"./index-DBkLeWDs.js";import{g as de}from"./audioContext-NbgqvQGz.js";import{S as ue}from"./shuffle-Dlr-c52A.js";import{P as B}from"./play-mcIZClKO.js";import{P as xe}from"./pause-CG1snUW9.js";import{R as me}from"./rotate-ccw-7GTUOPy4.js";import{V as ge,a as he}from"./volume-x-BSx9gxSg.js";function U(t,n,s,a){return t.length===0?"":t.length===1?`0,${s}`:t.map((r,l)=>{const o=l/(t.length-1)*n,c=s-Math.max(0,r)/Math.max(1,a)*s;return`${o},${c}`}).join(" ")}function pe({best:t,avg:n,targetLength:s}){const l=Math.max(s,...t,...n,1);return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-300",children:"Fitness Monitor"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-500",children:"Lab readout for best and average population health"})]}),e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("svg",{viewBox:"0 0 640 220",className:"w-full min-w-[560px] h-56 rounded-xl bg-slate-950/80 ring-1 ring-slate-700/50",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"fitnessGlow",x1:"0",x2:"1",y1:"0",y2:"0",children:[e.jsx("stop",{offset:"0%",stopColor:"rgb(244 63 94)"}),e.jsx("stop",{offset:"100%",stopColor:"rgb(52 211 153)"})]})}),e.jsx("line",{x1:"0",y1:220,x2:640,y2:220,stroke:"rgb(71 85 105 / 0.7)",strokeWidth:"1"}),e.jsx("line",{x1:"0",y1:"0",x2:"0",y2:220,stroke:"rgb(71 85 105 / 0.7)",strokeWidth:"1"}),s>0&&e.jsx("line",{x1:"0",y1:220-s/l*220,x2:640,y2:220-s/l*220,stroke:"rgb(74 222 128 / 0.35)",strokeDasharray:"4 4",strokeWidth:"1"}),e.jsx("polyline",{fill:"none",stroke:"url(#fitnessGlow)",strokeWidth:"3",points:U(t,640,220,l)}),e.jsx("polyline",{fill:"none",stroke:"rgb(56 189 248)",strokeWidth:"2",points:U(n,640,220,l)})]})}),e.jsxs("div",{className:"mt-2 flex items-center gap-4 text-[10px] text-slate-400",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-rose-500"})," Best Fitness"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-sky-400"})," Average Fitness"]})]})]})}function be({population:t,target:n}){return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-300",children:"Candidate Profiles"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-500",children:"The strongest survivors in this generation"})]}),e.jsxs("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-semibold text-emerald-300 ring-1 ring-emerald-500/25",children:["Top ",t.length||0]})]}),e.jsx("div",{className:"space-y-1.5 max-h-72 overflow-auto pr-1",children:t.map((s,a)=>e.jsxs("div",{className:`rounded-xl px-3 py-2 ring-1 transition-all ${a===0?"bg-emerald-500/10 ring-emerald-500/30 shadow-lg shadow-emerald-950/20":"bg-slate-800/50 ring-slate-700/40"}`,children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-500",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${a===0?"bg-emerald-400":"bg-slate-600"}`}),"Subject #",a+1]}),e.jsxs("span",{className:"font-mono",children:[s.fitness," / ",n.length]})]}),e.jsx("div",{className:"mt-1 font-mono text-xs text-slate-200 tracking-wide break-all",children:s.genes}),e.jsx("div",{className:"mt-2 h-1 overflow-hidden rounded-full bg-slate-950/70",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-emerald-400 to-cyan-300",style:{width:`${s.fitness/Math.max(1,n.length)*100}%`}})})]},`${s.genes}-${a}`))})]})}function fe({target:t,bestGenes:n}){return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-300",children:"DNA Match Board"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-500",children:"Green cells already match the target phrase"})]}),e.jsxs("div",{className:"space-y-3 font-mono text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-slate-500 mb-1",children:"Target"}),e.jsx("div",{className:"rounded-xl bg-slate-950/70 ring-1 ring-slate-700/40 px-3 py-2 break-all tracking-wide text-slate-200",children:t||"(empty)"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-slate-500 mb-1",children:"Best Individual"}),e.jsxs("div",{className:"rounded-xl bg-slate-950/70 ring-1 ring-slate-700/40 px-3 py-2 break-all tracking-wide",children:[(n||"").split("").map((s,a)=>{const r=t[a]===s;return e.jsx("span",{className:`mx-0.5 inline-flex min-w-5 justify-center rounded px-1 py-0.5 ${r?"bg-emerald-500/20 text-emerald-200 ring-1 ring-emerald-500/30":"bg-slate-800/60 text-slate-300 ring-1 ring-slate-700/40"}`,children:s},`${s}-${a}`)}),!n&&e.jsx("span",{className:"text-slate-500",children:"Start the simulator to see candidate DNA."})]})]})]})]})}const q=["#f8c9a5","#d99b6c","#8d5524","#f1b982","#c68642"],K=["#22c55e","#38bdf8","#a78bfa","#fb7185","#facc15","#2dd4bf"];function ve({population:t,target:n,generation:s,convergence:a,status:r}){const l=t.length>0?t.slice(0,12):Array.from({length:12},(c,d)=>({genes:"????",fitness:Math.max(0,12-d)})),o=Math.max(1,n.length);return e.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-emerald-700/30 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.18),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.42))] p-4 shadow-2xl shadow-black/30 md:p-5",children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-28 bg-gradient-to-t from-emerald-950/50 to-transparent"}),e.jsxs("div",{className:"relative z-10 flex flex-col gap-3 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-white md:text-lg",children:"Population Habitat"}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-emerald-100/65",children:"Each person is a candidate solution. Brighter badges mean more matching genes survived selection."})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsx(_,{label:"Gen",value:s}),e.jsx(_,{label:"Fit",value:`${a.toFixed(0)}%`}),e.jsx(_,{label:"State",value:r})]})]}),e.jsxs("div",{className:"relative z-10 mt-5 rounded-2xl border border-emerald-950/50 bg-emerald-950/25 p-4 shadow-inner",children:[e.jsx("div",{className:"absolute inset-x-6 bottom-3 h-10 rounded-[50%] bg-black/20 blur-xl"}),e.jsx("div",{className:"relative grid grid-cols-3 gap-x-3 gap-y-5 sm:grid-cols-4 lg:grid-cols-6",children:l.map((c,d)=>{const p=c.fitness/o,m=d===0&&t.length>0;return e.jsx(je,{rank:d+1,genes:c.genes,fitnessRatio:p,isElite:m,skin:q[d%q.length],shirt:K[d%K.length]},`${c.genes}-${d}`)})})]})]})}function je({rank:t,genes:n,fitnessRatio:s,isElite:a,skin:r,shirt:l}){const o=Math.max(0,Math.min(1,s)),c=a?"shadow-[0_0_26px_rgba(52,211,153,0.45)]":"",d=.4+o*.6;return e.jsxs("div",{className:`group relative flex flex-col items-center rounded-2xl border px-2 py-3 transition-all hover:-translate-y-1 ${a?"border-emerald-300/50 bg-emerald-400/10":"border-emerald-900/30 bg-slate-950/25"} ${c}`,children:[e.jsxs("div",{className:"absolute right-1.5 top-1.5 rounded-full bg-slate-950/70 px-1.5 py-0.5 text-[9px] font-bold text-slate-400 ring-1 ring-slate-700/50",children:["#",t]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsxs("div",{className:"h-9 w-9 rounded-full border border-black/15 shadow-inner",style:{backgroundColor:r,opacity:d},children:[e.jsxs("div",{className:"mx-auto mt-3 flex w-4 justify-between",children:[e.jsx("span",{className:"h-1 w-1 rounded-full bg-slate-950/70"}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-slate-950/70"})]}),e.jsx("div",{className:"mx-auto mt-1 h-1 w-3 rounded-full bg-slate-950/40"})]}),e.jsx("div",{className:"mx-auto -mt-1 h-10 w-12 rounded-t-2xl rounded-b-lg border border-black/15 shadow-lg",style:{backgroundColor:l,opacity:d}})]}),e.jsx("div",{className:"mt-2 h-1.5 w-full overflow-hidden rounded-full bg-slate-950/70",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-emerald-400 to-cyan-300 transition-all",style:{width:`${o*100}%`}})}),e.jsx("div",{className:"mt-1 max-w-full truncate font-mono text-[9px] text-emerald-100/70",children:n||"waiting"})]})}function _({label:t,value:n}){return e.jsxs("div",{className:"rounded-xl bg-slate-950/45 px-3 py-2 ring-1 ring-emerald-500/20",children:[e.jsx("div",{className:"text-[9px] uppercase tracking-wider text-emerald-100/45",children:t}),e.jsx("div",{className:"mt-0.5 text-xs font-bold capitalize text-emerald-100",children:n})]})}const J="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,!?-",$={target:"HELLO WORLD",populationSize:300,mutationRate:.03,crossoverRate:.75,maxGenerations:500,selectionStrategy:"roulette"},X=["HELLO WORLD","GENETIC ALGORITHM","EVOLUTION IN ACTION","SURVIVAL OF THE FITTEST","OPTIMIZE THE GENES"];function Q(t){let n=t>>>0;const s=()=>(n=1664525*n+1013904223>>>0,n/4294967296);return{next:s,int:(r,l)=>l<=r?r:Math.floor(s()*(l-r+1))+r}}function Ne(t,n,s){let a="";for(let r=0;r({...s,fitness:we(s.genes,n)}))}function ee(t){return t.length===0?0:t.reduce((s,a)=>s+a.fitness,0)/t.length}function Se(t,n){const s=t.reduce((l,o)=>l+o.fitness,0);if(s<=0)return t[n.int(0,t.length-1)];const a=n.next()*s;let r=0;for(let l=0;l=a)return t[l];return t[t.length-1]}function ke(t,n,s){let a=t[s.int(0,t.length-1)];const r=Math.max(1,n);for(let l=1;la.fitness&&(a=o)}return a}function Y(t,n,s,a){return n==="tournament"?ke(t,s,a):Se(t,a)}function Ce(t,n,s,a){const r=t.genes.length;if(r<=1||a.next()>s)return t.genes;const l=a.int(1,r-1);return t.genes.slice(0,l)+n.genes.slice(l)}function Te(t,n,s,a){if(t.length===0)return t;let r="";for(let l=0;ls.fitness-n.fitness)}function te(t,n,s,a){return n===0?"Target is empty. Enter a target to evolve.":t>=n?`Solution found in ${s} generations`:s>=a?"Max generations reached without full match":"Evolving..."}function Re(t,n){const s=t.target.length,a=Q(n),r=ye(t.populationSize,s,t.allowedChars,a),l=V(D(r,t.target)),o=l[0]??{genes:"",fitness:0},c=ee(l),d=s===0||o.fitness>=s;return{generation:0,population:l,bestIndividual:W(o),averageFitness:c,bestFitnessHistory:[o.fitness],averageFitnessHistory:[c],rngSeed:n,done:d,message:te(o.fitness,s,0,t.maxGenerations)}}function Me(t,n){if(n.done)return n;const s=t.target.length,a=Q(n.rngSeed+n.generation+1),r=V(D(n.population,t.target)),l=r[0]?W(r[0]):{genes:"",fitness:0},o=[l];for(;o.length=s||d>=t.maxGenerations;return{generation:d,population:c,bestIndividual:W(p),averageFitness:m,bestFitnessHistory:[...n.bestFitnessHistory,p.fitness],averageFitnessHistory:[...n.averageFitnessHistory,m],rngSeed:n.rngSeed,done:x,message:te(p.fitness,s,d,t.maxGenerations)}}const H=[220,261.63,293.66,329.63,392,440,523.25,659.25,783.99];function Ee(){const t=i.useRef(!0),n=i.useCallback(()=>de(),[]),s=i.useCallback(c=>{t.current=c},[]),a=i.useCallback((c,d,p,m=.05)=>{if(!t.current)return;const x=n();if(!x)return;const h=x.createOscillator(),v=x.createGain();h.type=d,h.frequency.setValueAtTime(c,x.currentTime),v.gain.setValueAtTime(m,x.currentTime),v.gain.exponentialRampToValueAtTime(.001,x.currentTime+p),h.connect(v),v.connect(x.destination),h.start(x.currentTime),h.stop(x.currentTime+p)},[n]),r=i.useCallback((c,d)=>{const p=d>0?c/d:0,m=Math.max(0,Math.min(H.length-1,Math.floor(p*(H.length-1))));a(H[m],"sine",.06,.03)},[a]),l=i.useCallback(()=>{a(523.25,"triangle",.08,.05)},[a]),o=i.useCallback(()=>{if(!t.current)return;const c=n();c&&[523.25,659.25,783.99].forEach((d,p)=>{const m=c.createOscillator(),x=c.createGain(),h=c.currentTime+p*.1;m.type="sine",m.frequency.setValueAtTime(d,h),x.gain.setValueAtTime(.06,h),x.gain.exponentialRampToValueAtTime(.001,h+.16),m.connect(x),x.connect(c.destination),m.start(h),m.stop(h+.16)})},[n]);return{setEnabled:s,playGenerationTick:r,playImprove:l,playComplete:o}}function Z(t){const n=t.toUpperCase();let s="";for(let a=0;a{n(g),g==="guided"&&(a("HELLO WORLD"),l(300),c(3),p(75),x(500),v("roulette"),M(35))},[]);i.useEffect(()=>{O(S)},[S,O]);const C=i.useCallback(()=>{k.current&&(clearTimeout(k.current),k.current=null)},[]),z=i.useCallback(()=>({target:Z(s),populationSize:Math.max(1,r),mutationRate:Math.min(1,Math.max(0,o/100)),crossoverRate:Math.min(1,Math.max(0,d/100)),maxGenerations:Math.max(1,m),selectionStrategy:h,tournamentSize:5,allowedChars:J}),[s,r,o,d,m,h]),u=i.useCallback(()=>{N(g=>{if(!g||!E.current)return g;const T=Me(E.current,g),R=E.current.target.length;return G(T.bestIndividual.fitness,R),T.bestIndividual.fitness>F.current&&P(),F.current=T.bestIndividual.fitness,T.done&&(f(),y("finished")),T})},[G,P,f]);i.useEffect(()=>{if(j!=="running"){C();return}const g=()=>{u(),k.current=setTimeout(g,w)};return k.current=setTimeout(g,w),C},[j,w,u,C]);const se=i.useCallback(()=>{const g=z();E.current=g;const R=Re(g,1337);F.current=R.bestIndividual.fitness,N(R),R.bestIndividual.fitness>0&&G(R.bestIndividual.fitness,g.target.length),y(R.done?"finished":"running")},[z,G]),ne=i.useCallback(()=>{j==="running"&&y("paused")},[j]),ae=i.useCallback(()=>{j==="paused"&&y("running")},[j]),re=i.useCallback(()=>{C(),N(null),y("idle"),F.current=0},[C]),le=i.useCallback(g=>{A(g)},[]),ie=i.useCallback(()=>{const g=Math.floor(Math.random()*X.length);a(X[g])},[]),oe=i.useMemo(()=>b?.population?b.population.slice(0,10):[],[b]),ce=i.useMemo(()=>{const g=Math.max(1,Z(s).length);return(b?.bestIndividual.fitness??0)/g*100},[b,s]);return{mode:t,setMode:L,target:s,setTarget:a,populationSize:r,setPopulationSize:l,mutationRatePercent:o,setMutationRatePercent:c,crossoverRatePercent:d,setCrossoverRatePercent:p,maxGenerations:m,setMaxGenerations:x,selectionStrategy:h,setSelectionStrategy:v,speedMs:w,setSpeedMs:M,soundEnabled:S,toggleSound:le,state:b,status:j,topIndividuals:oe,convergence:ce,start:se,pause:ne,resume:ae,reset:re,randomTarget:ie}}const Ge=[{label:"Slow",value:120},{label:"Med",value:35},{label:"Fast",value:8}];function He(){const{mode:t,setMode:n,target:s,setTarget:a,populationSize:r,setPopulationSize:l,mutationRatePercent:o,setMutationRatePercent:c,crossoverRatePercent:d,setCrossoverRatePercent:p,maxGenerations:m,setMaxGenerations:x,selectionStrategy:h,setSelectionStrategy:v,speedMs:w,setSpeedMs:M,soundEnabled:S,toggleSound:A,state:b,status:N,topIndividuals:j,convergence:y,start:k,pause:E,resume:F,reset:O,randomTarget:G}=Fe(),P=N==="running",f=t==="guided",L=b?.bestIndividual,C=b?.averageFitness??0,z=Pe({status:N,generation:b?.generation??0,bestFitness:L?.fitness??0,targetLength:s.length,convergence:y});return e.jsx("div",{className:"flex-1 overflow-y-auto bg-[radial-gradient(circle_at_top,rgba(16,185,129,0.12),transparent_34%),linear-gradient(180deg,rgba(15,23,42,0),rgba(6,78,59,0.16))] p-4 md:p-6",children:e.jsxs("div",{className:"mx-auto max-w-6xl space-y-4",children:[e.jsxs("section",{className:"relative overflow-hidden rounded-2xl border border-emerald-700/30 bg-[radial-gradient(circle_at_top_left,rgba(34,197,94,0.18),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.36))] p-4 shadow-2xl shadow-black/30 backdrop-blur-sm md:p-5",children:[e.jsx("div",{className:"pointer-events-none absolute right-6 top-4 text-7xl opacity-10",children:"🧬"}),e.jsx("h2",{className:"text-lg md:text-xl font-bold text-white",children:"Evolution Lab — Genetic Algorithm"}),e.jsx("p",{className:"text-xs text-emerald-100/65 mt-1",children:"Evolve a population of digital people toward a target phrase using selection, crossover, and mutation."}),e.jsx("div",{className:"mt-3 rounded-xl bg-emerald-500/10 ring-1 ring-emerald-500/20 px-3 py-2",children:e.jsx("p",{className:"text-[11px] text-emerald-50/80 leading-relaxed",children:"Each generation is a lab cycle: evaluate every person → select stronger parents → combine DNA → mutate a few genes → keep the elite survivor."})}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 md:max-w-sm",children:[e.jsx("button",{onClick:()=>n("guided"),className:`rounded-lg px-3 py-2 text-xs font-semibold ring-1 transition-all ${f?"bg-amber-500/20 text-amber-300 ring-amber-500/40":"bg-slate-800/60 text-slate-400 ring-slate-700/40 hover:bg-slate-700/60"}`,children:"Guided Mode"}),e.jsx("button",{onClick:()=>n("free-play"),className:`rounded-lg px-3 py-2 text-xs font-semibold ring-1 transition-all ${f?"bg-slate-800/60 text-slate-400 ring-slate-700/40 hover:bg-slate-700/60":"bg-cyan-500/20 text-cyan-300 ring-cyan-500/40"}`,children:"Free-play Mode"})]}),f&&e.jsx("p",{className:"mt-2 text-[10px] text-amber-300/80",children:"Guided mode uses recommended settings (HELLO WORLD, pop 300, mutation 3%, crossover 75%) for stable learning."}),f&&e.jsxs("div",{className:"mt-3 rounded-xl border border-amber-500/20 bg-amber-500/5 p-3",children:[e.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-300",children:"Guided Walkthrough"}),e.jsx("p",{className:"mt-1 text-xs text-slate-300 leading-relaxed",children:z.main}),e.jsx("ul",{className:"mt-2 space-y-1 text-[11px] text-slate-400 list-disc pl-4",children:z.points.map(u=>e.jsx("li",{children:u},u))})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Target String"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("input",{value:s,onChange:u=>a(u.target.value),placeholder:"HELLO WORLD",disabled:f,className:"flex-1 rounded-lg bg-slate-950/70 px-3 py-2 text-sm text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-cyan-500/50"}),e.jsx("button",{onClick:G,disabled:f,className:"rounded-lg bg-slate-800/70 px-3 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:e.jsx(ue,{size:14})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Population Size"}),e.jsx("input",{type:"number",min:1,max:2e3,value:r,disabled:f,onChange:u=>l(Number(u.target.value)||1),className:"mt-1 w-full rounded-lg bg-slate-950/70 px-3 py-2 text-sm text-slate-200 ring-1 ring-slate-700/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Max Generations"}),e.jsx("input",{type:"number",min:1,max:2e4,value:m,disabled:f,onChange:u=>x(Number(u.target.value)||1),className:"mt-1 w-full rounded-lg bg-slate-950/70 px-3 py-2 text-sm text-slate-200 ring-1 ring-slate-700/50"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-slate-400 mb-1",children:[e.jsx("span",{children:"Mutation Rate"}),e.jsxs("span",{children:[o,"%"]})]}),e.jsx("input",{type:"range",min:0,max:100,value:o,disabled:f,onChange:u=>c(Number(u.target.value)),className:"w-full accent-rose-500"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-slate-400 mb-1",children:[e.jsx("span",{children:"Crossover Rate"}),e.jsxs("span",{children:[d,"%"]})]}),e.jsx("input",{type:"range",min:0,max:100,value:d,disabled:f,onChange:u=>p(Number(u.target.value)),className:"w-full accent-sky-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Selection Strategy"}),e.jsx("div",{className:"mt-1 grid grid-cols-2 gap-2",children:["roulette","tournament"].map(u=>e.jsx("button",{disabled:f,onClick:()=>v(u),className:`rounded-lg px-3 py-2 text-xs font-medium ring-1 transition-all ${h===u?"bg-emerald-500/20 text-emerald-300 ring-emerald-500/40":"bg-slate-800/60 text-slate-400 ring-slate-700/40 hover:bg-slate-700/60"}`,children:u==="roulette"?"Roulette Wheel":"Tournament"},u))})]})]})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:k,className:"inline-flex items-center gap-1.5 rounded-lg bg-cyan-500/20 px-3 py-2 text-xs font-semibold text-cyan-300 ring-1 ring-cyan-500/40 hover:bg-cyan-500/30",children:[e.jsx(B,{size:14})," Start"]}),e.jsxs("button",{onClick:P?E:F,disabled:N==="idle"||N==="finished",className:"inline-flex items-center gap-1.5 rounded-lg bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70 disabled:opacity-40",children:[P?e.jsx(xe,{size:14}):e.jsx(B,{size:14}),P?"Pause":"Resume"]}),e.jsxs("button",{onClick:O,className:"inline-flex items-center gap-1.5 rounded-lg bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[e.jsx(me,{size:14})," Reset"]}),e.jsxs("button",{onClick:()=>A(!S),className:`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-semibold ring-1 ${S?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[S?e.jsx(ge,{size:14}):e.jsx(he,{size:14}),S?"Sound On":"Sound Off"]}),e.jsxs("div",{className:"ml-auto inline-flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] text-slate-500",children:"Speed"}),Ge.map(u=>e.jsx("button",{onClick:()=>M(u.value),className:`rounded px-2 py-1 text-[10px] font-medium ${w===u.value?"bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/40":"bg-slate-800/60 text-slate-400 ring-1 ring-slate-700/40"}`,children:u.label},u.value))]})]})]}),e.jsx(ve,{population:j,target:s.toUpperCase(),generation:b?.generation??0,convergence:y,status:N}),e.jsxs("section",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Statistics"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[e.jsx(I,{label:"Generation",value:b?.generation??0}),e.jsx(I,{label:"Best Fitness",value:`${L?.fitness??0} / ${s.length}`}),e.jsx(I,{label:"Avg Fitness",value:C.toFixed(2)}),e.jsx(I,{label:"Convergence",value:`${y.toFixed(1)}%`}),e.jsx(I,{label:"Mutation",value:`${o}%`}),e.jsx(I,{label:"Population",value:r})]}),e.jsx("p",{className:"mt-3 text-[11px] text-slate-400",children:b?.message??"Ready to evolve."})]}),e.jsx("div",{className:"lg:col-span-2",children:e.jsx(fe,{target:s.toUpperCase(),bestGenes:L?.genes??""})})]}),e.jsxs("section",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsx(pe,{best:b?.bestFitnessHistory??[],avg:b?.averageFitnessHistory??[],targetLength:s.length})}),e.jsx(be,{population:j,target:s.toUpperCase()})]})]})})}function I({label:t,value:n}){return e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2.5 py-2 ring-1 ring-slate-700/40",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:t}),e.jsx("div",{className:"text-sm font-mono text-slate-100",children:n})]})}function Pe({status:t,generation:n,bestFitness:s,targetLength:a,convergence:r}){if(t==="idle")return{main:"Start the simulator to create the initial random population. Every individual has the same length as the target string.",points:["Fitness = number of correct characters in correct positions.","Roulette selection gives fitter strings higher chance to reproduce.","Elitism keeps the best individual every generation."]};if(t==="paused")return{main:"Simulation is paused. Compare the best and average fitness lines before continuing.",points:[`Current convergence is ${r.toFixed(1)}%.`,"If average fitness is catching best fitness, population is stabilizing.","Resume to observe further crossover + mutation effects."]};if(t==="finished"){const l=a>0&&s>=a;return{main:l?`Solved in ${n} generations. The best individual now exactly matches the target.`:`Reached max generations at ${r.toFixed(1)}% convergence without full match.`,points:l?["Notice how best fitness rose in steps when useful mutations appeared.","Average fitness should trend upward as good genes spread.","Try Free-play to test lower mutation or alternate selection strategy."]:["Try increasing max generations or population size.","Slightly higher mutation can help escape local plateaus.","Free-play mode lets you experiment with these trade-offs."]}}return n<10?{main:"Early phase: selection pressure is starting to amplify better character matches.",points:["Watch the best-fitness line jump when a useful mutation appears.","Average fitness may rise slowly at first—this is normal.","Crossover recombines partial matches from different parents."]}:r<60?{main:"Middle phase: the population is accumulating correct characters in more positions.",points:["Best fitness reflects the strongest candidate so far.","Average fitness indicates overall population quality.","Gap between best and average shows remaining diversity."]}:{main:"Late phase: convergence is high; progress often comes from rare beneficial mutations.",points:["Near the end, single-character improvements become more important.","If progress stalls, Free-play can help you tune mutation and generation budget.","Use Gene Comparison to see exactly which positions remain incorrect."]}}export{He as default}; diff --git a/docs/assets/FibonacciGamePage-CoiJID2A.js b/docs/assets/FibonacciGamePage-Bd8sKYsw.js similarity index 98% rename from docs/assets/FibonacciGamePage-CoiJID2A.js rename to docs/assets/FibonacciGamePage-Bd8sKYsw.js index b25a672..6e91470 100644 --- a/docs/assets/FibonacciGamePage-CoiJID2A.js +++ b/docs/assets/FibonacciGamePage-Bd8sKYsw.js @@ -1,4 +1,4 @@ -import{c as re,r as x,j as e}from"./index-eCXyAnHs.js";import{T as le}from"./trophy-DkUzH7jB.js";import{F as oe,L as ce}from"./lightbulb-B7pRWk3f.js";import{T as de}from"./timer-DSbfy6P3.js";import{R as xe}from"./rotate-ccw-B8GZP3d7.js";import{V as me,a as ue}from"./volume-x-CTbtCvt-.js";import{g as fe}from"./audioContext-NbgqvQGz.js";const he=[["path",{d:"M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5",key:"1fkcox"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5",key:"10m8kw"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],ge=re("lightbulb-off",he),pe=["right","up","left","down"],D={guided:{name:"Guided",description:"Learn step-by-step with hints and formula guidance."},challenge:{name:"Challenge",description:"Race against time! Pick the right block from multiple choices."},sandbox:{name:"Sandbox",description:"Explore freely with no scoring or time pressure."}},C={title:"Fibonacci Spiral Builder",subtitle:"Inspired by Leonardo Fibonacci",what:"Build a golden spiral by placing squares in the Fibonacci sequence. Each square's side length equals the sum of the two before it (1, 1, 2, 3, 5, 8, 13...). As you place them, a beautiful spiral emerges — the same pattern found in sunflowers, seashells, and galaxies.",skills:["Pattern Recognition","Mathematical Sequences","Spatial Reasoning","Golden Ratio Intuition"]};function W(t){if(t.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let s=1/0,a=1/0,o=-1/0,n=-1/0;for(const l of t)s=Math.min(s,l.x),a=Math.min(a,l.y),o=Math.max(o,l.x+l.size),n=Math.max(n,l.y+l.size);return{minX:s,minY:a,maxX:o,maxY:n}}function be(t,s,a){if(t.length===0)return{x:0,y:0,direction:"right"};if(t.length===1){const i=t[0];return{x:i.x+i.size,y:i.y,direction:"right"}}const o=W(t),n=pe[a%4];let l=0,d=0;switch(n){case"right":l=o.maxX,d=o.maxY-s;break;case"up":l=o.maxX-s,d=o.minY-s;break;case"left":l=o.minX-s,d=o.minY;break;case"down":l=o.minX,d=o.maxY;break}return{x:l,y:d,direction:n}}function je(t){const{x:s,y:a,size:o,direction:n}=t,l=o;switch(n){case"right":return`M ${s} ${a+o} A ${l} ${l} 0 0 1 ${s+o} ${a}`;case"up":return`M ${s+o} ${a+o} A ${l} ${l} 0 0 1 ${s} ${a}`;case"left":return`M ${s+o} ${a} A ${l} ${l} 0 0 1 ${s} ${a+o}`;case"down":return`M ${s} ${a} A ${l} ${l} 0 0 1 ${s+o} ${a+o}`;default:return""}}function B(){return[{id:0,size:1,x:0,y:0,direction:"right",fibIndex:0},{id:1,size:1,x:1,y:0,direction:"right",fibIndex:1}]}const I=["#818cf8","#a78bfa","#c084fc","#e879f9","#f472b6","#fb7185","#f97316","#facc15","#4ade80","#34d399","#2dd4bf","#22d3ee","#38bdf8","#60a5fa","#818cf8","#a78bfa"];function Ne({placedSquares:t,lastPlacedId:s}){const{viewBox:a,squares:o}=x.useMemo(()=>{if(t.length===0)return{viewBox:"-5 -5 10 10",squares:[]};const n=W(t),l=Math.max((n.maxX-n.minX)*.15,2);return{viewBox:`${n.minX-l} ${n.minY-l} ${n.maxX-n.minX+l*2} ${n.maxY-n.minY+l*2}`,squares:t}},[t]);return t.length===0?e.jsx("div",{className:"flex flex-1 w-full min-h-[200px] h-full items-center justify-center rounded-xl border border-slate-700/50 bg-slate-950/80 text-slate-500",children:"Place the first block to begin"}):e.jsx("div",{className:"flex-1 w-full min-h-[200px] rounded-xl border border-slate-700/50 bg-slate-950/80 p-2 shadow-2xl backdrop-blur-sm overflow-hidden",children:e.jsxs("svg",{viewBox:a,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[e.jsx("defs",{children:e.jsxs("filter",{id:"glow",children:[e.jsx("feGaussianBlur",{stdDeviation:"0.5",result:"coloredBlur"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{in:"coloredBlur"}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),o.map((n,l)=>{const d=I[l%I.length],i=n.id===s;return e.jsxs("g",{children:[e.jsx("rect",{x:n.x,y:n.y,width:n.size,height:n.size,fill:d,fillOpacity:.12,stroke:d,strokeWidth:Math.max(n.size*.02,.15),strokeOpacity:.6,rx:n.size*.02,className:i?"animate-pulse":"",filter:i?"url(#glow)":void 0}),e.jsx("text",{x:n.x+n.size/2,y:n.y+n.size/2,textAnchor:"middle",dominantBaseline:"central",fill:d,fillOpacity:.7,fontSize:Math.max(n.size*.35,.6),fontWeight:700,fontFamily:"ui-monospace, monospace",children:n.size})]},n.id)}),o.map((n,l)=>{const d=I[l%I.length],i=je(n);return e.jsx("path",{d:i,fill:"none",stroke:d,strokeWidth:Math.max(n.size*.03,.15),strokeOpacity:.8,strokeLinecap:"round"},`arc-${n.id}`)})]})})}function ye({blocks:t,mode:s,lastError:a,shakeBlockId:o,isComplete:n,onPlaceBlock:l}){const[d,i]=x.useState("");if(n)return e.jsxs("div",{className:"rounded-xl border border-emerald-500/30 bg-emerald-500/5 p-6 text-center",children:[e.jsx("div",{className:"text-3xl mb-2",children:"🎉"}),e.jsx("p",{className:"text-emerald-300 font-semibold text-sm",children:"Spiral Complete!"}),e.jsx("p",{className:"text-emerald-400/60 text-xs mt-1",children:"Beautiful golden spiral achieved"})]});const r=()=>{const c=parseInt(d,10);isNaN(c)||c<=0||(l(c),i(""))},u=s==="sandbox";return e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Place Next Block"}),u?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"number",inputMode:"numeric",value:d,onChange:c=>i(c.target.value),onKeyDown:c=>c.key==="Enter"&&r(),placeholder:"Enter next number...",className:"flex-1 rounded-lg bg-slate-800/60 px-3 py-3 text-center text-lg font-mono font-bold text-white placeholder-slate-500 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50"}),e.jsx("button",{onClick:r,disabled:!d.trim(),className:"rounded-lg bg-gradient-to-br from-indigo-500/20 to-violet-500/20 px-5 py-3 text-sm font-semibold text-indigo-200 ring-1 ring-indigo-500/30 transition-all hover:from-indigo-500/30 hover:to-violet-500/30 active:scale-95 disabled:opacity-40 disabled:cursor-not-allowed",children:"Place"})]}):e.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:t.map(c=>{const m=o===c.size;return e.jsx("button",{onClick:()=>l(c.size),className:` +import{c as re,r as x,j as e}from"./index-DBkLeWDs.js";import{T as le}from"./trophy-C1QWh03u.js";import{F as oe,L as ce}from"./lightbulb-xA5HFx8I.js";import{T as de}from"./timer-e0gb0oZa.js";import{R as xe}from"./rotate-ccw-7GTUOPy4.js";import{V as me,a as ue}from"./volume-x-BSx9gxSg.js";import{g as fe}from"./audioContext-NbgqvQGz.js";const he=[["path",{d:"M16.8 11.2c.8-.9 1.2-2 1.2-3.2a6 6 0 0 0-9.3-5",key:"1fkcox"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M6.3 6.3a4.67 4.67 0 0 0 1.2 5.2c.7.7 1.3 1.5 1.5 2.5",key:"10m8kw"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],ge=re("lightbulb-off",he),pe=["right","up","left","down"],D={guided:{name:"Guided",description:"Learn step-by-step with hints and formula guidance."},challenge:{name:"Challenge",description:"Race against time! Pick the right block from multiple choices."},sandbox:{name:"Sandbox",description:"Explore freely with no scoring or time pressure."}},C={title:"Fibonacci Spiral Builder",subtitle:"Inspired by Leonardo Fibonacci",what:"Build a golden spiral by placing squares in the Fibonacci sequence. Each square's side length equals the sum of the two before it (1, 1, 2, 3, 5, 8, 13...). As you place them, a beautiful spiral emerges — the same pattern found in sunflowers, seashells, and galaxies.",skills:["Pattern Recognition","Mathematical Sequences","Spatial Reasoning","Golden Ratio Intuition"]};function W(t){if(t.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let s=1/0,a=1/0,o=-1/0,n=-1/0;for(const l of t)s=Math.min(s,l.x),a=Math.min(a,l.y),o=Math.max(o,l.x+l.size),n=Math.max(n,l.y+l.size);return{minX:s,minY:a,maxX:o,maxY:n}}function be(t,s,a){if(t.length===0)return{x:0,y:0,direction:"right"};if(t.length===1){const i=t[0];return{x:i.x+i.size,y:i.y,direction:"right"}}const o=W(t),n=pe[a%4];let l=0,d=0;switch(n){case"right":l=o.maxX,d=o.maxY-s;break;case"up":l=o.maxX-s,d=o.minY-s;break;case"left":l=o.minX-s,d=o.minY;break;case"down":l=o.minX,d=o.maxY;break}return{x:l,y:d,direction:n}}function je(t){const{x:s,y:a,size:o,direction:n}=t,l=o;switch(n){case"right":return`M ${s} ${a+o} A ${l} ${l} 0 0 1 ${s+o} ${a}`;case"up":return`M ${s+o} ${a+o} A ${l} ${l} 0 0 1 ${s} ${a}`;case"left":return`M ${s+o} ${a} A ${l} ${l} 0 0 1 ${s} ${a+o}`;case"down":return`M ${s} ${a} A ${l} ${l} 0 0 1 ${s+o} ${a+o}`;default:return""}}function B(){return[{id:0,size:1,x:0,y:0,direction:"right",fibIndex:0},{id:1,size:1,x:1,y:0,direction:"right",fibIndex:1}]}const I=["#818cf8","#a78bfa","#c084fc","#e879f9","#f472b6","#fb7185","#f97316","#facc15","#4ade80","#34d399","#2dd4bf","#22d3ee","#38bdf8","#60a5fa","#818cf8","#a78bfa"];function Ne({placedSquares:t,lastPlacedId:s}){const{viewBox:a,squares:o}=x.useMemo(()=>{if(t.length===0)return{viewBox:"-5 -5 10 10",squares:[]};const n=W(t),l=Math.max((n.maxX-n.minX)*.15,2);return{viewBox:`${n.minX-l} ${n.minY-l} ${n.maxX-n.minX+l*2} ${n.maxY-n.minY+l*2}`,squares:t}},[t]);return t.length===0?e.jsx("div",{className:"flex flex-1 w-full min-h-[200px] h-full items-center justify-center rounded-xl border border-slate-700/50 bg-slate-950/80 text-slate-500",children:"Place the first block to begin"}):e.jsx("div",{className:"flex-1 w-full min-h-[200px] rounded-xl border border-slate-700/50 bg-slate-950/80 p-2 shadow-2xl backdrop-blur-sm overflow-hidden",children:e.jsxs("svg",{viewBox:a,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[e.jsx("defs",{children:e.jsxs("filter",{id:"glow",children:[e.jsx("feGaussianBlur",{stdDeviation:"0.5",result:"coloredBlur"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{in:"coloredBlur"}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),o.map((n,l)=>{const d=I[l%I.length],i=n.id===s;return e.jsxs("g",{children:[e.jsx("rect",{x:n.x,y:n.y,width:n.size,height:n.size,fill:d,fillOpacity:.12,stroke:d,strokeWidth:Math.max(n.size*.02,.15),strokeOpacity:.6,rx:n.size*.02,className:i?"animate-pulse":"",filter:i?"url(#glow)":void 0}),e.jsx("text",{x:n.x+n.size/2,y:n.y+n.size/2,textAnchor:"middle",dominantBaseline:"central",fill:d,fillOpacity:.7,fontSize:Math.max(n.size*.35,.6),fontWeight:700,fontFamily:"ui-monospace, monospace",children:n.size})]},n.id)}),o.map((n,l)=>{const d=I[l%I.length],i=je(n);return e.jsx("path",{d:i,fill:"none",stroke:d,strokeWidth:Math.max(n.size*.03,.15),strokeOpacity:.8,strokeLinecap:"round"},`arc-${n.id}`)})]})})}function ye({blocks:t,mode:s,lastError:a,shakeBlockId:o,isComplete:n,onPlaceBlock:l}){const[d,i]=x.useState("");if(n)return e.jsxs("div",{className:"rounded-xl border border-emerald-500/30 bg-emerald-500/5 p-6 text-center",children:[e.jsx("div",{className:"text-3xl mb-2",children:"🎉"}),e.jsx("p",{className:"text-emerald-300 font-semibold text-sm",children:"Spiral Complete!"}),e.jsx("p",{className:"text-emerald-400/60 text-xs mt-1",children:"Beautiful golden spiral achieved"})]});const r=()=>{const c=parseInt(d,10);isNaN(c)||c<=0||(l(c),i(""))},u=s==="sandbox";return e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Place Next Block"}),u?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"number",inputMode:"numeric",value:d,onChange:c=>i(c.target.value),onKeyDown:c=>c.key==="Enter"&&r(),placeholder:"Enter next number...",className:"flex-1 rounded-lg bg-slate-800/60 px-3 py-3 text-center text-lg font-mono font-bold text-white placeholder-slate-500 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50"}),e.jsx("button",{onClick:r,disabled:!d.trim(),className:"rounded-lg bg-gradient-to-br from-indigo-500/20 to-violet-500/20 px-5 py-3 text-sm font-semibold text-indigo-200 ring-1 ring-indigo-500/30 transition-all hover:from-indigo-500/30 hover:to-violet-500/30 active:scale-95 disabled:opacity-40 disabled:cursor-not-allowed",children:"Place"})]}):e.jsx("div",{className:"flex flex-wrap gap-2 justify-center",children:t.map(c=>{const m=o===c.size;return e.jsx("button",{onClick:()=>l(c.size),className:` relative flex items-center justify-center rounded-lg font-mono font-bold transition-all duration-200 active:scale-95 min-w-[56px] min-h-[56px] px-4 py-3 text-lg diff --git a/docs/assets/GitPage-2XUhCvHg.js b/docs/assets/GitPage-B_7vY4jd.js similarity index 99% rename from docs/assets/GitPage-2XUhCvHg.js rename to docs/assets/GitPage-B_7vY4jd.js index 5f75a9f..020a208 100644 --- a/docs/assets/GitPage-2XUhCvHg.js +++ b/docs/assets/GitPage-B_7vY4jd.js @@ -1,4 +1,4 @@ -import{r as w,j as i}from"./index-eCXyAnHs.js";import{g as je}from"./audioContext-NbgqvQGz.js";const V=["#818cf8","#34d399","#fb923c","#f472b6","#38bdf8","#a78bfa","#fbbf24","#2dd4bf","#f87171","#c084fc"],H=16,ne=64,ie=40,re=50,oe=50,Ce=28;function ve({state:e}){const{commits:t,branches:s,tags:o,head:n,detachedHead:r,commitOrder:c}=e,a=w.useMemo(()=>{if(c.length===0)return{nodes:[],edges:[],labels:[],width:400,height:300};const m=new Map;s.forEach((k,C)=>{m.set(k.name,V[C%V.length])});const l=new Map;let g=0;const u=[...c].reverse(),x=new Map;for(const k of u){const C=t[k];if(!C)continue;const v=C.branch;l.has(v)||l.set(v,g++),x.set(k,l.get(v))}const b=u.map((k,C)=>{const v=t[k],E=x.get(k)??0;return{id:k,x:re+E*ie,y:oe+C*ne,commit:v,color:m.get(v.branch)??V[0],col:E}}),p=new Map(b.map(k=>[k.id,k])),h=[];for(const k of b)for(let C=0;C0})}const y=r?n:s.find(k=>k.name===n)?.commitId,$=r?null:n,N=[];for(const k of s){const C=p.get(k.commitId);if(!C)continue;const v=k.name===$,E=N.filter(_=>_.commitId===k.commitId).length;N.push({text:k.name,commitId:k.commitId,x:C.x+H+12,y:C.y-6+E*22,color:m.get(k.name)??V[0],isHead:v,isTag:!1})}for(const k of o){const C=p.get(k.commitId);if(!C)continue;const v=N.filter(E=>E.commitId===k.commitId).length;N.push({text:k.name,commitId:k.commitId,x:C.x+H+12,y:C.y-6+v*22,color:"#fbbf24",isHead:!1,isTag:!0})}const O=g,P=Math.max(400,re*2+O*ie+200),M=Math.max(300,oe*2+u.length*ne);return{nodes:b,edges:h,labels:N,width:P,height:M,headCommitId:y}},[t,s,o,n,r,c]);return c.length===0?i.jsx("div",{className:"flex flex-1 items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-950/70 shadow-2xl shadow-black/30 backdrop-blur-sm",children:i.jsxs("div",{className:"text-center px-6",children:[i.jsx("div",{className:"mb-3 text-4xl opacity-40",children:i.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"mx-auto text-slate-500",children:[i.jsx("circle",{cx:"12",cy:"12",r:"3"}),i.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),i.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"21"})]})}),i.jsx("p",{className:"text-sm text-slate-400",children:"No commits yet"}),i.jsxs("p",{className:"text-xs text-slate-600 mt-1",children:["Run ",i.jsx("code",{className:"text-indigo-400",children:"git init"}),", then create and commit files"]})]})}):i.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden rounded-2xl border border-slate-700/50 bg-slate-950/70 shadow-2xl shadow-black/30 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-slate-700/50 bg-slate-900/80 px-4 py-2.5",children:[i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-indigo-400",children:[i.jsx("circle",{cx:"18",cy:"18",r:"3"}),i.jsx("circle",{cx:"6",cy:"6",r:"3"}),i.jsx("path",{d:"M6 21V9a9 9 0 0 0 9 9"})]}),i.jsx("span",{className:"text-xs font-semibold text-slate-300",children:"Commit Graph"}),i.jsx("span",{className:"rounded bg-indigo-500/10 px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-indigo-300 ring-1 ring-indigo-500/20",children:"live history"}),i.jsxs("span",{className:"ml-auto text-[10px] text-slate-500",children:[c.length," commit",c.length!==1?"s":""]})]}),i.jsx("div",{className:"flex-1 overflow-auto bg-[radial-gradient(circle_at_1px_1px,rgba(148,163,184,0.12)_1px,transparent_0)] bg-[length:24px_24px] p-2",children:i.jsxs("svg",{width:a.width,height:a.height,className:"block",style:{minWidth:a.width,minHeight:a.height},children:[a.edges.map((m,l)=>{if(m.from.x===m.to.x)return i.jsx("line",{x1:m.from.x,y1:m.from.y,x2:m.to.x,y2:m.to.y,stroke:m.color,strokeWidth:3,opacity:m.isMerge?.5:.7,strokeDasharray:m.isMerge?"6,3":void 0},`e${l}`);const g=(m.from.y+m.to.y)/2;return i.jsx("path",{d:`M${m.from.x},${m.from.y} C${m.from.x},${g} ${m.to.x},${g} ${m.to.x},${m.to.y}`,stroke:m.color,strokeWidth:3,fill:"none",opacity:m.isMerge?.5:.7,strokeDasharray:m.isMerge?"6,3":void 0},`e${l}`)}),a.nodes.map(m=>{const l=m.id===a.headCommitId;return i.jsxs("g",{children:[l&&i.jsxs("circle",{cx:m.x,cy:m.y,r:H+4,fill:"none",stroke:m.color,strokeWidth:2,opacity:.4,children:[i.jsx("animate",{attributeName:"r",values:`${H+3};${H+6};${H+3}`,dur:"2s",repeatCount:"indefinite"}),i.jsx("animate",{attributeName:"opacity",values:"0.4;0.15;0.4",dur:"2s",repeatCount:"indefinite"})]}),i.jsx("circle",{cx:m.x,cy:m.y,r:H,fill:l?m.color:`${m.color}33`,stroke:m.color,strokeWidth:l?3:2,filter:"drop-shadow(0 6px 8px rgba(0,0,0,0.35))",className:"transition-all duration-300"}),i.jsx("text",{x:m.x,y:m.y+1,textAnchor:"middle",dominantBaseline:"central",className:"select-none pointer-events-none",fill:l?"#0f172a":m.color,fontSize:8,fontWeight:700,fontFamily:"monospace",children:m.id.slice(0,4)}),i.jsx("text",{x:m.x,y:m.y+Ce,textAnchor:"middle",fill:"#94a3b8",fontSize:9,className:"select-none pointer-events-none",children:m.commit.message.length>22?m.commit.message.slice(0,20)+"...":m.commit.message})]},m.id)}),a.labels.map((m,l)=>i.jsxs("g",{children:[i.jsx("rect",{x:m.x-2,y:m.y-8,width:m.text.length*7.5+(m.isHead?40:8)+(m.isTag?10:0),height:18,rx:4,fill:`${m.color}22`,stroke:m.color,strokeWidth:1,opacity:.8}),m.isTag&&i.jsx("text",{x:m.x+4,y:m.y+4,fill:m.color,fontSize:8,children:"tag"}),m.isHead&&i.jsx("text",{x:m.x+4,y:m.y+4,fill:"#fbbf24",fontSize:9,fontWeight:700,fontFamily:"monospace",children:"HEAD→"}),i.jsx("text",{x:m.x+(m.isHead?44:m.isTag?18:4),y:m.y+4,fill:m.color,fontSize:10,fontWeight:600,fontFamily:"monospace",children:m.text})]},`l${l}`))]})})]})}const $e=w.memo(ve);function Ne({history:e,commandHistory:t,onExecute:s,disabled:o,promptBranch:n="main"}){const[r,c]=w.useState(""),[a,m]=w.useState(-1),l=w.useRef(null),g=w.useRef(null);w.useEffect(()=>{l.current?.scrollIntoView({behavior:"smooth"})},[e]),w.useEffect(()=>{o||g.current?.focus()},[o]);const u=w.useCallback(p=>{p.preventDefault(),!(!r.trim()||o)&&(s(r),c(""),m(-1))},[r,o,s]),x=w.useCallback(p=>{if(p.key==="ArrowUp"){if(p.preventDefault(),t.length===0)return;const h=a===-1?t.length-1:Math.max(0,a-1);m(h),c(t[h])}else if(p.key==="ArrowDown"){if(p.preventDefault(),a===-1)return;const h=a+1;h>=t.length?(m(-1),c("")):(m(h),c(t[h]))}},[t,a]),b=p=>{switch(p){case"input":return"text-emerald-400";case"error":return"text-red-400";case"info":return"text-indigo-400";case"hint":return"text-amber-400/90";default:return"text-slate-300"}};return i.jsxs("div",{className:"flex flex-col overflow-hidden rounded-2xl border border-slate-700/50 bg-slate-950/90 font-mono text-xs shadow-2xl shadow-black/30 backdrop-blur-sm",onClick:()=>g.current?.focus(),children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-slate-700/50 bg-slate-900/80 px-4 py-2.5",children:[i.jsxs("div",{className:"flex gap-1.5",children:[i.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-red-500/70"}),i.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-yellow-500/70"}),i.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-green-500/70"})]}),i.jsx("span",{className:"ml-2 text-[10px] font-semibold text-slate-400",children:"Git Terminal"}),i.jsx("span",{className:"ml-auto rounded bg-slate-950/80 px-2 py-0.5 text-[9px] text-slate-500 ring-1 ring-slate-800",children:"~/visual-repo"})]}),i.jsxs("div",{className:"min-h-[240px] flex-1 space-y-0.5 overflow-y-auto bg-[linear-gradient(rgba(148,163,184,0.03)_1px,transparent_1px)] bg-[length:100%_22px] p-3",children:[e.map((p,h)=>i.jsx("div",{className:`whitespace-pre-wrap leading-relaxed ${b(p.type)}`,children:p.text},h)),i.jsx("div",{ref:l})]}),i.jsxs("form",{onSubmit:u,className:"flex items-center gap-2 border-t border-slate-800/60 bg-slate-900/70 px-3 py-2",children:[i.jsx("span",{className:"select-none text-sky-400",children:"visual-repo"}),i.jsxs("span",{className:"select-none text-slate-600",children:["git:(",n,")"]}),i.jsx("span",{className:"select-none font-bold text-emerald-500",children:"$"}),i.jsx("input",{ref:g,type:"text",value:r,onChange:p=>c(p.target.value),onKeyDown:x,disabled:o,placeholder:o?"Demo running...":"Type a git command...",className:"flex-1 bg-transparent text-slate-200 placeholder-slate-600 outline-none caret-emerald-400",autoComplete:"off",spellCheck:!1})]})]})}const De=w.memo(Ne);function Se({state:e}){const{workingDirectory:t,stagingArea:s,commits:o,head:n,detachedHead:r,branches:c}=e,a=r?n:c.find(h=>h.name===n)?.commitId??null,l=(a?o[a]:null)?.files??{},g=Object.keys(t),u=Object.keys(s),x=h=>h in s?"staged":h in l?t[h]!==l[h]?"modified":"clean":"untracked",b=h=>{switch(h){case"staged":return"text-emerald-400 bg-emerald-500/10";case"modified":return"text-amber-400 bg-amber-500/10";case"untracked":return"text-red-400 bg-red-500/10";default:return"text-slate-500 bg-slate-500/10"}},p=h=>{switch(h){case"staged":return"S";case"modified":return"M";case"untracked":return"U";default:return"✓"}};return i.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[i.jsxs("div",{className:"rounded-2xl border border-amber-500/20 bg-slate-950/70 p-3 shadow-xl shadow-black/20 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-amber-500/10 text-amber-300 ring-1 ring-amber-500/20",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M3 7h5l2 3h11v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"}),i.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h4l2 3h5"})]})}),i.jsx("span",{className:"text-[10px] font-semibold text-slate-300 uppercase tracking-wider",children:"Working Dir"}),i.jsx("span",{className:"ml-auto text-[10px] text-slate-600",children:g.length})]}),i.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:g.length===0?i.jsx("p",{className:"text-[10px] text-slate-600 italic",children:"empty"}):g.map(h=>{const y=x(h);return i.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-slate-900/50 px-1.5 py-1 ring-1 ring-slate-800/50",children:[i.jsx("span",{className:`inline-flex h-4 w-4 items-center justify-center rounded text-[8px] font-bold ${b(y)}`,children:p(y)}),i.jsx("span",{className:"text-[10px] text-slate-400 truncate",children:h})]},h)})})]}),i.jsxs("div",{className:"rounded-2xl border border-emerald-500/20 bg-slate-950/70 p-3 shadow-xl shadow-black/20 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-emerald-500/10 text-emerald-300 ring-1 ring-emerald-500/20",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M12 5v14"}),i.jsx("path",{d:"M5 12h14"})]})}),i.jsx("span",{className:"text-[10px] font-semibold text-slate-300 uppercase tracking-wider",children:"Staging"}),i.jsx("span",{className:"ml-auto text-[10px] text-slate-600",children:u.length})]}),i.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:u.length===0?i.jsx("p",{className:"text-[10px] text-slate-600 italic",children:"empty"}):u.map(h=>i.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-slate-900/50 px-1.5 py-1 ring-1 ring-slate-800/50",children:[i.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded text-[8px] font-bold text-emerald-400 bg-emerald-500/10",children:"+"}),i.jsx("span",{className:"text-[10px] text-slate-400 truncate",children:h})]},h))})]}),i.jsxs("div",{className:"rounded-2xl border border-indigo-500/20 bg-slate-950/70 p-3 shadow-xl shadow-black/20 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-indigo-500/10 text-indigo-300 ring-1 ring-indigo-500/20",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),i.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),i.jsx("path",{d:"M12 22V12"})]})}),i.jsx("span",{className:"text-[10px] font-semibold text-slate-300 uppercase tracking-wider",children:"Repository"}),i.jsx("span",{className:"ml-auto text-[10px] text-slate-600",children:Object.keys(l).length})]}),i.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:Object.keys(l).length===0?i.jsx("p",{className:"text-[10px] text-slate-600 italic",children:"no commits"}):Object.keys(l).map(h=>i.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-slate-900/50 px-1.5 py-1 ring-1 ring-slate-800/50",children:[i.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded text-[8px] font-bold text-indigo-400 bg-indigo-500/10",children:"✓"}),i.jsx("span",{className:"text-[10px] text-slate-400 truncate",children:h})]},h))})]})]})}const Ie=w.memo(Se),Ae=[{title:"Setup",commands:[{cmd:"git init",desc:"Initialize a new repository"},{cmd:"git clone ",desc:"Clone a remote repository"}]},{title:"File Ops",commands:[{cmd:"touch [content]",desc:"Create a new file"},{cmd:"edit ",desc:"Modify a file"},{cmd:"cat ",desc:"View file content"},{cmd:"mv ",desc:"Move/rename a file"},{cmd:"rm ",desc:"Delete a file"},{cmd:"ls",desc:"List files"}]},{title:"Staging & Committing",commands:[{cmd:"git add ",desc:"Stage changes"},{cmd:'git commit -m "msg"',desc:"Create a commit"},{cmd:'git commit -am "msg"',desc:"Stage tracked & commit"},{cmd:"git status",desc:"Show status"},{cmd:"git diff",desc:"Show unstaged changes"},{cmd:"git diff --staged",desc:"Show staged changes"},{cmd:"git status --short",desc:"Compact porcelain view"},{cmd:"git log --oneline --all",desc:"View history"},{cmd:"git show HEAD",desc:"Inspect a commit"},{cmd:"git blame ",desc:"Line attribution"}]},{title:"Branching",commands:[{cmd:"git branch ",desc:"Create branch"},{cmd:"git branch",desc:"List branches"},{cmd:"git branch -r",desc:"List remote branches"},{cmd:"git branch -d ",desc:"Delete a branch"},{cmd:"git checkout ",desc:"Switch branches"},{cmd:"git checkout -b ",desc:"Create & switch"},{cmd:"git switch ",desc:"Modern branch switch"},{cmd:"git switch -c ",desc:"Create & switch"}]},{title:"Merging & Rebasing",commands:[{cmd:"git merge ",desc:"Merge a branch"},{cmd:"git rebase ",desc:"Rebase onto branch"},{cmd:"git cherry-pick ",desc:"Apply a commit"}]},{title:"Remote Sync",commands:[{cmd:"git remote add ",desc:"Add a remote"},{cmd:"git remote -v",desc:"List remotes"},{cmd:"git remote rename ",desc:"Rename a remote"},{cmd:"git remote set-url ",desc:"Change remote URL"},{cmd:"git push -u ",desc:"Push & set upstream"},{cmd:"git push",desc:"Push to tracked remote"},{cmd:"git pull",desc:"Fetch & merge"},{cmd:"git fetch",desc:"Download remote changes"}]},{title:"Undo & Stash",commands:[{cmd:"git reset --soft HEAD~1",desc:"Soft reset (keep staged)"},{cmd:"git reset --mixed HEAD~1",desc:"Mixed reset (unstage)"},{cmd:"git reset --hard HEAD~1",desc:"Hard reset (discard)"},{cmd:"git restore ",desc:"Discard worktree changes"},{cmd:"git restore --staged ",desc:"Unstage a file"},{cmd:"git clean -n",desc:"Preview untracked cleanup"},{cmd:"git clean -f",desc:"Remove untracked files"},{cmd:"git revert HEAD",desc:"Revert last commit"},{cmd:"git stash",desc:"Stash changes"},{cmd:"git stash pop",desc:"Restore stash"},{cmd:"git stash list",desc:"List stashes"}]},{title:"Inspect & Utilities",commands:[{cmd:"git tag ",desc:"Create a tag"},{cmd:"git tag",desc:"List tags"},{cmd:"git tag -d ",desc:"Delete a tag"},{cmd:"git describe HEAD",desc:"Show closest tag/name"},{cmd:"git reflog",desc:"Show HEAD history"},{cmd:"git config --list",desc:"Show Git config"},{cmd:"git rm ",desc:"Remove and stage deletion"},{cmd:"git mv ",desc:"Rename and stage change"}]}];function Re({onRunCommand:e,disabled:t}){const[s,o]=w.useState(null);return i.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/70 p-3 shadow-2xl shadow-black/20 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-violet-400",children:i.jsx("path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"})}),i.jsx("span",{className:"text-xs font-semibold text-slate-300",children:"Command Reference"})]}),i.jsx("div",{className:"space-y-1",children:Ae.map(n=>i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>o(s===n.title?null:n.title),className:"flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-[10px] font-semibold text-slate-400 uppercase tracking-wider transition-colors hover:bg-slate-800/70",children:[n.title,i.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`transition-transform ${s===n.title?"rotate-180":""}`,children:i.jsx("path",{d:"m6 9 6 6 6-6"})})]}),s===n.title&&i.jsx("div",{className:"ml-2 space-y-0.5 pb-1",children:n.commands.map(({cmd:r,desc:c})=>{const a=!r.includes("<")&&!r.includes("[");return i.jsxs("button",{onClick:()=>a&&!t&&e(r),disabled:t||!a,className:` +import{r as w,j as i}from"./index-DBkLeWDs.js";import{g as je}from"./audioContext-NbgqvQGz.js";const V=["#818cf8","#34d399","#fb923c","#f472b6","#38bdf8","#a78bfa","#fbbf24","#2dd4bf","#f87171","#c084fc"],H=16,ne=64,ie=40,re=50,oe=50,Ce=28;function ve({state:e}){const{commits:t,branches:s,tags:o,head:n,detachedHead:r,commitOrder:c}=e,a=w.useMemo(()=>{if(c.length===0)return{nodes:[],edges:[],labels:[],width:400,height:300};const m=new Map;s.forEach((k,C)=>{m.set(k.name,V[C%V.length])});const l=new Map;let g=0;const u=[...c].reverse(),x=new Map;for(const k of u){const C=t[k];if(!C)continue;const v=C.branch;l.has(v)||l.set(v,g++),x.set(k,l.get(v))}const b=u.map((k,C)=>{const v=t[k],E=x.get(k)??0;return{id:k,x:re+E*ie,y:oe+C*ne,commit:v,color:m.get(v.branch)??V[0],col:E}}),p=new Map(b.map(k=>[k.id,k])),h=[];for(const k of b)for(let C=0;C0})}const y=r?n:s.find(k=>k.name===n)?.commitId,$=r?null:n,N=[];for(const k of s){const C=p.get(k.commitId);if(!C)continue;const v=k.name===$,E=N.filter(_=>_.commitId===k.commitId).length;N.push({text:k.name,commitId:k.commitId,x:C.x+H+12,y:C.y-6+E*22,color:m.get(k.name)??V[0],isHead:v,isTag:!1})}for(const k of o){const C=p.get(k.commitId);if(!C)continue;const v=N.filter(E=>E.commitId===k.commitId).length;N.push({text:k.name,commitId:k.commitId,x:C.x+H+12,y:C.y-6+v*22,color:"#fbbf24",isHead:!1,isTag:!0})}const O=g,P=Math.max(400,re*2+O*ie+200),M=Math.max(300,oe*2+u.length*ne);return{nodes:b,edges:h,labels:N,width:P,height:M,headCommitId:y}},[t,s,o,n,r,c]);return c.length===0?i.jsx("div",{className:"flex flex-1 items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-950/70 shadow-2xl shadow-black/30 backdrop-blur-sm",children:i.jsxs("div",{className:"text-center px-6",children:[i.jsx("div",{className:"mb-3 text-4xl opacity-40",children:i.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"mx-auto text-slate-500",children:[i.jsx("circle",{cx:"12",cy:"12",r:"3"}),i.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"9"}),i.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"21"})]})}),i.jsx("p",{className:"text-sm text-slate-400",children:"No commits yet"}),i.jsxs("p",{className:"text-xs text-slate-600 mt-1",children:["Run ",i.jsx("code",{className:"text-indigo-400",children:"git init"}),", then create and commit files"]})]})}):i.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden rounded-2xl border border-slate-700/50 bg-slate-950/70 shadow-2xl shadow-black/30 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-slate-700/50 bg-slate-900/80 px-4 py-2.5",children:[i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-indigo-400",children:[i.jsx("circle",{cx:"18",cy:"18",r:"3"}),i.jsx("circle",{cx:"6",cy:"6",r:"3"}),i.jsx("path",{d:"M6 21V9a9 9 0 0 0 9 9"})]}),i.jsx("span",{className:"text-xs font-semibold text-slate-300",children:"Commit Graph"}),i.jsx("span",{className:"rounded bg-indigo-500/10 px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-indigo-300 ring-1 ring-indigo-500/20",children:"live history"}),i.jsxs("span",{className:"ml-auto text-[10px] text-slate-500",children:[c.length," commit",c.length!==1?"s":""]})]}),i.jsx("div",{className:"flex-1 overflow-auto bg-[radial-gradient(circle_at_1px_1px,rgba(148,163,184,0.12)_1px,transparent_0)] bg-[length:24px_24px] p-2",children:i.jsxs("svg",{width:a.width,height:a.height,className:"block",style:{minWidth:a.width,minHeight:a.height},children:[a.edges.map((m,l)=>{if(m.from.x===m.to.x)return i.jsx("line",{x1:m.from.x,y1:m.from.y,x2:m.to.x,y2:m.to.y,stroke:m.color,strokeWidth:3,opacity:m.isMerge?.5:.7,strokeDasharray:m.isMerge?"6,3":void 0},`e${l}`);const g=(m.from.y+m.to.y)/2;return i.jsx("path",{d:`M${m.from.x},${m.from.y} C${m.from.x},${g} ${m.to.x},${g} ${m.to.x},${m.to.y}`,stroke:m.color,strokeWidth:3,fill:"none",opacity:m.isMerge?.5:.7,strokeDasharray:m.isMerge?"6,3":void 0},`e${l}`)}),a.nodes.map(m=>{const l=m.id===a.headCommitId;return i.jsxs("g",{children:[l&&i.jsxs("circle",{cx:m.x,cy:m.y,r:H+4,fill:"none",stroke:m.color,strokeWidth:2,opacity:.4,children:[i.jsx("animate",{attributeName:"r",values:`${H+3};${H+6};${H+3}`,dur:"2s",repeatCount:"indefinite"}),i.jsx("animate",{attributeName:"opacity",values:"0.4;0.15;0.4",dur:"2s",repeatCount:"indefinite"})]}),i.jsx("circle",{cx:m.x,cy:m.y,r:H,fill:l?m.color:`${m.color}33`,stroke:m.color,strokeWidth:l?3:2,filter:"drop-shadow(0 6px 8px rgba(0,0,0,0.35))",className:"transition-all duration-300"}),i.jsx("text",{x:m.x,y:m.y+1,textAnchor:"middle",dominantBaseline:"central",className:"select-none pointer-events-none",fill:l?"#0f172a":m.color,fontSize:8,fontWeight:700,fontFamily:"monospace",children:m.id.slice(0,4)}),i.jsx("text",{x:m.x,y:m.y+Ce,textAnchor:"middle",fill:"#94a3b8",fontSize:9,className:"select-none pointer-events-none",children:m.commit.message.length>22?m.commit.message.slice(0,20)+"...":m.commit.message})]},m.id)}),a.labels.map((m,l)=>i.jsxs("g",{children:[i.jsx("rect",{x:m.x-2,y:m.y-8,width:m.text.length*7.5+(m.isHead?40:8)+(m.isTag?10:0),height:18,rx:4,fill:`${m.color}22`,stroke:m.color,strokeWidth:1,opacity:.8}),m.isTag&&i.jsx("text",{x:m.x+4,y:m.y+4,fill:m.color,fontSize:8,children:"tag"}),m.isHead&&i.jsx("text",{x:m.x+4,y:m.y+4,fill:"#fbbf24",fontSize:9,fontWeight:700,fontFamily:"monospace",children:"HEAD→"}),i.jsx("text",{x:m.x+(m.isHead?44:m.isTag?18:4),y:m.y+4,fill:m.color,fontSize:10,fontWeight:600,fontFamily:"monospace",children:m.text})]},`l${l}`))]})})]})}const $e=w.memo(ve);function Ne({history:e,commandHistory:t,onExecute:s,disabled:o,promptBranch:n="main"}){const[r,c]=w.useState(""),[a,m]=w.useState(-1),l=w.useRef(null),g=w.useRef(null);w.useEffect(()=>{l.current?.scrollIntoView({behavior:"smooth"})},[e]),w.useEffect(()=>{o||g.current?.focus()},[o]);const u=w.useCallback(p=>{p.preventDefault(),!(!r.trim()||o)&&(s(r),c(""),m(-1))},[r,o,s]),x=w.useCallback(p=>{if(p.key==="ArrowUp"){if(p.preventDefault(),t.length===0)return;const h=a===-1?t.length-1:Math.max(0,a-1);m(h),c(t[h])}else if(p.key==="ArrowDown"){if(p.preventDefault(),a===-1)return;const h=a+1;h>=t.length?(m(-1),c("")):(m(h),c(t[h]))}},[t,a]),b=p=>{switch(p){case"input":return"text-emerald-400";case"error":return"text-red-400";case"info":return"text-indigo-400";case"hint":return"text-amber-400/90";default:return"text-slate-300"}};return i.jsxs("div",{className:"flex flex-col overflow-hidden rounded-2xl border border-slate-700/50 bg-slate-950/90 font-mono text-xs shadow-2xl shadow-black/30 backdrop-blur-sm",onClick:()=>g.current?.focus(),children:[i.jsxs("div",{className:"flex items-center gap-2 border-b border-slate-700/50 bg-slate-900/80 px-4 py-2.5",children:[i.jsxs("div",{className:"flex gap-1.5",children:[i.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-red-500/70"}),i.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-yellow-500/70"}),i.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-green-500/70"})]}),i.jsx("span",{className:"ml-2 text-[10px] font-semibold text-slate-400",children:"Git Terminal"}),i.jsx("span",{className:"ml-auto rounded bg-slate-950/80 px-2 py-0.5 text-[9px] text-slate-500 ring-1 ring-slate-800",children:"~/visual-repo"})]}),i.jsxs("div",{className:"min-h-[240px] flex-1 space-y-0.5 overflow-y-auto bg-[linear-gradient(rgba(148,163,184,0.03)_1px,transparent_1px)] bg-[length:100%_22px] p-3",children:[e.map((p,h)=>i.jsx("div",{className:`whitespace-pre-wrap leading-relaxed ${b(p.type)}`,children:p.text},h)),i.jsx("div",{ref:l})]}),i.jsxs("form",{onSubmit:u,className:"flex items-center gap-2 border-t border-slate-800/60 bg-slate-900/70 px-3 py-2",children:[i.jsx("span",{className:"select-none text-sky-400",children:"visual-repo"}),i.jsxs("span",{className:"select-none text-slate-600",children:["git:(",n,")"]}),i.jsx("span",{className:"select-none font-bold text-emerald-500",children:"$"}),i.jsx("input",{ref:g,type:"text",value:r,onChange:p=>c(p.target.value),onKeyDown:x,disabled:o,placeholder:o?"Demo running...":"Type a git command...",className:"flex-1 bg-transparent text-slate-200 placeholder-slate-600 outline-none caret-emerald-400",autoComplete:"off",spellCheck:!1})]})]})}const De=w.memo(Ne);function Se({state:e}){const{workingDirectory:t,stagingArea:s,commits:o,head:n,detachedHead:r,branches:c}=e,a=r?n:c.find(h=>h.name===n)?.commitId??null,l=(a?o[a]:null)?.files??{},g=Object.keys(t),u=Object.keys(s),x=h=>h in s?"staged":h in l?t[h]!==l[h]?"modified":"clean":"untracked",b=h=>{switch(h){case"staged":return"text-emerald-400 bg-emerald-500/10";case"modified":return"text-amber-400 bg-amber-500/10";case"untracked":return"text-red-400 bg-red-500/10";default:return"text-slate-500 bg-slate-500/10"}},p=h=>{switch(h){case"staged":return"S";case"modified":return"M";case"untracked":return"U";default:return"✓"}};return i.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[i.jsxs("div",{className:"rounded-2xl border border-amber-500/20 bg-slate-950/70 p-3 shadow-xl shadow-black/20 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-amber-500/10 text-amber-300 ring-1 ring-amber-500/20",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M3 7h5l2 3h11v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"}),i.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h4l2 3h5"})]})}),i.jsx("span",{className:"text-[10px] font-semibold text-slate-300 uppercase tracking-wider",children:"Working Dir"}),i.jsx("span",{className:"ml-auto text-[10px] text-slate-600",children:g.length})]}),i.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:g.length===0?i.jsx("p",{className:"text-[10px] text-slate-600 italic",children:"empty"}):g.map(h=>{const y=x(h);return i.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-slate-900/50 px-1.5 py-1 ring-1 ring-slate-800/50",children:[i.jsx("span",{className:`inline-flex h-4 w-4 items-center justify-center rounded text-[8px] font-bold ${b(y)}`,children:p(y)}),i.jsx("span",{className:"text-[10px] text-slate-400 truncate",children:h})]},h)})})]}),i.jsxs("div",{className:"rounded-2xl border border-emerald-500/20 bg-slate-950/70 p-3 shadow-xl shadow-black/20 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-emerald-500/10 text-emerald-300 ring-1 ring-emerald-500/20",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M12 5v14"}),i.jsx("path",{d:"M5 12h14"})]})}),i.jsx("span",{className:"text-[10px] font-semibold text-slate-300 uppercase tracking-wider",children:"Staging"}),i.jsx("span",{className:"ml-auto text-[10px] text-slate-600",children:u.length})]}),i.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:u.length===0?i.jsx("p",{className:"text-[10px] text-slate-600 italic",children:"empty"}):u.map(h=>i.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-slate-900/50 px-1.5 py-1 ring-1 ring-slate-800/50",children:[i.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded text-[8px] font-bold text-emerald-400 bg-emerald-500/10",children:"+"}),i.jsx("span",{className:"text-[10px] text-slate-400 truncate",children:h})]},h))})]}),i.jsxs("div",{className:"rounded-2xl border border-indigo-500/20 bg-slate-950/70 p-3 shadow-xl shadow-black/20 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-indigo-500/10 text-indigo-300 ring-1 ring-indigo-500/20",children:i.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),i.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),i.jsx("path",{d:"M12 22V12"})]})}),i.jsx("span",{className:"text-[10px] font-semibold text-slate-300 uppercase tracking-wider",children:"Repository"}),i.jsx("span",{className:"ml-auto text-[10px] text-slate-600",children:Object.keys(l).length})]}),i.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:Object.keys(l).length===0?i.jsx("p",{className:"text-[10px] text-slate-600 italic",children:"no commits"}):Object.keys(l).map(h=>i.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-slate-900/50 px-1.5 py-1 ring-1 ring-slate-800/50",children:[i.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded text-[8px] font-bold text-indigo-400 bg-indigo-500/10",children:"✓"}),i.jsx("span",{className:"text-[10px] text-slate-400 truncate",children:h})]},h))})]})]})}const Ie=w.memo(Se),Ae=[{title:"Setup",commands:[{cmd:"git init",desc:"Initialize a new repository"},{cmd:"git clone ",desc:"Clone a remote repository"}]},{title:"File Ops",commands:[{cmd:"touch [content]",desc:"Create a new file"},{cmd:"edit ",desc:"Modify a file"},{cmd:"cat ",desc:"View file content"},{cmd:"mv ",desc:"Move/rename a file"},{cmd:"rm ",desc:"Delete a file"},{cmd:"ls",desc:"List files"}]},{title:"Staging & Committing",commands:[{cmd:"git add ",desc:"Stage changes"},{cmd:'git commit -m "msg"',desc:"Create a commit"},{cmd:'git commit -am "msg"',desc:"Stage tracked & commit"},{cmd:"git status",desc:"Show status"},{cmd:"git diff",desc:"Show unstaged changes"},{cmd:"git diff --staged",desc:"Show staged changes"},{cmd:"git status --short",desc:"Compact porcelain view"},{cmd:"git log --oneline --all",desc:"View history"},{cmd:"git show HEAD",desc:"Inspect a commit"},{cmd:"git blame ",desc:"Line attribution"}]},{title:"Branching",commands:[{cmd:"git branch ",desc:"Create branch"},{cmd:"git branch",desc:"List branches"},{cmd:"git branch -r",desc:"List remote branches"},{cmd:"git branch -d ",desc:"Delete a branch"},{cmd:"git checkout ",desc:"Switch branches"},{cmd:"git checkout -b ",desc:"Create & switch"},{cmd:"git switch ",desc:"Modern branch switch"},{cmd:"git switch -c ",desc:"Create & switch"}]},{title:"Merging & Rebasing",commands:[{cmd:"git merge ",desc:"Merge a branch"},{cmd:"git rebase ",desc:"Rebase onto branch"},{cmd:"git cherry-pick ",desc:"Apply a commit"}]},{title:"Remote Sync",commands:[{cmd:"git remote add ",desc:"Add a remote"},{cmd:"git remote -v",desc:"List remotes"},{cmd:"git remote rename ",desc:"Rename a remote"},{cmd:"git remote set-url ",desc:"Change remote URL"},{cmd:"git push -u ",desc:"Push & set upstream"},{cmd:"git push",desc:"Push to tracked remote"},{cmd:"git pull",desc:"Fetch & merge"},{cmd:"git fetch",desc:"Download remote changes"}]},{title:"Undo & Stash",commands:[{cmd:"git reset --soft HEAD~1",desc:"Soft reset (keep staged)"},{cmd:"git reset --mixed HEAD~1",desc:"Mixed reset (unstage)"},{cmd:"git reset --hard HEAD~1",desc:"Hard reset (discard)"},{cmd:"git restore ",desc:"Discard worktree changes"},{cmd:"git restore --staged ",desc:"Unstage a file"},{cmd:"git clean -n",desc:"Preview untracked cleanup"},{cmd:"git clean -f",desc:"Remove untracked files"},{cmd:"git revert HEAD",desc:"Revert last commit"},{cmd:"git stash",desc:"Stash changes"},{cmd:"git stash pop",desc:"Restore stash"},{cmd:"git stash list",desc:"List stashes"}]},{title:"Inspect & Utilities",commands:[{cmd:"git tag ",desc:"Create a tag"},{cmd:"git tag",desc:"List tags"},{cmd:"git tag -d ",desc:"Delete a tag"},{cmd:"git describe HEAD",desc:"Show closest tag/name"},{cmd:"git reflog",desc:"Show HEAD history"},{cmd:"git config --list",desc:"Show Git config"},{cmd:"git rm ",desc:"Remove and stage deletion"},{cmd:"git mv ",desc:"Rename and stage change"}]}];function Re({onRunCommand:e,disabled:t}){const[s,o]=w.useState(null);return i.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/70 p-3 shadow-2xl shadow-black/20 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-violet-400",children:i.jsx("path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"})}),i.jsx("span",{className:"text-xs font-semibold text-slate-300",children:"Command Reference"})]}),i.jsx("div",{className:"space-y-1",children:Ae.map(n=>i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>o(s===n.title?null:n.title),className:"flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-[10px] font-semibold text-slate-400 uppercase tracking-wider transition-colors hover:bg-slate-800/70",children:[n.title,i.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`transition-transform ${s===n.title?"rotate-180":""}`,children:i.jsx("path",{d:"m6 9 6 6 6-6"})})]}),s===n.title&&i.jsx("div",{className:"ml-2 space-y-0.5 pb-1",children:n.commands.map(({cmd:r,desc:c})=>{const a=!r.includes("<")&&!r.includes("[");return i.jsxs("button",{onClick:()=>a&&!t&&e(r),disabled:t||!a,className:` flex w-full items-start gap-2 rounded px-2 py-1 text-left transition-colors ${a&&!t?"hover:bg-indigo-500/10 hover:ring-1 hover:ring-indigo-500/20 cursor-pointer":"cursor-default opacity-75"} `,children:[i.jsx("code",{className:"text-[10px] text-emerald-400 font-mono whitespace-nowrap",children:r}),i.jsx("span",{className:"text-[9px] text-slate-500 mt-px",children:c})]},r)})})]},n.title))})]})}const Ee=w.memo(Re);function Te({state:e}){const t=e.detachedHead?null:e.head,s=e.detachedHead?e.head:e.branches.find(a=>a.name===e.head)?.commitId??"",o=s?e.commits[s]?.files??{}:{},n=Object.keys(e.stagingArea).length,r=Object.keys(e.workingDirectory).filter(a=>a in o&&e.workingDirectory[a]!==o[a]&&!(a in e.stagingArea)).length,c=Object.keys(e.workingDirectory).filter(a=>!(a in o)).length;return i.jsxs("aside",{className:"flex flex-col gap-3 rounded-2xl border border-slate-700/50 bg-slate-950/70 p-3 shadow-2xl shadow-black/30 backdrop-blur-sm lg:w-64 lg:shrink-0",children:[i.jsxs("div",{className:"rounded-xl border border-slate-700/40 bg-[radial-gradient(circle_at_top_left,rgba(249,115,22,0.18),transparent_38%),rgba(15,23,42,0.8)] p-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-orange-500/15 text-orange-300 ring-1 ring-orange-500/30",children:i.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("circle",{cx:"18",cy:"18",r:"3"}),i.jsx("circle",{cx:"6",cy:"6",r:"3"}),i.jsx("path",{d:"M6 21V9a9 9 0 0 0 9 9"})]})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("div",{className:"truncate text-sm font-bold text-white",children:"visual-repo"}),i.jsx("div",{className:"text-[10px] text-slate-500",children:e.initialized?"Git repository":"No repository"})]})]}),i.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-1.5",children:[i.jsx(Z,{label:"Commits",value:e.commitOrder.length}),i.jsx(Z,{label:"Files",value:Object.keys(e.workingDirectory).length}),i.jsx(Z,{label:"Stash",value:e.stash.length})]})]}),i.jsxs(Y,{title:"Working Tree",children:[i.jsx(Q,{label:"Staged",value:n,color:"emerald"}),i.jsx(Q,{label:"Modified",value:r,color:"amber"}),i.jsx(Q,{label:"Untracked",value:c,color:"rose"})]}),i.jsx(Y,{title:"Branches",children:e.branches.length===0?i.jsx(X,{children:"No branches"}):i.jsx("div",{className:"space-y-1",children:e.branches.map(a=>i.jsxs("div",{className:`flex items-center gap-2 rounded-lg px-2 py-1.5 text-[11px] ${a.name===t?"bg-indigo-500/15 text-indigo-200 ring-1 ring-indigo-500/25":"text-slate-400 hover:bg-slate-800/50"}`,children:[i.jsx("span",{className:`h-2 w-2 rounded-full ${a.name===t?"bg-indigo-400":"bg-slate-600"}`}),i.jsx("span",{className:"truncate font-mono",children:a.name}),i.jsx("span",{className:"ml-auto font-mono text-[9px] text-slate-600",children:a.commitId.slice(0,4)||"-"})]},a.name))})}),i.jsx(Y,{title:"Remotes",children:e.remotes.length===0?i.jsx(X,{children:"No remotes configured"}):i.jsx("div",{className:"space-y-1",children:e.remotes.map(a=>i.jsxs("div",{className:"rounded-lg bg-slate-900/60 px-2 py-1.5 ring-1 ring-slate-800/70",children:[i.jsx("div",{className:"font-mono text-[11px] text-sky-300",children:a.name}),i.jsx("div",{className:"truncate text-[9px] text-slate-600",children:a.url})]},a.name))})}),i.jsx(Y,{title:"Tags & Stash",children:i.jsxs("div",{className:"space-y-1.5",children:[e.tags.length===0?i.jsx(X,{children:"No tags"}):e.tags.map(a=>i.jsxs("div",{className:"rounded-lg bg-amber-500/10 px-2 py-1 text-[11px] font-mono text-amber-300 ring-1 ring-amber-500/20",children:["tag: ",a.name]},a.name)),e.stash.length>0&&e.stash.map((a,m)=>i.jsxs("div",{className:"rounded-lg bg-violet-500/10 px-2 py-1 text-[11px] text-violet-300 ring-1 ring-violet-500/20",children:["stash@","{",m,"}"," ",a.message]},a.id))]})})]})}function Y({title:e,children:t}){return i.jsxs("section",{className:"rounded-xl border border-slate-800/80 bg-slate-900/55 p-3",children:[i.jsx("h3",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:e}),t]})}function Z({label:e,value:t}){return i.jsxs("div",{className:"rounded-lg bg-slate-950/55 px-2 py-1.5 text-center ring-1 ring-slate-800/80",children:[i.jsx("div",{className:"text-[9px] text-slate-600",children:e}),i.jsx("div",{className:"font-mono text-xs font-bold text-slate-200",children:t})]})}function Q({label:e,value:t,color:s}){const o={emerald:"bg-emerald-500/10 text-emerald-300 ring-emerald-500/25",amber:"bg-amber-500/10 text-amber-300 ring-amber-500/25",rose:"bg-rose-500/10 text-rose-300 ring-rose-500/25"};return i.jsxs("div",{className:`mb-1 flex items-center justify-between rounded-lg px-2 py-1.5 text-[11px] ring-1 ${o[s]}`,children:[i.jsx("span",{children:e}),i.jsx("span",{className:"font-mono font-bold",children:t})]})}function X({children:e}){return i.jsx("p",{className:"text-[11px] italic text-slate-600",children:e})}const Ue=w.memo(Te);function Oe({lessons:e,completedLessons:t,activeLessonId:s,onSelect:o}){const n=r=>{switch(r){case"beginner":return"text-emerald-400 bg-emerald-500/10 ring-emerald-500/30";case"intermediate":return"text-amber-400 bg-amber-500/10 ring-amber-500/30";case"advanced":return"text-rose-400 bg-rose-500/10 ring-rose-500/30"}};return i.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-3 backdrop-blur-sm",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-amber-400",children:[i.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),i.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]}),i.jsx("span",{className:"text-xs font-semibold text-slate-300",children:"Guided Lessons"}),i.jsxs("span",{className:"ml-auto text-[10px] text-slate-500",children:[t.size,"/",e.length]})]}),i.jsx("div",{className:"space-y-1.5",children:e.map(r=>{const c=t.has(r.id),a=r.id===s;return i.jsxs("button",{onClick:()=>o(r.id),className:` diff --git a/docs/assets/GraphTraversalPage-B_xobZ-f.js b/docs/assets/GraphTraversalPage-B_xobZ-f.js new file mode 100644 index 0000000..149a232 --- /dev/null +++ b/docs/assets/GraphTraversalPage-B_xobZ-f.js @@ -0,0 +1,18 @@ +import{c as W,r,j as e,F as Q}from"./index-DBkLeWDs.js";import{N as a,A as D,r as Z,S as ee}from"./index-DrhCNtmA.js";import{V as te,a as se}from"./volume-x-BSx9gxSg.js";import{S as ae}from"./sparkles-3Zw4K66N.js";import{S as ne}from"./square-Bc_q5e3l.js";import{P as oe}from"./play-mcIZClKO.js";import{R as re}from"./rotate-ccw-7GTUOPy4.js";import{S as le}from"./shuffle-Dlr-c52A.js";import{g as ie}from"./audioContext-NbgqvQGz.js";const ce=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],de=W("eraser",ce);const ue=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],me=W("map-pin",ue);const pe=[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]],xe=W("paintbrush",pe),fe={[a.EMPTY]:"bg-slate-900/40 hover:bg-slate-700/60",[a.WALL]:"bg-slate-300 animate-wall",[a.START]:"bg-emerald-500 shadow-lg shadow-emerald-500/30",[a.END]:"bg-rose-500 shadow-lg shadow-rose-500/30",[a.VISITED]:"bg-indigo-500/70 animate-visited",[a.PATH]:"bg-amber-400 animate-path shadow-md shadow-amber-400/30",[a.EXPLORING]:"bg-cyan-400 animate-pulse"};function he({row:l,col:n,type:y,onMouseDown:x,onMouseEnter:g,onMouseUp:b}){return e.jsx("div",{className:` + w-[22px] h-[22px] border border-slate-800/30 transition-colors duration-100 + cursor-pointer select-none ${fe[y]} + `,onMouseDown:()=>x(l,n),onMouseEnter:()=>g(l,n),onMouseUp:b,role:"button","aria-label":`Node ${l},${n} - ${y}`})}const ge=r.memo(he,(l,n)=>l.type===n.type&&l.row===n.row&&l.col===n.col);function be({grid:l,isRunning:n,isDrawing:y,setIsDrawing:x,handleNodeInteraction:g}){const b=r.useCallback((f,s)=>{n||(x(!0),g(f,s))},[n,x,g]),T=r.useCallback((f,s)=>{!y||n||g(f,s)},[y,n,g]),m=r.useCallback(()=>{x(!1)},[x]),t=r.useRef(null),u=r.useRef(null),[i,w]=r.useState(1),[h,N]=r.useState("auto");return r.useEffect(()=>{const f=t.current,s=u.current;if(!f||!s)return;const o=()=>{const c=f.clientWidth,p=s.scrollWidth;p>c?w(c/p):w(1)};o();const d=new ResizeObserver(o);return d.observe(f),()=>d.disconnect()},[l]),r.useLayoutEffect(()=>{const f=u.current;f&&N(f.scrollHeight*i)},[i,l]),e.jsx("div",{ref:t,className:"w-full overflow-hidden",children:e.jsx("div",{style:{transform:`scale(${i})`,transformOrigin:"top left",height:h},children:e.jsx("div",{ref:u,className:"inline-block rounded-xl border border-slate-700/50 bg-slate-950/80 p-2 shadow-2xl backdrop-blur-sm",onMouseLeave:()=>x(!1),children:l.map((f,s)=>e.jsx("div",{className:"flex",children:f.map(o=>e.jsx(ge,{row:o.row,col:o.col,type:o.type,onMouseDown:b,onMouseEnter:T,onMouseUp:m},`${o.row}-${o.col}`))},s))})})})}const ye=["bfs","dfs","dijkstra","astar"],Te=["slow","medium","fast","instant"],we=[{mode:"wall",label:"Wall",icon:xe},{mode:"eraser",label:"Eraser",icon:de},{mode:"start",label:"Start",icon:me},{mode:"end",label:"End",icon:Q}];function je({algorithm:l,setAlgorithm:n,speed:y,setSpeed:x,drawMode:g,setDrawMode:b,isRunning:T,isFinished:m,visitedCount:t,pathLength:u,onVisualize:i,onStop:w,onReset:h,onClearVisualization:N,onGenerateMaze:f,soundEnabled:s,onToggleSound:o}){const d=D[l];return e.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Algorithm"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(c=>e.jsx("button",{onClick:()=>!T&&n(c),disabled:T,className:` + rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200 + ${l===c?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 shadow-lg shadow-indigo-500/10":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} + disabled:opacity-50 disabled:cursor-not-allowed + `,children:D[c].name.split(" ").length>2?D[c].name.split(" ").slice(0,-1).join(" "):D[c].name},c))}),e.jsxs("div",{className:"mt-3 rounded-lg bg-slate-800/40 p-3",children:[e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:d.description}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[d.guaranteesShortestPath&&e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-400 ring-1 ring-emerald-500/20",children:"Shortest Path"}),d.weighted&&e.jsx("span",{className:"inline-flex items-center rounded-full bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-400 ring-1 ring-amber-500/20",children:"Weighted"})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Speed"}),e.jsxs("button",{onClick:()=>o(!s),className:` + flex items-center gap-1.5 rounded-lg px-2 py-1 text-xs font-medium transition-all duration-200 + ${s?"bg-emerald-500/15 text-emerald-400 ring-1 ring-emerald-500/30":"bg-slate-800/50 text-slate-500 hover:text-slate-400"} + `,title:s?"Mute sound":"Unmute sound",children:[s?e.jsx(te,{size:12}):e.jsx(se,{size:12}),s?"Sound On":"Sound Off"]})]}),e.jsx("div",{className:"flex gap-1",children:Te.map(c=>e.jsx("button",{onClick:()=>x(c),className:` + flex-1 rounded-lg px-2 py-1.5 text-xs font-medium capitalize transition-all duration-200 + ${y===c?"bg-violet-500/20 text-violet-300 ring-1 ring-violet-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} + `,children:c},c))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Tools"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:we.map(({mode:c,label:p,icon:v})=>e.jsxs("button",{onClick:()=>b(c),disabled:T,className:` + flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200 + ${g===c?"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} + disabled:opacity-50 disabled:cursor-not-allowed + `,children:[e.jsx(v,{size:14}),p]},c))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[T?e.jsxs("button",{onClick:w,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500 to-pink-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-rose-500/25 transition-all duration-200 hover:brightness-110 active:scale-[0.98]",children:[e.jsx(ne,{size:16}),"Stop"]}):e.jsxs("button",{onClick:i,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-500/25 transition-all duration-200 hover:shadow-xl hover:shadow-indigo-500/30 hover:brightness-110 active:scale-[0.98]",children:[e.jsx(ae,{size:16}),"Visualize ",d.name]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:N,disabled:T,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(oe,{size:12}),"Clear"]}),e.jsxs("button",{onClick:h,disabled:T,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(re,{size:12}),"Reset"]}),e.jsxs("button",{onClick:f,disabled:T,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(le,{size:12}),"Maze"]})]})]}),(T||m)&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Statistics"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Nodes Visited"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-indigo-400",children:t})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Path Length"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-amber-400",children:u>0?u:m?"No path":"—"})]})]})]})]})}const Ne=[{label:"Start",color:"bg-emerald-500"},{label:"End",color:"bg-rose-500"},{label:"Wall",color:"bg-slate-300"},{label:"Visited",color:"bg-indigo-500/70"},{label:"Path",color:"bg-amber-400"},{label:"Empty",color:"bg-slate-900/40 ring-1 ring-slate-700"}];function ve(){return e.jsx("div",{className:"flex items-center justify-center gap-6 py-3",children:Ne.map(({label:l,color:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`h-4 w-4 rounded-sm ${n}`}),e.jsx("span",{className:"text-xs text-slate-400",children:l})]},l))})}const I=25,O=50,M={row:12,col:10},z={row:12,col:39};function Se(l,n){return{row:l,col:n,type:a.EMPTY,distance:1/0,heuristic:0,totalCost:1/0,parent:null,isVisited:!1}}function $(l,n,y,x){const g=[];for(let b=0;b$(I,O,M,z)),[y,x]=r.useState(M),[g,b]=r.useState(z),[T,m]=r.useState(!1),[t,u]=r.useState("wall"),i=r.useCallback(()=>{n($(I,O,M,z)),x(M),b(z)},[]),w=r.useCallback(()=>{n(s=>s.map(o=>o.map(d=>({...d,type:d.type===a.VISITED||d.type===a.PATH||d.type===a.EXPLORING?a.EMPTY:d.type,isVisited:!1,distance:1/0,heuristic:0,totalCost:1/0,parent:null}))))},[]),h=r.useCallback((s,o)=>{n(d=>{const c=d.map(v=>v.map(S=>({...S}))),p=c[s][o];return t==="start"?p.type===a.END?d:(c[y.row][y.col].type=a.EMPTY,p.type=a.START,x({row:s,col:o}),c):t==="end"?p.type===a.START?d:(c[g.row][g.col].type=a.EMPTY,p.type=a.END,b({row:s,col:o}),c):p.type===a.START||p.type===a.END?d:(t==="wall"?p.type=a.WALL:t==="eraser"&&(p.type=a.EMPTY),c)})},[t,y,g]),N=r.useCallback((s,o,d)=>{n(c=>{const p=c.map(v=>v.map(S=>({...S})));return p[s][o].type=d,p})},[]),f=r.useCallback(()=>{const s=$(I,O,M,z);for(let o=0;oie(),[]),y=r.useCallback((m,t,u,i,w)=>{if(!l.current||w==="instant")return;const h=n();if(!h)return;const N=F[w],f=H[w],s=(m*i+t)/(u*i),o=Math.floor(s*(q.length-1)),d=q[Math.min(o,q.length-1)],c=h.createOscillator(),p=h.createGain();c.type="sine",c.frequency.setValueAtTime(d,h.currentTime),p.gain.setValueAtTime(f,h.currentTime),p.gain.exponentialRampToValueAtTime(.001,h.currentTime+N),c.connect(p),p.connect(h.destination),c.start(h.currentTime),c.stop(h.currentTime+N)},[n]),x=r.useCallback((m,t,u)=>{if(!l.current||u==="instant")return;const i=n();if(!i)return;const w=F[u]*3,h=H[u]*1.5,f=440+m/Math.max(t-1,1)*440,s=i.createOscillator(),o=i.createGain();s.type="triangle",s.frequency.setValueAtTime(f,i.currentTime),o.gain.setValueAtTime(h,i.currentTime),o.gain.exponentialRampToValueAtTime(.001,i.currentTime+w),s.connect(o),o.connect(i.destination),s.start(i.currentTime),s.stop(i.currentTime+w)},[n]),g=r.useCallback(m=>{if(!l.current)return;const t=n();if(!t)return;const u=t.createOscillator(),i=t.createGain();u.type="sine",i.gain.setValueAtTime(.1,t.currentTime),m?(u.frequency.setValueAtTime(523.25,t.currentTime),u.frequency.setValueAtTime(659.25,t.currentTime+.15),u.frequency.setValueAtTime(783.99,t.currentTime+.3),i.gain.exponentialRampToValueAtTime(.001,t.currentTime+.5),u.connect(i),i.connect(t.destination),u.start(t.currentTime),u.stop(t.currentTime+.5)):(u.frequency.setValueAtTime(392,t.currentTime),u.frequency.setValueAtTime(293.66,t.currentTime+.2),i.gain.exponentialRampToValueAtTime(.001,t.currentTime+.4),u.connect(i),i.connect(t.destination),u.start(t.currentTime),u.stop(t.currentTime+.4))},[n]),b=r.useCallback(m=>{l.current=m},[]),T=r.useCallback(()=>l.current,[]);return{playVisitedTone:y,playPathTone:x,playCompleteTone:g,setEnabled:b,isEnabled:T}}function Ae({grid:l,startPos:n,endPos:y,setNodeType:x,clearVisualization:g}){const[b,T]=r.useState("bfs"),[m,t]=r.useState("fast"),[u,i]=r.useState(!1),[w,h]=r.useState(!1),[N,f]=r.useState(0),[s,o]=r.useState(0),[d,c]=r.useState(!0),p=r.useRef([]),{playVisitedTone:v,playPathTone:S,playCompleteTone:A,setEnabled:R}=ke(),U=r.useCallback(C=>{c(C),R(C)},[R]),G=r.useCallback(()=>{p.current.forEach(C=>clearTimeout(C)),p.current=[],i(!1)},[]),Y=r.useCallback(()=>{G(),g(),h(!1),f(0),o(0);const C=Z(b,l,n,y),{visitedNodesInOrder:V,shortestPath:E}=C,_=ee[m],X=l.length,B=l[0].length;if(i(!0),_===0){for(const j of V)j.type!==a.START&&j.type!==a.END&&x(j.row,j.col,a.VISITED);for(const j of E)j.type!==a.START&&j.type!==a.END&&x(j.row,j.col,a.PATH);f(V.length),o(E.length),i(!1),h(!0),A(E.length>0);return}for(let j=0;j{const P=V[j];if(P.type!==a.START&&P.type!==a.END&&x(P.row,P.col,a.VISITED),v(P.row,P.col,X,B,m),f(j+1),j===V.length-1){for(let k=0;k{const L=E[k];L.type!==a.START&&L.type!==a.END&&x(L.row,L.col,a.PATH),S(k,E.length,m),o(k+1),k===E.length-1&&(i(!1),h(!0),A(!0))},_*3*k);p.current.push(K)}E.length===0&&(i(!1),h(!0),A(!1))}},_*j);p.current.push(J)}V.length===0&&(i(!1),h(!0))},[b,l,n,y,m,x,g,G,v,S,A]);return{algorithm:b,setAlgorithm:T,speed:m,setSpeed:t,isRunning:u,isFinished:w,visitedCount:N,pathLength:s,soundEnabled:d,toggleSound:U,visualize:Y,stopVisualization:G}}function Oe(){const{grid:l,startPos:n,endPos:y,isDrawing:x,drawMode:g,setDrawMode:b,setIsDrawing:T,resetGrid:m,clearVisualization:t,handleNodeInteraction:u,setNodeType:i,generateMaze:w}=Ee(),{algorithm:h,setAlgorithm:N,speed:f,setSpeed:s,isRunning:o,isFinished:d,visitedCount:c,pathLength:p,soundEnabled:v,toggleSound:S,visualize:A,stopVisualization:R}=Ae({grid:l,startPos:n,endPos:y,setNodeType:i,clearVisualization:t});return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col items-center justify-center gap-3 min-h-[40vh] md:min-h-0 max-h-[50vh] md:max-h-none overflow-auto",children:[e.jsx(be,{grid:l,isRunning:o,isDrawing:x,drawMode:g,setIsDrawing:T,handleNodeInteraction:u}),e.jsx(ve,{})]}),e.jsx(je,{algorithm:h,setAlgorithm:N,speed:f,setSpeed:s,drawMode:g,setDrawMode:b,isRunning:o,isFinished:d,visitedCount:c,pathLength:p,onVisualize:A,onStop:R,onReset:m,onClearVisualization:t,onGenerateMaze:w,soundEnabled:v,onToggleSound:S})]})}export{Oe as default}; diff --git a/docs/assets/GraphTraversalPage-Ck5aejUZ.js b/docs/assets/GraphTraversalPage-Ck5aejUZ.js deleted file mode 100644 index 3b4214b..0000000 --- a/docs/assets/GraphTraversalPage-Ck5aejUZ.js +++ /dev/null @@ -1,18 +0,0 @@ -import{c as W,r,j as e,F as Q,d as Z}from"./index-eCXyAnHs.js";import{N as a,A as D,r as ee,S as te}from"./index-DrhCNtmA.js";import{V as se,a as ae}from"./volume-x-CTbtCvt-.js";import{S as ne}from"./square-CEHTCuQK.js";import{P as oe}from"./play-BqZilH6N.js";import{R as re}from"./rotate-ccw-B8GZP3d7.js";import{S as le}from"./shuffle-CdKU4ZYx.js";import{g as ie}from"./audioContext-NbgqvQGz.js";const ce=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],de=W("eraser",ce);const ue=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],me=W("map-pin",ue);const pe=[["path",{d:"m14.622 17.897-10.68-2.913",key:"vj2p1u"}],["path",{d:"M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z",key:"18tc5c"}],["path",{d:"M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15",key:"ytzfxy"}]],xe=W("paintbrush",pe),fe={[a.EMPTY]:"bg-slate-900/40 hover:bg-slate-700/60",[a.WALL]:"bg-slate-300 animate-wall",[a.START]:"bg-emerald-500 shadow-lg shadow-emerald-500/30",[a.END]:"bg-rose-500 shadow-lg shadow-rose-500/30",[a.VISITED]:"bg-indigo-500/70 animate-visited",[a.PATH]:"bg-amber-400 animate-path shadow-md shadow-amber-400/30",[a.EXPLORING]:"bg-cyan-400 animate-pulse"};function he({row:l,col:n,type:y,onMouseDown:x,onMouseEnter:g,onMouseUp:b}){return e.jsx("div",{className:` - w-[22px] h-[22px] border border-slate-800/30 transition-colors duration-100 - cursor-pointer select-none ${fe[y]} - `,onMouseDown:()=>x(l,n),onMouseEnter:()=>g(l,n),onMouseUp:b,role:"button","aria-label":`Node ${l},${n} - ${y}`})}const ge=r.memo(he,(l,n)=>l.type===n.type&&l.row===n.row&&l.col===n.col);function be({grid:l,isRunning:n,isDrawing:y,setIsDrawing:x,handleNodeInteraction:g}){const b=r.useCallback((f,s)=>{n||(x(!0),g(f,s))},[n,x,g]),T=r.useCallback((f,s)=>{!y||n||g(f,s)},[y,n,g]),m=r.useCallback(()=>{x(!1)},[x]),t=r.useRef(null),u=r.useRef(null),[i,w]=r.useState(1),[h,N]=r.useState("auto");return r.useEffect(()=>{const f=t.current,s=u.current;if(!f||!s)return;const o=()=>{const c=f.clientWidth,p=s.scrollWidth;p>c?w(c/p):w(1)};o();const d=new ResizeObserver(o);return d.observe(f),()=>d.disconnect()},[l]),r.useLayoutEffect(()=>{const f=u.current;f&&N(f.scrollHeight*i)},[i,l]),e.jsx("div",{ref:t,className:"w-full overflow-hidden",children:e.jsx("div",{style:{transform:`scale(${i})`,transformOrigin:"top left",height:h},children:e.jsx("div",{ref:u,className:"inline-block rounded-xl border border-slate-700/50 bg-slate-950/80 p-2 shadow-2xl backdrop-blur-sm",onMouseLeave:()=>x(!1),children:l.map((f,s)=>e.jsx("div",{className:"flex",children:f.map(o=>e.jsx(ge,{row:o.row,col:o.col,type:o.type,onMouseDown:b,onMouseEnter:T,onMouseUp:m},`${o.row}-${o.col}`))},s))})})})}const ye=["bfs","dfs","dijkstra","astar"],Te=["slow","medium","fast","instant"],we=[{mode:"wall",label:"Wall",icon:xe},{mode:"eraser",label:"Eraser",icon:de},{mode:"start",label:"Start",icon:me},{mode:"end",label:"End",icon:Q}];function je({algorithm:l,setAlgorithm:n,speed:y,setSpeed:x,drawMode:g,setDrawMode:b,isRunning:T,isFinished:m,visitedCount:t,pathLength:u,onVisualize:i,onStop:w,onReset:h,onClearVisualization:N,onGenerateMaze:f,soundEnabled:s,onToggleSound:o}){const d=D[l];return e.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Algorithm"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(c=>e.jsx("button",{onClick:()=>!T&&n(c),disabled:T,className:` - rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200 - ${l===c?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 shadow-lg shadow-indigo-500/10":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} - disabled:opacity-50 disabled:cursor-not-allowed - `,children:D[c].name.split(" ").length>2?D[c].name.split(" ").slice(0,-1).join(" "):D[c].name},c))}),e.jsxs("div",{className:"mt-3 rounded-lg bg-slate-800/40 p-3",children:[e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:d.description}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[d.guaranteesShortestPath&&e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-400 ring-1 ring-emerald-500/20",children:"Shortest Path"}),d.weighted&&e.jsx("span",{className:"inline-flex items-center rounded-full bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-400 ring-1 ring-amber-500/20",children:"Weighted"})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Speed"}),e.jsxs("button",{onClick:()=>o(!s),className:` - flex items-center gap-1.5 rounded-lg px-2 py-1 text-xs font-medium transition-all duration-200 - ${s?"bg-emerald-500/15 text-emerald-400 ring-1 ring-emerald-500/30":"bg-slate-800/50 text-slate-500 hover:text-slate-400"} - `,title:s?"Mute sound":"Unmute sound",children:[s?e.jsx(se,{size:12}):e.jsx(ae,{size:12}),s?"Sound On":"Sound Off"]})]}),e.jsx("div",{className:"flex gap-1",children:Te.map(c=>e.jsx("button",{onClick:()=>x(c),className:` - flex-1 rounded-lg px-2 py-1.5 text-xs font-medium capitalize transition-all duration-200 - ${y===c?"bg-violet-500/20 text-violet-300 ring-1 ring-violet-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} - `,children:c},c))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Tools"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:we.map(({mode:c,label:p,icon:v})=>e.jsxs("button",{onClick:()=>b(c),disabled:T,className:` - flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200 - ${g===c?"bg-cyan-500/20 text-cyan-300 ring-1 ring-cyan-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} - disabled:opacity-50 disabled:cursor-not-allowed - `,children:[e.jsx(v,{size:14}),p]},c))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[T?e.jsxs("button",{onClick:w,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500 to-pink-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-rose-500/25 transition-all duration-200 hover:brightness-110 active:scale-[0.98]",children:[e.jsx(ne,{size:16}),"Stop"]}):e.jsxs("button",{onClick:i,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-500/25 transition-all duration-200 hover:shadow-xl hover:shadow-indigo-500/30 hover:brightness-110 active:scale-[0.98]",children:[e.jsx(Z,{size:16}),"Visualize ",d.name]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{onClick:N,disabled:T,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(oe,{size:12}),"Clear"]}),e.jsxs("button",{onClick:h,disabled:T,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(re,{size:12}),"Reset"]}),e.jsxs("button",{onClick:f,disabled:T,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(le,{size:12}),"Maze"]})]})]}),(T||m)&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Statistics"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Nodes Visited"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-indigo-400",children:t})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Path Length"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-amber-400",children:u>0?u:m?"No path":"—"})]})]})]})]})}const Ne=[{label:"Start",color:"bg-emerald-500"},{label:"End",color:"bg-rose-500"},{label:"Wall",color:"bg-slate-300"},{label:"Visited",color:"bg-indigo-500/70"},{label:"Path",color:"bg-amber-400"},{label:"Empty",color:"bg-slate-900/40 ring-1 ring-slate-700"}];function ve(){return e.jsx("div",{className:"flex items-center justify-center gap-6 py-3",children:Ne.map(({label:l,color:n})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`h-4 w-4 rounded-sm ${n}`}),e.jsx("span",{className:"text-xs text-slate-400",children:l})]},l))})}const I=25,O=50,M={row:12,col:10},z={row:12,col:39};function Se(l,n){return{row:l,col:n,type:a.EMPTY,distance:1/0,heuristic:0,totalCost:1/0,parent:null,isVisited:!1}}function $(l,n,y,x){const g=[];for(let b=0;b$(I,O,M,z)),[y,x]=r.useState(M),[g,b]=r.useState(z),[T,m]=r.useState(!1),[t,u]=r.useState("wall"),i=r.useCallback(()=>{n($(I,O,M,z)),x(M),b(z)},[]),w=r.useCallback(()=>{n(s=>s.map(o=>o.map(d=>({...d,type:d.type===a.VISITED||d.type===a.PATH||d.type===a.EXPLORING?a.EMPTY:d.type,isVisited:!1,distance:1/0,heuristic:0,totalCost:1/0,parent:null}))))},[]),h=r.useCallback((s,o)=>{n(d=>{const c=d.map(v=>v.map(S=>({...S}))),p=c[s][o];return t==="start"?p.type===a.END?d:(c[y.row][y.col].type=a.EMPTY,p.type=a.START,x({row:s,col:o}),c):t==="end"?p.type===a.START?d:(c[g.row][g.col].type=a.EMPTY,p.type=a.END,b({row:s,col:o}),c):p.type===a.START||p.type===a.END?d:(t==="wall"?p.type=a.WALL:t==="eraser"&&(p.type=a.EMPTY),c)})},[t,y,g]),N=r.useCallback((s,o,d)=>{n(c=>{const p=c.map(v=>v.map(S=>({...S})));return p[s][o].type=d,p})},[]),f=r.useCallback(()=>{const s=$(I,O,M,z);for(let o=0;oie(),[]),y=r.useCallback((m,t,u,i,w)=>{if(!l.current||w==="instant")return;const h=n();if(!h)return;const N=F[w],f=H[w],s=(m*i+t)/(u*i),o=Math.floor(s*(q.length-1)),d=q[Math.min(o,q.length-1)],c=h.createOscillator(),p=h.createGain();c.type="sine",c.frequency.setValueAtTime(d,h.currentTime),p.gain.setValueAtTime(f,h.currentTime),p.gain.exponentialRampToValueAtTime(.001,h.currentTime+N),c.connect(p),p.connect(h.destination),c.start(h.currentTime),c.stop(h.currentTime+N)},[n]),x=r.useCallback((m,t,u)=>{if(!l.current||u==="instant")return;const i=n();if(!i)return;const w=F[u]*3,h=H[u]*1.5,f=440+m/Math.max(t-1,1)*440,s=i.createOscillator(),o=i.createGain();s.type="triangle",s.frequency.setValueAtTime(f,i.currentTime),o.gain.setValueAtTime(h,i.currentTime),o.gain.exponentialRampToValueAtTime(.001,i.currentTime+w),s.connect(o),o.connect(i.destination),s.start(i.currentTime),s.stop(i.currentTime+w)},[n]),g=r.useCallback(m=>{if(!l.current)return;const t=n();if(!t)return;const u=t.createOscillator(),i=t.createGain();u.type="sine",i.gain.setValueAtTime(.1,t.currentTime),m?(u.frequency.setValueAtTime(523.25,t.currentTime),u.frequency.setValueAtTime(659.25,t.currentTime+.15),u.frequency.setValueAtTime(783.99,t.currentTime+.3),i.gain.exponentialRampToValueAtTime(.001,t.currentTime+.5),u.connect(i),i.connect(t.destination),u.start(t.currentTime),u.stop(t.currentTime+.5)):(u.frequency.setValueAtTime(392,t.currentTime),u.frequency.setValueAtTime(293.66,t.currentTime+.2),i.gain.exponentialRampToValueAtTime(.001,t.currentTime+.4),u.connect(i),i.connect(t.destination),u.start(t.currentTime),u.stop(t.currentTime+.4))},[n]),b=r.useCallback(m=>{l.current=m},[]),T=r.useCallback(()=>l.current,[]);return{playVisitedTone:y,playPathTone:x,playCompleteTone:g,setEnabled:b,isEnabled:T}}function Ae({grid:l,startPos:n,endPos:y,setNodeType:x,clearVisualization:g}){const[b,T]=r.useState("bfs"),[m,t]=r.useState("fast"),[u,i]=r.useState(!1),[w,h]=r.useState(!1),[N,f]=r.useState(0),[s,o]=r.useState(0),[d,c]=r.useState(!0),p=r.useRef([]),{playVisitedTone:v,playPathTone:S,playCompleteTone:A,setEnabled:R}=ke(),U=r.useCallback(C=>{c(C),R(C)},[R]),G=r.useCallback(()=>{p.current.forEach(C=>clearTimeout(C)),p.current=[],i(!1)},[]),Y=r.useCallback(()=>{G(),g(),h(!1),f(0),o(0);const C=ee(b,l,n,y),{visitedNodesInOrder:V,shortestPath:E}=C,_=te[m],X=l.length,B=l[0].length;if(i(!0),_===0){for(const j of V)j.type!==a.START&&j.type!==a.END&&x(j.row,j.col,a.VISITED);for(const j of E)j.type!==a.START&&j.type!==a.END&&x(j.row,j.col,a.PATH);f(V.length),o(E.length),i(!1),h(!0),A(E.length>0);return}for(let j=0;j{const P=V[j];if(P.type!==a.START&&P.type!==a.END&&x(P.row,P.col,a.VISITED),v(P.row,P.col,X,B,m),f(j+1),j===V.length-1){for(let k=0;k{const L=E[k];L.type!==a.START&&L.type!==a.END&&x(L.row,L.col,a.PATH),S(k,E.length,m),o(k+1),k===E.length-1&&(i(!1),h(!0),A(!0))},_*3*k);p.current.push(K)}E.length===0&&(i(!1),h(!0),A(!1))}},_*j);p.current.push(J)}V.length===0&&(i(!1),h(!0))},[b,l,n,y,m,x,g,G,v,S,A]);return{algorithm:b,setAlgorithm:T,speed:m,setSpeed:t,isRunning:u,isFinished:w,visitedCount:N,pathLength:s,soundEnabled:d,toggleSound:U,visualize:Y,stopVisualization:G}}function Ie(){const{grid:l,startPos:n,endPos:y,isDrawing:x,drawMode:g,setDrawMode:b,setIsDrawing:T,resetGrid:m,clearVisualization:t,handleNodeInteraction:u,setNodeType:i,generateMaze:w}=Ee(),{algorithm:h,setAlgorithm:N,speed:f,setSpeed:s,isRunning:o,isFinished:d,visitedCount:c,pathLength:p,soundEnabled:v,toggleSound:S,visualize:A,stopVisualization:R}=Ae({grid:l,startPos:n,endPos:y,setNodeType:i,clearVisualization:t});return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col items-center justify-center gap-3 min-h-[40vh] md:min-h-0 max-h-[50vh] md:max-h-none overflow-auto",children:[e.jsx(be,{grid:l,isRunning:o,isDrawing:x,drawMode:g,setIsDrawing:T,handleNodeInteraction:u}),e.jsx(ve,{})]}),e.jsx(je,{algorithm:h,setAlgorithm:N,speed:f,setSpeed:s,drawMode:g,setDrawMode:b,isRunning:o,isFinished:d,visitedCount:c,pathLength:p,onVisualize:A,onStop:R,onReset:m,onClearVisualization:t,onGenerateMaze:w,soundEnabled:v,onToggleSound:S})]})}export{Ie as default}; diff --git a/docs/assets/LinkedListAlgoPage-k8JPNHuX.js b/docs/assets/LinkedListAlgoPage-qNeBmS2f.js similarity index 98% rename from docs/assets/LinkedListAlgoPage-k8JPNHuX.js rename to docs/assets/LinkedListAlgoPage-qNeBmS2f.js index 80ae846..c3b5862 100644 --- a/docs/assets/LinkedListAlgoPage-k8JPNHuX.js +++ b/docs/assets/LinkedListAlgoPage-qNeBmS2f.js @@ -1 +1 @@ -import{r as j,j as i,L as Q}from"./index-eCXyAnHs.js";import{P as Z}from"./linkedListAlgo-0_WYfSZm.js";import{u as ee,A as te}from"./AlgorithmCodePanel-DQpanVTO.js";import{S as ne}from"./shuffle-CdKU4ZYx.js";import{C as se,a as oe}from"./chevron-right-BZqZw4c2.js";import{P as ie}from"./pause-nC-0zhw8.js";import{P as re}from"./play-BqZilH6N.js";import{R as le}from"./rotate-ccw-B8GZP3d7.js";import{V as ae,a as de}from"./volume-x-CTbtCvt-.js";import{A as ce}from"./arrow-left-DiyrXoev.js";import"./audioContext-NbgqvQGz.js";let V=1;function _(g){return g.map(t=>({id:V++,value:t}))}function O(g){return g.split(",").map(t=>Number(t.trim())).filter(t=>Number.isFinite(t))}function u(g){return g.map(t=>({...t}))}function q(g,t){switch(g){case"find-middle":return he(O(t));case"reverse-list":return pe(O(t));case"add-two-numbers":return ue(t);case"reverse-k-group":return me(t);case"palindrome":return xe(O(t));case"lru-cache":return ge(t);case"segregate":return fe(O(t));case"detect-cycle":return ve(t);case"sort-list":return ye(O(t));default:return[]}}function he(g){const t=_(g),c=[],x=t.length;if(x===0)return[{description:"List is empty — no middle.",event:"not-found",nodes:[],pointers:[],highlights:[],done:!0}];c.push({description:"Set slow = head (index 0).",event:"visit",nodes:u(t),pointers:[{name:"slow",index:0,color:"green"}],highlights:[{index:0,color:"blue"}],meta:["slow = head"],codeLine:1}),c.push({description:"Set fast = head (index 0). Both pointers start together.",event:"visit",nodes:u(t),pointers:[{name:"slow",index:0,color:"green"},{name:"fast",index:0,color:"red"}],highlights:[{index:0,color:"blue"}],meta:["slow = head","fast = head"],codeLine:2});let e=0,r=0;for(;r+2<=x-1;)c.push({description:`Loop check: fast can move two nodes ahead (fast at index ${r}). Enter the loop.`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:3}),e+=1,c.push({description:`slow = slow.next → index ${e} (value ${t[e].value}). slow walks 1 step.`,event:"visit",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:4}),r+=2,c.push({description:`fast = fast.next.next → index ${r} (value ${t[r].value}). fast walks 2 steps.`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:5});return r+1===x-1&&(c.push({description:"Loop check: fast has a single node ahead — take one more paired step.",event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:3}),e+=1,r+=1,c.push({description:`slow → ${e} (${t[e].value}); fast → ${r} (${t[r].value}).`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:5})),c.push({description:`fast reached the end, so slow stops at the middle: index ${e}, value ${t[e].value}.`,event:"found",nodes:u(t),pointers:[{name:"middle",index:e,color:"green"}],highlights:[{index:e,color:"green"}],meta:[`middle index = ${e}`,`middle value = ${t[e].value}`],codeLine:6,done:!0}),c}function pe(g){const t=_(g),c=t.length;if(c===0)return[{description:"List is empty — nothing to reverse.",event:"complete",nodes:[],pointers:[],highlights:[],done:!0}];if(c===1)return[{description:"Single node — reversing leaves it unchanged.",event:"complete",nodes:u(t),pointers:[{name:"head",index:0,color:"green"}],highlights:[{index:0,color:"green"}],codeLine:8,done:!0}];const x=[];x.push({description:"Set prev = null. This will become the new head once we finish.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["prev = null"],codeLine:1}),x.push({description:"Set curr = head. We walk the list once, flipping each next pointer to point backwards.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["prev = null","curr = head"],codeLine:2});const e=[];for(let n=0;nh.value).join(", ")}]`],codeLine:3}),x.push({description:`Remember next = ${n+1h.value).join(", ")}]`],codeLine:4}),x.push({description:`Flip curr (${l.value}) → point at prev (${e.length?e[e.length-1].value:"null"}).`,event:"swap",nodes:u(d),pointers:[...p,{name:"curr",index:s,color:"yellow"},...o],highlights:[{index:s,color:"yellow"}],meta:[`reversed = [${[...e].reverse().map(h=>h.value).join(", ")}]`],codeLine:5}),e.push(l);const a=[...e].reverse().concat(t.slice(n+1));x.push({description:`Advance prev = ${l.value}. Reversed prefix is now [${[...e].reverse().map(h=>h.value).join(", ")}].`,event:"visit",nodes:u(a),pointers:[{name:"prev",index:0,color:"green"},...n+1h.value).join(", ")}]`],codeLine:6}),x.push({description:`Advance curr = ${n+1h.value).join(", ")}]`],codeLine:7})}const r=[...e].reverse();return x.push({description:`curr is null → done. prev is the new head. Reversed list: [${r.map(n=>n.value).join(", ")}]. ✓`,event:"complete",nodes:u(r),pointers:[{name:"head",index:0,color:"green"}],highlights:r.map((n,l)=>({index:l,color:"green"})),codeLine:8,done:!0}),x}function ue(g){const[t="0",c="0"]=g.split(";"),x=Math.abs(Math.trunc(Number(t.trim())||0)),e=Math.abs(Math.trunc(Number(c.trim())||0)),r=v=>String(v).split("").map(Number).reverse(),n=r(x),l=r(e),d=[],s=[],p=`A = ${n.join("→")} (=${x})`,o=`B = ${l.join("→")} (=${e})`;d.push({description:`Add ${x} + ${e}. Digits are stored least-significant-first, so we add node by node from the front, carrying overflow.`,event:"visit",nodes:[],pointers:[],highlights:[],meta:[p,o,"carry = 0"],codeLine:1}),d.push({description:"Initialise carry = 0 before walking both digit lists.",event:"visit",nodes:[],pointers:[],highlights:[],meta:[p,o,"carry = 0"],codeLine:2});let a=0;const h=Math.max(n.length,l.length);for(let v=0;v0;v+=1){const y=n[v]??0,$=l[v]??0,f=a,b=v=0?[{name:"tail",index:L,color:"green"}]:[],A=L>=0?[{index:L,color:"blue"}]:[];d.push({description:`Loop check: ${b?"A has a digit":"A exhausted"}, ${R?"B has a digit":"B exhausted"}, carry = ${f}. Continue.`,event:"visit",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`carry = ${f}`],codeLine:3});let k=f;d.push({description:`Start this position's sum with the incoming carry: sum = ${f}.`,event:"visit",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`sum = ${k}`,`carry = ${f}`],codeLine:4}),k+=y,d.push({description:b?`A has digit ${y} at this position → sum += ${y} = ${k}; advance A.`:`A is exhausted at this position → nothing to add. sum = ${k}.`,event:"compare",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`sum = ${k}`,`carry = ${f}`],codeLine:5}),k+=$,d.push({description:R?`B has digit ${$} at this position → sum += ${$} = ${k}; advance B.`:`B is exhausted at this position → nothing to add. sum = ${k}.`,event:"compare",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`sum = ${k}`,`carry = ${f}`],codeLine:6}),a=Math.floor(k/10);const K=k%10;d.push({description:`carry = floor(${k} / 10) = ${a}.`,event:"compare",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`sum = ${k}`,`carry = ${a}`],codeLine:7}),s.push({id:V++,value:K}),d.push({description:`Append a node with digit sum % 10 = ${K}.`,event:"push",nodes:u(s),pointers:[{name:"tail",index:s.length-1,color:"green"}],highlights:[{index:s.length-1,color:"green"}],meta:[p,o,`sum = ${k}`,`carry = ${a}`],codeLine:8}),d.push({description:`Advance tail to the node just appended (digit ${K}).`,event:"visit",nodes:u(s),pointers:[{name:"tail",index:s.length-1,color:"green"}],highlights:[{index:s.length-1,color:"blue"}],meta:[p,o,`carry = ${a}`],codeLine:9})}const m=x+e;return d.push({description:`Done. Result list (least-significant-first): [${s.map(v=>v.value).join(", ")}] = ${m}. ✓`,event:"complete",nodes:u(s),pointers:[{name:"head",index:0,color:"green"}],highlights:s.map((v,y)=>({index:y,color:"green"})),meta:[p,o,`${x} + ${e} = ${m}`],codeLine:10,done:!0}),d}function me(g){const[t="",c="2"]=g.split(";"),x=O(t),e=_(x),r=e.length,n=Math.max(1,Math.trunc(Number(c.trim())||2));if(r===0)return[{description:"List is empty — nothing to reverse.",event:"complete",nodes:[],pointers:[],highlights:[],done:!0}];const l=[],d=e.slice();l.push({description:`Reverse the list in groups of k = ${n}. Each full block of ${n} nodes is reversed; a trailing group with fewer than ${n} nodes is left untouched.`,event:"visit",nodes:u(d),pointers:[],highlights:d.map((o,a)=>({index:a,color:"blue"})),meta:[`k = ${n}`,`length = ${r}`],codeLine:0});let s=0,p=0;for(;s+n<=r;){p+=1,l.push({description:`Group ${p}: look k = ${n} nodes ahead from index ${s}.`,event:"recurse",nodes:u(d),pointers:[{name:"start",index:s,color:"green"}],highlights:I(s,Math.min(s+n,r)).map(h=>({index:h,color:"blue"})),meta:[`group ${p}`],codeLine:3}),l.push({description:`kth node of this group is at index ${s+n-1} (value ${d[s+n-1].value}).`,event:"compare",nodes:u(d),pointers:[{name:"start",index:s,color:"green"},{name:"kth",index:s+n-1,color:"red"}],highlights:I(s,s+n).map(h=>({index:h,color:"yellow"})),meta:[`group ${p}`],codeLine:4}),l.push({description:`Full block of ${n} found → reverse indices ${s}…${s+n-1} in place.`,event:"visit",nodes:u(d),pointers:[{name:"start",index:s,color:"green"},{name:"kth",index:s+n-1,color:"red"}],highlights:I(s,s+n).map(h=>({index:h,color:"yellow"})),codeLine:8});let o=s,a=s+n-1;for(;o({index:m,color:"yellow"})),codeLine:11})}l.push({description:`Group ${p} reversed → [${d.slice(s,s+n).map(h=>h.value).join(", ")}]. Relink it and move groupPrev forward.`,event:"visit",nodes:u(d),pointers:[],highlights:I(s,s+n).map(h=>({index:h,color:"purple"})),codeLine:13}),s+=n}return s({index:o,color:"blue"})),codeLine:4}),l.push({description:`Remaining indices ${s}…${r-1} are fewer than k = ${n} — kth is null, so break and leave them as-is.`,event:"compare",nodes:u(d),pointers:[{name:"rest",index:s,color:"yellow"}],highlights:I(s,r).map(o=>({index:o,color:"blue"})),codeLine:5})),l.push({description:`Done. Result: [${d.map(o=>o.value).join(", ")}]. ✓`,event:"complete",nodes:u(d),pointers:[{name:"head",index:0,color:"green"}],highlights:d.map((o,a)=>({index:a,color:"green"})),codeLine:14,done:!0}),l}function xe(g){const t=_(g),c=[],x=t.length;if(x===0)return[{description:"Empty list is trivially a palindrome.",event:"found",nodes:[],pointers:[],highlights:[],done:!0}];c.push({description:"Phase 1 — find the middle with slow (1×) and fast (2×) pointers.",event:"visit",nodes:u(t),pointers:[{name:"slow",index:0,color:"green"},{name:"fast",index:0,color:"red"}],highlights:[{index:0,color:"blue"}],codeLine:2});let e=0,r=0;for(;r+2<=x-1;)c.push({description:`Loop check: fast can move two nodes ahead (fast at index ${r}). Continue scanning for the middle.`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],codeLine:3}),e+=1,r+=2,c.push({description:`Advance: slow → ${e} (${t[e].value}), fast → ${r} (${t[r].value}).`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],codeLine:4});const n=(x%2===0,e+1);c.push({description:`Middle found at index ${e}. The second half (indices ${n}…${x-1}) will be reversed.`,event:"visit",nodes:u(t),pointers:[{name:"mid",index:e,color:"yellow"}],highlights:Array.from({length:x-n},(m,v)=>({index:n+v,color:"purple"})),meta:["Phase 2 — reverse 2nd half"],codeLine:6});const l=t.slice(0,n),d=t.slice(n).reverse(),s=[...l,...d];c.push({description:"Second half reversed. Set p = head, q = second (start of reversed half). Compare moving inward.",event:"swap",nodes:u(s),pointers:[{name:"p",index:0,color:"green"},{name:"q",index:n,color:"red"}],highlights:Array.from({length:d.length},(m,v)=>({index:l.length+v,color:"purple"})),codeLine:8});let p=0,o=n,a=!0;const h=d.length;for(let m=0;m({index:v,color:a?"green":"red"})),meta:[a?"palindrome = true":"palindrome = false"],codeLine:a?12:10,done:!0}),c}function ge(g){const[t,c=""]=g.split(";"),x=Math.max(1,Number(t.trim())||1),e=c.split(",").map(d=>d.trim()).filter(Boolean),r=[];let n=[];const l=(d,s,p={},o,a=!1)=>{r.push({description:d,event:s,nodes:[],pointers:[],highlights:[],lru:{capacity:x,entries:n.map(h=>({...h})),op:p?.op,hitKey:p?.hitKey??null,missKey:p?.missKey??null,evictKey:p?.evictKey??null},meta:[`capacity = ${x}`,`size = ${n.length}`],codeLine:o,done:a})};l(`Create an LRU cache with capacity ${x}. The front is most-recently-used, the back is least-recently-used.`,"visit",{op:"init"},0);for(const d of e){const s=d.split(/\s+/),p=s[0]?.toLowerCase();if(p==="put"){const o=Number(s[1]),a=Number(s[2]),h=n.findIndex(m=>m.key===o);if(h>=0){const[m]=n.splice(h,1);m.value=a,n.unshift(m),l(`put(${o}, ${a}): key ${o} already exists → update value and move to front (most-recently-used).`,"swap",{op:`put ${o} ${a}`,hitKey:o},11)}else{if(n.length>=x){const m=n[n.length-1];l(`put(${o}, ${a}): cache is full → evict least-recently-used key ${m.key}.`,"pop",{op:`put ${o} ${a}`,evictKey:m.key},13),n=n.slice(0,n.length-1)}n.unshift({key:o,value:a}),l(`put(${o}, ${a}): insert new entry at the front.`,"push",{op:`put ${o} ${a}`,hitKey:o},14)}}else if(p==="get"){const o=Number(s[1]),a=n.findIndex(h=>h.key===o);if(a>=0){const[h]=n.splice(a,1);n.unshift(h),l(`get(${o}) → ${h.value} (HIT). Move key ${o} to the front.`,"found",{op:`get ${o}`,hitKey:o},6)}else l(`get(${o}) → -1 (MISS). Key ${o} is not in the cache.`,"not-found",{op:`get ${o}`,missKey:o},5)}}return l("All operations processed.","complete",{op:"done"},0,!0),r}function fe(g){const t=_(g),c=[],x=t.length;if(x===0)return[{description:"List is empty — nothing to segregate.",event:"complete",nodes:[],pointers:[],highlights:[],done:!0}];c.push({description:"Goal: move all even-valued nodes before all odd-valued nodes, preserving relative order. Scan from the head.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["evens = [ ]","odds = [ ]"],codeLine:0}),c.push({description:"Create an empty evens chain to collect even-valued nodes.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["evens = [ ]"],codeLine:1}),c.push({description:"Create an empty odds chain to collect odd-valued nodes.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["evens = [ ]","odds = [ ]"],codeLine:2}),c.push({description:"Set curr = head and scan the list once.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["evens = [ ]","odds = [ ]"],codeLine:3});const e=[],r=[];for(let l=0;lp.value).join(", ")}]`,`odds = [${r.map(p=>p.value).join(", ")}]`],codeLine:4}),s?e.push(d):r.push(d),c.push({description:`Node ${d.value} is ${s?"EVEN → append to evens chain":"ODD → append to odds chain"}.`,event:"compare",nodes:u(t),pointers:[{name:"curr",index:l,color:"yellow"}],highlights:[{index:l,color:s?"green":"red"}],meta:[`evens = [${e.map(p=>p.value).join(", ")}]`,`odds = [${r.map(p=>p.value).join(", ")}]`],codeLine:s?5:6}),c.push({description:l+1p.value).join(", ")}]`,`odds = [${r.map(p=>p.value).join(", ")}]`],codeLine:7})}const n=[...e,...r];return c.push({description:`Join the chains: evens (${e.length}) followed by odds (${r.length}).`,event:"swap",nodes:u(n),pointers:[],highlights:n.map((l,d)=>({index:d,color:l.value%2===0?"green":"red"})),meta:[`evens = [${e.map(l=>l.value).join(", ")}]`,`odds = [${r.map(l=>l.value).join(", ")}]`],codeLine:8,done:!0}),c}function ve(g){const[t,c="-1"]=g.split(";"),x=O(t),e=_(x),r=e.length,n=Math.trunc(Number(c.trim())),l=n>=0&&n0,d=l?n:null,s=[];if(r===0)return[{description:"List is empty — no cycle.",event:"not-found",nodes:[],pointers:[],highlights:[],cycleTo:null,done:!0}];const p=L=>L===r-1?l?n:-1:L+1;s.push({description:l?`Tail (index ${r-1}) links back to index ${n}. Run Floyd's tortoise & hare from the head.`:"No cycle declared (tail → null). Run Floyd's tortoise & hare to confirm.",event:"visit",nodes:u(e),pointers:[{name:"slow",index:0,color:"green"},{name:"fast",index:0,color:"red"}],highlights:[{index:0,color:"blue"}],cycleTo:d,meta:["Phase 1 — detect"],codeLine:2});let o=0,a=0,h=-1,m=0;const v=r*4+10;for(;m=0?[{name:"slow",index:o,color:"green"}]:[],highlights:[],cycleTo:d,meta:["cycle = false"],codeLine:6,done:!0}),s;if(s.push({description:`slow → ${o} (${e[o].value}), fast → ${a} (${e[a].value}). ${o===a?"They MET — a cycle exists!":"Not equal yet, keep moving."}`,event:o===a?"found":"compare",nodes:u(e),pointers:[{name:"slow",index:o,color:"green"},{name:"fast",index:a,color:"red"}],highlights:o===a?[{index:o,color:"yellow"}]:[{index:o,color:"green"},{index:a,color:"red"}],cycleTo:d,codeLine:o===a?5:4}),o===a){h=o;break}}if(h===-1)return s.push({description:"No cycle detected.",event:"not-found",nodes:u(e),pointers:[],highlights:[],cycleTo:d,codeLine:6,done:!0}),s;let y=1,$=p(h);for(;$!==h;)y+=1,$=p($);s.push({description:`Phase 2 — measure loop length: walk from the meeting node until returning to it → length = ${y}.`,event:"visit",nodes:u(e),pointers:[{name:"meet",index:h,color:"yellow"}],highlights:$e(h,p).map(L=>({index:L,color:"purple"})),cycleTo:d,meta:[`loop length = ${y}`],codeLine:8});let f=0,b=h;for(s.push({description:"Phase 3 — find loop start: reset one pointer to head; advance both one step at a time. They meet at the loop entry.",event:"visit",nodes:u(e),pointers:[{name:"p1",index:f,color:"green"},{name:"p2",index:b,color:"red"}],highlights:[{index:f,color:"green"},{index:b,color:"red"}],cycleTo:d,codeLine:10});f!==b;)f=p(f),b=p(b),s.push({description:`p1 → ${f} (${e[f].value}), p2 → ${b} (${e[b].value}). ${f===b?"Met at the loop start!":"Advance both by one."}`,event:f===b?"found":"compare",nodes:u(e),pointers:[{name:"p1",index:f,color:"green"},{name:"p2",index:b,color:"red"}],highlights:f===b?[{index:f,color:"yellow"}]:[{index:f,color:"green"},{index:b,color:"red"}],cycleTo:d,codeLine:11});const R=f;return s.push({description:`Phase 4 — remove the loop: the node before the loop start (the tail, index ${r-1}) has its next set to null.`,event:"swap",nodes:u(e),pointers:[{name:"start",index:R,color:"yellow"},{name:"tail",index:r-1,color:"red"}],highlights:[{index:R,color:"yellow"},{index:r-1,color:"red"}],cycleTo:d,meta:[`loop start = index ${R}`,`loop length = ${y}`],codeLine:12}),s.push({description:"Loop removed — the list is now a clean acyclic chain ending in null. ✓",event:"complete",nodes:u(e),pointers:[],highlights:e.map((L,w)=>({index:w,color:"green"})),cycleTo:null,meta:["cycle = false",`removed link tail → ${n}`],codeLine:13,done:!0}),s}function $e(g,t){const c=[g];let x=t(g);for(;x!==g;)c.push(x),x=t(x);return c}function ye(g){const t=_(g),c=[],x=t.length;if(x<=1)return[{description:x===0?"Empty list — already sorted.":"Single node — already sorted.",event:"complete",nodes:u(t),pointers:[],highlights:t.map((n,l)=>({index:l,color:"green"})),codeLine:2,done:!0}];c.push({description:"Merge sort: recursively split the list into halves until single nodes remain, then merge sorted runs.",event:"visit",nodes:u(t),pointers:[],highlights:t.map((n,l)=>({index:l,color:"blue"})),meta:["Time O(n log n)"],codeLine:0});const e=t.slice(),r=(n,l)=>{if(l-n<=1){c.push({description:`Base case: indices ${n}…${l-1} is a single node (${e[n].value}) — already sorted, return it.`,event:"visit",nodes:u(e),pointers:[],highlights:n>1;c.push({description:`Split indices ${n}…${l-1} into [${n}…${d-1}] and [${d}…${l-1}].`,event:"recurse",nodes:u(e),pointers:[{name:"mid",index:d,color:"yellow"}],highlights:[...I(n,d).map(m=>({index:m,color:"green"})),...I(d,l).map(m=>({index:m,color:"red"}))],codeLine:3}),c.push({description:`Recurse on the left half: sortList(indices ${n}…${d-1}).`,event:"recurse",nodes:u(e),pointers:[],highlights:I(n,d).map(m=>({index:m,color:"green"})),codeLine:4}),r(n,d),c.push({description:`Recurse on the right half: sortList(indices ${d}…${l-1}).`,event:"recurse",nodes:u(e),pointers:[],highlights:I(d,l).map(m=>({index:m,color:"red"})),codeLine:5}),r(d,l);const s=e.slice(n,d),p=e.slice(d,l),o=[];let a=0,h=0;for(;am.value).join(", ")}] sorted into indices ${n}…${l-1}.`,event:"swap",nodes:u(e),pointers:[],highlights:I(n,l).map(m=>({index:m,color:"purple"})),codeLine:6})};return r(0,x),c.push({description:`Done — list sorted: [${e.map(n=>n.value).join(", ")}]. ✓`,event:"complete",nodes:u(e),pointers:[],highlights:e.map((n,l)=>({index:l,color:"green"})),codeLine:6,done:!0}),c}function I(g,t){const c=[];for(let x=g;xq(g,t.defaultInput)),[n,l]=j.useState(0),[d,s]=j.useState(!1),[p,o]=j.useState(700),a=j.useRef(p),h=j.useRef(null),m=j.useRef(e),{soundEnabled:v,toggleSound:y,playEvent:$}=ee(),f=j.useRef($);j.useEffect(()=>{a.current=p},[p]),j.useEffect(()=>{m.current=e},[e]),j.useEffect(()=>{f.current=$},[$]);const b=j.useCallback(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]);j.useEffect(()=>()=>b(),[b]);const R=e[n]??e[0]??null,L=e.length>0?(n+1)/e.length*100:0,w=j.useCallback(()=>{s(!1),b()},[b]),A=j.useCallback((S,M=!0)=>{const E=m.current,z=Math.max(0,Math.min(E.length-1,S));if(l(z),M){const D=E[z];D&&f.current(D.event,z,E.length)}},[]),k=j.useCallback(()=>{const S=m.current;if(S.length===0)return;let M=n>=S.length-1?0:n;l(M),s(!0);const E=()=>{if(M>=S.length-1){s(!1),b();return}M+=1,l(M);const D=S[M];D&&f.current(D.event,M,S.length),h.current=setTimeout(E,a.current)},z=S[M];z&&f.current(z.event,M,S.length),h.current=setTimeout(E,a.current)},[n,b]),K=j.useCallback(()=>{d?w():k()},[d,k,w]),H=j.useCallback(()=>{w(),A(n+1)},[w,A,n]),U=j.useCallback(()=>{w(),A(n-1)},[w,A,n]),X=j.useCallback(()=>{w(),A(0,!1)},[w,A]),Y=j.useCallback(S=>{w();const E=q(g,S??c);r(E),m.current=E,l(0),E[0]&&f.current(E[0].event,0,E.length)},[c,g,w]),J=j.useMemo(()=>e.reduce((S,M)=>Math.max(S,M.nodes.length),0),[e]);return{info:t,input:c,setInput:x,steps:e,stepIndex:n,currentStep:R,progress:L,isPlaying:d,speed:p,setSpeed:o,soundEnabled:v,toggleSound:y,maxNodes:J,run:Y,togglePlay:K,next:H,prev:U,reset:X,goToStep:S=>{w(),A(S)},canGoNext:n0}}const we={green:{border:"#34d399",bg:"rgba(52,211,153,0.18)",text:"#6ee7b7"},red:{border:"#f87171",bg:"rgba(248,113,113,0.18)",text:"#fca5a5"},yellow:{border:"#fbbf24",bg:"rgba(251,191,36,0.18)",text:"#fde68a"},blue:{border:"#60a5fa",bg:"rgba(96,165,250,0.18)",text:"#93c5fd"},purple:{border:"#c084fc",bg:"rgba(192,132,252,0.18)",text:"#d8b4fe"}},je={border:"#475569",bg:"rgba(30,41,59,0.7)",text:"#cbd5e1"},Le={green:"#34d399",red:"#f87171",yellow:"#fbbf24",blue:"#60a5fa",purple:"#c084fc"},C=60,N=48,W=40,F=C+W,B=6,G=N+78;function ke({step:g}){return g?g.lru?i.jsx(Se,{step:g}):i.jsx(Ne,{step:g}):null}function Ne({step:g}){const{nodes:t,pointers:c,highlights:x,cycleTo:e}=g,r=new Map(x.map(h=>[h.index,h.color])),n=new Map;for(const h of c){const m=n.get(h.index)??[];m.push(h),n.set(h.index,m)}if(t.length===0)return i.jsx("div",{className:"flex h-full min-h-[260px] w-full items-center justify-center",children:i.jsx("div",{className:"flex h-16 w-48 items-center justify-center rounded-lg border-2 border-dashed border-slate-700 text-xs text-slate-600",children:"Empty list — null"})});const l=Math.ceil(t.length/B),s=Math.min(t.length,B)*F+W,p=l*G+20,o=28,a=h=>{const m=Math.floor(h/B);return{x:h%B*F+W,y:m*G+o}};return i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4 overflow-auto px-2",children:[i.jsxs("svg",{viewBox:`0 0 ${s+20} ${p}`,width:"100%",style:{maxWidth:`${s+20}px`,overflow:"visible"},children:[t.map((h,m)=>{const v=m===t.length-1,{x:y,y:$}=a(m),f=m%B!==B-1;if(v)return null;if(f)return i.jsxs("g",{children:[i.jsx("line",{x1:y+C,y1:$+N/2,x2:y+F,y2:$+N/2,stroke:"#475569",strokeWidth:1.6}),i.jsx("polygon",{points:`${y+F},${$+N/2} ${y+F-7},${$+N/2-4} ${y+F-7},${$+N/2+4}`,fill:"#475569"})]},`edge-${h.id}`);const b=a(m+1);return i.jsx("path",{d:`M ${y+C} ${$+N/2} L ${y+C+14} ${$+N/2} L ${y+C+14} ${$+N+28} L ${b.x-14} ${b.y+N/2} L ${b.x} ${b.y+N/2}`,fill:"none",stroke:"#475569",strokeWidth:1.6,markerEnd:""},`wrap-${h.id}`)}),e==null&&t.length>0&&(()=>{const h=t.length-1,{x:m,y:v}=a(h);return i.jsx("text",{x:m+C+22,y:v+N/2+4,textAnchor:"middle",fontSize:"10",fill:"#64748b",fontFamily:"monospace",children:"null"},"null")})(),e!=null&&t.length>0&&(()=>{const h=a(t.length-1),m=a(e),v=h.x+C/2,y=h.y+N,$=m.x+C/2,f=m.y+N,b=Math.max(y,f)+46;return i.jsxs("g",{children:[i.jsx("path",{d:`M ${v} ${y} C ${v} ${b}, ${$} ${b}, ${$} ${f}`,fill:"none",stroke:"#f59e0b",strokeWidth:1.8,strokeDasharray:"5 4"}),i.jsx("polygon",{points:`${$},${f} ${$-4},${f+8} ${$+4},${f+8}`,fill:"#f59e0b"}),i.jsxs("text",{x:(v+$)/2,y:b+12,textAnchor:"middle",fontSize:"9",fill:"#fbbf24",fontFamily:"monospace",children:["cycle → index ",e]})]})})(),t.map((h,m)=>{const{x:v,y}=a(m),$=r.get(m),f=$?we[$]:je,b=n.get(m)??[];return i.jsxs("g",{children:[m===0&&i.jsx("text",{x:v+C/2,y:y-16,textAnchor:"middle",fontSize:"9",fill:"#818cf8",fontFamily:"monospace",children:"head"}),b.map((R,L)=>i.jsx("g",{children:i.jsxs("text",{x:v+C/2,y:y-6-L*11,textAnchor:"middle",fontSize:"9",fontWeight:"bold",fill:Le[R.color??"blue"],fontFamily:"monospace",children:[R.name,"↓"]})},R.name)),i.jsx("rect",{x:v,y,width:C,height:N,rx:8,fill:f.bg,stroke:f.border,strokeWidth:$?2.2:1.5}),i.jsx("text",{x:v+C/2,y:y+N/2+5,textAnchor:"middle",fontSize:"15",fontWeight:"bold",fill:f.text,fontFamily:"sans-serif",children:h.value}),i.jsxs("text",{x:v+C/2,y:y+N+12,textAnchor:"middle",fontSize:"8",fill:"#475569",fontFamily:"monospace",children:["[",m,"]"]})]},h.id)})]}),g.description&&i.jsx("div",{className:"w-full max-w-xl rounded-lg bg-slate-800/60 px-4 py-2 text-center text-xs leading-relaxed text-indigo-300",children:g.description}),g.meta&&g.meta.length>0&&i.jsx("div",{className:"flex flex-wrap justify-center gap-1.5",children:g.meta.map(h=>i.jsx("span",{className:"rounded-full bg-slate-800/80 px-2.5 py-0.5 text-[10px] font-mono text-slate-300 ring-1 ring-slate-700/50",children:h},h))})]})}function Se({step:g}){const t=g.lru,c=Array.from({length:t.capacity});return i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-5 overflow-auto px-2",children:[i.jsxs("div",{className:"flex w-full max-w-2xl items-center justify-between text-[10px] uppercase tracking-wider text-slate-500",children:[i.jsx("span",{className:"text-emerald-400",children:"← Most recently used"}),i.jsx("span",{className:"text-rose-400",children:"Least recently used →"})]}),i.jsx("div",{className:"flex flex-wrap items-center justify-center gap-3",children:c.map((x,e)=>{const r=t.entries[e];if(!r)return i.jsx("div",{className:"flex h-20 w-24 flex-col items-center justify-center rounded-xl border-2 border-dashed border-slate-700 text-[10px] text-slate-600",children:"empty"},`empty-${e}`);const n=t.hitKey===r.key,d=t.evictKey===r.key?"border-rose-400 bg-rose-500/15":n?"border-emerald-400 bg-emerald-500/15":"border-slate-600 bg-slate-800/70";return i.jsxs("div",{className:`flex h-20 w-24 flex-col items-center justify-center rounded-xl border-2 ${d} transition-all`,children:[i.jsxs("span",{className:"text-[9px] font-mono uppercase tracking-wide text-slate-400",children:["key ",r.key]}),i.jsx("span",{className:"mt-0.5 text-xl font-bold text-white",children:r.value}),e===0&&i.jsx("span",{className:"mt-0.5 text-[8px] font-mono text-emerald-400",children:"MRU"}),e===t.entries.length-1&&t.entries.length===t.capacity&&e!==0&&i.jsx("span",{className:"mt-0.5 text-[8px] font-mono text-rose-400",children:"LRU"})]},r.key)})}),t.missKey!=null&&i.jsxs("div",{className:"rounded-lg bg-rose-500/10 px-3 py-1 text-xs font-mono text-rose-300 ring-1 ring-rose-500/30",children:["MISS · key ",t.missKey," not present"]}),g.description&&i.jsx("div",{className:"w-full max-w-xl rounded-lg bg-slate-800/60 px-4 py-2 text-center text-xs leading-relaxed text-indigo-300",children:g.description}),g.meta&&g.meta.length>0&&i.jsx("div",{className:"flex flex-wrap justify-center gap-1.5",children:g.meta.map(x=>i.jsx("span",{className:"rounded-full bg-slate-800/80 px-2.5 py-0.5 text-[10px] font-mono text-slate-300 ring-1 ring-slate-700/50",children:x},x))})]})}const P=(g,t)=>Math.floor(Math.random()*(t-g+1))+g;function T(g,t=1,c=99){return Array.from({length:g},()=>P(t,c))}function Re(g){switch(g){case"find-middle":return T(P(5,9)).join(",");case"palindrome":{const t=T(P(2,3));if(Math.random()<.6){const c=Math.random()<.5?[P(1,9)]:[];return[...t,...c,...[...t].reverse()].join(",")}return T(P(4,7)).join(",")}case"lru-cache":{const t=P(2,3),c=[1,2,3,4,5],x=[];for(let e=0;e{const w=Re(t);e(w),m(w)};return i.jsxs("aside",{className:"w-full space-y-4 xl:w-80 xl:shrink-0",children:[i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Input"}),i.jsx("label",{className:"text-[11px] text-slate-500",children:c.inputLabel}),i.jsx("textarea",{value:x,onChange:w=>e(w.target.value),rows:3,className:"mt-1 w-full resize-none rounded-xl bg-slate-950/70 px-3 py-2 text-xs font-mono text-slate-200 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50"}),i.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:c.helper}),i.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[i.jsx("button",{onClick:()=>m(),className:"rounded-xl bg-indigo-500/20 px-3 py-2 text-xs font-semibold text-indigo-300 ring-1 ring-indigo-500/40 hover:bg-indigo-500/30",children:"Build Steps"}),i.jsxs("button",{onClick:L,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[i.jsx(ne,{size:13})," Random"]})]})]}),i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Playback"}),i.jsxs("span",{className:"font-mono text-xs text-indigo-300",children:[Math.min(n+1,r.length)," / ",r.length]})]}),i.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-slate-800",children:i.jsx("div",{className:"h-full rounded-full bg-indigo-400 transition-all",style:{width:`${d}%`}})}),i.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Animation Speed"}),i.jsxs("span",{className:"font-mono text-[10px] text-indigo-300",children:[(p/1e3).toFixed(2),"s"]})]}),i.jsx("input",{type:"range",min:120,max:3e3,step:20,value:3120-p,onChange:w=>o(3120-Number(w.target.value)),className:"w-full accent-indigo-400","aria-label":"Animation speed"}),i.jsxs("div",{className:"mt-1 flex justify-between text-[9px] uppercase tracking-wide text-slate-600",children:[i.jsx("span",{children:"Slow"}),i.jsx("span",{children:"Fast"})]})]}),i.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[i.jsxs("button",{onClick:$,disabled:!R,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:[i.jsx(se,{size:13})," Back"]}),i.jsx("button",{onClick:v,className:`inline-flex items-center justify-center gap-1 rounded-xl px-2 py-2 text-xs font-semibold ring-1 ${s?"bg-amber-500/15 text-amber-300 ring-amber-500/30":"bg-emerald-500/15 text-emerald-300 ring-emerald-500/30"}`,children:s?i.jsxs(i.Fragment,{children:[i.jsx(ie,{size:13})," Pause"]}):i.jsxs(i.Fragment,{children:[i.jsx(re,{size:13})," Play"]})}),i.jsxs("button",{onClick:y,disabled:!b,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:["Next ",i.jsx(oe,{size:13})]})]}),i.jsxs("button",{onClick:f,className:"mt-2 inline-flex w-full items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[i.jsx(le,{size:13})," Reset"]}),i.jsx("p",{className:"mt-3 min-h-10 text-xs leading-relaxed text-slate-300",children:l?.description})]}),i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsxs("button",{onClick:()=>h(!a),className:`inline-flex w-full items-center justify-center gap-2 rounded-xl px-3 py-2 text-xs font-semibold ring-1 ${a?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[a?i.jsx(ae,{size:14}):i.jsx(de,{size:14}),a?"Sound On":"Sound Off"]}),i.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:c.tags.map(w=>i.jsx("span",{className:"rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-300 ring-1 ring-violet-500/20",children:w},w))}),i.jsx("p",{className:"mt-2 text-[10px] font-mono text-slate-500",children:c.complexity})]})]})}function Ke({problem:g}){const t=be(g),{info:c}=t;return i.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[i.jsxs("main",{className:"order-last flex min-h-[520px] flex-1 flex-col gap-4 xl:order-first",children:[i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm",children:[i.jsxs(Q,{to:"/algorithms/linked-list",className:"mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-slate-400 transition-colors hover:text-indigo-300",children:[i.jsx(ce,{size:13})," Linked List Algorithms"]}),i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-indigo-300",children:"Linked List Algorithms"}),i.jsx("h2",{className:"mt-1 text-xl font-bold text-white",children:c.title}),i.jsx("p",{className:"mt-1 text-sm text-slate-400",children:c.subtitle})]}),i.jsx("section",{className:"flex flex-1 items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-900/40 p-4 backdrop-blur-sm",children:i.jsx(ke,{step:t.currentStep})}),i.jsx(te,{pseudocode:c.pseudocode,activeLine:t.currentStep?.codeLine??null})]}),i.jsx(Ae,{hook:t,problem:g})]})}export{Ke as default}; +import{r as j,j as i,L as Q}from"./index-DBkLeWDs.js";import{P as Z}from"./linkedListAlgo-0_WYfSZm.js";import{u as ee,A as te}from"./AlgorithmCodePanel-CE3r0DXd.js";import{S as ne}from"./shuffle-Dlr-c52A.js";import{C as se,a as oe}from"./chevron-right-CFBAUJsk.js";import{P as ie}from"./pause-CG1snUW9.js";import{P as re}from"./play-mcIZClKO.js";import{R as le}from"./rotate-ccw-7GTUOPy4.js";import{V as ae,a as de}from"./volume-x-BSx9gxSg.js";import{A as ce}from"./arrow-left-CTMPG6pL.js";import"./audioContext-NbgqvQGz.js";let V=1;function _(g){return g.map(t=>({id:V++,value:t}))}function O(g){return g.split(",").map(t=>Number(t.trim())).filter(t=>Number.isFinite(t))}function u(g){return g.map(t=>({...t}))}function q(g,t){switch(g){case"find-middle":return he(O(t));case"reverse-list":return pe(O(t));case"add-two-numbers":return ue(t);case"reverse-k-group":return me(t);case"palindrome":return xe(O(t));case"lru-cache":return ge(t);case"segregate":return fe(O(t));case"detect-cycle":return ve(t);case"sort-list":return ye(O(t));default:return[]}}function he(g){const t=_(g),c=[],x=t.length;if(x===0)return[{description:"List is empty — no middle.",event:"not-found",nodes:[],pointers:[],highlights:[],done:!0}];c.push({description:"Set slow = head (index 0).",event:"visit",nodes:u(t),pointers:[{name:"slow",index:0,color:"green"}],highlights:[{index:0,color:"blue"}],meta:["slow = head"],codeLine:1}),c.push({description:"Set fast = head (index 0). Both pointers start together.",event:"visit",nodes:u(t),pointers:[{name:"slow",index:0,color:"green"},{name:"fast",index:0,color:"red"}],highlights:[{index:0,color:"blue"}],meta:["slow = head","fast = head"],codeLine:2});let e=0,r=0;for(;r+2<=x-1;)c.push({description:`Loop check: fast can move two nodes ahead (fast at index ${r}). Enter the loop.`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:3}),e+=1,c.push({description:`slow = slow.next → index ${e} (value ${t[e].value}). slow walks 1 step.`,event:"visit",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:4}),r+=2,c.push({description:`fast = fast.next.next → index ${r} (value ${t[r].value}). fast walks 2 steps.`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:5});return r+1===x-1&&(c.push({description:"Loop check: fast has a single node ahead — take one more paired step.",event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:3}),e+=1,r+=1,c.push({description:`slow → ${e} (${t[e].value}); fast → ${r} (${t[r].value}).`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],meta:[`slow = ${e}`,`fast = ${r}`],codeLine:5})),c.push({description:`fast reached the end, so slow stops at the middle: index ${e}, value ${t[e].value}.`,event:"found",nodes:u(t),pointers:[{name:"middle",index:e,color:"green"}],highlights:[{index:e,color:"green"}],meta:[`middle index = ${e}`,`middle value = ${t[e].value}`],codeLine:6,done:!0}),c}function pe(g){const t=_(g),c=t.length;if(c===0)return[{description:"List is empty — nothing to reverse.",event:"complete",nodes:[],pointers:[],highlights:[],done:!0}];if(c===1)return[{description:"Single node — reversing leaves it unchanged.",event:"complete",nodes:u(t),pointers:[{name:"head",index:0,color:"green"}],highlights:[{index:0,color:"green"}],codeLine:8,done:!0}];const x=[];x.push({description:"Set prev = null. This will become the new head once we finish.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["prev = null"],codeLine:1}),x.push({description:"Set curr = head. We walk the list once, flipping each next pointer to point backwards.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["prev = null","curr = head"],codeLine:2});const e=[];for(let n=0;nh.value).join(", ")}]`],codeLine:3}),x.push({description:`Remember next = ${n+1h.value).join(", ")}]`],codeLine:4}),x.push({description:`Flip curr (${l.value}) → point at prev (${e.length?e[e.length-1].value:"null"}).`,event:"swap",nodes:u(d),pointers:[...p,{name:"curr",index:s,color:"yellow"},...o],highlights:[{index:s,color:"yellow"}],meta:[`reversed = [${[...e].reverse().map(h=>h.value).join(", ")}]`],codeLine:5}),e.push(l);const a=[...e].reverse().concat(t.slice(n+1));x.push({description:`Advance prev = ${l.value}. Reversed prefix is now [${[...e].reverse().map(h=>h.value).join(", ")}].`,event:"visit",nodes:u(a),pointers:[{name:"prev",index:0,color:"green"},...n+1h.value).join(", ")}]`],codeLine:6}),x.push({description:`Advance curr = ${n+1h.value).join(", ")}]`],codeLine:7})}const r=[...e].reverse();return x.push({description:`curr is null → done. prev is the new head. Reversed list: [${r.map(n=>n.value).join(", ")}]. ✓`,event:"complete",nodes:u(r),pointers:[{name:"head",index:0,color:"green"}],highlights:r.map((n,l)=>({index:l,color:"green"})),codeLine:8,done:!0}),x}function ue(g){const[t="0",c="0"]=g.split(";"),x=Math.abs(Math.trunc(Number(t.trim())||0)),e=Math.abs(Math.trunc(Number(c.trim())||0)),r=v=>String(v).split("").map(Number).reverse(),n=r(x),l=r(e),d=[],s=[],p=`A = ${n.join("→")} (=${x})`,o=`B = ${l.join("→")} (=${e})`;d.push({description:`Add ${x} + ${e}. Digits are stored least-significant-first, so we add node by node from the front, carrying overflow.`,event:"visit",nodes:[],pointers:[],highlights:[],meta:[p,o,"carry = 0"],codeLine:1}),d.push({description:"Initialise carry = 0 before walking both digit lists.",event:"visit",nodes:[],pointers:[],highlights:[],meta:[p,o,"carry = 0"],codeLine:2});let a=0;const h=Math.max(n.length,l.length);for(let v=0;v0;v+=1){const y=n[v]??0,$=l[v]??0,f=a,b=v=0?[{name:"tail",index:L,color:"green"}]:[],A=L>=0?[{index:L,color:"blue"}]:[];d.push({description:`Loop check: ${b?"A has a digit":"A exhausted"}, ${R?"B has a digit":"B exhausted"}, carry = ${f}. Continue.`,event:"visit",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`carry = ${f}`],codeLine:3});let k=f;d.push({description:`Start this position's sum with the incoming carry: sum = ${f}.`,event:"visit",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`sum = ${k}`,`carry = ${f}`],codeLine:4}),k+=y,d.push({description:b?`A has digit ${y} at this position → sum += ${y} = ${k}; advance A.`:`A is exhausted at this position → nothing to add. sum = ${k}.`,event:"compare",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`sum = ${k}`,`carry = ${f}`],codeLine:5}),k+=$,d.push({description:R?`B has digit ${$} at this position → sum += ${$} = ${k}; advance B.`:`B is exhausted at this position → nothing to add. sum = ${k}.`,event:"compare",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`sum = ${k}`,`carry = ${f}`],codeLine:6}),a=Math.floor(k/10);const K=k%10;d.push({description:`carry = floor(${k} / 10) = ${a}.`,event:"compare",nodes:u(s),pointers:w,highlights:A,meta:[p,o,`sum = ${k}`,`carry = ${a}`],codeLine:7}),s.push({id:V++,value:K}),d.push({description:`Append a node with digit sum % 10 = ${K}.`,event:"push",nodes:u(s),pointers:[{name:"tail",index:s.length-1,color:"green"}],highlights:[{index:s.length-1,color:"green"}],meta:[p,o,`sum = ${k}`,`carry = ${a}`],codeLine:8}),d.push({description:`Advance tail to the node just appended (digit ${K}).`,event:"visit",nodes:u(s),pointers:[{name:"tail",index:s.length-1,color:"green"}],highlights:[{index:s.length-1,color:"blue"}],meta:[p,o,`carry = ${a}`],codeLine:9})}const m=x+e;return d.push({description:`Done. Result list (least-significant-first): [${s.map(v=>v.value).join(", ")}] = ${m}. ✓`,event:"complete",nodes:u(s),pointers:[{name:"head",index:0,color:"green"}],highlights:s.map((v,y)=>({index:y,color:"green"})),meta:[p,o,`${x} + ${e} = ${m}`],codeLine:10,done:!0}),d}function me(g){const[t="",c="2"]=g.split(";"),x=O(t),e=_(x),r=e.length,n=Math.max(1,Math.trunc(Number(c.trim())||2));if(r===0)return[{description:"List is empty — nothing to reverse.",event:"complete",nodes:[],pointers:[],highlights:[],done:!0}];const l=[],d=e.slice();l.push({description:`Reverse the list in groups of k = ${n}. Each full block of ${n} nodes is reversed; a trailing group with fewer than ${n} nodes is left untouched.`,event:"visit",nodes:u(d),pointers:[],highlights:d.map((o,a)=>({index:a,color:"blue"})),meta:[`k = ${n}`,`length = ${r}`],codeLine:0});let s=0,p=0;for(;s+n<=r;){p+=1,l.push({description:`Group ${p}: look k = ${n} nodes ahead from index ${s}.`,event:"recurse",nodes:u(d),pointers:[{name:"start",index:s,color:"green"}],highlights:I(s,Math.min(s+n,r)).map(h=>({index:h,color:"blue"})),meta:[`group ${p}`],codeLine:3}),l.push({description:`kth node of this group is at index ${s+n-1} (value ${d[s+n-1].value}).`,event:"compare",nodes:u(d),pointers:[{name:"start",index:s,color:"green"},{name:"kth",index:s+n-1,color:"red"}],highlights:I(s,s+n).map(h=>({index:h,color:"yellow"})),meta:[`group ${p}`],codeLine:4}),l.push({description:`Full block of ${n} found → reverse indices ${s}…${s+n-1} in place.`,event:"visit",nodes:u(d),pointers:[{name:"start",index:s,color:"green"},{name:"kth",index:s+n-1,color:"red"}],highlights:I(s,s+n).map(h=>({index:h,color:"yellow"})),codeLine:8});let o=s,a=s+n-1;for(;o({index:m,color:"yellow"})),codeLine:11})}l.push({description:`Group ${p} reversed → [${d.slice(s,s+n).map(h=>h.value).join(", ")}]. Relink it and move groupPrev forward.`,event:"visit",nodes:u(d),pointers:[],highlights:I(s,s+n).map(h=>({index:h,color:"purple"})),codeLine:13}),s+=n}return s({index:o,color:"blue"})),codeLine:4}),l.push({description:`Remaining indices ${s}…${r-1} are fewer than k = ${n} — kth is null, so break and leave them as-is.`,event:"compare",nodes:u(d),pointers:[{name:"rest",index:s,color:"yellow"}],highlights:I(s,r).map(o=>({index:o,color:"blue"})),codeLine:5})),l.push({description:`Done. Result: [${d.map(o=>o.value).join(", ")}]. ✓`,event:"complete",nodes:u(d),pointers:[{name:"head",index:0,color:"green"}],highlights:d.map((o,a)=>({index:a,color:"green"})),codeLine:14,done:!0}),l}function xe(g){const t=_(g),c=[],x=t.length;if(x===0)return[{description:"Empty list is trivially a palindrome.",event:"found",nodes:[],pointers:[],highlights:[],done:!0}];c.push({description:"Phase 1 — find the middle with slow (1×) and fast (2×) pointers.",event:"visit",nodes:u(t),pointers:[{name:"slow",index:0,color:"green"},{name:"fast",index:0,color:"red"}],highlights:[{index:0,color:"blue"}],codeLine:2});let e=0,r=0;for(;r+2<=x-1;)c.push({description:`Loop check: fast can move two nodes ahead (fast at index ${r}). Continue scanning for the middle.`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],codeLine:3}),e+=1,r+=2,c.push({description:`Advance: slow → ${e} (${t[e].value}), fast → ${r} (${t[r].value}).`,event:"compare",nodes:u(t),pointers:[{name:"slow",index:e,color:"green"},{name:"fast",index:r,color:"red"}],highlights:[{index:e,color:"green"},{index:r,color:"red"}],codeLine:4});const n=(x%2===0,e+1);c.push({description:`Middle found at index ${e}. The second half (indices ${n}…${x-1}) will be reversed.`,event:"visit",nodes:u(t),pointers:[{name:"mid",index:e,color:"yellow"}],highlights:Array.from({length:x-n},(m,v)=>({index:n+v,color:"purple"})),meta:["Phase 2 — reverse 2nd half"],codeLine:6});const l=t.slice(0,n),d=t.slice(n).reverse(),s=[...l,...d];c.push({description:"Second half reversed. Set p = head, q = second (start of reversed half). Compare moving inward.",event:"swap",nodes:u(s),pointers:[{name:"p",index:0,color:"green"},{name:"q",index:n,color:"red"}],highlights:Array.from({length:d.length},(m,v)=>({index:l.length+v,color:"purple"})),codeLine:8});let p=0,o=n,a=!0;const h=d.length;for(let m=0;m({index:v,color:a?"green":"red"})),meta:[a?"palindrome = true":"palindrome = false"],codeLine:a?12:10,done:!0}),c}function ge(g){const[t,c=""]=g.split(";"),x=Math.max(1,Number(t.trim())||1),e=c.split(",").map(d=>d.trim()).filter(Boolean),r=[];let n=[];const l=(d,s,p={},o,a=!1)=>{r.push({description:d,event:s,nodes:[],pointers:[],highlights:[],lru:{capacity:x,entries:n.map(h=>({...h})),op:p?.op,hitKey:p?.hitKey??null,missKey:p?.missKey??null,evictKey:p?.evictKey??null},meta:[`capacity = ${x}`,`size = ${n.length}`],codeLine:o,done:a})};l(`Create an LRU cache with capacity ${x}. The front is most-recently-used, the back is least-recently-used.`,"visit",{op:"init"},0);for(const d of e){const s=d.split(/\s+/),p=s[0]?.toLowerCase();if(p==="put"){const o=Number(s[1]),a=Number(s[2]),h=n.findIndex(m=>m.key===o);if(h>=0){const[m]=n.splice(h,1);m.value=a,n.unshift(m),l(`put(${o}, ${a}): key ${o} already exists → update value and move to front (most-recently-used).`,"swap",{op:`put ${o} ${a}`,hitKey:o},11)}else{if(n.length>=x){const m=n[n.length-1];l(`put(${o}, ${a}): cache is full → evict least-recently-used key ${m.key}.`,"pop",{op:`put ${o} ${a}`,evictKey:m.key},13),n=n.slice(0,n.length-1)}n.unshift({key:o,value:a}),l(`put(${o}, ${a}): insert new entry at the front.`,"push",{op:`put ${o} ${a}`,hitKey:o},14)}}else if(p==="get"){const o=Number(s[1]),a=n.findIndex(h=>h.key===o);if(a>=0){const[h]=n.splice(a,1);n.unshift(h),l(`get(${o}) → ${h.value} (HIT). Move key ${o} to the front.`,"found",{op:`get ${o}`,hitKey:o},6)}else l(`get(${o}) → -1 (MISS). Key ${o} is not in the cache.`,"not-found",{op:`get ${o}`,missKey:o},5)}}return l("All operations processed.","complete",{op:"done"},0,!0),r}function fe(g){const t=_(g),c=[],x=t.length;if(x===0)return[{description:"List is empty — nothing to segregate.",event:"complete",nodes:[],pointers:[],highlights:[],done:!0}];c.push({description:"Goal: move all even-valued nodes before all odd-valued nodes, preserving relative order. Scan from the head.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["evens = [ ]","odds = [ ]"],codeLine:0}),c.push({description:"Create an empty evens chain to collect even-valued nodes.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["evens = [ ]"],codeLine:1}),c.push({description:"Create an empty odds chain to collect odd-valued nodes.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["evens = [ ]","odds = [ ]"],codeLine:2}),c.push({description:"Set curr = head and scan the list once.",event:"visit",nodes:u(t),pointers:[{name:"curr",index:0,color:"yellow"}],highlights:[{index:0,color:"blue"}],meta:["evens = [ ]","odds = [ ]"],codeLine:3});const e=[],r=[];for(let l=0;lp.value).join(", ")}]`,`odds = [${r.map(p=>p.value).join(", ")}]`],codeLine:4}),s?e.push(d):r.push(d),c.push({description:`Node ${d.value} is ${s?"EVEN → append to evens chain":"ODD → append to odds chain"}.`,event:"compare",nodes:u(t),pointers:[{name:"curr",index:l,color:"yellow"}],highlights:[{index:l,color:s?"green":"red"}],meta:[`evens = [${e.map(p=>p.value).join(", ")}]`,`odds = [${r.map(p=>p.value).join(", ")}]`],codeLine:s?5:6}),c.push({description:l+1p.value).join(", ")}]`,`odds = [${r.map(p=>p.value).join(", ")}]`],codeLine:7})}const n=[...e,...r];return c.push({description:`Join the chains: evens (${e.length}) followed by odds (${r.length}).`,event:"swap",nodes:u(n),pointers:[],highlights:n.map((l,d)=>({index:d,color:l.value%2===0?"green":"red"})),meta:[`evens = [${e.map(l=>l.value).join(", ")}]`,`odds = [${r.map(l=>l.value).join(", ")}]`],codeLine:8,done:!0}),c}function ve(g){const[t,c="-1"]=g.split(";"),x=O(t),e=_(x),r=e.length,n=Math.trunc(Number(c.trim())),l=n>=0&&n0,d=l?n:null,s=[];if(r===0)return[{description:"List is empty — no cycle.",event:"not-found",nodes:[],pointers:[],highlights:[],cycleTo:null,done:!0}];const p=L=>L===r-1?l?n:-1:L+1;s.push({description:l?`Tail (index ${r-1}) links back to index ${n}. Run Floyd's tortoise & hare from the head.`:"No cycle declared (tail → null). Run Floyd's tortoise & hare to confirm.",event:"visit",nodes:u(e),pointers:[{name:"slow",index:0,color:"green"},{name:"fast",index:0,color:"red"}],highlights:[{index:0,color:"blue"}],cycleTo:d,meta:["Phase 1 — detect"],codeLine:2});let o=0,a=0,h=-1,m=0;const v=r*4+10;for(;m=0?[{name:"slow",index:o,color:"green"}]:[],highlights:[],cycleTo:d,meta:["cycle = false"],codeLine:6,done:!0}),s;if(s.push({description:`slow → ${o} (${e[o].value}), fast → ${a} (${e[a].value}). ${o===a?"They MET — a cycle exists!":"Not equal yet, keep moving."}`,event:o===a?"found":"compare",nodes:u(e),pointers:[{name:"slow",index:o,color:"green"},{name:"fast",index:a,color:"red"}],highlights:o===a?[{index:o,color:"yellow"}]:[{index:o,color:"green"},{index:a,color:"red"}],cycleTo:d,codeLine:o===a?5:4}),o===a){h=o;break}}if(h===-1)return s.push({description:"No cycle detected.",event:"not-found",nodes:u(e),pointers:[],highlights:[],cycleTo:d,codeLine:6,done:!0}),s;let y=1,$=p(h);for(;$!==h;)y+=1,$=p($);s.push({description:`Phase 2 — measure loop length: walk from the meeting node until returning to it → length = ${y}.`,event:"visit",nodes:u(e),pointers:[{name:"meet",index:h,color:"yellow"}],highlights:$e(h,p).map(L=>({index:L,color:"purple"})),cycleTo:d,meta:[`loop length = ${y}`],codeLine:8});let f=0,b=h;for(s.push({description:"Phase 3 — find loop start: reset one pointer to head; advance both one step at a time. They meet at the loop entry.",event:"visit",nodes:u(e),pointers:[{name:"p1",index:f,color:"green"},{name:"p2",index:b,color:"red"}],highlights:[{index:f,color:"green"},{index:b,color:"red"}],cycleTo:d,codeLine:10});f!==b;)f=p(f),b=p(b),s.push({description:`p1 → ${f} (${e[f].value}), p2 → ${b} (${e[b].value}). ${f===b?"Met at the loop start!":"Advance both by one."}`,event:f===b?"found":"compare",nodes:u(e),pointers:[{name:"p1",index:f,color:"green"},{name:"p2",index:b,color:"red"}],highlights:f===b?[{index:f,color:"yellow"}]:[{index:f,color:"green"},{index:b,color:"red"}],cycleTo:d,codeLine:11});const R=f;return s.push({description:`Phase 4 — remove the loop: the node before the loop start (the tail, index ${r-1}) has its next set to null.`,event:"swap",nodes:u(e),pointers:[{name:"start",index:R,color:"yellow"},{name:"tail",index:r-1,color:"red"}],highlights:[{index:R,color:"yellow"},{index:r-1,color:"red"}],cycleTo:d,meta:[`loop start = index ${R}`,`loop length = ${y}`],codeLine:12}),s.push({description:"Loop removed — the list is now a clean acyclic chain ending in null. ✓",event:"complete",nodes:u(e),pointers:[],highlights:e.map((L,w)=>({index:w,color:"green"})),cycleTo:null,meta:["cycle = false",`removed link tail → ${n}`],codeLine:13,done:!0}),s}function $e(g,t){const c=[g];let x=t(g);for(;x!==g;)c.push(x),x=t(x);return c}function ye(g){const t=_(g),c=[],x=t.length;if(x<=1)return[{description:x===0?"Empty list — already sorted.":"Single node — already sorted.",event:"complete",nodes:u(t),pointers:[],highlights:t.map((n,l)=>({index:l,color:"green"})),codeLine:2,done:!0}];c.push({description:"Merge sort: recursively split the list into halves until single nodes remain, then merge sorted runs.",event:"visit",nodes:u(t),pointers:[],highlights:t.map((n,l)=>({index:l,color:"blue"})),meta:["Time O(n log n)"],codeLine:0});const e=t.slice(),r=(n,l)=>{if(l-n<=1){c.push({description:`Base case: indices ${n}…${l-1} is a single node (${e[n].value}) — already sorted, return it.`,event:"visit",nodes:u(e),pointers:[],highlights:n>1;c.push({description:`Split indices ${n}…${l-1} into [${n}…${d-1}] and [${d}…${l-1}].`,event:"recurse",nodes:u(e),pointers:[{name:"mid",index:d,color:"yellow"}],highlights:[...I(n,d).map(m=>({index:m,color:"green"})),...I(d,l).map(m=>({index:m,color:"red"}))],codeLine:3}),c.push({description:`Recurse on the left half: sortList(indices ${n}…${d-1}).`,event:"recurse",nodes:u(e),pointers:[],highlights:I(n,d).map(m=>({index:m,color:"green"})),codeLine:4}),r(n,d),c.push({description:`Recurse on the right half: sortList(indices ${d}…${l-1}).`,event:"recurse",nodes:u(e),pointers:[],highlights:I(d,l).map(m=>({index:m,color:"red"})),codeLine:5}),r(d,l);const s=e.slice(n,d),p=e.slice(d,l),o=[];let a=0,h=0;for(;am.value).join(", ")}] sorted into indices ${n}…${l-1}.`,event:"swap",nodes:u(e),pointers:[],highlights:I(n,l).map(m=>({index:m,color:"purple"})),codeLine:6})};return r(0,x),c.push({description:`Done — list sorted: [${e.map(n=>n.value).join(", ")}]. ✓`,event:"complete",nodes:u(e),pointers:[],highlights:e.map((n,l)=>({index:l,color:"green"})),codeLine:6,done:!0}),c}function I(g,t){const c=[];for(let x=g;xq(g,t.defaultInput)),[n,l]=j.useState(0),[d,s]=j.useState(!1),[p,o]=j.useState(700),a=j.useRef(p),h=j.useRef(null),m=j.useRef(e),{soundEnabled:v,toggleSound:y,playEvent:$}=ee(),f=j.useRef($);j.useEffect(()=>{a.current=p},[p]),j.useEffect(()=>{m.current=e},[e]),j.useEffect(()=>{f.current=$},[$]);const b=j.useCallback(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]);j.useEffect(()=>()=>b(),[b]);const R=e[n]??e[0]??null,L=e.length>0?(n+1)/e.length*100:0,w=j.useCallback(()=>{s(!1),b()},[b]),A=j.useCallback((S,M=!0)=>{const E=m.current,z=Math.max(0,Math.min(E.length-1,S));if(l(z),M){const D=E[z];D&&f.current(D.event,z,E.length)}},[]),k=j.useCallback(()=>{const S=m.current;if(S.length===0)return;let M=n>=S.length-1?0:n;l(M),s(!0);const E=()=>{if(M>=S.length-1){s(!1),b();return}M+=1,l(M);const D=S[M];D&&f.current(D.event,M,S.length),h.current=setTimeout(E,a.current)},z=S[M];z&&f.current(z.event,M,S.length),h.current=setTimeout(E,a.current)},[n,b]),K=j.useCallback(()=>{d?w():k()},[d,k,w]),H=j.useCallback(()=>{w(),A(n+1)},[w,A,n]),U=j.useCallback(()=>{w(),A(n-1)},[w,A,n]),X=j.useCallback(()=>{w(),A(0,!1)},[w,A]),Y=j.useCallback(S=>{w();const E=q(g,S??c);r(E),m.current=E,l(0),E[0]&&f.current(E[0].event,0,E.length)},[c,g,w]),J=j.useMemo(()=>e.reduce((S,M)=>Math.max(S,M.nodes.length),0),[e]);return{info:t,input:c,setInput:x,steps:e,stepIndex:n,currentStep:R,progress:L,isPlaying:d,speed:p,setSpeed:o,soundEnabled:v,toggleSound:y,maxNodes:J,run:Y,togglePlay:K,next:H,prev:U,reset:X,goToStep:S=>{w(),A(S)},canGoNext:n0}}const we={green:{border:"#34d399",bg:"rgba(52,211,153,0.18)",text:"#6ee7b7"},red:{border:"#f87171",bg:"rgba(248,113,113,0.18)",text:"#fca5a5"},yellow:{border:"#fbbf24",bg:"rgba(251,191,36,0.18)",text:"#fde68a"},blue:{border:"#60a5fa",bg:"rgba(96,165,250,0.18)",text:"#93c5fd"},purple:{border:"#c084fc",bg:"rgba(192,132,252,0.18)",text:"#d8b4fe"}},je={border:"#475569",bg:"rgba(30,41,59,0.7)",text:"#cbd5e1"},Le={green:"#34d399",red:"#f87171",yellow:"#fbbf24",blue:"#60a5fa",purple:"#c084fc"},C=60,N=48,W=40,F=C+W,B=6,G=N+78;function ke({step:g}){return g?g.lru?i.jsx(Se,{step:g}):i.jsx(Ne,{step:g}):null}function Ne({step:g}){const{nodes:t,pointers:c,highlights:x,cycleTo:e}=g,r=new Map(x.map(h=>[h.index,h.color])),n=new Map;for(const h of c){const m=n.get(h.index)??[];m.push(h),n.set(h.index,m)}if(t.length===0)return i.jsx("div",{className:"flex h-full min-h-[260px] w-full items-center justify-center",children:i.jsx("div",{className:"flex h-16 w-48 items-center justify-center rounded-lg border-2 border-dashed border-slate-700 text-xs text-slate-600",children:"Empty list — null"})});const l=Math.ceil(t.length/B),s=Math.min(t.length,B)*F+W,p=l*G+20,o=28,a=h=>{const m=Math.floor(h/B);return{x:h%B*F+W,y:m*G+o}};return i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4 overflow-auto px-2",children:[i.jsxs("svg",{viewBox:`0 0 ${s+20} ${p}`,width:"100%",style:{maxWidth:`${s+20}px`,overflow:"visible"},children:[t.map((h,m)=>{const v=m===t.length-1,{x:y,y:$}=a(m),f=m%B!==B-1;if(v)return null;if(f)return i.jsxs("g",{children:[i.jsx("line",{x1:y+C,y1:$+N/2,x2:y+F,y2:$+N/2,stroke:"#475569",strokeWidth:1.6}),i.jsx("polygon",{points:`${y+F},${$+N/2} ${y+F-7},${$+N/2-4} ${y+F-7},${$+N/2+4}`,fill:"#475569"})]},`edge-${h.id}`);const b=a(m+1);return i.jsx("path",{d:`M ${y+C} ${$+N/2} L ${y+C+14} ${$+N/2} L ${y+C+14} ${$+N+28} L ${b.x-14} ${b.y+N/2} L ${b.x} ${b.y+N/2}`,fill:"none",stroke:"#475569",strokeWidth:1.6,markerEnd:""},`wrap-${h.id}`)}),e==null&&t.length>0&&(()=>{const h=t.length-1,{x:m,y:v}=a(h);return i.jsx("text",{x:m+C+22,y:v+N/2+4,textAnchor:"middle",fontSize:"10",fill:"#64748b",fontFamily:"monospace",children:"null"},"null")})(),e!=null&&t.length>0&&(()=>{const h=a(t.length-1),m=a(e),v=h.x+C/2,y=h.y+N,$=m.x+C/2,f=m.y+N,b=Math.max(y,f)+46;return i.jsxs("g",{children:[i.jsx("path",{d:`M ${v} ${y} C ${v} ${b}, ${$} ${b}, ${$} ${f}`,fill:"none",stroke:"#f59e0b",strokeWidth:1.8,strokeDasharray:"5 4"}),i.jsx("polygon",{points:`${$},${f} ${$-4},${f+8} ${$+4},${f+8}`,fill:"#f59e0b"}),i.jsxs("text",{x:(v+$)/2,y:b+12,textAnchor:"middle",fontSize:"9",fill:"#fbbf24",fontFamily:"monospace",children:["cycle → index ",e]})]})})(),t.map((h,m)=>{const{x:v,y}=a(m),$=r.get(m),f=$?we[$]:je,b=n.get(m)??[];return i.jsxs("g",{children:[m===0&&i.jsx("text",{x:v+C/2,y:y-16,textAnchor:"middle",fontSize:"9",fill:"#818cf8",fontFamily:"monospace",children:"head"}),b.map((R,L)=>i.jsx("g",{children:i.jsxs("text",{x:v+C/2,y:y-6-L*11,textAnchor:"middle",fontSize:"9",fontWeight:"bold",fill:Le[R.color??"blue"],fontFamily:"monospace",children:[R.name,"↓"]})},R.name)),i.jsx("rect",{x:v,y,width:C,height:N,rx:8,fill:f.bg,stroke:f.border,strokeWidth:$?2.2:1.5}),i.jsx("text",{x:v+C/2,y:y+N/2+5,textAnchor:"middle",fontSize:"15",fontWeight:"bold",fill:f.text,fontFamily:"sans-serif",children:h.value}),i.jsxs("text",{x:v+C/2,y:y+N+12,textAnchor:"middle",fontSize:"8",fill:"#475569",fontFamily:"monospace",children:["[",m,"]"]})]},h.id)})]}),g.description&&i.jsx("div",{className:"w-full max-w-xl rounded-lg bg-slate-800/60 px-4 py-2 text-center text-xs leading-relaxed text-indigo-300",children:g.description}),g.meta&&g.meta.length>0&&i.jsx("div",{className:"flex flex-wrap justify-center gap-1.5",children:g.meta.map(h=>i.jsx("span",{className:"rounded-full bg-slate-800/80 px-2.5 py-0.5 text-[10px] font-mono text-slate-300 ring-1 ring-slate-700/50",children:h},h))})]})}function Se({step:g}){const t=g.lru,c=Array.from({length:t.capacity});return i.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-5 overflow-auto px-2",children:[i.jsxs("div",{className:"flex w-full max-w-2xl items-center justify-between text-[10px] uppercase tracking-wider text-slate-500",children:[i.jsx("span",{className:"text-emerald-400",children:"← Most recently used"}),i.jsx("span",{className:"text-rose-400",children:"Least recently used →"})]}),i.jsx("div",{className:"flex flex-wrap items-center justify-center gap-3",children:c.map((x,e)=>{const r=t.entries[e];if(!r)return i.jsx("div",{className:"flex h-20 w-24 flex-col items-center justify-center rounded-xl border-2 border-dashed border-slate-700 text-[10px] text-slate-600",children:"empty"},`empty-${e}`);const n=t.hitKey===r.key,d=t.evictKey===r.key?"border-rose-400 bg-rose-500/15":n?"border-emerald-400 bg-emerald-500/15":"border-slate-600 bg-slate-800/70";return i.jsxs("div",{className:`flex h-20 w-24 flex-col items-center justify-center rounded-xl border-2 ${d} transition-all`,children:[i.jsxs("span",{className:"text-[9px] font-mono uppercase tracking-wide text-slate-400",children:["key ",r.key]}),i.jsx("span",{className:"mt-0.5 text-xl font-bold text-white",children:r.value}),e===0&&i.jsx("span",{className:"mt-0.5 text-[8px] font-mono text-emerald-400",children:"MRU"}),e===t.entries.length-1&&t.entries.length===t.capacity&&e!==0&&i.jsx("span",{className:"mt-0.5 text-[8px] font-mono text-rose-400",children:"LRU"})]},r.key)})}),t.missKey!=null&&i.jsxs("div",{className:"rounded-lg bg-rose-500/10 px-3 py-1 text-xs font-mono text-rose-300 ring-1 ring-rose-500/30",children:["MISS · key ",t.missKey," not present"]}),g.description&&i.jsx("div",{className:"w-full max-w-xl rounded-lg bg-slate-800/60 px-4 py-2 text-center text-xs leading-relaxed text-indigo-300",children:g.description}),g.meta&&g.meta.length>0&&i.jsx("div",{className:"flex flex-wrap justify-center gap-1.5",children:g.meta.map(x=>i.jsx("span",{className:"rounded-full bg-slate-800/80 px-2.5 py-0.5 text-[10px] font-mono text-slate-300 ring-1 ring-slate-700/50",children:x},x))})]})}const P=(g,t)=>Math.floor(Math.random()*(t-g+1))+g;function T(g,t=1,c=99){return Array.from({length:g},()=>P(t,c))}function Re(g){switch(g){case"find-middle":return T(P(5,9)).join(",");case"palindrome":{const t=T(P(2,3));if(Math.random()<.6){const c=Math.random()<.5?[P(1,9)]:[];return[...t,...c,...[...t].reverse()].join(",")}return T(P(4,7)).join(",")}case"lru-cache":{const t=P(2,3),c=[1,2,3,4,5],x=[];for(let e=0;e{const w=Re(t);e(w),m(w)};return i.jsxs("aside",{className:"w-full space-y-4 xl:w-80 xl:shrink-0",children:[i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsx("h3",{className:"mb-2 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Input"}),i.jsx("label",{className:"text-[11px] text-slate-500",children:c.inputLabel}),i.jsx("textarea",{value:x,onChange:w=>e(w.target.value),rows:3,className:"mt-1 w-full resize-none rounded-xl bg-slate-950/70 px-3 py-2 text-xs font-mono text-slate-200 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50"}),i.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:c.helper}),i.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[i.jsx("button",{onClick:()=>m(),className:"rounded-xl bg-indigo-500/20 px-3 py-2 text-xs font-semibold text-indigo-300 ring-1 ring-indigo-500/40 hover:bg-indigo-500/30",children:"Build Steps"}),i.jsxs("button",{onClick:L,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[i.jsx(ne,{size:13})," Random"]})]})]}),i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[i.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Playback"}),i.jsxs("span",{className:"font-mono text-xs text-indigo-300",children:[Math.min(n+1,r.length)," / ",r.length]})]}),i.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-slate-800",children:i.jsx("div",{className:"h-full rounded-full bg-indigo-400 transition-all",style:{width:`${d}%`}})}),i.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[i.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[i.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Animation Speed"}),i.jsxs("span",{className:"font-mono text-[10px] text-indigo-300",children:[(p/1e3).toFixed(2),"s"]})]}),i.jsx("input",{type:"range",min:120,max:3e3,step:20,value:3120-p,onChange:w=>o(3120-Number(w.target.value)),className:"w-full accent-indigo-400","aria-label":"Animation speed"}),i.jsxs("div",{className:"mt-1 flex justify-between text-[9px] uppercase tracking-wide text-slate-600",children:[i.jsx("span",{children:"Slow"}),i.jsx("span",{children:"Fast"})]})]}),i.jsxs("div",{className:"mt-3 grid grid-cols-3 gap-2",children:[i.jsxs("button",{onClick:$,disabled:!R,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:[i.jsx(se,{size:13})," Back"]}),i.jsx("button",{onClick:v,className:`inline-flex items-center justify-center gap-1 rounded-xl px-2 py-2 text-xs font-semibold ring-1 ${s?"bg-amber-500/15 text-amber-300 ring-amber-500/30":"bg-emerald-500/15 text-emerald-300 ring-emerald-500/30"}`,children:s?i.jsxs(i.Fragment,{children:[i.jsx(ie,{size:13})," Pause"]}):i.jsxs(i.Fragment,{children:[i.jsx(re,{size:13})," Play"]})}),i.jsxs("button",{onClick:y,disabled:!b,className:"inline-flex items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-2 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 disabled:opacity-30",children:["Next ",i.jsx(oe,{size:13})]})]}),i.jsxs("button",{onClick:f,className:"mt-2 inline-flex w-full items-center justify-center gap-1 rounded-xl bg-slate-800/70 px-3 py-2 text-xs text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:[i.jsx(le,{size:13})," Reset"]}),i.jsx("p",{className:"mt-3 min-h-10 text-xs leading-relaxed text-slate-300",children:l?.description})]}),i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[i.jsxs("button",{onClick:()=>h(!a),className:`inline-flex w-full items-center justify-center gap-2 rounded-xl px-3 py-2 text-xs font-semibold ring-1 ${a?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[a?i.jsx(ae,{size:14}):i.jsx(de,{size:14}),a?"Sound On":"Sound Off"]}),i.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:c.tags.map(w=>i.jsx("span",{className:"rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-300 ring-1 ring-violet-500/20",children:w},w))}),i.jsx("p",{className:"mt-2 text-[10px] font-mono text-slate-500",children:c.complexity})]})]})}function Ke({problem:g}){const t=be(g),{info:c}=t;return i.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[i.jsxs("main",{className:"order-last flex min-h-[520px] flex-1 flex-col gap-4 xl:order-first",children:[i.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-5 backdrop-blur-sm",children:[i.jsxs(Q,{to:"/algorithms/linked-list",className:"mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-slate-400 transition-colors hover:text-indigo-300",children:[i.jsx(ce,{size:13})," Linked List Algorithms"]}),i.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-indigo-300",children:"Linked List Algorithms"}),i.jsx("h2",{className:"mt-1 text-xl font-bold text-white",children:c.title}),i.jsx("p",{className:"mt-1 text-sm text-slate-400",children:c.subtitle})]}),i.jsx("section",{className:"flex flex-1 items-center justify-center rounded-2xl border border-slate-700/50 bg-slate-900/40 p-4 backdrop-blur-sm",children:i.jsx(ke,{step:t.currentStep})}),i.jsx(te,{pseudocode:c.pseudocode,activeLine:t.currentStep?.codeLine??null})]}),i.jsx(Ae,{hook:t,problem:g})]})}export{Ke as default}; diff --git a/docs/assets/LinkedListAlgorithmsPage-bVyDUoFQ.js b/docs/assets/LinkedListAlgorithmsPage-CUxv2ABR.js similarity index 95% rename from docs/assets/LinkedListAlgorithmsPage-bVyDUoFQ.js rename to docs/assets/LinkedListAlgorithmsPage-CUxv2ABR.js index feed259..723e38d 100644 --- a/docs/assets/LinkedListAlgorithmsPage-bVyDUoFQ.js +++ b/docs/assets/LinkedListAlgorithmsPage-CUxv2ABR.js @@ -1 +1 @@ -import{c as a,j as e,L as r,N as c,G as d,a as x,S as m,b as h,A as p}from"./index-eCXyAnHs.js";import{P as g}from"./linkedListAlgo-0_WYfSZm.js";import{A as f}from"./arrow-left-DiyrXoev.js";import{R as u}from"./rotate-ccw-B8GZP3d7.js";const k=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],w=a("repeat",k);const y=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],b=a("scissors",y);const j=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],N=a("skip-back",j);const v=[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]],L=a("spline",v),C={"find-middle":{gradient:"from-sky-500 to-cyan-500",shadowColor:"shadow-sky-500/20",icon:h},"reverse-list":{gradient:"from-rose-500 to-pink-500",shadowColor:"shadow-rose-500/20",icon:u},"add-two-numbers":{gradient:"from-blue-500 to-indigo-500",shadowColor:"shadow-blue-500/20",icon:m},"reverse-k-group":{gradient:"from-purple-500 to-fuchsia-500",shadowColor:"shadow-purple-500/20",icon:N},palindrome:{gradient:"from-fuchsia-500 to-pink-500",shadowColor:"shadow-fuchsia-500/20",icon:L},"lru-cache":{gradient:"from-emerald-500 to-teal-500",shadowColor:"shadow-emerald-500/20",icon:x},segregate:{gradient:"from-lime-500 to-green-500",shadowColor:"shadow-lime-500/20",icon:b},"detect-cycle":{gradient:"from-amber-500 to-orange-500",shadowColor:"shadow-amber-500/20",icon:w},"sort-list":{gradient:"from-indigo-500 to-violet-500",shadowColor:"shadow-indigo-500/20",icon:d}},R=["find-middle","reverse-list","add-two-numbers","reverse-k-group","palindrome","lru-cache","segregate","detect-cycle","sort-list"];function z(){return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center justify-center px-6 pt-12 pb-8 text-center",children:[e.jsxs(r,{to:"/algorithms",className:"mb-4 inline-flex items-center gap-1.5 rounded-full bg-slate-800/60 px-3 py-1.5 text-xs font-medium text-slate-400 ring-1 ring-slate-700/50 transition-colors hover:text-indigo-300",children:[e.jsx(f,{size:13})," Back to Algorithms"]}),e.jsxs("div",{className:"mb-4 inline-flex items-center gap-2 rounded-full bg-indigo-500/10 px-4 py-1.5 ring-1 ring-indigo-500/20",children:[e.jsx(c,{size:14,className:"text-indigo-400"}),e.jsx("span",{className:"text-xs font-medium text-indigo-300",children:"Linked List Algorithms"})]}),e.jsxs("h2",{className:"text-3xl font-extrabold tracking-tight text-white",children:["Linked ",e.jsx("span",{className:"bg-gradient-to-r from-indigo-400 to-fuchsia-400 bg-clip-text text-transparent",children:"List"})]}),e.jsx("p",{className:"mt-3 max-w-2xl mx-auto text-sm text-slate-400 leading-relaxed",children:"Two-pointer tricks, Floyd's cycle detection, merge sort, and an LRU cache — each with step playback, a speed slider, and audio feedback."})]}),e.jsx("section",{className:"px-6 pb-12",children:e.jsx("div",{className:"mx-auto grid max-w-6xl grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3",children:R.map(t=>{const s=g[t],{gradient:l,shadowColor:o,icon:n}=C[t];return e.jsxs(r,{to:`/algorithms/linked-list/${t}`,className:`group relative flex flex-col rounded-2xl border border-slate-700/40 bg-slate-900/50 p-6 shadow-lg backdrop-blur-sm transition-all duration-300 hover:scale-[1.01] hover:border-slate-600/60 hover:bg-slate-900/70 ${o}`,children:[e.jsx("div",{className:`mb-3 flex h-11 w-11 items-center justify-center rounded-xl bg-gradient-to-br ${l} shadow-lg ${o}`,children:e.jsx(n,{size:20,className:"text-white"})}),e.jsx("h4",{className:"text-base font-bold text-white",children:s.title}),e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:s.subtitle}),e.jsx("p",{className:"mt-2 flex-1 text-xs leading-relaxed text-slate-400",children:s.helper}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:s.tags.map(i=>e.jsx("span",{className:"rounded-full bg-slate-800/60 px-2 py-0.5 text-[10px] font-medium text-slate-400",children:i},i))}),e.jsxs("div",{className:"mt-3 flex items-center gap-1 text-xs font-medium text-indigo-400 opacity-0 transition-opacity group-hover:opacity-100",children:["Explore ",e.jsx(p,{size:12})]})]},t)})})})]})}export{z as default}; +import{c as a,j as e,L as r,N as c,G as d,a as x,S as m,b as h,A as p}from"./index-DBkLeWDs.js";import{P as g}from"./linkedListAlgo-0_WYfSZm.js";import{A as f}from"./arrow-left-CTMPG6pL.js";import{R as u}from"./rotate-ccw-7GTUOPy4.js";const k=[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]],w=a("repeat",k);const y=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],b=a("scissors",y);const j=[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]],N=a("skip-back",j);const v=[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]],L=a("spline",v),C={"find-middle":{gradient:"from-sky-500 to-cyan-500",shadowColor:"shadow-sky-500/20",icon:h},"reverse-list":{gradient:"from-rose-500 to-pink-500",shadowColor:"shadow-rose-500/20",icon:u},"add-two-numbers":{gradient:"from-blue-500 to-indigo-500",shadowColor:"shadow-blue-500/20",icon:m},"reverse-k-group":{gradient:"from-purple-500 to-fuchsia-500",shadowColor:"shadow-purple-500/20",icon:N},palindrome:{gradient:"from-fuchsia-500 to-pink-500",shadowColor:"shadow-fuchsia-500/20",icon:L},"lru-cache":{gradient:"from-emerald-500 to-teal-500",shadowColor:"shadow-emerald-500/20",icon:x},segregate:{gradient:"from-lime-500 to-green-500",shadowColor:"shadow-lime-500/20",icon:b},"detect-cycle":{gradient:"from-amber-500 to-orange-500",shadowColor:"shadow-amber-500/20",icon:w},"sort-list":{gradient:"from-indigo-500 to-violet-500",shadowColor:"shadow-indigo-500/20",icon:d}},R=["find-middle","reverse-list","add-two-numbers","reverse-k-group","palindrome","lru-cache","segregate","detect-cycle","sort-list"];function z(){return e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("section",{className:"flex flex-col items-center justify-center px-6 pt-12 pb-8 text-center",children:[e.jsxs(r,{to:"/algorithms",className:"mb-4 inline-flex items-center gap-1.5 rounded-full bg-slate-800/60 px-3 py-1.5 text-xs font-medium text-slate-400 ring-1 ring-slate-700/50 transition-colors hover:text-indigo-300",children:[e.jsx(f,{size:13})," Back to Algorithms"]}),e.jsxs("div",{className:"mb-4 inline-flex items-center gap-2 rounded-full bg-indigo-500/10 px-4 py-1.5 ring-1 ring-indigo-500/20",children:[e.jsx(c,{size:14,className:"text-indigo-400"}),e.jsx("span",{className:"text-xs font-medium text-indigo-300",children:"Linked List Algorithms"})]}),e.jsxs("h2",{className:"text-3xl font-extrabold tracking-tight text-white",children:["Linked ",e.jsx("span",{className:"bg-gradient-to-r from-indigo-400 to-fuchsia-400 bg-clip-text text-transparent",children:"List"})]}),e.jsx("p",{className:"mt-3 max-w-2xl mx-auto text-sm text-slate-400 leading-relaxed",children:"Two-pointer tricks, Floyd's cycle detection, merge sort, and an LRU cache — each with step playback, a speed slider, and audio feedback."})]}),e.jsx("section",{className:"px-6 pb-12",children:e.jsx("div",{className:"mx-auto grid max-w-6xl grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3",children:R.map(t=>{const s=g[t],{gradient:l,shadowColor:o,icon:n}=C[t];return e.jsxs(r,{to:`/algorithms/linked-list/${t}`,className:`group relative flex flex-col rounded-2xl border border-slate-700/40 bg-slate-900/50 p-6 shadow-lg backdrop-blur-sm transition-all duration-300 hover:scale-[1.01] hover:border-slate-600/60 hover:bg-slate-900/70 ${o}`,children:[e.jsx("div",{className:`mb-3 flex h-11 w-11 items-center justify-center rounded-xl bg-gradient-to-br ${l} shadow-lg ${o}`,children:e.jsx(n,{size:20,className:"text-white"})}),e.jsx("h4",{className:"text-base font-bold text-white",children:s.title}),e.jsx("p",{className:"text-[10px] text-slate-500 italic",children:s.subtitle}),e.jsx("p",{className:"mt-2 flex-1 text-xs leading-relaxed text-slate-400",children:s.helper}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:s.tags.map(i=>e.jsx("span",{className:"rounded-full bg-slate-800/60 px-2 py-0.5 text-[10px] font-medium text-slate-400",children:i},i))}),e.jsxs("div",{className:"mt-3 flex items-center gap-1 text-xs font-medium text-indigo-400 opacity-0 transition-opacity group-hover:opacity-100",children:["Explore ",e.jsx(p,{size:12})]})]},t)})})})]})}export{z as default}; diff --git a/docs/assets/LinkedListPage-DDic5oaj.js b/docs/assets/LinkedListPage-CPh-u55R.js similarity index 97% rename from docs/assets/LinkedListPage-DDic5oaj.js rename to docs/assets/LinkedListPage-CPh-u55R.js index 6b9cb0f..261e517 100644 --- a/docs/assets/LinkedListPage-DDic5oaj.js +++ b/docs/assets/LinkedListPage-CPh-u55R.js @@ -1 +1 @@ -import{r as a,j as e,e as de}from"./index-eCXyAnHs.js";import{u as ce}from"./useDSSound-CIDAFkgj.js";import{P as K}from"./plus-CffLiizr.js";import{T as xe}from"./trash-2-DQ8BZrIf.js";import{R as ue}from"./rotate-ccw-B8GZP3d7.js";import{S as he}from"./shuffle-CdKU4ZYx.js";import{V as ge,a as pe}from"./volume-x-CTbtCvt-.js";import{C as me,a as fe}from"./chevron-right-BZqZw4c2.js";import"./audioContext-NbgqvQGz.js";let U=1;const be=[3,7,1,9].map(p=>({id:U++,value:p}));function je(){const[p,m]=a.useState(be),[c,H]=a.useState("singly"),[h,y]=a.useState([]),[x,r]=a.useState(-1),[S,M]=a.useState(""),[V,X]=a.useState(""),[G,P]=a.useState([]),[j,A]=a.useState(400),[n,C]=a.useState(!1),$=a.useRef(null),R=a.useRef(j),v=a.useRef(!1),{soundEnabled:o,toggleSound:F,playInsert:N,playDelete:I,playTraverse:k,playFound:T,playNotFound:D}=ce(),B=a.useRef(N),Y=a.useRef(I),q=a.useRef(k);a.useEffect(()=>{B.current=N},[N]),a.useEffect(()=>{Y.current=I},[I]),a.useEffect(()=>{q.current=k},[k]),a.useEffect(()=>{R.current=j},[j]),a.useEffect(()=>{if(!v.current||h.length===0)return;v.current=!1,$.current&&clearTimeout($.current),C(!0);let t=0;const s=()=>{if(t>=h.length-1){C(!1);return}t++,r(t);const i=h[t];i&&(i.highlightColor==="green"?B.current():i.highlightColor==="red"?Y.current():i.highlightColor==="yellow"&&q.current(t,h.length)),$.current=setTimeout(s,R.current)};$.current=setTimeout(s,R.current)},[h]);const J=x>=0&&h[x]?h[x].nodes:p,l=x>=0?h[x]:null,E=c==="singly"?"singly linked list":c==="doubly"?"doubly linked list":"circular linked list",O=t=>P(s=>[t,...s].slice(0,20)),Q=a.useCallback(t=>{H(t),y([]),r(-1),C(!1),P(s=>[`Switch to ${t}`,...s].slice(0,20))},[]),w=(t,s,i=[],d=null,u=null)=>({description:t,nodes:s,highlightIds:new Set(i),highlightColor:d,newNodeId:u}),Z=a.useCallback(t=>{const s={id:U++,value:t};m(i=>{const d=[s,...i],u=[w(`Prepend ${t}: creating new node at head in the ${E}...`,i,[],null,s.id),w(`${t} inserted at position 0. Updating ${c==="doubly"?"prev/next pointers":c==="circular"?"tail.next back to head":"head pointer"}.`,d,[s.id],"green",s.id)];return y(u),r(0),v.current=!0,N(),O(`Prepend ${t}`),d})},[N,c,E]),ee=a.useCallback(t=>{const s={id:U++,value:t};m(i=>{const d=[...i,s],u=[];for(let f=0;f{const i={id:U++,value:t};m(d=>{if(s<0||s>d.length)return d;const u=[...d.slice(0,s),i,...d.slice(s)],f=[];for(let W=0;W{m(s=>{if(t<0||t>=s.length)return s;const i=s[t],d=[];for(let f=0;f<=t;f++)d.push(w(`Traversing to index ${t}: at node ${s[f].value}...`,s,[s[f].id],"yellow"));d.push(w(`Deleting node ${i.value} at index ${t}: re-linking ${c==="doubly"?"prev and next pointers":c==="circular"?"cycle pointers":"next pointer"}.`,s,[i.id],"red"));const u=s.filter((f,W)=>W!==t);return d.push(w(`Node ${i.value} removed. List size: ${u.length}`,u,[],null)),y(d),r(0),v.current=!0,I(),O(`Delete [${t}] → ${i.value}`),u})},[I,c]),le=a.useCallback(t=>{m(s=>{const i=[];let d=-1;for(let u=0;u{m([]),y([]),r(-1),O("Clear list")},[]),ae=a.useCallback(()=>{const t=Math.floor(Math.random()*4)+4,s=Array.from({length:t},()=>({id:U++,value:Math.floor(Math.random()*90)+1}));m(s),y([]),r(-1),O("Random list")},[]),ie=a.useCallback(()=>{r(t=>Math.min(t+1,h.length-1))},[h.length]),re=a.useCallback(()=>{r(t=>Math.max(t-1,0))},[]),oe=a.useCallback(()=>{if(n){C(!1),$.current&&clearTimeout($.current);return}if(x>=h.length-1)return;C(!0);let t=x;const s=()=>{if(t>=h.length-1){C(!1);return}t++,r(t),$.current=setTimeout(s,j)};$.current=setTimeout(s,j)},[n,x,h.length,j]);return{nodes:p,variant:c,changeVariant:Q,displayNodes:J,steps:h,stepIndex:x,currentStep:l,inputValue:S,setInputValue:M,indexValue:V,setIndexValue:X,history:G,speed:j,setSpeed:A,isPlaying:n,prepend:Z,append:ee,insertAt:te,deleteAt:se,search:le,clear:ne,generateRandom:ae,nextStep:ie,prevStep:re,autoPlay:oe,canGoNext:x0,soundEnabled:o,toggleSound:F}}const ye={green:{border:"#34d399",bg:"rgba(52,211,153,0.15)",text:"#6ee7b7"},red:{border:"#f87171",bg:"rgba(248,113,113,0.15)",text:"#fca5a5"},yellow:{border:"#fbbf24",bg:"rgba(251,191,36,0.15)",text:"#fde68a"},blue:{border:"#60a5fa",bg:"rgba(96,165,250,0.15)",text:"#93c5fd"}},Ne={border:"#475569",bg:"rgba(30,41,59,0.7)",text:"#cbd5e1"},b=64,g=48,L=36,z=b+L,_=5;function ve({nodes:p,currentStep:m,variant:c}){const H=m?.highlightIds??new Set,h=m?.highlightColor??null,y=[];for(let j=0;j{const n=A*r+20,C=A===y.length-1,$=A*_;return e.jsx("g",{children:j.map((R,v)=>{const o=v*z+L/2,F=H.has(R.id),N=F&&h?ye[h]:Ne,I=$+v,k=I===0,T=I===p.length-1,D=v===j.length-1;return e.jsxs("g",{children:[k&&e.jsx("text",{x:o+b/2,y:n-8,textAnchor:"middle",fontSize:"10",fill:"#818cf8",fontFamily:"monospace",children:"head"}),e.jsx("rect",{x:o,y:n,width:b,height:g,rx:8,fill:N.bg,stroke:N.border,strokeWidth:F?2:1.5}),e.jsx("text",{x:o+b*.38,y:n+g/2+5,textAnchor:"middle",fontSize:"15",fontWeight:"bold",fill:N.text,fontFamily:"sans-serif",children:R.value}),e.jsx("line",{x1:o+b*.62,y1:n+4,x2:o+b*.62,y2:n+g-4,stroke:N.border,strokeWidth:1,opacity:.5}),e.jsx("text",{x:o+b*.82,y:n+g/2+4,textAnchor:"middle",fontSize:"9",fill:"#64748b",fontFamily:"monospace",children:T?c==="circular"?"↺":"null":"→"}),c==="doubly"&&e.jsx("text",{x:o+b*.2,y:n+g-7,textAnchor:"middle",fontSize:"8",fill:"#93c5fd",fontFamily:"monospace",children:k?"null":"←"}),!T&&!D&&e.jsxs("g",{children:[e.jsx("line",{x1:o+b,y1:n+g/2,x2:o+z,y2:n+g/2,stroke:"#475569",strokeWidth:1.5}),e.jsx("polygon",{points:`${o+z},${n+g/2} ${o+z-6},${n+g/2-4} ${o+z-6},${n+g/2+4}`,fill:"#475569"})]}),c==="doubly"&&!T&&!D&&e.jsxs("g",{opacity:.75,children:[e.jsx("line",{x1:o+z,y1:n+g/2+12,x2:o+b,y2:n+g/2+12,stroke:"#60a5fa",strokeWidth:1.2}),e.jsx("polygon",{points:`${o+b},${n+g/2+12} ${o+b+6},${n+g/2+8} ${o+b+6},${n+g/2+16}`,fill:"#60a5fa"})]}),D&&!C&&e.jsxs("g",{children:[e.jsx("path",{d:`M ${o+b} ${n+g/2} L ${o+b+14} ${n+g/2} L ${o+b+14} ${n+g+20} L ${L/2} ${n+g+20} L ${L/2} ${n+r}`,fill:"none",stroke:"#475569",strokeWidth:1.5}),e.jsx("polygon",{points:`${L/2},${n+r} ${L/2-4},${n+r-6} ${L/2+4},${n+r-6}`,fill:"#475569"})]})]},R.id)})},A)}),c==="circular"&&y.length>0&&p.length>1&&e.jsxs("g",{children:[e.jsx("path",{d:`M ${G+b} ${P+g/2} C ${x+40} ${S+16}, -20 ${S+16}, ${L/2+b/2} 78`,fill:"none",stroke:"#f59e0b",strokeDasharray:"5 5",strokeWidth:1.5}),e.jsx("text",{x:x/2,y:S-4,textAnchor:"middle",fontSize:"10",fill:"#fbbf24",fontFamily:"monospace",children:"tail.next → head"})]})]}),m?.description&&e.jsx("div",{className:"w-full max-w-sm rounded-lg bg-slate-800/60 px-4 py-2 text-center text-xs text-indigo-300 leading-relaxed",children:m.description}),e.jsxs("div",{className:"text-xs text-slate-500 font-mono",children:[c," list · length = ",p.length]})]})}const $e=[{label:"Slow",value:700},{label:"Med",value:350},{label:"Fast",value:120}];function ke({hook:p}){const{nodes:m,variant:c,changeVariant:H,steps:h,stepIndex:y,inputValue:x,setInputValue:r,indexValue:S,setIndexValue:M,history:V,speed:X,setSpeed:G,isPlaying:P,prepend:j,append:A,insertAt:n,deleteAt:C,search:$,clear:R,generateRandom:v,nextStep:o,prevStep:F,canGoNext:N,canGoPrev:I,soundEnabled:k,toggleSound:T}=p,D=()=>{const l=parseInt(x);isNaN(l)||(j(l),r(""))},B=()=>{const l=parseInt(x);isNaN(l)||(A(l),r(""))},Y=()=>{const l=parseInt(x),E=parseInt(S);!isNaN(l)&&!isNaN(E)&&(n(l,E),r(""))},q=()=>{const l=parseInt(S);isNaN(l)||C(l)},J=()=>{const l=parseInt(x);isNaN(l)||$(l)};return e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-sm font-bold text-indigo-300 mb-1",children:"Linked List"}),e.jsxs("p",{className:"text-xs text-slate-400 leading-relaxed",children:["A chain of ",e.jsx("strong",{className:"text-slate-300",children:"nodes"}),". Switch between singly, doubly, and circular pointer layouts while keeping the same operations."]}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:["Prepend O(1)","Append O(n)","Insert O(n)","Delete O(n)","Search O(n)"].map(l=>e.jsx("span",{className:"rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-400 ring-1 ring-violet-500/20",children:l},l))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"List Type"}),e.jsx("div",{className:"grid grid-cols-3 gap-1",children:["singly","doubly","circular"].map(l=>e.jsx("button",{onClick:()=>H(l),className:`rounded-lg px-2 py-2 text-[10px] font-semibold capitalize transition-all ${c===l?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40":"bg-slate-800/60 text-slate-400 hover:bg-slate-700/60"}`,children:l},l))}),e.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:"Doubly lists show backward pointers; circular lists connect the tail back to the head."})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Operations"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Value"}),e.jsx("input",{type:"number",value:x,onChange:l=>r(l.target.value),placeholder:"e.g. 42",className:"w-full rounded-lg bg-slate-800/60 px-3 py-2 text-sm text-slate-200 placeholder-slate-600 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50 transition-all"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Index"}),e.jsx("input",{type:"number",value:S,onChange:l=>M(l.target.value),placeholder:"e.g. 0",min:"0",className:"w-full rounded-lg bg-slate-800/60 px-3 py-2 text-sm text-slate-200 placeholder-slate-600 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50 transition-all"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:D,disabled:m.length>=12,className:"flex items-center justify-center gap-1.5 rounded-lg bg-gradient-to-r from-emerald-500/80 to-green-500/80 px-3 py-2 text-xs font-semibold text-white shadow-lg shadow-emerald-500/15 transition-all hover:brightness-110 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(K,{size:13})," Prepend"]}),e.jsxs("button",{onClick:B,disabled:m.length>=12,className:"flex items-center justify-center gap-1.5 rounded-lg bg-indigo-500/20 px-3 py-2 text-xs font-semibold text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(K,{size:13})," Append"]}),e.jsxs("button",{onClick:Y,disabled:m.length>=12,className:"flex items-center justify-center gap-1.5 rounded-lg bg-violet-500/20 px-3 py-2 text-xs font-semibold text-violet-300 ring-1 ring-violet-500/30 transition-all hover:bg-violet-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(K,{size:13})," Insert at"]}),e.jsxs("button",{onClick:q,disabled:m.length===0,className:"flex items-center justify-center gap-1.5 rounded-lg bg-gradient-to-r from-rose-500/80 to-pink-500/80 px-3 py-2 text-xs font-semibold text-white shadow-lg shadow-rose-500/15 transition-all hover:brightness-110 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(xe,{size:13})," Delete at"]}),e.jsxs("button",{onClick:J,disabled:m.length===0,className:"flex items-center justify-center gap-1.5 rounded-lg bg-amber-500/20 px-3 py-2 text-xs font-semibold text-amber-300 ring-1 ring-amber-500/30 transition-all hover:bg-amber-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(de,{size:13})," Search"]}),e.jsxs("button",{onClick:R,disabled:m.length===0,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(ue,{size:13})," Clear"]})]}),e.jsxs("button",{onClick:v,className:"mt-2 w-full flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(he,{size:12})," Random List"]}),e.jsxs("button",{onClick:()=>T(!k),className:`mt-2 w-full flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-xs font-medium transition-all ${k?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400 hover:bg-slate-700/60"}`,children:[k?e.jsx(ge,{size:12}):e.jsx(pe,{size:12}),k?"Sound On":"Sound Off"]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Animation Speed"}),e.jsx("div",{className:"flex gap-1",children:$e.map(l=>e.jsx("button",{onClick:()=>G(l.value),className:`flex-1 rounded-lg px-2 py-1.5 text-xs font-medium transition-all duration-200 ${X===l.value?"bg-violet-500/20 text-violet-300 ring-1 ring-violet-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"}`,children:l.label},l.value))})]}),h.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Step Through"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:F,disabled:!I||P,className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-slate-800/60 px-3 py-2.5 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(me,{size:16})," Prev"]}),e.jsxs("button",{onClick:o,disabled:!N||P,className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-slate-800/60 px-3 py-2.5 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:["Next ",e.jsx(fe,{size:16})]})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Step"}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-indigo-400",children:[Math.max(0,y+1)," / ",h.length]})]})]}),V.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"History"}),e.jsx("div",{className:"max-h-36 overflow-y-auto space-y-1",children:V.map((l,E)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-mono text-slate-600 w-4 text-right",children:E+1}),e.jsx("span",{className:l.startsWith("Prepend")||l.startsWith("Append")||l.startsWith("Insert")?"text-emerald-400":l.startsWith("Delete")?"text-rose-400":l.startsWith("Search")?"text-amber-400":"text-slate-400",children:l})]},E))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Legend"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-emerald-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Insert / found"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-rose-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Delete"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-amber-400"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Traversal / search"})]})]})]})]})}function Ee(){const p=je();return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsx("div",{className:"order-last md:order-first flex md:flex-1 flex-col items-center justify-center gap-3 min-h-[40vh] md:min-h-0 max-h-[55vh] md:max-h-none overflow-auto",children:e.jsx(ve,{nodes:p.displayNodes,currentStep:p.currentStep,variant:p.variant})}),e.jsx(ke,{hook:p})]})}export{Ee as default}; +import{r as a,j as e,d as de}from"./index-DBkLeWDs.js";import{u as ce}from"./useDSSound-KKipmh13.js";import{P as K}from"./plus-DVazsZHX.js";import{T as xe}from"./trash-2-C6_cMdiI.js";import{R as ue}from"./rotate-ccw-7GTUOPy4.js";import{S as he}from"./shuffle-Dlr-c52A.js";import{V as ge,a as pe}from"./volume-x-BSx9gxSg.js";import{C as me,a as fe}from"./chevron-right-CFBAUJsk.js";import"./audioContext-NbgqvQGz.js";let U=1;const be=[3,7,1,9].map(p=>({id:U++,value:p}));function je(){const[p,m]=a.useState(be),[c,H]=a.useState("singly"),[h,y]=a.useState([]),[x,r]=a.useState(-1),[S,M]=a.useState(""),[V,X]=a.useState(""),[G,P]=a.useState([]),[j,A]=a.useState(400),[n,C]=a.useState(!1),$=a.useRef(null),R=a.useRef(j),v=a.useRef(!1),{soundEnabled:o,toggleSound:F,playInsert:N,playDelete:I,playTraverse:k,playFound:T,playNotFound:D}=ce(),B=a.useRef(N),Y=a.useRef(I),q=a.useRef(k);a.useEffect(()=>{B.current=N},[N]),a.useEffect(()=>{Y.current=I},[I]),a.useEffect(()=>{q.current=k},[k]),a.useEffect(()=>{R.current=j},[j]),a.useEffect(()=>{if(!v.current||h.length===0)return;v.current=!1,$.current&&clearTimeout($.current),C(!0);let t=0;const s=()=>{if(t>=h.length-1){C(!1);return}t++,r(t);const i=h[t];i&&(i.highlightColor==="green"?B.current():i.highlightColor==="red"?Y.current():i.highlightColor==="yellow"&&q.current(t,h.length)),$.current=setTimeout(s,R.current)};$.current=setTimeout(s,R.current)},[h]);const J=x>=0&&h[x]?h[x].nodes:p,l=x>=0?h[x]:null,E=c==="singly"?"singly linked list":c==="doubly"?"doubly linked list":"circular linked list",O=t=>P(s=>[t,...s].slice(0,20)),Q=a.useCallback(t=>{H(t),y([]),r(-1),C(!1),P(s=>[`Switch to ${t}`,...s].slice(0,20))},[]),w=(t,s,i=[],d=null,u=null)=>({description:t,nodes:s,highlightIds:new Set(i),highlightColor:d,newNodeId:u}),Z=a.useCallback(t=>{const s={id:U++,value:t};m(i=>{const d=[s,...i],u=[w(`Prepend ${t}: creating new node at head in the ${E}...`,i,[],null,s.id),w(`${t} inserted at position 0. Updating ${c==="doubly"?"prev/next pointers":c==="circular"?"tail.next back to head":"head pointer"}.`,d,[s.id],"green",s.id)];return y(u),r(0),v.current=!0,N(),O(`Prepend ${t}`),d})},[N,c,E]),ee=a.useCallback(t=>{const s={id:U++,value:t};m(i=>{const d=[...i,s],u=[];for(let f=0;f{const i={id:U++,value:t};m(d=>{if(s<0||s>d.length)return d;const u=[...d.slice(0,s),i,...d.slice(s)],f=[];for(let W=0;W{m(s=>{if(t<0||t>=s.length)return s;const i=s[t],d=[];for(let f=0;f<=t;f++)d.push(w(`Traversing to index ${t}: at node ${s[f].value}...`,s,[s[f].id],"yellow"));d.push(w(`Deleting node ${i.value} at index ${t}: re-linking ${c==="doubly"?"prev and next pointers":c==="circular"?"cycle pointers":"next pointer"}.`,s,[i.id],"red"));const u=s.filter((f,W)=>W!==t);return d.push(w(`Node ${i.value} removed. List size: ${u.length}`,u,[],null)),y(d),r(0),v.current=!0,I(),O(`Delete [${t}] → ${i.value}`),u})},[I,c]),le=a.useCallback(t=>{m(s=>{const i=[];let d=-1;for(let u=0;u{m([]),y([]),r(-1),O("Clear list")},[]),ae=a.useCallback(()=>{const t=Math.floor(Math.random()*4)+4,s=Array.from({length:t},()=>({id:U++,value:Math.floor(Math.random()*90)+1}));m(s),y([]),r(-1),O("Random list")},[]),ie=a.useCallback(()=>{r(t=>Math.min(t+1,h.length-1))},[h.length]),re=a.useCallback(()=>{r(t=>Math.max(t-1,0))},[]),oe=a.useCallback(()=>{if(n){C(!1),$.current&&clearTimeout($.current);return}if(x>=h.length-1)return;C(!0);let t=x;const s=()=>{if(t>=h.length-1){C(!1);return}t++,r(t),$.current=setTimeout(s,j)};$.current=setTimeout(s,j)},[n,x,h.length,j]);return{nodes:p,variant:c,changeVariant:Q,displayNodes:J,steps:h,stepIndex:x,currentStep:l,inputValue:S,setInputValue:M,indexValue:V,setIndexValue:X,history:G,speed:j,setSpeed:A,isPlaying:n,prepend:Z,append:ee,insertAt:te,deleteAt:se,search:le,clear:ne,generateRandom:ae,nextStep:ie,prevStep:re,autoPlay:oe,canGoNext:x0,soundEnabled:o,toggleSound:F}}const ye={green:{border:"#34d399",bg:"rgba(52,211,153,0.15)",text:"#6ee7b7"},red:{border:"#f87171",bg:"rgba(248,113,113,0.15)",text:"#fca5a5"},yellow:{border:"#fbbf24",bg:"rgba(251,191,36,0.15)",text:"#fde68a"},blue:{border:"#60a5fa",bg:"rgba(96,165,250,0.15)",text:"#93c5fd"}},Ne={border:"#475569",bg:"rgba(30,41,59,0.7)",text:"#cbd5e1"},b=64,g=48,L=36,z=b+L,_=5;function ve({nodes:p,currentStep:m,variant:c}){const H=m?.highlightIds??new Set,h=m?.highlightColor??null,y=[];for(let j=0;j{const n=A*r+20,C=A===y.length-1,$=A*_;return e.jsx("g",{children:j.map((R,v)=>{const o=v*z+L/2,F=H.has(R.id),N=F&&h?ye[h]:Ne,I=$+v,k=I===0,T=I===p.length-1,D=v===j.length-1;return e.jsxs("g",{children:[k&&e.jsx("text",{x:o+b/2,y:n-8,textAnchor:"middle",fontSize:"10",fill:"#818cf8",fontFamily:"monospace",children:"head"}),e.jsx("rect",{x:o,y:n,width:b,height:g,rx:8,fill:N.bg,stroke:N.border,strokeWidth:F?2:1.5}),e.jsx("text",{x:o+b*.38,y:n+g/2+5,textAnchor:"middle",fontSize:"15",fontWeight:"bold",fill:N.text,fontFamily:"sans-serif",children:R.value}),e.jsx("line",{x1:o+b*.62,y1:n+4,x2:o+b*.62,y2:n+g-4,stroke:N.border,strokeWidth:1,opacity:.5}),e.jsx("text",{x:o+b*.82,y:n+g/2+4,textAnchor:"middle",fontSize:"9",fill:"#64748b",fontFamily:"monospace",children:T?c==="circular"?"↺":"null":"→"}),c==="doubly"&&e.jsx("text",{x:o+b*.2,y:n+g-7,textAnchor:"middle",fontSize:"8",fill:"#93c5fd",fontFamily:"monospace",children:k?"null":"←"}),!T&&!D&&e.jsxs("g",{children:[e.jsx("line",{x1:o+b,y1:n+g/2,x2:o+z,y2:n+g/2,stroke:"#475569",strokeWidth:1.5}),e.jsx("polygon",{points:`${o+z},${n+g/2} ${o+z-6},${n+g/2-4} ${o+z-6},${n+g/2+4}`,fill:"#475569"})]}),c==="doubly"&&!T&&!D&&e.jsxs("g",{opacity:.75,children:[e.jsx("line",{x1:o+z,y1:n+g/2+12,x2:o+b,y2:n+g/2+12,stroke:"#60a5fa",strokeWidth:1.2}),e.jsx("polygon",{points:`${o+b},${n+g/2+12} ${o+b+6},${n+g/2+8} ${o+b+6},${n+g/2+16}`,fill:"#60a5fa"})]}),D&&!C&&e.jsxs("g",{children:[e.jsx("path",{d:`M ${o+b} ${n+g/2} L ${o+b+14} ${n+g/2} L ${o+b+14} ${n+g+20} L ${L/2} ${n+g+20} L ${L/2} ${n+r}`,fill:"none",stroke:"#475569",strokeWidth:1.5}),e.jsx("polygon",{points:`${L/2},${n+r} ${L/2-4},${n+r-6} ${L/2+4},${n+r-6}`,fill:"#475569"})]})]},R.id)})},A)}),c==="circular"&&y.length>0&&p.length>1&&e.jsxs("g",{children:[e.jsx("path",{d:`M ${G+b} ${P+g/2} C ${x+40} ${S+16}, -20 ${S+16}, ${L/2+b/2} 78`,fill:"none",stroke:"#f59e0b",strokeDasharray:"5 5",strokeWidth:1.5}),e.jsx("text",{x:x/2,y:S-4,textAnchor:"middle",fontSize:"10",fill:"#fbbf24",fontFamily:"monospace",children:"tail.next → head"})]})]}),m?.description&&e.jsx("div",{className:"w-full max-w-sm rounded-lg bg-slate-800/60 px-4 py-2 text-center text-xs text-indigo-300 leading-relaxed",children:m.description}),e.jsxs("div",{className:"text-xs text-slate-500 font-mono",children:[c," list · length = ",p.length]})]})}const $e=[{label:"Slow",value:700},{label:"Med",value:350},{label:"Fast",value:120}];function ke({hook:p}){const{nodes:m,variant:c,changeVariant:H,steps:h,stepIndex:y,inputValue:x,setInputValue:r,indexValue:S,setIndexValue:M,history:V,speed:X,setSpeed:G,isPlaying:P,prepend:j,append:A,insertAt:n,deleteAt:C,search:$,clear:R,generateRandom:v,nextStep:o,prevStep:F,canGoNext:N,canGoPrev:I,soundEnabled:k,toggleSound:T}=p,D=()=>{const l=parseInt(x);isNaN(l)||(j(l),r(""))},B=()=>{const l=parseInt(x);isNaN(l)||(A(l),r(""))},Y=()=>{const l=parseInt(x),E=parseInt(S);!isNaN(l)&&!isNaN(E)&&(n(l,E),r(""))},q=()=>{const l=parseInt(S);isNaN(l)||C(l)},J=()=>{const l=parseInt(x);isNaN(l)||$(l)};return e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-sm font-bold text-indigo-300 mb-1",children:"Linked List"}),e.jsxs("p",{className:"text-xs text-slate-400 leading-relaxed",children:["A chain of ",e.jsx("strong",{className:"text-slate-300",children:"nodes"}),". Switch between singly, doubly, and circular pointer layouts while keeping the same operations."]}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:["Prepend O(1)","Append O(n)","Insert O(n)","Delete O(n)","Search O(n)"].map(l=>e.jsx("span",{className:"rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-400 ring-1 ring-violet-500/20",children:l},l))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"List Type"}),e.jsx("div",{className:"grid grid-cols-3 gap-1",children:["singly","doubly","circular"].map(l=>e.jsx("button",{onClick:()=>H(l),className:`rounded-lg px-2 py-2 text-[10px] font-semibold capitalize transition-all ${c===l?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40":"bg-slate-800/60 text-slate-400 hover:bg-slate-700/60"}`,children:l},l))}),e.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:"Doubly lists show backward pointers; circular lists connect the tail back to the head."})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Operations"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Value"}),e.jsx("input",{type:"number",value:x,onChange:l=>r(l.target.value),placeholder:"e.g. 42",className:"w-full rounded-lg bg-slate-800/60 px-3 py-2 text-sm text-slate-200 placeholder-slate-600 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50 transition-all"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-[10px] text-slate-500 uppercase tracking-wider",children:"Index"}),e.jsx("input",{type:"number",value:S,onChange:l=>M(l.target.value),placeholder:"e.g. 0",min:"0",className:"w-full rounded-lg bg-slate-800/60 px-3 py-2 text-sm text-slate-200 placeholder-slate-600 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50 transition-all"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:D,disabled:m.length>=12,className:"flex items-center justify-center gap-1.5 rounded-lg bg-gradient-to-r from-emerald-500/80 to-green-500/80 px-3 py-2 text-xs font-semibold text-white shadow-lg shadow-emerald-500/15 transition-all hover:brightness-110 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(K,{size:13})," Prepend"]}),e.jsxs("button",{onClick:B,disabled:m.length>=12,className:"flex items-center justify-center gap-1.5 rounded-lg bg-indigo-500/20 px-3 py-2 text-xs font-semibold text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(K,{size:13})," Append"]}),e.jsxs("button",{onClick:Y,disabled:m.length>=12,className:"flex items-center justify-center gap-1.5 rounded-lg bg-violet-500/20 px-3 py-2 text-xs font-semibold text-violet-300 ring-1 ring-violet-500/30 transition-all hover:bg-violet-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(K,{size:13})," Insert at"]}),e.jsxs("button",{onClick:q,disabled:m.length===0,className:"flex items-center justify-center gap-1.5 rounded-lg bg-gradient-to-r from-rose-500/80 to-pink-500/80 px-3 py-2 text-xs font-semibold text-white shadow-lg shadow-rose-500/15 transition-all hover:brightness-110 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(xe,{size:13})," Delete at"]}),e.jsxs("button",{onClick:J,disabled:m.length===0,className:"flex items-center justify-center gap-1.5 rounded-lg bg-amber-500/20 px-3 py-2 text-xs font-semibold text-amber-300 ring-1 ring-amber-500/30 transition-all hover:bg-amber-500/30 active:scale-[0.98] disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(de,{size:13})," Search"]}),e.jsxs("button",{onClick:R,disabled:m.length===0,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(ue,{size:13})," Clear"]})]}),e.jsxs("button",{onClick:v,className:"mt-2 w-full flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(he,{size:12})," Random List"]}),e.jsxs("button",{onClick:()=>T(!k),className:`mt-2 w-full flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-xs font-medium transition-all ${k?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400 hover:bg-slate-700/60"}`,children:[k?e.jsx(ge,{size:12}):e.jsx(pe,{size:12}),k?"Sound On":"Sound Off"]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Animation Speed"}),e.jsx("div",{className:"flex gap-1",children:$e.map(l=>e.jsx("button",{onClick:()=>G(l.value),className:`flex-1 rounded-lg px-2 py-1.5 text-xs font-medium transition-all duration-200 ${X===l.value?"bg-violet-500/20 text-violet-300 ring-1 ring-violet-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"}`,children:l.label},l.value))})]}),h.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Step Through"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:F,disabled:!I||P,className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-slate-800/60 px-3 py-2.5 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(me,{size:16})," Prev"]}),e.jsxs("button",{onClick:o,disabled:!N||P,className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-slate-800/60 px-3 py-2.5 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:["Next ",e.jsx(fe,{size:16})]})]}),e.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Step"}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-indigo-400",children:[Math.max(0,y+1)," / ",h.length]})]})]}),V.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"History"}),e.jsx("div",{className:"max-h-36 overflow-y-auto space-y-1",children:V.map((l,E)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"font-mono text-slate-600 w-4 text-right",children:E+1}),e.jsx("span",{className:l.startsWith("Prepend")||l.startsWith("Append")||l.startsWith("Insert")?"text-emerald-400":l.startsWith("Delete")?"text-rose-400":l.startsWith("Search")?"text-amber-400":"text-slate-400",children:l})]},E))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Legend"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-emerald-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Insert / found"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-rose-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Delete"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-amber-400"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Traversal / search"})]})]})]})]})}function Ee(){const p=je();return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsx("div",{className:"order-last md:order-first flex md:flex-1 flex-col items-center justify-center gap-3 min-h-[40vh] md:min-h-0 max-h-[55vh] md:max-h-none overflow-auto",children:e.jsx(ve,{nodes:p.displayNodes,currentStep:p.currentStep,variant:p.variant})}),e.jsx(ke,{hook:p})]})}export{Ee as default}; diff --git a/docs/assets/MahjongGamePage-D5Ek5nyq.js b/docs/assets/MahjongGamePage-CBqcyOb2.js similarity index 91% rename from docs/assets/MahjongGamePage-D5Ek5nyq.js rename to docs/assets/MahjongGamePage-CBqcyOb2.js index 8d3aa5e..2a1c5f9 100644 --- a/docs/assets/MahjongGamePage-D5Ek5nyq.js +++ b/docs/assets/MahjongGamePage-CBqcyOb2.js @@ -1,8 +1,8 @@ -import{c as U,j as e,d as ve,e as ke,E as we,r as c,A as de}from"./index-eCXyAnHs.js";import{S as Te}from"./shuffle-CdKU4ZYx.js";import{R as K}from"./rotate-ccw-B8GZP3d7.js";import{V as Q,a as ee}from"./volume-x-CTbtCvt-.js";import{E as Ce}from"./eye-off-EsCpy5pU.js";import{C as Se,a as $e}from"./chevron-right-BZqZw4c2.js";import{P as We}from"./pause-nC-0zhw8.js";import{P as Pe}from"./play-BqZilH6N.js";import{T as Y}from"./trophy-DkUzH7jB.js";import{g as _e}from"./audioContext-NbgqvQGz.js";import{L as Me,F as Ae}from"./lightbulb-B7pRWk3f.js";import{S as Re,B as ze}from"./skip-forward-BOek2ZcD.js";import{T as He}from"./timer-DSbfy6P3.js";import{Z as Ee}from"./zap-DNziIfcU.js";const Be=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],Ie=U("arrow-left-right",Be);const Oe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],V=U("circle-check-big",Oe);const Fe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],re=U("circle-x",Fe);const Ge=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],pe=U("users",Ge);const Ve=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Le=U("wrench",Ve),he={B:"Bamboo",C:"Characters",D:"Dots"},Z={B:"#4ade80",C:"#f87171",D:"#60a5fa"},De={sandbox:{label:"Sandbox",description:"Build any hand and check it freely"},guided:{label:"Guided",description:"Learn to spot pairs & melds step-by-step"},challenge:{label:"Challenge",description:"Speed rounds — Win or Not Win?"},"two-player":{label:"2 Player",description:"Take turns building hands"}},P=14,E=4,O=[1,2,3,4,5,6,7,8,9],B=["B","C","D"],J={title:"Mahjong Hand Solver",subtitle:"Backtracking-based winning hand validator",what:"Build a 14-tile Mahjong hand and check if it forms a valid winning combination — 4 melds (pongs or chows) plus 1 pair. Watch the backtracking solver try every possibility step-by-step.",skills:["Backtracking","Constraint Validation","Combinatorics","Pattern Matching"]},xe={sm:"w-9 h-12 sm:w-10 sm:h-14",md:"w-11 h-14 sm:w-12 sm:h-16 md:w-14 md:h-[4.35rem]",lg:"w-12 h-16 sm:w-14 sm:h-[4.6rem] md:w-16 md:h-20"};function I({code:t,index:s,count:n,size:a="md",selected:l=!1,disabled:r=!1,faded:m=!1,interactive:k=!1,removable:p=!1,placeholder:T=!1,onClick:i}){if(T||!t)return e.jsx("div",{className:`${xe[a]} relative rounded-xl border border-dashed border-emerald-900/30 bg-emerald-950/20 shadow-inner`,children:e.jsx("div",{className:"absolute inset-1 rounded-lg border border-emerald-900/20"})});const o=t[0],x=Number(t[1]),u=Z[o],g=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute inset-0 rounded-xl bg-gradient-to-br from-stone-50 via-amber-50 to-stone-200"}),e.jsx("div",{className:"absolute inset-x-1 top-1 h-1 rounded-full bg-white/80"}),e.jsx("div",{className:"absolute inset-1 rounded-lg border border-amber-950/10 bg-[radial-gradient(circle_at_30%_15%,rgba(255,255,255,0.8),transparent_38%),linear-gradient(135deg,rgba(255,255,255,0.35),transparent)]"}),e.jsx("div",{className:"absolute inset-y-1 right-0.5 w-1 rounded-r-lg bg-emerald-900/25"}),e.jsx("div",{className:"relative z-10 flex h-full flex-col items-center justify-center px-1 text-center",children:e.jsx(Ue,{suit:o,value:x,color:u,size:a})}),e.jsx("div",{className:"absolute left-1 top-1 text-[8px] font-black leading-none text-slate-900/35",children:x}),e.jsx("div",{className:"absolute bottom-1 right-1 rotate-180 text-[8px] font-black leading-none text-slate-900/35",children:x}),typeof s=="number"&&s>=0&&e.jsx("span",{className:"absolute -bottom-1 left-1/2 z-20 -translate-x-1/2 rounded-full bg-slate-950/80 px-1 text-[7px] font-mono text-slate-400 ring-1 ring-slate-700/50",children:s+1}),typeof n=="number"&&n>0&&e.jsx("span",{className:"absolute -right-1.5 -top-1.5 z-20 flex h-5 w-5 items-center justify-center rounded-full bg-emerald-950 text-[10px] font-bold text-emerald-200 ring-1 ring-emerald-500/50",children:n}),p&&e.jsx("span",{className:"absolute inset-0 z-30 flex items-center justify-center rounded-xl bg-red-950/70 text-sm font-black text-white opacity-0 transition-opacity group-hover:opacity-100",children:"x"})]}),b=` +import{c as U,j as e,d as ve,E as ke,r as c,A as de,B as we}from"./index-DBkLeWDs.js";import{S as Te}from"./shuffle-Dlr-c52A.js";import{S as Ce}from"./sparkles-3Zw4K66N.js";import{R as K}from"./rotate-ccw-7GTUOPy4.js";import{V as Q,a as ee}from"./volume-x-BSx9gxSg.js";import{E as Se}from"./eye-off-BfEKGZbc.js";import{C as $e,a as We}from"./chevron-right-CFBAUJsk.js";import{P as Pe}from"./pause-CG1snUW9.js";import{P as _e}from"./play-mcIZClKO.js";import{T as Y}from"./trophy-C1QWh03u.js";import{g as Me}from"./audioContext-NbgqvQGz.js";import{L as Ae,F as Re}from"./lightbulb-xA5HFx8I.js";import{S as ze}from"./skip-forward-C79KMIOU.js";import{T as He}from"./timer-e0gb0oZa.js";import{Z as Ee}from"./zap-CUITaKA-.js";const Be=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],Ie=U("arrow-left-right",Be);const Oe=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],V=U("circle-check-big",Oe);const Fe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],re=U("circle-x",Fe);const Ge=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],pe=U("users",Ge);const Ve=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Le=U("wrench",Ve),he={B:"Bamboo",C:"Characters",D:"Dots"},Z={B:"#4ade80",C:"#f87171",D:"#60a5fa"},De={sandbox:{label:"Sandbox",description:"Build any hand and check it freely"},guided:{label:"Guided",description:"Learn to spot pairs & melds step-by-step"},challenge:{label:"Challenge",description:"Speed rounds — Win or Not Win?"},"two-player":{label:"2 Player",description:"Take turns building hands"}},P=14,E=4,O=[1,2,3,4,5,6,7,8,9],B=["B","C","D"],J={title:"Mahjong Hand Solver",subtitle:"Backtracking-based winning hand validator",what:"Build a 14-tile Mahjong hand and check if it forms a valid winning combination — 4 melds (pongs or chows) plus 1 pair. Watch the backtracking solver try every possibility step-by-step.",skills:["Backtracking","Constraint Validation","Combinatorics","Pattern Matching"]},xe={sm:"w-9 h-12 sm:w-10 sm:h-14",md:"w-11 h-14 sm:w-12 sm:h-16 md:w-14 md:h-[4.35rem]",lg:"w-12 h-16 sm:w-14 sm:h-[4.6rem] md:w-16 md:h-20"};function I({code:t,index:s,count:n,size:a="md",selected:l=!1,disabled:r=!1,faded:m=!1,interactive:k=!1,removable:p=!1,placeholder:T=!1,onClick:i}){if(T||!t)return e.jsx("div",{className:`${xe[a]} relative rounded-xl border border-dashed border-emerald-900/30 bg-emerald-950/20 shadow-inner`,children:e.jsx("div",{className:"absolute inset-1 rounded-lg border border-emerald-900/20"})});const o=t[0],x=Number(t[1]),u=Z[o],g=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute inset-0 rounded-xl bg-gradient-to-br from-stone-50 via-amber-50 to-stone-200"}),e.jsx("div",{className:"absolute inset-x-1 top-1 h-1 rounded-full bg-white/80"}),e.jsx("div",{className:"absolute inset-1 rounded-lg border border-amber-950/10 bg-[radial-gradient(circle_at_30%_15%,rgba(255,255,255,0.8),transparent_38%),linear-gradient(135deg,rgba(255,255,255,0.35),transparent)]"}),e.jsx("div",{className:"absolute inset-y-1 right-0.5 w-1 rounded-r-lg bg-emerald-900/25"}),e.jsx("div",{className:"relative z-10 flex h-full flex-col items-center justify-center px-1 text-center",children:e.jsx(Ue,{suit:o,value:x,color:u,size:a})}),e.jsx("div",{className:"absolute left-1 top-1 text-[8px] font-black leading-none text-slate-900/35",children:x}),e.jsx("div",{className:"absolute bottom-1 right-1 rotate-180 text-[8px] font-black leading-none text-slate-900/35",children:x}),typeof s=="number"&&s>=0&&e.jsx("span",{className:"absolute -bottom-1 left-1/2 z-20 -translate-x-1/2 rounded-full bg-slate-950/80 px-1 text-[7px] font-mono text-slate-400 ring-1 ring-slate-700/50",children:s+1}),typeof n=="number"&&n>0&&e.jsx("span",{className:"absolute -right-1.5 -top-1.5 z-20 flex h-5 w-5 items-center justify-center rounded-full bg-emerald-950 text-[10px] font-bold text-emerald-200 ring-1 ring-emerald-500/50",children:n}),p&&e.jsx("span",{className:"absolute inset-0 z-30 flex items-center justify-center rounded-xl bg-red-950/70 text-sm font-black text-white opacity-0 transition-opacity group-hover:opacity-100",children:"x"})]}),b=` group relative ${xe[a]} shrink-0 overflow-visible rounded-xl border transition-all duration-200 shadow-[0_10px_18px_rgba(0,0,0,0.35),inset_0_-3px_0_rgba(0,0,0,0.18)] ${l?"z-10 -translate-y-2 rotate-[-1deg] border-amber-300 ring-2 ring-amber-300/50":"border-amber-950/25"} ${r?"cursor-not-allowed opacity-45 grayscale":""} ${m?"opacity-35":""} ${k&&!r?"cursor-pointer hover:-translate-y-2 hover:rotate-1 hover:shadow-[0_18px_28px_rgba(0,0,0,0.45)] active:translate-y-0":""} - `;return k||i?e.jsx("button",{onClick:i,disabled:r,title:t,className:b,children:g}):e.jsx("div",{className:b,children:g})}function Ue({suit:t,value:s,color:n,size:a}){return t==="C"?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{style:{color:n},className:`${a==="sm"?"text-xl":a==="lg"?"text-3xl":"text-2xl"} font-black leading-none drop-shadow-sm`,children:s}),e.jsx("span",{style:{color:n},className:`${a==="sm"?"text-base":"text-lg"} font-black leading-none`,children:"萬"})]}):t==="B"?e.jsx("div",{className:"grid grid-cols-3 gap-0.5",children:Array.from({length:s}).map((l,r)=>e.jsx("span",{className:"h-3 w-1 rounded-full border border-emerald-950/20 bg-gradient-to-b from-emerald-300 to-emerald-700 shadow-sm"},r))}):e.jsx("div",{className:"grid grid-cols-3 gap-0.5",children:Array.from({length:s}).map((l,r)=>e.jsx("span",{className:"h-2.5 w-2.5 rounded-full border border-blue-950/30 bg-white shadow-sm",style:{boxShadow:`inset 0 0 0 2px ${n}`}},r))})}function Je(t,s){return t.filter(n=>n===s).length}function qe({suit:t,value:s,count:n,disabled:a,onClick:l}){const r=n>=4,m=`${t}${s}`;return e.jsx(I,{code:m,count:n,size:"md",disabled:a||r,interactive:!0,onClick:l})}function Ye({hand:t,handIsFull:s,onAddTile:n}){return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm md:p-5",children:[e.jsxs("div",{className:"mb-3 md:mb-4",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-300",children:"Tile Wall"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-500",children:"Choose up to four copies of each realistic Mahjong tile"})]}),e.jsx("div",{className:"space-y-4 md:space-y-5",children:B.map(a=>e.jsxs("div",{className:"rounded-xl border border-slate-800/70 bg-slate-950/35 p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:Z[a]}}),e.jsx("p",{className:"text-[10px] md:text-xs font-semibold uppercase tracking-wider",style:{color:Z[a]},children:he[a]})]}),e.jsx("div",{className:"flex flex-wrap items-end gap-1.5 md:gap-2",children:O.map(l=>{const r=`${a}${l}`;return e.jsx(qe,{suit:a,value:l,count:Je(t,r),disabled:s,onClick:()=>n(r)},r)})})]},a))})]})}function Ze({hand:t,onRemoveTile:s}){const n=P-t.length;return e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-emerald-900/40 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.14),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.36))] p-4 shadow-2xl shadow-black/30 md:p-5",children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-black/25 to-transparent"}),e.jsxs("div",{className:"flex items-center justify-between mb-3 md:mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-emerald-200",children:"Your Hand"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-emerald-100/50",children:"Click a tile to discard it from the rack"})]}),e.jsxs("span",{className:`text-xs md:text-sm font-mono font-bold ${t.length===P?"text-emerald-400":"text-slate-500"}`,children:[t.length," / ",P]})]}),e.jsxs("div",{className:"relative flex min-h-[5.5rem] flex-wrap items-end gap-1.5 rounded-xl border border-emerald-950/40 bg-emerald-950/20 p-3 shadow-inner md:gap-2",children:[t.map((a,l)=>e.jsx(I,{code:a,index:l,size:"lg",interactive:!0,removable:!0,onClick:()=>s(l)},`${a}-${l}`)),n>0&&Array.from({length:n}).map((a,l)=>e.jsx(I,{size:"lg",placeholder:!0},`empty-${l}`))]})]})}function ie({code:t}){return e.jsx(I,{code:t,size:"sm"})}function Xe({meld:t,index:s}){return e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-slate-950/35 p-2 ring-1 ring-slate-800/70 md:gap-3",children:[e.jsxs("span",{className:"w-14 shrink-0 text-[10px] font-semibold uppercase tracking-wider text-slate-500 md:w-16 md:text-xs",children:[t.type==="pong"?"Pong":"Chow"," ",s+1]}),e.jsx("div",{className:"flex gap-1 md:gap-1.5",children:t.tiles.map((n,a)=>e.jsx(ie,{code:n},`${n}-${a}`))})]})}function Ke({result:t}){return t?t.isWin?e.jsxs("div",{className:"rounded-2xl border border-emerald-500/30 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.18),transparent_36%),rgba(16,185,129,0.05)] p-4 shadow-xl shadow-emerald-950/20 backdrop-blur-sm md:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 md:mb-4",children:[e.jsx("span",{className:"text-lg md:text-2xl",children:"🀄"}),e.jsx("h3",{className:"text-sm md:text-base font-bold text-emerald-300",children:"Winning Hand!"})]}),e.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-xl bg-slate-950/35 p-2 ring-1 ring-slate-800/70 md:mb-4 md:gap-3",children:[e.jsx("span",{className:"w-14 shrink-0 text-[10px] font-semibold uppercase tracking-wider text-slate-500 md:w-16 md:text-xs",children:"Pair"}),e.jsxs("div",{className:"flex gap-1 md:gap-1.5",children:[e.jsx(ie,{code:t.pair[0]}),e.jsx(ie,{code:t.pair[1]})]})]}),e.jsx("div",{className:"space-y-2 md:space-y-3",children:t.melds.map((s,n)=>e.jsx(Xe,{meld:s,index:n},n))})]}):e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/5 p-4 md:p-5 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg md:text-2xl",children:"❌"}),e.jsx("h3",{className:"text-sm md:text-base font-bold text-red-300",children:"Not a Winning Hand"})]}),e.jsx("p",{className:"mt-2 text-xs md:text-sm text-slate-400",children:"Hand is not a valid winning combination. A winning hand needs 4 melds (pongs or chows) and 1 pair."})]}):null}const Qe=[{label:"Slow",value:800},{label:"Med",value:400},{label:"Fast",value:150}];function et({handIsFull:t,result:s,showAnimation:n,steps:a,stepIndex:l,stepsTotal:r,isAnimating:m,animSpeed:k,currentStep:p,lastError:T,onCheckHand:i,onResetHand:o,onRandomHand:x,onWinningHand:u,onToggleAnimation:g,onStepForward:b,onStepBack:w,onAutoPlay:$,onSetAnimSpeed:N,soundEnabled:f,onToggleSound:C}){return e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-80 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-sm md:text-base font-bold text-indigo-300 mb-1",children:J.title}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500 italic mb-2",children:J.subtitle}),e.jsx("p",{className:"text-xs md:text-sm text-slate-400 leading-relaxed",children:J.what}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:J.skills.map(h=>e.jsx("span",{className:"inline-flex items-center rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] md:text-xs font-medium text-violet-400 ring-1 ring-violet-500/20",children:h},h))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Actions"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 md:gap-2.5 mb-3",children:[e.jsxs("button",{onClick:x,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(Te,{size:14})," Random"]}),e.jsxs("button",{onClick:u,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(ve,{size:14})," Winning"]}),e.jsxs("button",{onClick:o,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(K,{size:14})," Reset"]}),e.jsxs("button",{onClick:i,disabled:!t,className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${t?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 hover:bg-indigo-500/30":"bg-slate-800/40 text-slate-600 cursor-not-allowed"}`,children:[e.jsx(ke,{size:14})," Check"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 md:gap-2.5",children:[e.jsxs("button",{onClick:()=>C(!f),className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${f?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400 hover:bg-slate-700/60 hover:text-slate-300"}`,children:[f?e.jsx(Q,{size:14}):e.jsx(ee,{size:14})," Sound"]}),e.jsxs("button",{onClick:g,className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${n?"bg-amber-500/15 text-amber-300 ring-1 ring-amber-500/30":"bg-slate-800/60 text-slate-400 hover:bg-slate-700/60 hover:text-slate-300"}`,children:[n?e.jsx(we,{size:14}):e.jsx(Ce,{size:14}),n?"Anim On":"Anim Off"]})]})]}),n&&a.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Solver Steps"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("button",{onClick:w,disabled:l<=-1,className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-slate-800/60 px-2 py-2.5 text-xs md:text-sm font-medium text-slate-400 hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(Se,{size:14})," Prev"]}),e.jsx("button",{onClick:$,className:`flex-1 flex items-center justify-center gap-1 rounded-lg px-2 py-2.5 text-xs md:text-sm font-medium transition-all ${m?"bg-amber-500/20 text-amber-300 ring-1 ring-amber-500/30":"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/30 hover:bg-indigo-500/30"}`,children:m?e.jsxs(e.Fragment,{children:[e.jsx(We,{size:14})," Pause"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{size:14})," Play"]})}),e.jsxs("button",{onClick:b,disabled:l>=r-1,className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-slate-800/60 px-2 py-2.5 text-xs md:text-sm font-medium text-slate-400 hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:["Next ",e.jsx($e,{size:14})]})]}),e.jsx("div",{className:"flex gap-1 mb-2",children:Qe.map(h=>e.jsx("button",{onClick:()=>N(h.value),className:`flex-1 rounded-md px-2 py-1.5 text-[10px] md:text-xs font-medium transition-all ${k===h.value?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/50 text-slate-500 hover:text-slate-400"}`,children:h.label},h.value))}),r>0&&e.jsxs("div",{className:"flex items-center justify-between text-[10px] md:text-xs text-slate-500",children:[e.jsx("span",{children:"Step"}),e.jsxs("span",{className:"font-mono font-semibold text-indigo-300",children:[Math.max(0,l+1)," / ",r]})]})]}),n&&p&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${p.action.type==="found_win"?"border-emerald-500/30 bg-emerald-500/5":p.action.type==="backtrack"||p.action.type==="pair_failed"?"border-amber-500/30 bg-amber-500/5":p.action.type==="no_win"?"border-red-500/30 bg-red-500/5":"border-slate-700/50 bg-slate-900/60"}`,children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-2",children:"Current Step"}),e.jsx("p",{className:"text-xs md:text-sm text-slate-300 leading-relaxed",children:p.description})]}),s&&!n&&e.jsx("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${s.isWin?"border-emerald-500/30 bg-emerald-500/5":"border-red-500/30 bg-red-500/5"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{size:16,className:s.isWin?"text-emerald-400":"text-red-400"}),e.jsx("span",{className:`text-sm md:text-base font-bold ${s.isWin?"text-emerald-300":"text-red-300"}`,children:s.isWin?"Winning Hand!":"Not a Winner"})]})}),T&&e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/5 px-3 py-2.5 text-center text-xs md:text-sm font-medium text-red-400 animate-pulse",children:T})]})}const oe=B.flatMap(t=>O.map(s=>`${t}${s}`));function fe(t){return{suit:t[0],value:Number(t[1])}}function tt(t){const s={};for(const n of t)s[n]=(s[n]??0)+1;return s}const me={B:0,C:1,D:2};function L(t){return[...t].sort((s,n)=>{const a=me[s[0]],l=me[n[0]];return a!==l?a-l:Number(s[1])-Number(n[1])})}function st(t){if(t.length===0)return"Hand is empty. Add 14 tiles.";if(t.lengthP)return`Hand has ${t.length} tiles. Maximum is ${P}.`;const s=tt(t);for(const[n,a]of Object.entries(s))if(a>E)return`Too many copies of ${n} (${a}). Maximum is ${E}.`;return null}function be(t,s){return t.length>=P?`Hand is full (${P} tiles).`:t.filter(a=>a===s).length>=E?`Already have ${E} copies of ${s}.`:null}function D(){const t={},s=[];for(;s.length(s[r]??0)>=E?!1:(t.push(r),s[r]=(s[r]??0)+1,!0);for(let r=0;r<4;r++){const m=B[Math.floor(Math.random()*B.length)];if(Math.random()<.4){const i=O[Math.floor(Math.random()*O.length)],o=`${m}${i}`;if((s[o]??0)+3<=E){n(o),n(o),n(o);continue}}let p=!1;const T=[...O.filter(i=>i<=7)].sort(()=>Math.random()-.5);for(const i of T){const o=`${m}${i}`,x=`${m}${i+1}`,u=`${m}${i+2}`;if((s[o]??0)Math.random()-.5);for(const r of l)if((s[r]??0)+2<=E){n(r),n(r),a=!0;break}return!a||t.length!==P?L(["B1","B2","B3","C4","C5","C6","D7","D7","D7","B8","B8","B8","C1","C1"]):L(t)}function je(t){const s={B:{},C:{},D:{}};for(const n of t){const{suit:a,value:l}=fe(n);s[a][l]=(s[a][l]??0)+1}return s}function ye(t){const s={B:{},C:{},D:{}};for(const n of B)for(const[a,l]of Object.entries(t[n]))s[n][Number(a)]=l;return s}function F(t){const s={};for(const n of B)for(const[a,l]of Object.entries(t[n]))l>0&&(s[`${n}${a}`]=l);return s}function nt(t){let s=0;for(const n of B)for(const a of Object.values(t[n]))s+=a;return s}function X(t,s,n,a){if(s===0)return nt(t)===0;for(const l of B)for(let r=1;r<=9;r++)if(!((t[l][r]??0)<=0)){if(t[l][r]>=3){const m=[`${l}${r}`,`${l}${r}`,`${l}${r}`];if(t[l][r]-=3,a&&a.push({action:{type:"try_meld",meldType:"pong",tiles:m,success:!0},description:`Try Pong: ${m.join(" ")}`,remaining:F(t)}),n.push({type:"pong",tiles:m}),X(t,s-1,n,a))return!0;n.pop(),t[l][r]+=3,a&&a.push({action:{type:"backtrack",tiles:m},description:`Backtrack: undo Pong ${m.join(" ")}`,remaining:F(t)})}if(r<=7&&(t[l][r]??0)>=1&&(t[l][r+1]??0)>=1&&(t[l][r+2]??0)>=1){const m=[`${l}${r}`,`${l}${r+1}`,`${l}${r+2}`];if(t[l][r]-=1,t[l][r+1]-=1,t[l][r+2]-=1,a&&a.push({action:{type:"try_meld",meldType:"chow",tiles:m,success:!0},description:`Try Chow: ${m.join(" ")}`,remaining:F(t)}),n.push({type:"chow",tiles:m}),X(t,s-1,n,a))return!0;n.pop(),t[l][r]+=1,t[l][r+1]+=1,t[l][r+2]+=1,a&&a.push({action:{type:"backtrack",tiles:m},description:`Backtrack: undo Chow ${m.join(" ")}`,remaining:F(t)})}return!1}return s===0}function G(t){const s=je(t),n=[];for(const a of B)for(let l=1;l<=9;l++)(s[a][l]??0)>=2&&n.push({suit:a,value:l});for(const{suit:a,value:l}of n){const r=ye(s);r[a][l]-=2;const m=[];if(X(r,4,m,null)){const k=`${a}${l}`;return{isWin:!0,pair:[k,k],melds:m}}}return{isWin:!1}}function at(t){const s=je(t),n=[],a=[];for(const l of B)for(let r=1;r<=9;r++)(s[l][r]??0)>=2&&a.push({suit:l,value:r});for(const{suit:l,value:r}of a){const m=`${l}${r}`;n.push({action:{type:"select_pair",pair:m},description:`Try pair: ${m} ${m}`,remaining:F(s)});const k=ye(s);k[l][r]-=2;const p=[];if(X(k,4,p,n)){const T={type:"found_win",pair:[m,m],melds:p.map(i=>({...i,tiles:[...i.tiles]}))};return n.push({action:T,description:`WIN! Pair: ${m} ${m} | Melds: ${p.map(i=>i.tiles.join(" ")).join(" | ")}`,remaining:{}}),{result:{isWin:!0,pair:[m,m],melds:p},steps:n}}n.push({action:{type:"pair_failed",pair:m},description:`Pair ${m} ${m} failed — no valid 4 melds found`,remaining:F(s)})}return n.push({action:{type:"no_win"},description:"No valid winning combination found.",remaining:F(s)}),{result:{isWin:!1},steps:n}}const lt=[261.63,293.66,329.63,392,440,493.88,523.25,587.33,659.25];function te(){const t=c.useRef(!0),s=c.useCallback(()=>_e(),[]),n=c.useCallback(i=>{t.current=i},[]),a=c.useCallback(i=>{if(!t.current)return;const o=s();if(!o)return;const x=lt[Math.max(0,Math.min(i-1,8))],u=o.createOscillator(),g=o.createGain();u.type="sine",u.frequency.setValueAtTime(x,o.currentTime),g.gain.setValueAtTime(.1,o.currentTime),g.gain.exponentialRampToValueAtTime(.001,o.currentTime+.2),u.connect(g),g.connect(o.destination),u.start(),u.stop(o.currentTime+.2);const b=o.createOscillator(),w=o.createGain();b.type="triangle",b.frequency.setValueAtTime(x*2,o.currentTime),w.gain.setValueAtTime(.03,o.currentTime),w.gain.exponentialRampToValueAtTime(.001,o.currentTime+.15),b.connect(w),w.connect(o.destination),b.start(o.currentTime+.02),b.stop(o.currentTime+.17)},[s]),l=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;const o=i.createOscillator(),x=i.createGain();o.type="sine",o.frequency.setValueAtTime(480,i.currentTime),o.frequency.setValueAtTime(320,i.currentTime+.08),x.gain.setValueAtTime(.07,i.currentTime),x.gain.exponentialRampToValueAtTime(.001,i.currentTime+.12),o.connect(x),x.connect(i.destination),o.start(),o.stop(i.currentTime+.12)},[s]),r=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;[523.25,587.33,659.25,783.99,880,1046.5].forEach((x,u)=>{const g=i.createOscillator(),b=i.createGain();g.type="sine",g.frequency.value=x,b.gain.setValueAtTime(.08,i.currentTime+u*.09),b.gain.exponentialRampToValueAtTime(.001,i.currentTime+u*.09+.2),g.connect(b),b.connect(i.destination),g.start(i.currentTime+u*.09),g.stop(i.currentTime+u*.09+.2)})},[s]),m=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;[400,340,280].forEach((x,u)=>{const g=i.createOscillator(),b=i.createGain();g.type="sine",g.frequency.value=x,b.gain.setValueAtTime(.07,i.currentTime+u*.1),b.gain.exponentialRampToValueAtTime(.001,i.currentTime+u*.1+.2),g.connect(b),b.connect(i.destination),g.start(i.currentTime+u*.1),g.stop(i.currentTime+u*.1+.2)})},[s]),k=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;const o=i.createOscillator(),x=i.createGain();o.type="sawtooth",o.frequency.setValueAtTime(190,i.currentTime),o.frequency.setValueAtTime(130,i.currentTime+.12),x.gain.setValueAtTime(.07,i.currentTime),x.gain.exponentialRampToValueAtTime(.001,i.currentTime+.25),o.connect(x),x.connect(i.destination),o.start(),o.stop(i.currentTime+.25)},[s]),p=c.useCallback(i=>{if(!t.current)return;const o=s();if(!o)return;const x=400+i%8*50,u=o.createOscillator(),g=o.createGain();u.type="sine",u.frequency.setValueAtTime(x,o.currentTime),g.gain.setValueAtTime(.05,o.currentTime),g.gain.exponentialRampToValueAtTime(.001,o.currentTime+.08),u.connect(g),g.connect(o.destination),u.start(),u.stop(o.currentTime+.08)},[s]),T=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;const o=i.createOscillator(),x=i.createGain();o.type="triangle",o.frequency.setValueAtTime(550,i.currentTime),o.frequency.setValueAtTime(350,i.currentTime+.06),x.gain.setValueAtTime(.05,i.currentTime),x.gain.exponentialRampToValueAtTime(.001,i.currentTime+.1),o.connect(x),x.connect(i.destination),o.start(),o.stop(i.currentTime+.1)},[s]);return{playTilePlaced:a,playTileRemoved:l,playWinSound:r,playLoseSound:m,playErrorSound:k,playStepTick:p,playBacktrackSound:T,setEnabled:n}}function rt(){if(Math.random()<.6){const s=ce(),n=G(s);return{hand:s,isWinning:n.isWin,solution:n.isWin?n:null}}for(let s=0;s<50;s++){const n=D();if(!G(n).isWin)return{hand:n,isWinning:!1,solution:null}}return{hand:D(),isWinning:!1,solution:null}}const ne={hand:[],isWinning:!1,solution:null,phase:"judging",playerSaidWin:null,selectedTiles:[],foundPair:null,foundMelds:[],hintsUsed:0,showHint:!1,feedback:null,roundComplete:!1};function it(){const[t,s]=c.useState(ne),[n,a]=c.useState(0),[l,r]=c.useState(0),[m,k]=c.useState(0),[p,T]=c.useState(!1),[i,o]=c.useState(!0),x=te(),u=c.useCallback(()=>{const d=rt();s({...ne,hand:d.hand,isWinning:d.isWinning,solution:d.solution}),T(!0)},[]),g=c.useCallback(d=>{const v=d===t.isWinning;v&&t.isWinning&&t.solution?(x.playTilePlaced(5),s(j=>({...j,playerSaidWin:d,phase:"grouping",feedback:"Correct! Now identify the pair and melds."}))):v&&!t.isWinning?(x.playWinSound(),a(j=>j+100-t.hintsUsed*20),r(j=>j+1),k(j=>j+1),s(j=>({...j,playerSaidWin:d,phase:"feedback",feedback:"Correct! This hand is not a winner.",roundComplete:!0}))):(x.playLoseSound(),r(j=>j+1),s(j=>({...j,playerSaidWin:d,phase:"feedback",feedback:t.isWinning?"Wrong — this hand IS a winner! Check the solution below.":"Wrong — this hand is NOT a winner.",roundComplete:!0})))},[t,x]),b=c.useCallback(d=>{s(v=>{const j=v.selectedTiles.includes(d)?v.selectedTiles.filter(y=>y!==d):[...v.selectedTiles,d];return{...v,selectedTiles:j}}),x.playTilePlaced(3)},[x]),w=c.useCallback(()=>{if(t.selectedTiles.length!==2||!t.solution)return;const d=t.selectedTiles.map(y=>t.hand[y]),v=t.solution.pair;d[0]===d[1]&&d[0]===v[0]?(x.playTilePlaced(7),s(y=>({...y,foundPair:[d[0],d[1]],selectedTiles:[],feedback:"Pair found! Now identify the 4 melds."}))):(x.playErrorSound(),s(y=>({...y,selectedTiles:[],feedback:"That's not the correct pair. Try again!"})))},[t,x]),$=c.useCallback(()=>{if(t.selectedTiles.length!==3||!t.solution)return;const d=t.selectedTiles.map(y=>t.hand[y]).sort(),v=t.solution.melds.filter((y,W)=>!t.foundMelds.some(S=>JSON.stringify(S.tiles.sort())===JSON.stringify(t.solution.melds[W].tiles.sort()))),j=v.findIndex(y=>JSON.stringify([...y.tiles].sort())===JSON.stringify(d));if(j>=0){const y=v[j];x.playTilePlaced(8);const W=[...t.foundMelds,y];W.length===4?(x.playWinSound(),a(S=>S+200-t.hintsUsed*30),r(S=>S+1),k(S=>S+1),s(S=>({...S,foundMelds:W,selectedTiles:[],phase:"feedback",feedback:"Excellent! You identified all groups correctly!",roundComplete:!0}))):s(S=>({...S,foundMelds:W,selectedTiles:[],feedback:`Meld ${W.length}/4 found! Keep going.`}))}else x.playErrorSound(),s(y=>({...y,selectedTiles:[],feedback:"Those 3 tiles don't form a valid meld in the solution. Try again!"}))},[t,x]),N=c.useCallback(()=>{t.solution&&(x.playBacktrackSound(),s(d=>({...d,hintsUsed:d.hintsUsed+1,showHint:!0})),setTimeout(()=>{s(d=>({...d,showHint:!1}))},3e3))},[t.solution,x]),f=c.useCallback(()=>{r(d=>d+1),s(d=>({...d,phase:"feedback",feedback:"Skipped grouping. Here's the solution:",roundComplete:!0}))},[]),C=c.useCallback(()=>{s(ne),a(0),r(0),k(0),T(!1)},[]),h=c.useCallback(d=>{o(d),x.setEnabled(d)},[x]);return{round:t,score:n,totalRounds:l,correctRounds:m,started:p,soundEnabled:i,startNewRound:u,judgeHand:g,toggleTileSelection:b,submitPair:w,submitMeld:$,useHint:N,skipGrouping:f,resetGame:C,toggleSound:h}}function q({code:t,index:s,selected:n,onClick:a}){return e.jsx(I,{code:t,index:s,size:"lg",selected:n,interactive:!!a,disabled:!a,onClick:a})}function ot(){const{round:t,score:s,totalRounds:n,correctRounds:a,started:l,soundEnabled:r,startNewRound:m,judgeHand:k,toggleTileSelection:p,submitPair:T,submitMeld:i,useHint:o,skipGrouping:x,resetGame:u,toggleSound:g}=it();if(!l)return e.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md text-center",children:[e.jsx("div",{className:"text-4xl mb-4",children:"📖"}),e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white mb-2",children:"Guided Mode"}),e.jsxs("p",{className:"text-sm md:text-base text-slate-400 mb-6 leading-relaxed",children:["Practice identifying winning Mahjong hands step-by-step. First judge if the hand is a winner, then identify the ",e.jsx("span",{className:"text-indigo-300 font-semibold",children:"pair"})," and ",e.jsx("span",{className:"text-violet-300 font-semibold",children:"4 melds"})," by selecting tiles. Use hints if you get stuck!"]}),e.jsx("button",{onClick:m,className:"rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-8 py-3 text-sm md:text-base font-bold text-white shadow-lg shadow-indigo-500/25 transition-all hover:shadow-indigo-500/40 hover:scale-105 active:scale-95",children:"Start Learning"})]})});const{hand:b,phase:w,selectedTiles:$,foundPair:N,foundMelds:f,feedback:C,showHint:h,solution:d,roundComplete:v,hintsUsed:j}=t,y=d&&h?N?`Hint: Next meld is ${d.melds[f.length]?.tiles.join(" ")??"done!"}`:`Hint: The pair is ${d.pair[0]} ${d.pair[1]}`:null,W=new Set;if(N){let S=0;for(let M=0;M=0&&(W.add(z),M.splice(H,1))}}return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-80 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Progress"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-indigo-300",children:s}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Score"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-emerald-300",children:a}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Correct"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-slate-300",children:n}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Rounds"})]})]})]}),w==="judging"&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-2",children:"Step 1: Judge"}),e.jsx("p",{className:"text-xs md:text-sm text-slate-400 mb-4",children:"Is this a valid winning hand?"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>k(!0),className:"flex items-center justify-center gap-2 rounded-xl bg-emerald-500/15 px-4 py-3 text-sm md:text-base font-bold text-emerald-300 ring-1 ring-emerald-500/30 transition-all hover:bg-emerald-500/25 hover:scale-105 active:scale-95",children:[e.jsx(V,{size:16})," Win"]}),e.jsxs("button",{onClick:()=>k(!1),className:"flex items-center justify-center gap-2 rounded-xl bg-red-500/15 px-4 py-3 text-sm md:text-base font-bold text-red-300 ring-1 ring-red-500/30 transition-all hover:bg-red-500/25 hover:scale-105 active:scale-95",children:[e.jsx(re,{size:16})," Not Win"]})]})]}),w==="grouping"&&e.jsxs("div",{className:"rounded-xl border border-indigo-500/30 bg-indigo-500/5 p-4 md:p-5 backdrop-blur-sm",children:[e.jsxs("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-indigo-300 mb-2",children:["Step 2: ",N?`Find Meld ${f.length+1}/4`:"Find the Pair"]}),e.jsx("p",{className:"text-xs md:text-sm text-slate-400 mb-3",children:N?"Select 3 tiles that form a pong (AAA) or chow (ABC).":"Select 2 identical tiles that form the pair."}),e.jsxs("p",{className:"text-xs md:text-sm text-indigo-300 font-mono mb-3",children:["Selected: ",$.length," / ",N?3:2]}),e.jsx("div",{className:"flex gap-2 mb-3",children:N?e.jsxs("button",{onClick:i,disabled:$.length!==3,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-indigo-500/20 px-3 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(V,{size:14})," Submit Meld"]}):e.jsxs("button",{onClick:T,disabled:$.length!==2,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-indigo-500/20 px-3 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(V,{size:14})," Submit Pair"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:o,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-amber-500/15 px-3 py-2 text-xs md:text-sm font-medium text-amber-300 ring-1 ring-amber-500/30 transition-all hover:bg-amber-500/25",children:[e.jsx(Me,{size:14})," Hint (",j,")"]}),e.jsxs("button",{onClick:x,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60",children:[e.jsx(Re,{size:14})," Skip"]})]})]}),C&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${w==="feedback"&&v?t.playerSaidWin===t.isWinning?"border-emerald-500/30 bg-emerald-500/5":"border-red-500/30 bg-red-500/5":"border-indigo-500/30 bg-indigo-500/5"}`,children:[e.jsx("p",{className:"text-xs md:text-sm text-slate-300 leading-relaxed",children:C}),y&&e.jsx("p",{className:"mt-2 text-xs md:text-sm text-amber-300 font-mono animate-pulse",children:y}),v&&d&&e.jsxs("div",{className:"mt-3 text-[10px] md:text-xs text-slate-500",children:[e.jsxs("p",{children:["Solution: Pair ",d.pair.join(" ")]}),d.melds.map((S,M)=>e.jsxs("p",{children:[S.type==="pong"?"Pong":"Chow",": ",S.tiles.join(" ")]},M))]}),v&&e.jsxs("button",{onClick:m,className:"mt-3 w-full flex items-center justify-center gap-2 rounded-lg bg-indigo-500/20 px-4 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30",children:["Next Round ",e.jsx(de,{size:14})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:u,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(K,{size:14})," Reset"]}),e.jsx("button",{onClick:()=>g(!r),className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${r?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400"}`,children:r?e.jsx(Q,{size:14}):e.jsx(ee,{size:14})})]})]}),e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col gap-4 min-h-0 md:overflow-auto",children:[e.jsxs("div",{className:"rounded-2xl border border-emerald-900/40 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.14),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.32))] p-4 shadow-2xl shadow-black/30 md:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 md:mb-4",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-emerald-200",children:"Hand"}),N&&e.jsxs("span",{className:"text-xs md:text-sm font-mono text-emerald-300",children:["Pair ✓ | Melds ",f.length,"/4"]})]}),e.jsx("div",{className:"flex flex-wrap items-end gap-1.5 rounded-xl border border-emerald-950/40 bg-emerald-950/20 p-3 shadow-inner md:gap-2",children:b.map((S,M)=>{const z=W.has(M),H=$.includes(M),se=w==="grouping"&&!z;return e.jsx("div",{className:z?"opacity-30":"",children:e.jsx(q,{code:S,index:M,selected:H,onClick:se?()=>p(M):void 0})},`${S}-${M}`)})})]}),(N||f.length>0)&&e.jsxs("div",{className:"rounded-2xl border border-emerald-500/20 bg-emerald-500/5 p-4 shadow-xl shadow-emerald-950/20 backdrop-blur-sm md:p-5",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-emerald-400 mb-3",children:"Found Groups"}),N&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-slate-600 w-14 shrink-0",children:"Pair"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(q,{code:N[0],index:-1,selected:!1}),e.jsx(q,{code:N[1],index:-1,selected:!1})]})]}),f.map((S,M)=>e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("span",{className:"text-[10px] md:text-xs font-medium text-slate-600 w-14 shrink-0",children:[S.type==="pong"?"Pong":"Chow"," ",M+1]}),e.jsx("div",{className:"flex gap-1",children:S.tiles.map((z,H)=>e.jsx(q,{code:z,index:-1,selected:!1},`${z}-${H}`))})]},M))]})]})]})}function ue(){if(Math.random()<.5){const s=ce(),n=G(s);return{hand:s,isWinning:n.isWin,solution:n.isWin?n:null}}for(let s=0;s<50;s++){const n=D();if(!G(n).isWin)return{hand:n,isWinning:!1,solution:null}}return{hand:D(),isWinning:!1,solution:null}}const ae={hand:[],isWinning:!1,solution:null,round:0,score:0,streak:0,bestStreak:0,timer:0,answered:!1,lastCorrect:null,totalCorrect:0,totalAnswered:0};function dt(){const[t,s]=c.useState(ae),[n,a]=c.useState(!1),l=c.useRef(null),r=te(),[m,k]=c.useState(!0);c.useEffect(()=>(n&&!t.answered&&(l.current=setInterval(()=>{s(u=>({...u,timer:u.timer+1}))},1e3)),()=>{l.current&&clearInterval(l.current)}),[n,t.answered]);const p=c.useCallback(()=>{const{hand:u,isWinning:g,solution:b}=ue();s({...ae,hand:u,isWinning:g,solution:b,round:1}),a(!0)},[]),T=c.useCallback(()=>{const{hand:u,isWinning:g,solution:b}=ue();s(w=>({...w,hand:u,isWinning:g,solution:b,round:w.round+1,timer:0,answered:!1,lastCorrect:null}))},[]),i=c.useCallback(u=>{if(t.answered)return;const g=u===t.isWinning,b=Math.max(0,10-t.timer),w=g?100+b*10+t.streak*25:0;g?r.playWinSound():r.playLoseSound(),s($=>({...$,answered:!0,lastCorrect:g,score:$.score+w,streak:g?$.streak+1:0,bestStreak:g?Math.max($.bestStreak,$.streak+1):$.bestStreak,totalCorrect:$.totalCorrect+(g?1:0),totalAnswered:$.totalAnswered+1}))},[t.answered,t.isWinning,t.timer,t.streak,r]),o=c.useCallback(()=>{s(ae),a(!1),l.current&&clearInterval(l.current)},[]),x=c.useCallback(u=>{k(u),r.setEnabled(u)},[r]);return{...t,isRunning:n,soundEnabled:m,startGame:p,nextRound:T,answer:i,resetGame:o,toggleSound:x}}function ct({code:t}){return e.jsx(I,{code:t,size:"lg"})}function xt(){const{hand:t,isWinning:s,solution:n,round:a,score:l,streak:r,bestStreak:m,timer:k,answered:p,lastCorrect:T,totalCorrect:i,totalAnswered:o,isRunning:x,soundEnabled:u,startGame:g,nextRound:b,answer:w,resetGame:$,toggleSound:N}=dt();return x?e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-80 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Stats"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{size:14,className:"text-amber-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-white",children:l}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Score"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{size:14,className:"text-orange-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-orange-300",children:r}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Streak"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{size:14,className:"text-cyan-400"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-lg md:text-xl font-bold text-cyan-300",children:[k,"s"]}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Time"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{size:14,className:"text-emerald-400"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-lg md:text-xl font-bold text-emerald-300",children:[i,"/",o]}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Correct"})]})]})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-[10px] md:text-xs text-slate-500",children:[e.jsxs("span",{children:["Round ",a]}),e.jsxs("span",{children:["Best streak: ",m]})]})]}),!p&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Your Judgment"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>w(!0),className:"flex items-center justify-center gap-2 rounded-xl bg-emerald-500/15 px-4 py-4 text-sm md:text-base font-bold text-emerald-300 ring-1 ring-emerald-500/30 transition-all hover:bg-emerald-500/25 hover:scale-105 active:scale-95",children:[e.jsx(V,{size:18})," Win"]}),e.jsxs("button",{onClick:()=>w(!1),className:"flex items-center justify-center gap-2 rounded-xl bg-red-500/15 px-4 py-4 text-sm md:text-base font-bold text-red-300 ring-1 ring-red-500/30 transition-all hover:bg-red-500/25 hover:scale-105 active:scale-95",children:[e.jsx(re,{size:18})," Not Win"]})]})]}),p&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${T?"border-emerald-500/30 bg-emerald-500/5":"border-red-500/30 bg-red-500/5"}`,children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:T?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:18,className:"text-emerald-400"}),e.jsx("span",{className:"text-sm md:text-base font-bold text-emerald-300",children:"Correct!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{size:18,className:"text-red-400"}),e.jsx("span",{className:"text-sm md:text-base font-bold text-red-300",children:"Wrong!"})]})}),e.jsxs("p",{className:"text-xs md:text-sm text-slate-400 mb-3",children:["The hand was ",e.jsx("span",{className:`font-bold ${s?"text-emerald-300":"text-red-300"}`,children:s?"a Winner":"Not a Winner"}),"."]}),s&&n&&e.jsxs("div",{className:"text-[10px] md:text-xs text-slate-500 mb-3",children:["Pair: ",n.pair.join(" ")," | Melds: ",n.melds.map(f=>f.tiles.join(" ")).join(" | ")]}),e.jsxs("button",{onClick:b,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-indigo-500/20 px-4 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30",children:["Next Round ",e.jsx(de,{size:14})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:$,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(K,{size:14})," Reset"]}),e.jsx("button",{onClick:()=>N(!u),className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${u?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400"}`,children:u?e.jsx(Q,{size:14}):e.jsx(ee,{size:14})})]})]}),e.jsx("div",{className:"order-last md:order-first flex md:flex-1 flex-col gap-4 min-h-0 md:overflow-auto",children:e.jsxs("div",{className:"rounded-2xl border border-emerald-900/40 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.14),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.32))] p-4 shadow-2xl shadow-black/30 md:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 md:mb-4",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-emerald-200",children:"Hand to Judge"}),e.jsxs("span",{className:"text-xs md:text-sm font-mono font-bold text-indigo-300",children:["Round ",a]})]}),e.jsx("div",{className:"flex flex-wrap items-end gap-1.5 rounded-xl border border-emerald-950/40 bg-emerald-950/20 p-3 shadow-inner md:gap-2",children:t.map((f,C)=>e.jsx(ct,{code:f},`${f}-${C}`))})]})})]}):e.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md text-center",children:[e.jsx("div",{className:"text-4xl mb-4",children:"⚡"}),e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white mb-2",children:"Challenge Mode"}),e.jsxs("p",{className:"text-sm md:text-base text-slate-400 mb-6 leading-relaxed",children:["You'll see a 14-tile hand. Decide as fast as you can: is it a ",e.jsx("span",{className:"text-emerald-400 font-semibold",children:"Winning Hand"})," or ",e.jsx("span",{className:"text-red-400 font-semibold",children:"Not a Winner"}),"? Score points for correct answers. Faster = more bonus points. Build streaks for multipliers!"]}),e.jsx("button",{onClick:g,className:"rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-8 py-3 text-sm md:text-base font-bold text-white shadow-lg shadow-indigo-500/25 transition-all hover:shadow-indigo-500/40 hover:scale-105 active:scale-95",children:"Start Challenge"})]})})}function ge(t){return{name:t,hand:[],result:null,score:0}}const le={phase:"building",players:[ge("Player 1"),ge("Player 2")],currentPlayer:0,round:1,roundComplete:!1};function mt(){const[t,s]=c.useState(le),[n,a]=c.useState(null),[l,r]=c.useState(!1),[m,k]=c.useState(!0),p=te(),T=t.players[t.currentPlayer].hand,i=T.length>=P,o=t.players[0].hand.length>=P&&t.players[1].hand.length>=P,x=c.useCallback(()=>{s({...le}),r(!0),a(null)},[]),u=c.useCallback(h=>{if(t.phase!=="building")return;const d=t.players[t.currentPlayer].hand,v=be(d,h);if(v){a(v),p.playErrorSound();return}a(null);const{value:j}={value:Number(h[1])};p.playTilePlaced(j),s(y=>{const W=[...y.players],S={...W[y.currentPlayer]};S.hand=L([...S.hand,h]),W[y.currentPlayer]=S;const M=S.hand.length>=P,z=W[1-y.currentPlayer].hand.length>=P;let H=y.currentPlayer;return M&&!z?H=1-y.currentPlayer:M||(H=1-y.currentPlayer,W[H].hand.length>=P&&(H=y.currentPlayer)),{...y,players:W,currentPlayer:H}})},[t.phase,t.currentPlayer,t.players,p]),g=c.useCallback(h=>{t.phase==="building"&&(p.playTileRemoved(),a(null),s(d=>{const v=[...d.players],j={...v[d.currentPlayer]},y=[...j.hand];return y.splice(h,1),j.hand=y,v[d.currentPlayer]=j,{...d,players:v}}))},[t.phase,p]),b=c.useCallback(()=>{if(!o)return;const h=G(t.players[0].hand),d=G(t.players[1].hand),v=h.isWin?1:0,j=d.isWin?1:0;v>j||j>v?p.playWinSound():p.playLoseSound(),s(y=>{const W=[...y.players];return W[0]={...W[0],result:h,score:W[0].score+v},W[1]={...W[1],result:d,score:W[1].score+j},{...y,players:W,phase:"results",roundComplete:!0}})},[o,t.players,p]),w=c.useCallback(()=>{s(h=>({...h,phase:"building",players:[{...h.players[0],hand:[],result:null},{...h.players[1],hand:[],result:null}],currentPlayer:0,round:h.round+1,roundComplete:!1})),a(null)},[]),$=c.useCallback(()=>{s(le),r(!1),a(null)},[]),N=c.useCallback(()=>{if(t.phase!=="building")return;const h=1-t.currentPlayer;t.players[h].hand.length>=P||s(d=>({...d,currentPlayer:h}))},[t.phase,t.currentPlayer,t.players]),f=()=>{if(t.phase!=="results")return null;const h=t.players[0].result,d=t.players[1].result;return!h||!d?null:h.isWin&&!d.isWin?t.players[0].name:!h.isWin&&d.isWin?t.players[1].name:h.isWin&&d.isWin?"Both Win!":"Neither Wins"},C=c.useCallback(h=>{k(h),p.setEnabled(h)},[p]);return{state:t,lastError:n,started:l,soundEnabled:m,currentHand:T,currentHandIsFull:i,bothFull:o,winner:f(),startGame:x,addTile:u,removeTile:g,checkBothHands:b,nextRound:w,resetGame:$,switchPlayer:N,toggleSound:C}}function ut({code:t,onRemove:s}){return e.jsx(I,{code:t,size:"md",interactive:!!s,removable:!!s,onClick:s})}function gt(t,s){return t.filter(n=>n===s).length}function pt({suit:t,value:s,count:n,disabled:a,onClick:l}){const r=n>=4,m=`${t}${s}`;return e.jsx(I,{code:m,count:n,size:"sm",disabled:a||r,interactive:!0,onClick:l})}function ht(){const{state:t,lastError:s,started:n,soundEnabled:a,currentHand:l,currentHandIsFull:r,bothFull:m,winner:k,startGame:p,addTile:T,removeTile:i,checkBothHands:o,nextRound:x,resetGame:u,switchPlayer:g,toggleSound:b}=mt();if(!n)return e.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md text-center",children:[e.jsx("div",{className:"text-4xl mb-4",children:"👥"}),e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white mb-2",children:"2 Player Mode"}),e.jsxs("p",{className:"text-sm md:text-base text-slate-400 mb-6 leading-relaxed",children:["Take turns placing tiles to build your 14-tile hands. Players alternate picks. Once both hands are complete, the solver checks both — whoever has a valid ",e.jsx("span",{className:"text-emerald-400 font-semibold",children:"winning hand"})," scores a point!"]}),e.jsx("button",{onClick:p,className:"rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-8 py-3 text-sm md:text-base font-bold text-white shadow-lg shadow-indigo-500/25 transition-all hover:shadow-indigo-500/40 hover:scale-105 active:scale-95",children:"Start Game"})]})});const{phase:w,players:$,currentPlayer:N,round:f}=t,C=$[0],h=$[1];return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-80 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(pe,{size:14,className:"text-indigo-400"}),e.jsxs("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400",children:["Round ",f]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:`rounded-lg p-3 text-center transition-all ${w==="building"&&N===0?"bg-indigo-500/15 ring-2 ring-indigo-400/40":"bg-slate-800/40"}`,children:[e.jsx("p",{className:"text-sm md:text-base font-bold text-indigo-300",children:C.name}),e.jsx("p",{className:"text-lg md:text-xl font-extrabold text-white",children:C.score}),e.jsxs("p",{className:"text-[10px] md:text-xs text-slate-500",children:[C.hand.length,"/",P," tiles"]}),w==="results"&&C.result&&e.jsx("p",{className:`mt-1 text-[10px] md:text-xs font-bold ${C.result.isWin?"text-emerald-400":"text-red-400"}`,children:C.result.isWin?"✓ Winner":"✗ No Win"})]}),e.jsxs("div",{className:`rounded-lg p-3 text-center transition-all ${w==="building"&&N===1?"bg-violet-500/15 ring-2 ring-violet-400/40":"bg-slate-800/40"}`,children:[e.jsx("p",{className:"text-sm md:text-base font-bold text-violet-300",children:h.name}),e.jsx("p",{className:"text-lg md:text-xl font-extrabold text-white",children:h.score}),e.jsxs("p",{className:"text-[10px] md:text-xs text-slate-500",children:[h.hand.length,"/",P," tiles"]}),w==="results"&&h.result&&e.jsx("p",{className:`mt-1 text-[10px] md:text-xs font-bold ${h.result.isWin?"text-emerald-400":"text-red-400"}`,children:h.result.isWin?"✓ Winner":"✗ No Win"})]})]})]}),w==="building"&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${N===0?"border-indigo-500/30 bg-indigo-500/5":"border-violet-500/30 bg-violet-500/5"}`,children:[e.jsxs("p",{className:`text-sm md:text-base font-bold ${N===0?"text-indigo-300":"text-violet-300"}`,children:[$[N].name,"'s Turn"]}),e.jsx("p",{className:"text-xs md:text-sm text-slate-400 mt-1",children:"Pick a tile to add to your hand."}),!r&&e.jsxs("button",{onClick:g,className:"mt-3 w-full flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(Ie,{size:14})," Switch Player"]})]}),w==="building"&&m&&e.jsxs("button",{onClick:o,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-indigo-500/20 to-violet-500/20 px-4 py-3 text-sm md:text-base font-bold text-indigo-200 ring-1 ring-indigo-500/30 transition-all hover:from-indigo-500/30 hover:to-violet-500/30 active:scale-95",children:[e.jsx(Y,{size:16})," Check Both Hands"]}),w==="results"&&k&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${k.includes("Neither")?"border-slate-700/50 bg-slate-900/60":"border-emerald-500/30 bg-emerald-500/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Y,{size:18,className:"text-amber-400"}),e.jsx("span",{className:"text-base md:text-lg font-bold text-white",children:k})]}),$.map((d,v)=>d.result&&d.result.isWin&&e.jsxs("div",{className:"mt-2 text-[10px] md:text-xs text-slate-500",children:[e.jsxs("p",{className:"font-semibold text-slate-400",children:[d.name,":"]}),e.jsxs("p",{children:["Pair: ",d.result.pair.join(" ")]}),d.result.melds.map((j,y)=>e.jsxs("p",{children:[j.type==="pong"?"Pong":"Chow",": ",j.tiles.join(" ")]},y))]},v)),e.jsxs("button",{onClick:x,className:"mt-3 w-full flex items-center justify-center gap-2 rounded-lg bg-indigo-500/20 px-4 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30",children:["Next Round ",e.jsx(de,{size:14})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:u,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(K,{size:14})," Reset"]}),e.jsx("button",{onClick:()=>b(!a),className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${a?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400"}`,children:a?e.jsx(Q,{size:14}):e.jsx(ee,{size:14})})]}),s&&e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/5 px-3 py-2.5 text-center text-xs md:text-sm font-medium text-red-400 animate-pulse",children:s})]}),e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col gap-4 min-h-0 md:overflow-auto",children:[$.map((d,v)=>e.jsxs("div",{className:`rounded-2xl border p-4 shadow-xl backdrop-blur-sm md:p-5 ${w==="building"&&N===v?v===0?"border-indigo-500/30 bg-indigo-500/5":"border-violet-500/30 bg-violet-500/5":"border-emerald-900/40 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.12),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.28))]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:`text-xs md:text-sm font-semibold uppercase tracking-wider ${v===0?"text-indigo-400":"text-violet-400"}`,children:d.name}),e.jsxs("span",{className:`text-xs md:text-sm font-mono font-bold ${d.hand.length===P?"text-emerald-400":"text-slate-500"}`,children:[d.hand.length,"/",P]})]}),e.jsxs("div",{className:"flex min-h-[5rem] flex-wrap items-end gap-1.5 rounded-xl border border-emerald-950/40 bg-emerald-950/20 p-3 shadow-inner md:gap-2",children:[d.hand.map((j,y)=>e.jsx(ut,{code:j,onRemove:w==="building"&&N===v?()=>i(y):void 0},`${j}-${y}`)),d.hand.lengthe.jsx(I,{size:"md",placeholder:!0},`e-${y}`))]})]},v)),w==="building"&&!r&&e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm md:p-5",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-300 mb-3",children:"Tile Wall"}),e.jsx("div",{className:"space-y-3 md:space-y-4",children:B.map(d=>e.jsxs("div",{className:"rounded-xl border border-slate-800/70 bg-slate-950/35 p-3",children:[e.jsx("p",{className:"text-[10px] md:text-xs font-medium mb-1.5",style:{color:Z[d]},children:he[d]}),e.jsx("div",{className:"flex flex-wrap items-end gap-1 md:gap-1.5",children:O.map(v=>{const j=`${d}${v}`;return e.jsx(pt,{suit:d,value:v,count:gt(l,j),disabled:r,onClick:()=>T(j)},j)})})]},d))})]})]})]})}function ft(){const[t,s]=c.useState([]),[n,a]=c.useState(null),[l,r]=c.useState([]),[m,k]=c.useState(-1),[p,T]=c.useState(!1),[i,o]=c.useState(400),[x,u]=c.useState(null),[g,b]=c.useState(!1),[w,$]=c.useState(!0),N=c.useRef(null),f=te();c.useEffect(()=>()=>{N.current&&clearInterval(N.current)},[]);const C=c.useCallback(()=>{a(null),r([]),k(-1),T(!1),N.current&&(clearInterval(N.current),N.current=null)},[]),h=c.useCallback(_=>{s(A=>{const R=be(A,_);return R?(u(R),f.playErrorSound(),A):(u(null),C(),f.playTilePlaced(fe(_).value),L([...A,_]))})},[C,f]),d=c.useCallback(_=>{s(A=>{const R=[...A];return R.splice(_,1),C(),f.playTileRemoved(),R}),u(null)},[C,f]),v=c.useCallback(()=>{s([]),u(null),C()},[C]),j=c.useCallback(()=>{s(D()),u(null),C()},[C]),y=c.useCallback(()=>{s(ce()),u(null),C()},[C]),W=c.useCallback(()=>{const _=st(t);if(_){u(_),f.playErrorSound();return}if(u(null),g){const{result:A,steps:R}=at(t);a(A),r(R),k(-1)}else{const A=G(t);a(A),r([]),k(-1),A.isWin?f.playWinSound():f.playLoseSound()}},[t,g,f]),S=c.useCallback(()=>{k(_=>{const A=Math.min(_+1,l.length-1);if(A>=0&&A{k(_=>Math.max(_-1,-1))},[]),z=c.useCallback(()=>{if(p){N.current&&(clearInterval(N.current),N.current=null),T(!1);return}T(!0),k(_=>_>=l.length-1?-1:_),N.current=setInterval(()=>{k(_=>{if(_>=l.length-1)return N.current&&clearInterval(N.current),N.current=null,T(!1),_;const A=_+1;if(A{b(_=>!_),C()},[C]),se=c.useCallback(_=>{$(_),f.setEnabled(_)},[f]),Ne=m>=0&&m=P,soundEnabled:w,addTile:h,removeTile:d,resetHand:v,randomHand:j,winningHand:y,checkHand:W,stepForward:S,stepBack:M,autoPlay:z,setAnimSpeed:o,toggleAnimation:H,toggleSound:se}}const bt={sandbox:e.jsx(Le,{size:14}),guided:e.jsx(ze,{size:14}),challenge:e.jsx(Ee,{size:14}),"two-player":e.jsx(pe,{size:14})},jt=["sandbox","guided","challenge","two-player"];function yt(){const{hand:t,result:s,steps:n,stepIndex:a,stepsTotal:l,currentStep:r,isAnimating:m,animSpeed:k,showAnimation:p,lastError:T,handIsFull:i,addTile:o,removeTile:x,resetHand:u,randomHand:g,winningHand:b,checkHand:w,stepForward:$,stepBack:N,autoPlay:f,setAnimSpeed:C,toggleAnimation:h,soundEnabled:d,toggleSound:v}=ft();return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto bg-[radial-gradient(circle_at_top,rgba(16,185,129,0.08),transparent_34%),linear-gradient(180deg,rgba(15,23,42,0),rgba(6,78,59,0.16))] p-4 md:p-6",children:[e.jsx(et,{handIsFull:i,result:s,showAnimation:p,steps:n,stepIndex:a,stepsTotal:l,isAnimating:m,animSpeed:k,currentStep:r,lastError:T,onCheckHand:w,onResetHand:u,onRandomHand:g,onWinningHand:b,onToggleAnimation:h,onStepForward:$,onStepBack:N,onAutoPlay:f,onSetAnimSpeed:C,soundEnabled:d,onToggleSound:v}),e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col gap-4 min-h-0 md:min-h-0 md:overflow-auto",children:[e.jsx(Ze,{hand:t,onRemoveTile:x}),s&&e.jsx(Ke,{result:s}),e.jsx(Ye,{hand:t,handIsFull:i,onAddTile:o})]})]})}function zt(){const[t,s]=c.useState("sandbox");return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("div",{className:"shrink-0 border-b border-emerald-900/40 bg-[linear-gradient(135deg,rgba(15,23,42,0.9),rgba(6,78,59,0.34))] backdrop-blur-sm px-4 md:px-6 pt-3 pb-0",children:e.jsx("div",{className:"flex gap-1 overflow-x-auto",children:jt.map(n=>e.jsxs("button",{onClick:()=>s(n),className:`flex items-center gap-1.5 rounded-t-lg px-4 py-2.5 text-xs md:text-sm font-medium transition-all whitespace-nowrap ${t===n?"bg-slate-800/80 text-indigo-300 border border-b-0 border-slate-700/50 -mb-px":"text-slate-500 hover:text-slate-300 hover:bg-slate-800/30"}`,children:[bt[n],e.jsx("span",{children:De[n].label})]},n))})}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[t==="sandbox"&&e.jsx(yt,{}),t==="guided"&&e.jsx(ot,{}),t==="challenge"&&e.jsx(xt,{}),t==="two-player"&&e.jsx(ht,{})]})]})}export{zt as default}; + `;return k||i?e.jsx("button",{onClick:i,disabled:r,title:t,className:b,children:g}):e.jsx("div",{className:b,children:g})}function Ue({suit:t,value:s,color:n,size:a}){return t==="C"?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{style:{color:n},className:`${a==="sm"?"text-xl":a==="lg"?"text-3xl":"text-2xl"} font-black leading-none drop-shadow-sm`,children:s}),e.jsx("span",{style:{color:n},className:`${a==="sm"?"text-base":"text-lg"} font-black leading-none`,children:"萬"})]}):t==="B"?e.jsx("div",{className:"grid grid-cols-3 gap-0.5",children:Array.from({length:s}).map((l,r)=>e.jsx("span",{className:"h-3 w-1 rounded-full border border-emerald-950/20 bg-gradient-to-b from-emerald-300 to-emerald-700 shadow-sm"},r))}):e.jsx("div",{className:"grid grid-cols-3 gap-0.5",children:Array.from({length:s}).map((l,r)=>e.jsx("span",{className:"h-2.5 w-2.5 rounded-full border border-blue-950/30 bg-white shadow-sm",style:{boxShadow:`inset 0 0 0 2px ${n}`}},r))})}function Je(t,s){return t.filter(n=>n===s).length}function qe({suit:t,value:s,count:n,disabled:a,onClick:l}){const r=n>=4,m=`${t}${s}`;return e.jsx(I,{code:m,count:n,size:"md",disabled:a||r,interactive:!0,onClick:l})}function Ye({hand:t,handIsFull:s,onAddTile:n}){return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm md:p-5",children:[e.jsxs("div",{className:"mb-3 md:mb-4",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-300",children:"Tile Wall"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-slate-500",children:"Choose up to four copies of each realistic Mahjong tile"})]}),e.jsx("div",{className:"space-y-4 md:space-y-5",children:B.map(a=>e.jsxs("div",{className:"rounded-xl border border-slate-800/70 bg-slate-950/35 p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:Z[a]}}),e.jsx("p",{className:"text-[10px] md:text-xs font-semibold uppercase tracking-wider",style:{color:Z[a]},children:he[a]})]}),e.jsx("div",{className:"flex flex-wrap items-end gap-1.5 md:gap-2",children:O.map(l=>{const r=`${a}${l}`;return e.jsx(qe,{suit:a,value:l,count:Je(t,r),disabled:s,onClick:()=>n(r)},r)})})]},a))})]})}function Ze({hand:t,onRemoveTile:s}){const n=P-t.length;return e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-emerald-900/40 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.14),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.36))] p-4 shadow-2xl shadow-black/30 md:p-5",children:[e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-black/25 to-transparent"}),e.jsxs("div",{className:"flex items-center justify-between mb-3 md:mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-emerald-200",children:"Your Hand"}),e.jsx("p",{className:"mt-0.5 text-[10px] text-emerald-100/50",children:"Click a tile to discard it from the rack"})]}),e.jsxs("span",{className:`text-xs md:text-sm font-mono font-bold ${t.length===P?"text-emerald-400":"text-slate-500"}`,children:[t.length," / ",P]})]}),e.jsxs("div",{className:"relative flex min-h-[5.5rem] flex-wrap items-end gap-1.5 rounded-xl border border-emerald-950/40 bg-emerald-950/20 p-3 shadow-inner md:gap-2",children:[t.map((a,l)=>e.jsx(I,{code:a,index:l,size:"lg",interactive:!0,removable:!0,onClick:()=>s(l)},`${a}-${l}`)),n>0&&Array.from({length:n}).map((a,l)=>e.jsx(I,{size:"lg",placeholder:!0},`empty-${l}`))]})]})}function ie({code:t}){return e.jsx(I,{code:t,size:"sm"})}function Xe({meld:t,index:s}){return e.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-slate-950/35 p-2 ring-1 ring-slate-800/70 md:gap-3",children:[e.jsxs("span",{className:"w-14 shrink-0 text-[10px] font-semibold uppercase tracking-wider text-slate-500 md:w-16 md:text-xs",children:[t.type==="pong"?"Pong":"Chow"," ",s+1]}),e.jsx("div",{className:"flex gap-1 md:gap-1.5",children:t.tiles.map((n,a)=>e.jsx(ie,{code:n},`${n}-${a}`))})]})}function Ke({result:t}){return t?t.isWin?e.jsxs("div",{className:"rounded-2xl border border-emerald-500/30 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.18),transparent_36%),rgba(16,185,129,0.05)] p-4 shadow-xl shadow-emerald-950/20 backdrop-blur-sm md:p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 md:mb-4",children:[e.jsx("span",{className:"text-lg md:text-2xl",children:"🀄"}),e.jsx("h3",{className:"text-sm md:text-base font-bold text-emerald-300",children:"Winning Hand!"})]}),e.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-xl bg-slate-950/35 p-2 ring-1 ring-slate-800/70 md:mb-4 md:gap-3",children:[e.jsx("span",{className:"w-14 shrink-0 text-[10px] font-semibold uppercase tracking-wider text-slate-500 md:w-16 md:text-xs",children:"Pair"}),e.jsxs("div",{className:"flex gap-1 md:gap-1.5",children:[e.jsx(ie,{code:t.pair[0]}),e.jsx(ie,{code:t.pair[1]})]})]}),e.jsx("div",{className:"space-y-2 md:space-y-3",children:t.melds.map((s,n)=>e.jsx(Xe,{meld:s,index:n},n))})]}):e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/5 p-4 md:p-5 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg md:text-2xl",children:"❌"}),e.jsx("h3",{className:"text-sm md:text-base font-bold text-red-300",children:"Not a Winning Hand"})]}),e.jsx("p",{className:"mt-2 text-xs md:text-sm text-slate-400",children:"Hand is not a valid winning combination. A winning hand needs 4 melds (pongs or chows) and 1 pair."})]}):null}const Qe=[{label:"Slow",value:800},{label:"Med",value:400},{label:"Fast",value:150}];function et({handIsFull:t,result:s,showAnimation:n,steps:a,stepIndex:l,stepsTotal:r,isAnimating:m,animSpeed:k,currentStep:p,lastError:T,onCheckHand:i,onResetHand:o,onRandomHand:x,onWinningHand:u,onToggleAnimation:g,onStepForward:b,onStepBack:w,onAutoPlay:$,onSetAnimSpeed:N,soundEnabled:f,onToggleSound:C}){return e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-80 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-sm md:text-base font-bold text-indigo-300 mb-1",children:J.title}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500 italic mb-2",children:J.subtitle}),e.jsx("p",{className:"text-xs md:text-sm text-slate-400 leading-relaxed",children:J.what}),e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:J.skills.map(h=>e.jsx("span",{className:"inline-flex items-center rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] md:text-xs font-medium text-violet-400 ring-1 ring-violet-500/20",children:h},h))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Actions"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 md:gap-2.5 mb-3",children:[e.jsxs("button",{onClick:x,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(Te,{size:14})," Random"]}),e.jsxs("button",{onClick:u,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(Ce,{size:14})," Winning"]}),e.jsxs("button",{onClick:o,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(K,{size:14})," Reset"]}),e.jsxs("button",{onClick:i,disabled:!t,className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${t?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 hover:bg-indigo-500/30":"bg-slate-800/40 text-slate-600 cursor-not-allowed"}`,children:[e.jsx(ve,{size:14})," Check"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 md:gap-2.5",children:[e.jsxs("button",{onClick:()=>C(!f),className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${f?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400 hover:bg-slate-700/60 hover:text-slate-300"}`,children:[f?e.jsx(Q,{size:14}):e.jsx(ee,{size:14})," Sound"]}),e.jsxs("button",{onClick:g,className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${n?"bg-amber-500/15 text-amber-300 ring-1 ring-amber-500/30":"bg-slate-800/60 text-slate-400 hover:bg-slate-700/60 hover:text-slate-300"}`,children:[n?e.jsx(ke,{size:14}):e.jsx(Se,{size:14}),n?"Anim On":"Anim Off"]})]})]}),n&&a.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Solver Steps"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("button",{onClick:w,disabled:l<=-1,className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-slate-800/60 px-2 py-2.5 text-xs md:text-sm font-medium text-slate-400 hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx($e,{size:14})," Prev"]}),e.jsx("button",{onClick:$,className:`flex-1 flex items-center justify-center gap-1 rounded-lg px-2 py-2.5 text-xs md:text-sm font-medium transition-all ${m?"bg-amber-500/20 text-amber-300 ring-1 ring-amber-500/30":"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/30 hover:bg-indigo-500/30"}`,children:m?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{size:14})," Pause"]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{size:14})," Play"]})}),e.jsxs("button",{onClick:b,disabled:l>=r-1,className:"flex-1 flex items-center justify-center gap-1 rounded-lg bg-slate-800/60 px-2 py-2.5 text-xs md:text-sm font-medium text-slate-400 hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:["Next ",e.jsx(We,{size:14})]})]}),e.jsx("div",{className:"flex gap-1 mb-2",children:Qe.map(h=>e.jsx("button",{onClick:()=>N(h.value),className:`flex-1 rounded-md px-2 py-1.5 text-[10px] md:text-xs font-medium transition-all ${k===h.value?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/50 text-slate-500 hover:text-slate-400"}`,children:h.label},h.value))}),r>0&&e.jsxs("div",{className:"flex items-center justify-between text-[10px] md:text-xs text-slate-500",children:[e.jsx("span",{children:"Step"}),e.jsxs("span",{className:"font-mono font-semibold text-indigo-300",children:[Math.max(0,l+1)," / ",r]})]})]}),n&&p&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${p.action.type==="found_win"?"border-emerald-500/30 bg-emerald-500/5":p.action.type==="backtrack"||p.action.type==="pair_failed"?"border-amber-500/30 bg-amber-500/5":p.action.type==="no_win"?"border-red-500/30 bg-red-500/5":"border-slate-700/50 bg-slate-900/60"}`,children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-2",children:"Current Step"}),e.jsx("p",{className:"text-xs md:text-sm text-slate-300 leading-relaxed",children:p.description})]}),s&&!n&&e.jsx("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${s.isWin?"border-emerald-500/30 bg-emerald-500/5":"border-red-500/30 bg-red-500/5"}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{size:16,className:s.isWin?"text-emerald-400":"text-red-400"}),e.jsx("span",{className:`text-sm md:text-base font-bold ${s.isWin?"text-emerald-300":"text-red-300"}`,children:s.isWin?"Winning Hand!":"Not a Winner"})]})}),T&&e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/5 px-3 py-2.5 text-center text-xs md:text-sm font-medium text-red-400 animate-pulse",children:T})]})}const oe=B.flatMap(t=>O.map(s=>`${t}${s}`));function fe(t){return{suit:t[0],value:Number(t[1])}}function tt(t){const s={};for(const n of t)s[n]=(s[n]??0)+1;return s}const me={B:0,C:1,D:2};function L(t){return[...t].sort((s,n)=>{const a=me[s[0]],l=me[n[0]];return a!==l?a-l:Number(s[1])-Number(n[1])})}function st(t){if(t.length===0)return"Hand is empty. Add 14 tiles.";if(t.lengthP)return`Hand has ${t.length} tiles. Maximum is ${P}.`;const s=tt(t);for(const[n,a]of Object.entries(s))if(a>E)return`Too many copies of ${n} (${a}). Maximum is ${E}.`;return null}function be(t,s){return t.length>=P?`Hand is full (${P} tiles).`:t.filter(a=>a===s).length>=E?`Already have ${E} copies of ${s}.`:null}function D(){const t={},s=[];for(;s.length(s[r]??0)>=E?!1:(t.push(r),s[r]=(s[r]??0)+1,!0);for(let r=0;r<4;r++){const m=B[Math.floor(Math.random()*B.length)];if(Math.random()<.4){const i=O[Math.floor(Math.random()*O.length)],o=`${m}${i}`;if((s[o]??0)+3<=E){n(o),n(o),n(o);continue}}let p=!1;const T=[...O.filter(i=>i<=7)].sort(()=>Math.random()-.5);for(const i of T){const o=`${m}${i}`,x=`${m}${i+1}`,u=`${m}${i+2}`;if((s[o]??0)Math.random()-.5);for(const r of l)if((s[r]??0)+2<=E){n(r),n(r),a=!0;break}return!a||t.length!==P?L(["B1","B2","B3","C4","C5","C6","D7","D7","D7","B8","B8","B8","C1","C1"]):L(t)}function je(t){const s={B:{},C:{},D:{}};for(const n of t){const{suit:a,value:l}=fe(n);s[a][l]=(s[a][l]??0)+1}return s}function ye(t){const s={B:{},C:{},D:{}};for(const n of B)for(const[a,l]of Object.entries(t[n]))s[n][Number(a)]=l;return s}function F(t){const s={};for(const n of B)for(const[a,l]of Object.entries(t[n]))l>0&&(s[`${n}${a}`]=l);return s}function nt(t){let s=0;for(const n of B)for(const a of Object.values(t[n]))s+=a;return s}function X(t,s,n,a){if(s===0)return nt(t)===0;for(const l of B)for(let r=1;r<=9;r++)if(!((t[l][r]??0)<=0)){if(t[l][r]>=3){const m=[`${l}${r}`,`${l}${r}`,`${l}${r}`];if(t[l][r]-=3,a&&a.push({action:{type:"try_meld",meldType:"pong",tiles:m,success:!0},description:`Try Pong: ${m.join(" ")}`,remaining:F(t)}),n.push({type:"pong",tiles:m}),X(t,s-1,n,a))return!0;n.pop(),t[l][r]+=3,a&&a.push({action:{type:"backtrack",tiles:m},description:`Backtrack: undo Pong ${m.join(" ")}`,remaining:F(t)})}if(r<=7&&(t[l][r]??0)>=1&&(t[l][r+1]??0)>=1&&(t[l][r+2]??0)>=1){const m=[`${l}${r}`,`${l}${r+1}`,`${l}${r+2}`];if(t[l][r]-=1,t[l][r+1]-=1,t[l][r+2]-=1,a&&a.push({action:{type:"try_meld",meldType:"chow",tiles:m,success:!0},description:`Try Chow: ${m.join(" ")}`,remaining:F(t)}),n.push({type:"chow",tiles:m}),X(t,s-1,n,a))return!0;n.pop(),t[l][r]+=1,t[l][r+1]+=1,t[l][r+2]+=1,a&&a.push({action:{type:"backtrack",tiles:m},description:`Backtrack: undo Chow ${m.join(" ")}`,remaining:F(t)})}return!1}return s===0}function G(t){const s=je(t),n=[];for(const a of B)for(let l=1;l<=9;l++)(s[a][l]??0)>=2&&n.push({suit:a,value:l});for(const{suit:a,value:l}of n){const r=ye(s);r[a][l]-=2;const m=[];if(X(r,4,m,null)){const k=`${a}${l}`;return{isWin:!0,pair:[k,k],melds:m}}}return{isWin:!1}}function at(t){const s=je(t),n=[],a=[];for(const l of B)for(let r=1;r<=9;r++)(s[l][r]??0)>=2&&a.push({suit:l,value:r});for(const{suit:l,value:r}of a){const m=`${l}${r}`;n.push({action:{type:"select_pair",pair:m},description:`Try pair: ${m} ${m}`,remaining:F(s)});const k=ye(s);k[l][r]-=2;const p=[];if(X(k,4,p,n)){const T={type:"found_win",pair:[m,m],melds:p.map(i=>({...i,tiles:[...i.tiles]}))};return n.push({action:T,description:`WIN! Pair: ${m} ${m} | Melds: ${p.map(i=>i.tiles.join(" ")).join(" | ")}`,remaining:{}}),{result:{isWin:!0,pair:[m,m],melds:p},steps:n}}n.push({action:{type:"pair_failed",pair:m},description:`Pair ${m} ${m} failed — no valid 4 melds found`,remaining:F(s)})}return n.push({action:{type:"no_win"},description:"No valid winning combination found.",remaining:F(s)}),{result:{isWin:!1},steps:n}}const lt=[261.63,293.66,329.63,392,440,493.88,523.25,587.33,659.25];function te(){const t=c.useRef(!0),s=c.useCallback(()=>Me(),[]),n=c.useCallback(i=>{t.current=i},[]),a=c.useCallback(i=>{if(!t.current)return;const o=s();if(!o)return;const x=lt[Math.max(0,Math.min(i-1,8))],u=o.createOscillator(),g=o.createGain();u.type="sine",u.frequency.setValueAtTime(x,o.currentTime),g.gain.setValueAtTime(.1,o.currentTime),g.gain.exponentialRampToValueAtTime(.001,o.currentTime+.2),u.connect(g),g.connect(o.destination),u.start(),u.stop(o.currentTime+.2);const b=o.createOscillator(),w=o.createGain();b.type="triangle",b.frequency.setValueAtTime(x*2,o.currentTime),w.gain.setValueAtTime(.03,o.currentTime),w.gain.exponentialRampToValueAtTime(.001,o.currentTime+.15),b.connect(w),w.connect(o.destination),b.start(o.currentTime+.02),b.stop(o.currentTime+.17)},[s]),l=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;const o=i.createOscillator(),x=i.createGain();o.type="sine",o.frequency.setValueAtTime(480,i.currentTime),o.frequency.setValueAtTime(320,i.currentTime+.08),x.gain.setValueAtTime(.07,i.currentTime),x.gain.exponentialRampToValueAtTime(.001,i.currentTime+.12),o.connect(x),x.connect(i.destination),o.start(),o.stop(i.currentTime+.12)},[s]),r=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;[523.25,587.33,659.25,783.99,880,1046.5].forEach((x,u)=>{const g=i.createOscillator(),b=i.createGain();g.type="sine",g.frequency.value=x,b.gain.setValueAtTime(.08,i.currentTime+u*.09),b.gain.exponentialRampToValueAtTime(.001,i.currentTime+u*.09+.2),g.connect(b),b.connect(i.destination),g.start(i.currentTime+u*.09),g.stop(i.currentTime+u*.09+.2)})},[s]),m=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;[400,340,280].forEach((x,u)=>{const g=i.createOscillator(),b=i.createGain();g.type="sine",g.frequency.value=x,b.gain.setValueAtTime(.07,i.currentTime+u*.1),b.gain.exponentialRampToValueAtTime(.001,i.currentTime+u*.1+.2),g.connect(b),b.connect(i.destination),g.start(i.currentTime+u*.1),g.stop(i.currentTime+u*.1+.2)})},[s]),k=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;const o=i.createOscillator(),x=i.createGain();o.type="sawtooth",o.frequency.setValueAtTime(190,i.currentTime),o.frequency.setValueAtTime(130,i.currentTime+.12),x.gain.setValueAtTime(.07,i.currentTime),x.gain.exponentialRampToValueAtTime(.001,i.currentTime+.25),o.connect(x),x.connect(i.destination),o.start(),o.stop(i.currentTime+.25)},[s]),p=c.useCallback(i=>{if(!t.current)return;const o=s();if(!o)return;const x=400+i%8*50,u=o.createOscillator(),g=o.createGain();u.type="sine",u.frequency.setValueAtTime(x,o.currentTime),g.gain.setValueAtTime(.05,o.currentTime),g.gain.exponentialRampToValueAtTime(.001,o.currentTime+.08),u.connect(g),g.connect(o.destination),u.start(),u.stop(o.currentTime+.08)},[s]),T=c.useCallback(()=>{if(!t.current)return;const i=s();if(!i)return;const o=i.createOscillator(),x=i.createGain();o.type="triangle",o.frequency.setValueAtTime(550,i.currentTime),o.frequency.setValueAtTime(350,i.currentTime+.06),x.gain.setValueAtTime(.05,i.currentTime),x.gain.exponentialRampToValueAtTime(.001,i.currentTime+.1),o.connect(x),x.connect(i.destination),o.start(),o.stop(i.currentTime+.1)},[s]);return{playTilePlaced:a,playTileRemoved:l,playWinSound:r,playLoseSound:m,playErrorSound:k,playStepTick:p,playBacktrackSound:T,setEnabled:n}}function rt(){if(Math.random()<.6){const s=ce(),n=G(s);return{hand:s,isWinning:n.isWin,solution:n.isWin?n:null}}for(let s=0;s<50;s++){const n=D();if(!G(n).isWin)return{hand:n,isWinning:!1,solution:null}}return{hand:D(),isWinning:!1,solution:null}}const ne={hand:[],isWinning:!1,solution:null,phase:"judging",playerSaidWin:null,selectedTiles:[],foundPair:null,foundMelds:[],hintsUsed:0,showHint:!1,feedback:null,roundComplete:!1};function it(){const[t,s]=c.useState(ne),[n,a]=c.useState(0),[l,r]=c.useState(0),[m,k]=c.useState(0),[p,T]=c.useState(!1),[i,o]=c.useState(!0),x=te(),u=c.useCallback(()=>{const d=rt();s({...ne,hand:d.hand,isWinning:d.isWinning,solution:d.solution}),T(!0)},[]),g=c.useCallback(d=>{const v=d===t.isWinning;v&&t.isWinning&&t.solution?(x.playTilePlaced(5),s(j=>({...j,playerSaidWin:d,phase:"grouping",feedback:"Correct! Now identify the pair and melds."}))):v&&!t.isWinning?(x.playWinSound(),a(j=>j+100-t.hintsUsed*20),r(j=>j+1),k(j=>j+1),s(j=>({...j,playerSaidWin:d,phase:"feedback",feedback:"Correct! This hand is not a winner.",roundComplete:!0}))):(x.playLoseSound(),r(j=>j+1),s(j=>({...j,playerSaidWin:d,phase:"feedback",feedback:t.isWinning?"Wrong — this hand IS a winner! Check the solution below.":"Wrong — this hand is NOT a winner.",roundComplete:!0})))},[t,x]),b=c.useCallback(d=>{s(v=>{const j=v.selectedTiles.includes(d)?v.selectedTiles.filter(y=>y!==d):[...v.selectedTiles,d];return{...v,selectedTiles:j}}),x.playTilePlaced(3)},[x]),w=c.useCallback(()=>{if(t.selectedTiles.length!==2||!t.solution)return;const d=t.selectedTiles.map(y=>t.hand[y]),v=t.solution.pair;d[0]===d[1]&&d[0]===v[0]?(x.playTilePlaced(7),s(y=>({...y,foundPair:[d[0],d[1]],selectedTiles:[],feedback:"Pair found! Now identify the 4 melds."}))):(x.playErrorSound(),s(y=>({...y,selectedTiles:[],feedback:"That's not the correct pair. Try again!"})))},[t,x]),$=c.useCallback(()=>{if(t.selectedTiles.length!==3||!t.solution)return;const d=t.selectedTiles.map(y=>t.hand[y]).sort(),v=t.solution.melds.filter((y,W)=>!t.foundMelds.some(S=>JSON.stringify(S.tiles.sort())===JSON.stringify(t.solution.melds[W].tiles.sort()))),j=v.findIndex(y=>JSON.stringify([...y.tiles].sort())===JSON.stringify(d));if(j>=0){const y=v[j];x.playTilePlaced(8);const W=[...t.foundMelds,y];W.length===4?(x.playWinSound(),a(S=>S+200-t.hintsUsed*30),r(S=>S+1),k(S=>S+1),s(S=>({...S,foundMelds:W,selectedTiles:[],phase:"feedback",feedback:"Excellent! You identified all groups correctly!",roundComplete:!0}))):s(S=>({...S,foundMelds:W,selectedTiles:[],feedback:`Meld ${W.length}/4 found! Keep going.`}))}else x.playErrorSound(),s(y=>({...y,selectedTiles:[],feedback:"Those 3 tiles don't form a valid meld in the solution. Try again!"}))},[t,x]),N=c.useCallback(()=>{t.solution&&(x.playBacktrackSound(),s(d=>({...d,hintsUsed:d.hintsUsed+1,showHint:!0})),setTimeout(()=>{s(d=>({...d,showHint:!1}))},3e3))},[t.solution,x]),f=c.useCallback(()=>{r(d=>d+1),s(d=>({...d,phase:"feedback",feedback:"Skipped grouping. Here's the solution:",roundComplete:!0}))},[]),C=c.useCallback(()=>{s(ne),a(0),r(0),k(0),T(!1)},[]),h=c.useCallback(d=>{o(d),x.setEnabled(d)},[x]);return{round:t,score:n,totalRounds:l,correctRounds:m,started:p,soundEnabled:i,startNewRound:u,judgeHand:g,toggleTileSelection:b,submitPair:w,submitMeld:$,useHint:N,skipGrouping:f,resetGame:C,toggleSound:h}}function q({code:t,index:s,selected:n,onClick:a}){return e.jsx(I,{code:t,index:s,size:"lg",selected:n,interactive:!!a,disabled:!a,onClick:a})}function ot(){const{round:t,score:s,totalRounds:n,correctRounds:a,started:l,soundEnabled:r,startNewRound:m,judgeHand:k,toggleTileSelection:p,submitPair:T,submitMeld:i,useHint:o,skipGrouping:x,resetGame:u,toggleSound:g}=it();if(!l)return e.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md text-center",children:[e.jsx("div",{className:"text-4xl mb-4",children:"📖"}),e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white mb-2",children:"Guided Mode"}),e.jsxs("p",{className:"text-sm md:text-base text-slate-400 mb-6 leading-relaxed",children:["Practice identifying winning Mahjong hands step-by-step. First judge if the hand is a winner, then identify the ",e.jsx("span",{className:"text-indigo-300 font-semibold",children:"pair"})," and ",e.jsx("span",{className:"text-violet-300 font-semibold",children:"4 melds"})," by selecting tiles. Use hints if you get stuck!"]}),e.jsx("button",{onClick:m,className:"rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-8 py-3 text-sm md:text-base font-bold text-white shadow-lg shadow-indigo-500/25 transition-all hover:shadow-indigo-500/40 hover:scale-105 active:scale-95",children:"Start Learning"})]})});const{hand:b,phase:w,selectedTiles:$,foundPair:N,foundMelds:f,feedback:C,showHint:h,solution:d,roundComplete:v,hintsUsed:j}=t,y=d&&h?N?`Hint: Next meld is ${d.melds[f.length]?.tiles.join(" ")??"done!"}`:`Hint: The pair is ${d.pair[0]} ${d.pair[1]}`:null,W=new Set;if(N){let S=0;for(let M=0;M=0&&(W.add(z),M.splice(H,1))}}return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-80 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Progress"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-indigo-300",children:s}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Score"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-emerald-300",children:a}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Correct"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-slate-300",children:n}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Rounds"})]})]})]}),w==="judging"&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-2",children:"Step 1: Judge"}),e.jsx("p",{className:"text-xs md:text-sm text-slate-400 mb-4",children:"Is this a valid winning hand?"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>k(!0),className:"flex items-center justify-center gap-2 rounded-xl bg-emerald-500/15 px-4 py-3 text-sm md:text-base font-bold text-emerald-300 ring-1 ring-emerald-500/30 transition-all hover:bg-emerald-500/25 hover:scale-105 active:scale-95",children:[e.jsx(V,{size:16})," Win"]}),e.jsxs("button",{onClick:()=>k(!1),className:"flex items-center justify-center gap-2 rounded-xl bg-red-500/15 px-4 py-3 text-sm md:text-base font-bold text-red-300 ring-1 ring-red-500/30 transition-all hover:bg-red-500/25 hover:scale-105 active:scale-95",children:[e.jsx(re,{size:16})," Not Win"]})]})]}),w==="grouping"&&e.jsxs("div",{className:"rounded-xl border border-indigo-500/30 bg-indigo-500/5 p-4 md:p-5 backdrop-blur-sm",children:[e.jsxs("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-indigo-300 mb-2",children:["Step 2: ",N?`Find Meld ${f.length+1}/4`:"Find the Pair"]}),e.jsx("p",{className:"text-xs md:text-sm text-slate-400 mb-3",children:N?"Select 3 tiles that form a pong (AAA) or chow (ABC).":"Select 2 identical tiles that form the pair."}),e.jsxs("p",{className:"text-xs md:text-sm text-indigo-300 font-mono mb-3",children:["Selected: ",$.length," / ",N?3:2]}),e.jsx("div",{className:"flex gap-2 mb-3",children:N?e.jsxs("button",{onClick:i,disabled:$.length!==3,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-indigo-500/20 px-3 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(V,{size:14})," Submit Meld"]}):e.jsxs("button",{onClick:T,disabled:$.length!==2,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-indigo-500/20 px-3 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(V,{size:14})," Submit Pair"]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:o,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-amber-500/15 px-3 py-2 text-xs md:text-sm font-medium text-amber-300 ring-1 ring-amber-500/30 transition-all hover:bg-amber-500/25",children:[e.jsx(Ae,{size:14})," Hint (",j,")"]}),e.jsxs("button",{onClick:x,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60",children:[e.jsx(ze,{size:14})," Skip"]})]})]}),C&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${w==="feedback"&&v?t.playerSaidWin===t.isWinning?"border-emerald-500/30 bg-emerald-500/5":"border-red-500/30 bg-red-500/5":"border-indigo-500/30 bg-indigo-500/5"}`,children:[e.jsx("p",{className:"text-xs md:text-sm text-slate-300 leading-relaxed",children:C}),y&&e.jsx("p",{className:"mt-2 text-xs md:text-sm text-amber-300 font-mono animate-pulse",children:y}),v&&d&&e.jsxs("div",{className:"mt-3 text-[10px] md:text-xs text-slate-500",children:[e.jsxs("p",{children:["Solution: Pair ",d.pair.join(" ")]}),d.melds.map((S,M)=>e.jsxs("p",{children:[S.type==="pong"?"Pong":"Chow",": ",S.tiles.join(" ")]},M))]}),v&&e.jsxs("button",{onClick:m,className:"mt-3 w-full flex items-center justify-center gap-2 rounded-lg bg-indigo-500/20 px-4 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30",children:["Next Round ",e.jsx(de,{size:14})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:u,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(K,{size:14})," Reset"]}),e.jsx("button",{onClick:()=>g(!r),className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${r?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400"}`,children:r?e.jsx(Q,{size:14}):e.jsx(ee,{size:14})})]})]}),e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col gap-4 min-h-0 md:overflow-auto",children:[e.jsxs("div",{className:"rounded-2xl border border-emerald-900/40 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.14),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.32))] p-4 shadow-2xl shadow-black/30 md:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 md:mb-4",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-emerald-200",children:"Hand"}),N&&e.jsxs("span",{className:"text-xs md:text-sm font-mono text-emerald-300",children:["Pair ✓ | Melds ",f.length,"/4"]})]}),e.jsx("div",{className:"flex flex-wrap items-end gap-1.5 rounded-xl border border-emerald-950/40 bg-emerald-950/20 p-3 shadow-inner md:gap-2",children:b.map((S,M)=>{const z=W.has(M),H=$.includes(M),se=w==="grouping"&&!z;return e.jsx("div",{className:z?"opacity-30":"",children:e.jsx(q,{code:S,index:M,selected:H,onClick:se?()=>p(M):void 0})},`${S}-${M}`)})})]}),(N||f.length>0)&&e.jsxs("div",{className:"rounded-2xl border border-emerald-500/20 bg-emerald-500/5 p-4 shadow-xl shadow-emerald-950/20 backdrop-blur-sm md:p-5",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-emerald-400 mb-3",children:"Found Groups"}),N&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] md:text-xs font-medium text-slate-600 w-14 shrink-0",children:"Pair"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(q,{code:N[0],index:-1,selected:!1}),e.jsx(q,{code:N[1],index:-1,selected:!1})]})]}),f.map((S,M)=>e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("span",{className:"text-[10px] md:text-xs font-medium text-slate-600 w-14 shrink-0",children:[S.type==="pong"?"Pong":"Chow"," ",M+1]}),e.jsx("div",{className:"flex gap-1",children:S.tiles.map((z,H)=>e.jsx(q,{code:z,index:-1,selected:!1},`${z}-${H}`))})]},M))]})]})]})}function ue(){if(Math.random()<.5){const s=ce(),n=G(s);return{hand:s,isWinning:n.isWin,solution:n.isWin?n:null}}for(let s=0;s<50;s++){const n=D();if(!G(n).isWin)return{hand:n,isWinning:!1,solution:null}}return{hand:D(),isWinning:!1,solution:null}}const ae={hand:[],isWinning:!1,solution:null,round:0,score:0,streak:0,bestStreak:0,timer:0,answered:!1,lastCorrect:null,totalCorrect:0,totalAnswered:0};function dt(){const[t,s]=c.useState(ae),[n,a]=c.useState(!1),l=c.useRef(null),r=te(),[m,k]=c.useState(!0);c.useEffect(()=>(n&&!t.answered&&(l.current=setInterval(()=>{s(u=>({...u,timer:u.timer+1}))},1e3)),()=>{l.current&&clearInterval(l.current)}),[n,t.answered]);const p=c.useCallback(()=>{const{hand:u,isWinning:g,solution:b}=ue();s({...ae,hand:u,isWinning:g,solution:b,round:1}),a(!0)},[]),T=c.useCallback(()=>{const{hand:u,isWinning:g,solution:b}=ue();s(w=>({...w,hand:u,isWinning:g,solution:b,round:w.round+1,timer:0,answered:!1,lastCorrect:null}))},[]),i=c.useCallback(u=>{if(t.answered)return;const g=u===t.isWinning,b=Math.max(0,10-t.timer),w=g?100+b*10+t.streak*25:0;g?r.playWinSound():r.playLoseSound(),s($=>({...$,answered:!0,lastCorrect:g,score:$.score+w,streak:g?$.streak+1:0,bestStreak:g?Math.max($.bestStreak,$.streak+1):$.bestStreak,totalCorrect:$.totalCorrect+(g?1:0),totalAnswered:$.totalAnswered+1}))},[t.answered,t.isWinning,t.timer,t.streak,r]),o=c.useCallback(()=>{s(ae),a(!1),l.current&&clearInterval(l.current)},[]),x=c.useCallback(u=>{k(u),r.setEnabled(u)},[r]);return{...t,isRunning:n,soundEnabled:m,startGame:p,nextRound:T,answer:i,resetGame:o,toggleSound:x}}function ct({code:t}){return e.jsx(I,{code:t,size:"lg"})}function xt(){const{hand:t,isWinning:s,solution:n,round:a,score:l,streak:r,bestStreak:m,timer:k,answered:p,lastCorrect:T,totalCorrect:i,totalAnswered:o,isRunning:x,soundEnabled:u,startGame:g,nextRound:b,answer:w,resetGame:$,toggleSound:N}=dt();return x?e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-80 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Stats"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{size:14,className:"text-amber-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-white",children:l}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Score"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{size:14,className:"text-orange-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg md:text-xl font-bold text-orange-300",children:r}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Streak"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{size:14,className:"text-cyan-400"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-lg md:text-xl font-bold text-cyan-300",children:[k,"s"]}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Time"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{size:14,className:"text-emerald-400"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-lg md:text-xl font-bold text-emerald-300",children:[i,"/",o]}),e.jsx("p",{className:"text-[10px] md:text-xs text-slate-500",children:"Correct"})]})]})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-[10px] md:text-xs text-slate-500",children:[e.jsxs("span",{children:["Round ",a]}),e.jsxs("span",{children:["Best streak: ",m]})]})]}),!p&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Your Judgment"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>w(!0),className:"flex items-center justify-center gap-2 rounded-xl bg-emerald-500/15 px-4 py-4 text-sm md:text-base font-bold text-emerald-300 ring-1 ring-emerald-500/30 transition-all hover:bg-emerald-500/25 hover:scale-105 active:scale-95",children:[e.jsx(V,{size:18})," Win"]}),e.jsxs("button",{onClick:()=>w(!1),className:"flex items-center justify-center gap-2 rounded-xl bg-red-500/15 px-4 py-4 text-sm md:text-base font-bold text-red-300 ring-1 ring-red-500/30 transition-all hover:bg-red-500/25 hover:scale-105 active:scale-95",children:[e.jsx(re,{size:18})," Not Win"]})]})]}),p&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${T?"border-emerald-500/30 bg-emerald-500/5":"border-red-500/30 bg-red-500/5"}`,children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:T?e.jsxs(e.Fragment,{children:[e.jsx(V,{size:18,className:"text-emerald-400"}),e.jsx("span",{className:"text-sm md:text-base font-bold text-emerald-300",children:"Correct!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{size:18,className:"text-red-400"}),e.jsx("span",{className:"text-sm md:text-base font-bold text-red-300",children:"Wrong!"})]})}),e.jsxs("p",{className:"text-xs md:text-sm text-slate-400 mb-3",children:["The hand was ",e.jsx("span",{className:`font-bold ${s?"text-emerald-300":"text-red-300"}`,children:s?"a Winner":"Not a Winner"}),"."]}),s&&n&&e.jsxs("div",{className:"text-[10px] md:text-xs text-slate-500 mb-3",children:["Pair: ",n.pair.join(" ")," | Melds: ",n.melds.map(f=>f.tiles.join(" ")).join(" | ")]}),e.jsxs("button",{onClick:b,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-indigo-500/20 px-4 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30",children:["Next Round ",e.jsx(de,{size:14})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:$,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(K,{size:14})," Reset"]}),e.jsx("button",{onClick:()=>N(!u),className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${u?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400"}`,children:u?e.jsx(Q,{size:14}):e.jsx(ee,{size:14})})]})]}),e.jsx("div",{className:"order-last md:order-first flex md:flex-1 flex-col gap-4 min-h-0 md:overflow-auto",children:e.jsxs("div",{className:"rounded-2xl border border-emerald-900/40 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.14),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.32))] p-4 shadow-2xl shadow-black/30 md:p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 md:mb-4",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-emerald-200",children:"Hand to Judge"}),e.jsxs("span",{className:"text-xs md:text-sm font-mono font-bold text-indigo-300",children:["Round ",a]})]}),e.jsx("div",{className:"flex flex-wrap items-end gap-1.5 rounded-xl border border-emerald-950/40 bg-emerald-950/20 p-3 shadow-inner md:gap-2",children:t.map((f,C)=>e.jsx(ct,{code:f},`${f}-${C}`))})]})})]}):e.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md text-center",children:[e.jsx("div",{className:"text-4xl mb-4",children:"⚡"}),e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white mb-2",children:"Challenge Mode"}),e.jsxs("p",{className:"text-sm md:text-base text-slate-400 mb-6 leading-relaxed",children:["You'll see a 14-tile hand. Decide as fast as you can: is it a ",e.jsx("span",{className:"text-emerald-400 font-semibold",children:"Winning Hand"})," or ",e.jsx("span",{className:"text-red-400 font-semibold",children:"Not a Winner"}),"? Score points for correct answers. Faster = more bonus points. Build streaks for multipliers!"]}),e.jsx("button",{onClick:g,className:"rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-8 py-3 text-sm md:text-base font-bold text-white shadow-lg shadow-indigo-500/25 transition-all hover:shadow-indigo-500/40 hover:scale-105 active:scale-95",children:"Start Challenge"})]})})}function ge(t){return{name:t,hand:[],result:null,score:0}}const le={phase:"building",players:[ge("Player 1"),ge("Player 2")],currentPlayer:0,round:1,roundComplete:!1};function mt(){const[t,s]=c.useState(le),[n,a]=c.useState(null),[l,r]=c.useState(!1),[m,k]=c.useState(!0),p=te(),T=t.players[t.currentPlayer].hand,i=T.length>=P,o=t.players[0].hand.length>=P&&t.players[1].hand.length>=P,x=c.useCallback(()=>{s({...le}),r(!0),a(null)},[]),u=c.useCallback(h=>{if(t.phase!=="building")return;const d=t.players[t.currentPlayer].hand,v=be(d,h);if(v){a(v),p.playErrorSound();return}a(null);const{value:j}={value:Number(h[1])};p.playTilePlaced(j),s(y=>{const W=[...y.players],S={...W[y.currentPlayer]};S.hand=L([...S.hand,h]),W[y.currentPlayer]=S;const M=S.hand.length>=P,z=W[1-y.currentPlayer].hand.length>=P;let H=y.currentPlayer;return M&&!z?H=1-y.currentPlayer:M||(H=1-y.currentPlayer,W[H].hand.length>=P&&(H=y.currentPlayer)),{...y,players:W,currentPlayer:H}})},[t.phase,t.currentPlayer,t.players,p]),g=c.useCallback(h=>{t.phase==="building"&&(p.playTileRemoved(),a(null),s(d=>{const v=[...d.players],j={...v[d.currentPlayer]},y=[...j.hand];return y.splice(h,1),j.hand=y,v[d.currentPlayer]=j,{...d,players:v}}))},[t.phase,p]),b=c.useCallback(()=>{if(!o)return;const h=G(t.players[0].hand),d=G(t.players[1].hand),v=h.isWin?1:0,j=d.isWin?1:0;v>j||j>v?p.playWinSound():p.playLoseSound(),s(y=>{const W=[...y.players];return W[0]={...W[0],result:h,score:W[0].score+v},W[1]={...W[1],result:d,score:W[1].score+j},{...y,players:W,phase:"results",roundComplete:!0}})},[o,t.players,p]),w=c.useCallback(()=>{s(h=>({...h,phase:"building",players:[{...h.players[0],hand:[],result:null},{...h.players[1],hand:[],result:null}],currentPlayer:0,round:h.round+1,roundComplete:!1})),a(null)},[]),$=c.useCallback(()=>{s(le),r(!1),a(null)},[]),N=c.useCallback(()=>{if(t.phase!=="building")return;const h=1-t.currentPlayer;t.players[h].hand.length>=P||s(d=>({...d,currentPlayer:h}))},[t.phase,t.currentPlayer,t.players]),f=()=>{if(t.phase!=="results")return null;const h=t.players[0].result,d=t.players[1].result;return!h||!d?null:h.isWin&&!d.isWin?t.players[0].name:!h.isWin&&d.isWin?t.players[1].name:h.isWin&&d.isWin?"Both Win!":"Neither Wins"},C=c.useCallback(h=>{k(h),p.setEnabled(h)},[p]);return{state:t,lastError:n,started:l,soundEnabled:m,currentHand:T,currentHandIsFull:i,bothFull:o,winner:f(),startGame:x,addTile:u,removeTile:g,checkBothHands:b,nextRound:w,resetGame:$,switchPlayer:N,toggleSound:C}}function ut({code:t,onRemove:s}){return e.jsx(I,{code:t,size:"md",interactive:!!s,removable:!!s,onClick:s})}function gt(t,s){return t.filter(n=>n===s).length}function pt({suit:t,value:s,count:n,disabled:a,onClick:l}){const r=n>=4,m=`${t}${s}`;return e.jsx(I,{code:m,count:n,size:"sm",disabled:a||r,interactive:!0,onClick:l})}function ht(){const{state:t,lastError:s,started:n,soundEnabled:a,currentHand:l,currentHandIsFull:r,bothFull:m,winner:k,startGame:p,addTile:T,removeTile:i,checkBothHands:o,nextRound:x,resetGame:u,switchPlayer:g,toggleSound:b}=mt();if(!n)return e.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:e.jsxs("div",{className:"max-w-md text-center",children:[e.jsx("div",{className:"text-4xl mb-4",children:"👥"}),e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white mb-2",children:"2 Player Mode"}),e.jsxs("p",{className:"text-sm md:text-base text-slate-400 mb-6 leading-relaxed",children:["Take turns placing tiles to build your 14-tile hands. Players alternate picks. Once both hands are complete, the solver checks both — whoever has a valid ",e.jsx("span",{className:"text-emerald-400 font-semibold",children:"winning hand"})," scores a point!"]}),e.jsx("button",{onClick:p,className:"rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-8 py-3 text-sm md:text-base font-bold text-white shadow-lg shadow-indigo-500/25 transition-all hover:shadow-indigo-500/40 hover:scale-105 active:scale-95",children:"Start Game"})]})});const{phase:w,players:$,currentPlayer:N,round:f}=t,C=$[0],h=$[1];return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 w-full md:w-80 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(pe,{size:14,className:"text-indigo-400"}),e.jsxs("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-400",children:["Round ",f]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:`rounded-lg p-3 text-center transition-all ${w==="building"&&N===0?"bg-indigo-500/15 ring-2 ring-indigo-400/40":"bg-slate-800/40"}`,children:[e.jsx("p",{className:"text-sm md:text-base font-bold text-indigo-300",children:C.name}),e.jsx("p",{className:"text-lg md:text-xl font-extrabold text-white",children:C.score}),e.jsxs("p",{className:"text-[10px] md:text-xs text-slate-500",children:[C.hand.length,"/",P," tiles"]}),w==="results"&&C.result&&e.jsx("p",{className:`mt-1 text-[10px] md:text-xs font-bold ${C.result.isWin?"text-emerald-400":"text-red-400"}`,children:C.result.isWin?"✓ Winner":"✗ No Win"})]}),e.jsxs("div",{className:`rounded-lg p-3 text-center transition-all ${w==="building"&&N===1?"bg-violet-500/15 ring-2 ring-violet-400/40":"bg-slate-800/40"}`,children:[e.jsx("p",{className:"text-sm md:text-base font-bold text-violet-300",children:h.name}),e.jsx("p",{className:"text-lg md:text-xl font-extrabold text-white",children:h.score}),e.jsxs("p",{className:"text-[10px] md:text-xs text-slate-500",children:[h.hand.length,"/",P," tiles"]}),w==="results"&&h.result&&e.jsx("p",{className:`mt-1 text-[10px] md:text-xs font-bold ${h.result.isWin?"text-emerald-400":"text-red-400"}`,children:h.result.isWin?"✓ Winner":"✗ No Win"})]})]})]}),w==="building"&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${N===0?"border-indigo-500/30 bg-indigo-500/5":"border-violet-500/30 bg-violet-500/5"}`,children:[e.jsxs("p",{className:`text-sm md:text-base font-bold ${N===0?"text-indigo-300":"text-violet-300"}`,children:[$[N].name,"'s Turn"]}),e.jsx("p",{className:"text-xs md:text-sm text-slate-400 mt-1",children:"Pick a tile to add to your hand."}),!r&&e.jsxs("button",{onClick:g,className:"mt-3 w-full flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(Ie,{size:14})," Switch Player"]})]}),w==="building"&&m&&e.jsxs("button",{onClick:o,className:"w-full flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-indigo-500/20 to-violet-500/20 px-4 py-3 text-sm md:text-base font-bold text-indigo-200 ring-1 ring-indigo-500/30 transition-all hover:from-indigo-500/30 hover:to-violet-500/30 active:scale-95",children:[e.jsx(Y,{size:16})," Check Both Hands"]}),w==="results"&&k&&e.jsxs("div",{className:`rounded-xl border p-4 md:p-5 backdrop-blur-sm ${k.includes("Neither")?"border-slate-700/50 bg-slate-900/60":"border-emerald-500/30 bg-emerald-500/5"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Y,{size:18,className:"text-amber-400"}),e.jsx("span",{className:"text-base md:text-lg font-bold text-white",children:k})]}),$.map((d,v)=>d.result&&d.result.isWin&&e.jsxs("div",{className:"mt-2 text-[10px] md:text-xs text-slate-500",children:[e.jsxs("p",{className:"font-semibold text-slate-400",children:[d.name,":"]}),e.jsxs("p",{children:["Pair: ",d.result.pair.join(" ")]}),d.result.melds.map((j,y)=>e.jsxs("p",{children:[j.type==="pong"?"Pong":"Chow",": ",j.tiles.join(" ")]},y))]},v)),e.jsxs("button",{onClick:x,className:"mt-3 w-full flex items-center justify-center gap-2 rounded-lg bg-indigo-500/20 px-4 py-2.5 text-xs md:text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/30",children:["Next Round ",e.jsx(de,{size:14})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:u,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-xs md:text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(K,{size:14})," Reset"]}),e.jsx("button",{onClick:()=>b(!a),className:`flex items-center justify-center gap-1.5 rounded-lg px-3 py-2.5 text-xs md:text-sm font-medium transition-all ${a?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30":"bg-slate-800/60 text-slate-400"}`,children:a?e.jsx(Q,{size:14}):e.jsx(ee,{size:14})})]}),s&&e.jsx("div",{className:"rounded-lg border border-red-500/30 bg-red-500/5 px-3 py-2.5 text-center text-xs md:text-sm font-medium text-red-400 animate-pulse",children:s})]}),e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col gap-4 min-h-0 md:overflow-auto",children:[$.map((d,v)=>e.jsxs("div",{className:`rounded-2xl border p-4 shadow-xl backdrop-blur-sm md:p-5 ${w==="building"&&N===v?v===0?"border-indigo-500/30 bg-indigo-500/5":"border-violet-500/30 bg-violet-500/5":"border-emerald-900/40 bg-[radial-gradient(circle_at_top_left,rgba(16,185,129,0.12),transparent_34%),linear-gradient(135deg,rgba(15,23,42,0.96),rgba(6,78,59,0.28))]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:`text-xs md:text-sm font-semibold uppercase tracking-wider ${v===0?"text-indigo-400":"text-violet-400"}`,children:d.name}),e.jsxs("span",{className:`text-xs md:text-sm font-mono font-bold ${d.hand.length===P?"text-emerald-400":"text-slate-500"}`,children:[d.hand.length,"/",P]})]}),e.jsxs("div",{className:"flex min-h-[5rem] flex-wrap items-end gap-1.5 rounded-xl border border-emerald-950/40 bg-emerald-950/20 p-3 shadow-inner md:gap-2",children:[d.hand.map((j,y)=>e.jsx(ut,{code:j,onRemove:w==="building"&&N===v?()=>i(y):void 0},`${j}-${y}`)),d.hand.lengthe.jsx(I,{size:"md",placeholder:!0},`e-${y}`))]})]},v)),w==="building"&&!r&&e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/70 p-4 shadow-xl shadow-black/20 backdrop-blur-sm md:p-5",children:[e.jsx("h3",{className:"text-xs md:text-sm font-semibold uppercase tracking-wider text-slate-300 mb-3",children:"Tile Wall"}),e.jsx("div",{className:"space-y-3 md:space-y-4",children:B.map(d=>e.jsxs("div",{className:"rounded-xl border border-slate-800/70 bg-slate-950/35 p-3",children:[e.jsx("p",{className:"text-[10px] md:text-xs font-medium mb-1.5",style:{color:Z[d]},children:he[d]}),e.jsx("div",{className:"flex flex-wrap items-end gap-1 md:gap-1.5",children:O.map(v=>{const j=`${d}${v}`;return e.jsx(pt,{suit:d,value:v,count:gt(l,j),disabled:r,onClick:()=>T(j)},j)})})]},d))})]})]})]})}function ft(){const[t,s]=c.useState([]),[n,a]=c.useState(null),[l,r]=c.useState([]),[m,k]=c.useState(-1),[p,T]=c.useState(!1),[i,o]=c.useState(400),[x,u]=c.useState(null),[g,b]=c.useState(!1),[w,$]=c.useState(!0),N=c.useRef(null),f=te();c.useEffect(()=>()=>{N.current&&clearInterval(N.current)},[]);const C=c.useCallback(()=>{a(null),r([]),k(-1),T(!1),N.current&&(clearInterval(N.current),N.current=null)},[]),h=c.useCallback(_=>{s(A=>{const R=be(A,_);return R?(u(R),f.playErrorSound(),A):(u(null),C(),f.playTilePlaced(fe(_).value),L([...A,_]))})},[C,f]),d=c.useCallback(_=>{s(A=>{const R=[...A];return R.splice(_,1),C(),f.playTileRemoved(),R}),u(null)},[C,f]),v=c.useCallback(()=>{s([]),u(null),C()},[C]),j=c.useCallback(()=>{s(D()),u(null),C()},[C]),y=c.useCallback(()=>{s(ce()),u(null),C()},[C]),W=c.useCallback(()=>{const _=st(t);if(_){u(_),f.playErrorSound();return}if(u(null),g){const{result:A,steps:R}=at(t);a(A),r(R),k(-1)}else{const A=G(t);a(A),r([]),k(-1),A.isWin?f.playWinSound():f.playLoseSound()}},[t,g,f]),S=c.useCallback(()=>{k(_=>{const A=Math.min(_+1,l.length-1);if(A>=0&&A{k(_=>Math.max(_-1,-1))},[]),z=c.useCallback(()=>{if(p){N.current&&(clearInterval(N.current),N.current=null),T(!1);return}T(!0),k(_=>_>=l.length-1?-1:_),N.current=setInterval(()=>{k(_=>{if(_>=l.length-1)return N.current&&clearInterval(N.current),N.current=null,T(!1),_;const A=_+1;if(A{b(_=>!_),C()},[C]),se=c.useCallback(_=>{$(_),f.setEnabled(_)},[f]),Ne=m>=0&&m=P,soundEnabled:w,addTile:h,removeTile:d,resetHand:v,randomHand:j,winningHand:y,checkHand:W,stepForward:S,stepBack:M,autoPlay:z,setAnimSpeed:o,toggleAnimation:H,toggleSound:se}}const bt={sandbox:e.jsx(Le,{size:14}),guided:e.jsx(we,{size:14}),challenge:e.jsx(Ee,{size:14}),"two-player":e.jsx(pe,{size:14})},jt=["sandbox","guided","challenge","two-player"];function yt(){const{hand:t,result:s,steps:n,stepIndex:a,stepsTotal:l,currentStep:r,isAnimating:m,animSpeed:k,showAnimation:p,lastError:T,handIsFull:i,addTile:o,removeTile:x,resetHand:u,randomHand:g,winningHand:b,checkHand:w,stepForward:$,stepBack:N,autoPlay:f,setAnimSpeed:C,toggleAnimation:h,soundEnabled:d,toggleSound:v}=ft();return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto bg-[radial-gradient(circle_at_top,rgba(16,185,129,0.08),transparent_34%),linear-gradient(180deg,rgba(15,23,42,0),rgba(6,78,59,0.16))] p-4 md:p-6",children:[e.jsx(et,{handIsFull:i,result:s,showAnimation:p,steps:n,stepIndex:a,stepsTotal:l,isAnimating:m,animSpeed:k,currentStep:r,lastError:T,onCheckHand:w,onResetHand:u,onRandomHand:g,onWinningHand:b,onToggleAnimation:h,onStepForward:$,onStepBack:N,onAutoPlay:f,onSetAnimSpeed:C,soundEnabled:d,onToggleSound:v}),e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col gap-4 min-h-0 md:min-h-0 md:overflow-auto",children:[e.jsx(Ze,{hand:t,onRemoveTile:x}),s&&e.jsx(Ke,{result:s}),e.jsx(Ye,{hand:t,handIsFull:i,onAddTile:o})]})]})}function Ht(){const[t,s]=c.useState("sandbox");return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("div",{className:"shrink-0 border-b border-emerald-900/40 bg-[linear-gradient(135deg,rgba(15,23,42,0.9),rgba(6,78,59,0.34))] backdrop-blur-sm px-4 md:px-6 pt-3 pb-0",children:e.jsx("div",{className:"flex gap-1 overflow-x-auto",children:jt.map(n=>e.jsxs("button",{onClick:()=>s(n),className:`flex items-center gap-1.5 rounded-t-lg px-4 py-2.5 text-xs md:text-sm font-medium transition-all whitespace-nowrap ${t===n?"bg-slate-800/80 text-indigo-300 border border-b-0 border-slate-700/50 -mb-px":"text-slate-500 hover:text-slate-300 hover:bg-slate-800/30"}`,children:[bt[n],e.jsx("span",{children:De[n].label})]},n))})}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[t==="sandbox"&&e.jsx(yt,{}),t==="guided"&&e.jsx(ot,{}),t==="challenge"&&e.jsx(xt,{}),t==="two-player"&&e.jsx(ht,{})]})]})}export{Ht as default}; diff --git a/docs/assets/QueuePage-Zbw6nZfN.js b/docs/assets/QueuePage-0cpMqKev.js similarity index 97% rename from docs/assets/QueuePage-Zbw6nZfN.js rename to docs/assets/QueuePage-0cpMqKev.js index fdbdb1e..f430c60 100644 --- a/docs/assets/QueuePage-Zbw6nZfN.js +++ b/docs/assets/QueuePage-0cpMqKev.js @@ -1,4 +1,4 @@ -import{r as l,j as e,E as W}from"./index-eCXyAnHs.js";import{u as _}from"./useDSSound-CIDAFkgj.js";import{P as K}from"./plus-CffLiizr.js";import{T as U}from"./trash-2-DQ8BZrIf.js";import{R as X}from"./rotate-ccw-B8GZP3d7.js";import{S as B}from"./shuffle-CdKU4ZYx.js";import{V as J,a as Y}from"./volume-x-CTbtCvt-.js";import{C as Z,a as ee}from"./chevron-right-BZqZw4c2.js";import"./audioContext-NbgqvQGz.js";let I=1;const te=[{id:I++,value:5},{id:I++,value:12},{id:I++,value:8}];function se(){const[r,d]=l.useState(te),[n,m]=l.useState([]),[i,o]=l.useState(-1),[x,y]=l.useState(""),[p,b]=l.useState([]),[h,P]=l.useState(400),[w,j]=l.useState(!1),u=l.useRef(null),k=l.useRef(h),v=l.useRef(!1),{soundEnabled:$,toggleSound:z,playInsert:g,playDelete:N,playAccess:C,playTraverse:q}=_(),a=l.useRef(()=>{});l.useEffect(()=>{k.current=h},[h]),l.useEffect(()=>{if(!v.current||n.length===0)return;v.current=!1,u.current&&clearTimeout(u.current),j(!0);let t=0;const s=()=>{if(t>=n.length-1){j(!1);return}t++,o(t),a.current(t,n),u.current=setTimeout(s,k.current)};u.current=setTimeout(s,k.current)},[n]);const f=l.useCallback((t,s)=>{const c=s[t];c&&(c.highlightColor==="green"?g():c.highlightColor==="red"?N():c.highlightColor==="yellow"&&q(t,s.length))},[g,N,q]);l.useEffect(()=>{a.current=f},[f]);const Q=i>=0&&n[i]?n[i].queue:r,F=i>=0?n[i]:null,S=t=>b(s=>[t,...s].slice(0,20)),T=l.useCallback(t=>{const s={id:I++,value:t};d(c=>{const E=[...c,s],L=[{description:`Enqueuing ${t} at the rear of the queue...`,queue:c,highlightIndex:null,highlightColor:null},{description:`${t} added to the rear. Queue size: ${E.length}`,queue:E,highlightIndex:E.length-1,highlightColor:"green"}];return m(L),o(0),v.current=!0,g(),S(`Enqueue ${t}`),E})},[g]),O=l.useCallback(()=>{d(t=>{if(t.length===0)return t;const s=t[0],c=[{description:`Dequeue: checking front element ${s.value}...`,queue:t,highlightIndex:0,highlightColor:"yellow"},{description:`Removing ${s.value} from the front.`,queue:t,highlightIndex:0,highlightColor:"red"},{description:`${s.value} removed. Queue size: ${t.length-1}`,queue:t.slice(1),highlightIndex:null,highlightColor:null}];return m(c),o(0),v.current=!0,N(),S(`Dequeue → ${s.value}`),t.slice(1)})},[N]),D=l.useCallback(()=>{d(t=>{if(t.length===0)return t;const s=t[0],c=[{description:"Peek front: reading without removing.",queue:t,highlightIndex:0,highlightColor:"yellow"},{description:`Front element is ${s.value}.`,queue:t,highlightIndex:0,highlightColor:"yellow"}];return m(c),o(0),v.current=!0,C(),S(`Peek → ${s.value}`),t})},[C]),M=l.useCallback(()=>{d([]),m([]),o(-1),S("Clear queue")},[]),V=l.useCallback(()=>{const t=Math.floor(Math.random()*4)+3,s=Array.from({length:t},()=>({id:I++,value:Math.floor(Math.random()*90)+1}));d(s),m([]),o(-1),S("Random queue")},[]),H=l.useCallback(()=>{o(t=>{const s=Math.min(t+1,n.length-1);return f(s,n),s})},[n,f]),A=l.useCallback(()=>{o(t=>Math.max(t-1,0))},[]),G=l.useCallback(()=>{if(w){j(!1),u.current&&clearTimeout(u.current);return}j(!0);let t=i;const s=()=>{if(t>=n.length-1){j(!1);return}t++,o(t),f(t,n),u.current=setTimeout(s,h)};u.current=setTimeout(s,h)},[w,i,n,h,f]);return{queue:r,displayQueue:Q,steps:n,stepIndex:i,currentStep:F,inputValue:x,setInputValue:y,history:p,speed:h,setSpeed:P,isPlaying:w,enqueue:T,dequeue:O,peekFront:D,clear:M,generateRandom:V,nextStep:H,prevStep:A,autoPlay:G,soundEnabled:$,toggleSound:z,canGoNext:i0}}const le={green:"border-emerald-400 bg-emerald-500/20 text-emerald-300",red:"border-rose-400 bg-rose-500/20 text-rose-300",yellow:"border-amber-400 bg-amber-500/20 text-amber-300"},R=8;function ae({queue:r,currentStep:d}){const n=r.slice(0,R),m=d?.highlightIndex??null,i=d?.highlightColor??null;return e.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full min-h-[300px] gap-6 px-4",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 w-full",children:[e.jsx("div",{className:"flex items-center gap-1.5 w-full justify-center",children:r.length>0&&e.jsxs("div",{className:"flex items-end gap-1.5 flex-wrap justify-center",children:[n.map((o,x)=>{const y=x===m,p=x===0,b=x===r.length-1&&x{});l.useEffect(()=>{k.current=h},[h]),l.useEffect(()=>{if(!v.current||n.length===0)return;v.current=!1,u.current&&clearTimeout(u.current),j(!0);let t=0;const s=()=>{if(t>=n.length-1){j(!1);return}t++,o(t),a.current(t,n),u.current=setTimeout(s,k.current)};u.current=setTimeout(s,k.current)},[n]);const f=l.useCallback((t,s)=>{const c=s[t];c&&(c.highlightColor==="green"?g():c.highlightColor==="red"?N():c.highlightColor==="yellow"&&q(t,s.length))},[g,N,q]);l.useEffect(()=>{a.current=f},[f]);const Q=i>=0&&n[i]?n[i].queue:r,F=i>=0?n[i]:null,S=t=>b(s=>[t,...s].slice(0,20)),T=l.useCallback(t=>{const s={id:I++,value:t};d(c=>{const E=[...c,s],L=[{description:`Enqueuing ${t} at the rear of the queue...`,queue:c,highlightIndex:null,highlightColor:null},{description:`${t} added to the rear. Queue size: ${E.length}`,queue:E,highlightIndex:E.length-1,highlightColor:"green"}];return m(L),o(0),v.current=!0,g(),S(`Enqueue ${t}`),E})},[g]),O=l.useCallback(()=>{d(t=>{if(t.length===0)return t;const s=t[0],c=[{description:`Dequeue: checking front element ${s.value}...`,queue:t,highlightIndex:0,highlightColor:"yellow"},{description:`Removing ${s.value} from the front.`,queue:t,highlightIndex:0,highlightColor:"red"},{description:`${s.value} removed. Queue size: ${t.length-1}`,queue:t.slice(1),highlightIndex:null,highlightColor:null}];return m(c),o(0),v.current=!0,N(),S(`Dequeue → ${s.value}`),t.slice(1)})},[N]),D=l.useCallback(()=>{d(t=>{if(t.length===0)return t;const s=t[0],c=[{description:"Peek front: reading without removing.",queue:t,highlightIndex:0,highlightColor:"yellow"},{description:`Front element is ${s.value}.`,queue:t,highlightIndex:0,highlightColor:"yellow"}];return m(c),o(0),v.current=!0,C(),S(`Peek → ${s.value}`),t})},[C]),M=l.useCallback(()=>{d([]),m([]),o(-1),S("Clear queue")},[]),V=l.useCallback(()=>{const t=Math.floor(Math.random()*4)+3,s=Array.from({length:t},()=>({id:I++,value:Math.floor(Math.random()*90)+1}));d(s),m([]),o(-1),S("Random queue")},[]),H=l.useCallback(()=>{o(t=>{const s=Math.min(t+1,n.length-1);return f(s,n),s})},[n,f]),A=l.useCallback(()=>{o(t=>Math.max(t-1,0))},[]),G=l.useCallback(()=>{if(w){j(!1),u.current&&clearTimeout(u.current);return}j(!0);let t=i;const s=()=>{if(t>=n.length-1){j(!1);return}t++,o(t),f(t,n),u.current=setTimeout(s,h)};u.current=setTimeout(s,h)},[w,i,n,h,f]);return{queue:r,displayQueue:Q,steps:n,stepIndex:i,currentStep:F,inputValue:x,setInputValue:y,history:p,speed:h,setSpeed:P,isPlaying:w,enqueue:T,dequeue:O,peekFront:D,clear:M,generateRandom:V,nextStep:H,prevStep:A,autoPlay:G,soundEnabled:$,toggleSound:z,canGoNext:i0}}const le={green:"border-emerald-400 bg-emerald-500/20 text-emerald-300",red:"border-rose-400 bg-rose-500/20 text-rose-300",yellow:"border-amber-400 bg-amber-500/20 text-amber-300"},R=8;function ae({queue:r,currentStep:d}){const n=r.slice(0,R),m=d?.highlightIndex??null,i=d?.highlightColor??null;return e.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full min-h-[300px] gap-6 px-4",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3 w-full",children:[e.jsx("div",{className:"flex items-center gap-1.5 w-full justify-center",children:r.length>0&&e.jsxs("div",{className:"flex items-end gap-1.5 flex-wrap justify-center",children:[n.map((o,x)=>{const y=x===m,p=x===0,b=x===r.length-1&&x{r(h=>({x:he(h.x+i),y:h.y+C}))},[]),x=o.useCallback(()=>{r(be)},[]),f=o.useCallback(i=>{i.currentTarget.setPointerCapture(i.pointerId),S({pointerId:i.pointerId,startX:i.clientX,startY:i.clientY,rotation:l})},[l]),v=o.useCallback(i=>{if(!c||c.pointerId!==i.pointerId)return;const C=i.clientX-c.startX,h=i.clientY-c.startY;r({x:he(c.rotation.x-h*.35),y:c.rotation.y+C*.35})},[c]),p=o.useCallback(i=>{!c||c.pointerId!==i.pointerId||(i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId),S(null))},[c]);return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-white",children:"Cube State"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Drag the 3D cube to rotate the view"})]}),e.jsx("span",{className:`rounded-full px-2.5 py-1 text-[10px] font-semibold ring-1 ${s?"bg-emerald-500/15 text-emerald-300 ring-emerald-500/30":"bg-amber-500/15 text-amber-300 ring-amber-500/30"}`,children:s?"Solved":"Scrambled"})]}),e.jsx("div",{className:"flex min-h-[290px] touch-none cursor-grab items-center justify-center overflow-hidden rounded-xl bg-slate-950/40 ring-1 ring-slate-800/60 active:cursor-grabbing",role:"img","aria-label":"Interactive 3D Rubik's Cube view. Drag to rotate the cube.",onPointerDown:f,onPointerMove:v,onPointerUp:p,onPointerCancel:p,children:e.jsxs("div",{className:"relative h-56 w-56",style:{perspective:"900px"},children:[e.jsx("div",{className:`absolute left-1/2 top-1/2 h-36 w-36 ${c?"":"transition-transform duration-500"}`,style:{transformStyle:"preserve-3d",transform:`translate(-50%, -50%) rotateX(${l.x}deg) rotateY(${l.y}deg) rotateZ(0deg)`},children:Qe.map(i=>e.jsxs("div",{className:"absolute left-0 top-0 grid h-36 w-36 grid-cols-3 gap-1 rounded-xl border border-slate-950/70 bg-slate-950/90 p-1.5 shadow-2xl",style:{transform:Ke[i],backfaceVisibility:"hidden"},"aria-label":`${Ze[i]} face`,children:[t[i].map((C,h)=>e.jsx("div",{className:"rounded-md border border-slate-950/50 shadow-inner transition-colors duration-300",style:{backgroundColor:He[C]}},`${i}-${h}`)),e.jsx("span",{className:"pointer-events-none absolute left-2 top-1 text-[10px] font-black text-slate-950/50",children:i})]},i))}),e.jsx("div",{className:"absolute bottom-2 left-1/2 h-8 w-40 -translate-x-1/2 rounded-full bg-black/30 blur-xl"})]})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-[10px] text-slate-500",children:["View angle: X ",Math.round(l.x),"deg / Y ",Math.round(l.y),"deg"]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(W,{label:"Up",onClick:()=>d(-ee,0)}),e.jsx(W,{label:"Down",onClick:()=>d(ee,0)}),e.jsx(W,{label:"Left",onClick:()=>d(0,-ee)}),e.jsx(W,{label:"Right",onClick:()=>d(0,ee)}),e.jsx(W,{label:"Reset View",onClick:x})]})]}),e.jsxs("div",{className:"mt-5",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Quick Turns"}),e.jsx("span",{className:"text-[10px] text-slate-600",children:"Clockwise / inverse / double"})]}),e.jsx("div",{className:"grid grid-cols-6 gap-1.5 sm:grid-cols-9",children:ce.map(i=>e.jsx("button",{onClick:()=>a(i),className:"rounded-lg bg-slate-800/70 px-2 py-1.5 text-[11px] font-semibold text-slate-300 ring-1 ring-slate-700/40 transition-all hover:bg-indigo-500/15 hover:text-indigo-300 hover:ring-indigo-500/30",children:i},i))})]})]})}function he(t){return Math.max(-75,Math.min(75,t))}function W({label:t,onClick:s}){return e.jsx("button",{onClick:s,className:"rounded-md bg-slate-800/70 px-2 py-1 text-[10px] font-semibold text-slate-400 ring-1 ring-slate-700/40 transition-all hover:bg-indigo-500/15 hover:text-indigo-300 hover:ring-indigo-500/30",children:t})}const et=o.memo(Je),tt={U:"white",D:"yellow",F:"green",B:"blue",L:"orange",R:"red"},de=["U","D","F","B","L","R"],st={U:[["F",[0,1,2]],["R",[0,1,2]],["B",[0,1,2]],["L",[0,1,2]]],D:[["F",[6,7,8]],["L",[6,7,8]],["B",[6,7,8]],["R",[6,7,8]]],F:[["U",[6,7,8]],["R",[0,3,6]],["D",[2,1,0]],["L",[8,5,2]]],B:[["U",[2,1,0]],["L",[0,3,6]],["D",[6,7,8]],["R",[8,5,2]]],L:[["U",[0,3,6]],["F",[0,3,6]],["D",[0,3,6]],["B",[8,5,2]]],R:[["U",[8,5,2]],["B",[0,3,6]],["D",[8,5,2]],["F",[8,5,2]]]};function U(){return de.reduce((t,s)=>(t[s]=Array(9).fill(tt[s]),t),{})}function ke(t){return de.reduce((s,a)=>(s[a]=[...t[a]],s),{})}function te(t){return de.every(s=>t[s].every(a=>a===t[s][4]))}function Z(t,s){return s.reduce((a,l)=>se(a,l),t)}function se(t,s){const a=s[0],l=s.endsWith("2")?2:s.endsWith("'")?3:1;let r=ke(t);for(let c=0;c{const r=ct(l,s.length);return{move:a,phase:r,description:`${r}: apply ${a} as part of the inverse solve sequence.`}})}function at(t,s){const a=ke(t);a[s]=ot(t[s]);const l=st[s],r=l.map(([c,S])=>S.map(d=>t[c][d]));return l.forEach(([c,S],d)=>{const x=r[(d+l.length-1)%l.length];S.forEach((f,v)=>{a[c][f]=x[v]})}),a}function ot(t){return[t[6],t[3],t[0],t[7],t[4],t[1],t[8],t[5],t[2]]}function rt(t){const s=[];for(const a of t){const l=s[s.length-1];if(!l||l[0]!==a[0]){s.push(a);continue}const r=(ve(l)+ve(a))%4;s.pop(),r!==0&&s.push(it(a[0],r))}return s}function ve(t){return t.endsWith("2")?2:t.endsWith("'")?3:1}function it(t,s){return s===2?`${t}2`:s===3?`${t}'`:t}function ct(t,s){if(s<=4)return["Cross","F2L","2-Look OLL","2-Look PLL"][t%4];const a=t/s;return a<.25?"Cross":a<.62?"F2L":a<.82?"2-Look OLL":"2-Look PLL"}const dt=["U","D","F","B","L","R"],fe=[{id:"starter-cross",title:"Starter Scramble",description:"A short scramble for practicing move notation and inverse solving.",scramble:["R","U","R'","U'"],targetMoves:4},{id:"six-move",title:"Six Move Sprint",description:"Solve a slightly longer scramble with clean inverse turns.",scramble:["F","R","U","R'","U'","F'"],targetMoves:6},{id:"middle-layer",title:"Middle Layer Drill",description:"A medium scramble that touches side faces and top-layer turns.",scramble:["L","U2","F","R'","D","B2","L'"],targetMoves:7},{id:"full-cube",title:"Full Cube Challenge",description:"A longer scramble that rewards using the solver and reading move notation.",scramble:["R","U","F2","L'","D","B","R2","U'","F","D'"],targetMoves:10}];function Ne(t){const s=[];let a="";for(;s.length0?t.join(" "):"None"}function we(t){const s=t.trim().toUpperCase().replace("’","'").replace(/I$/,"'");if(!s)return null;const a=s[0],l=s.slice(1);return!dt.includes(a)||l!==""&&l!=="'"&&l!=="2"?null:`${a}${l}`}function ut(t){const s=t.split(/[\s,]+/).map(l=>l.trim()).filter(Boolean);if(s.length===0)return null;const a=s.map(we);return a.some(l=>l===null)?null:a}function mt(t,s=25){const a=Math.max(1,Math.min(t,100)),l=Array.from({length:a},()=>{const d=Ne(s);return{scramble:d,solutionLength:le(d).length}}),r=l.reduce((d,x)=>x.solutionLengthx.solutionLength>d.solutionLength?x:d,l[0]),S=l.reduce((d,x)=>d+x.solutionLength,0)/l.length;return{runs:a,best:r,worst:c,averageLength:S}}function xt({mode:t,message:s,moveHistory:a,scrambleMoves:l,solution:r,solutionIndex:c,solutionDone:S,solverPlaybackMode:d,solverSpeed:x,manualMove:f,customScramble:v,simulationRuns:p,simulationResult:i,guidedStep:C,guidedScript:h,challenges:w,selectedChallenge:k,challengeStarted:ne,challengeMoves:H,challengeSolved:N,soundEnabled:V,onManualMoveChange:g,onCustomScrambleChange:ae,onSimulationRunsChange:j,onApplyManualMove:K,onScramble:Q,onApplyCustomScramble:$,onSimulateSolves:G,onGenerateSolution:_,onStepSolution:J,onAutoSolve:D,onSolverSpeedChange:A,onUndo:oe,onReset:L,onNextGuidedStep:X,onSelectChallenge:F,onStartChallenge:M,onToggleSound:Y}){const u=Math.max(0,z.findIndex(b=>b.id===x)),re=z[u]??z[1];return e.jsxs("aside",{className:"w-full space-y-4 md:w-80 md:shrink-0",children:[e.jsxs(B,{title:"Status",children:[e.jsx("p",{className:"text-xs leading-relaxed text-slate-300",children:s}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[e.jsx(O,{label:"Moves",value:a.length}),e.jsx(O,{label:"Solution",value:r.length>0?`${c}/${r.length}`:"-"})]})]}),t==="guided"&&e.jsxs(B,{title:"Guided Mode",children:[e.jsx("p",{className:"text-[11px] leading-relaxed text-slate-400",children:"Learn notation, scrambling, and CFOP-inspired phase labels step by step."}),e.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:"Reference style: Cross → F2L → 2-Look OLL → 2-Look PLL."}),e.jsxs("div",{className:"mt-3 rounded-xl border border-amber-500/20 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-300",children:["Step ",C+1," / ",h.length]}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-300",children:h[C]})]}),e.jsx("button",{onClick:X,className:"mt-3 w-full rounded-lg bg-amber-500/20 px-3 py-2 text-xs font-semibold text-amber-300 ring-1 ring-amber-500/40 hover:bg-amber-500/30",children:"Continue Guided Step"})]}),t==="freeplay"&&e.jsxs(B,{title:"Freeplay Mode",children:[e.jsx(je,{value:f,onChange:g,onApply:K}),e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Custom scramble"}),e.jsx("textarea",{value:v,onChange:b=>ae(b.target.value),rows:2,placeholder:"R U R' U' or Ri U R U2",className:"mt-1 w-full resize-none rounded-lg bg-slate-950/70 px-3 py-2 text-xs font-mono text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-cyan-500/50"}),e.jsx("button",{onClick:$,className:"mt-2 w-full rounded-lg bg-violet-500/20 px-3 py-2 text-xs font-semibold text-violet-300 ring-1 ring-violet-500/40 hover:bg-violet-500/30",children:"Apply Custom Scramble"})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[e.jsx(T,{onClick:()=>Q(12),icon:e.jsx(xe,{size:13}),label:"12-Move Scramble"}),e.jsx(T,{onClick:()=>Q(25),icon:e.jsx(xe,{size:13}),label:"25-Move Scramble"}),e.jsx(T,{onClick:_,icon:e.jsx(ge,{size:13}),label:"Find Solution"}),e.jsx(T,{onClick:D,icon:e.jsx(pe,{size:13}),label:"Auto Run"}),e.jsx(T,{onClick:oe,label:"Undo"}),e.jsx(T,{onClick:L,icon:e.jsx(_e,{size:13}),label:"Reset"})]}),e.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Simulation runs"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("input",{type:"number",min:1,max:100,value:p,onChange:b=>j(Number(b.target.value)||1),className:"min-w-0 flex-1 rounded-lg bg-slate-950/70 px-3 py-2 text-sm font-mono text-slate-200 ring-1 ring-slate-700/50"}),e.jsx("button",{onClick:G,className:"rounded-lg bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:"Run"})]})]})]}),t==="challenge"&&e.jsxs(B,{title:"Challenge Mode",children:[e.jsx("div",{className:"space-y-2",children:w.map(b=>e.jsxs("button",{onClick:()=>F(b),className:`w-full rounded-lg px-3 py-2 text-left ring-1 transition-all ${k.id===b.id?"bg-rose-500/15 text-rose-200 ring-rose-500/40":"bg-slate-800/50 text-slate-400 ring-slate-700/40 hover:bg-slate-700/50"}`,children:[e.jsx("div",{className:"text-xs font-semibold",children:b.title}),e.jsx("div",{className:"mt-0.5 text-[10px] text-slate-500",children:b.description})]},b.id))}),e.jsx("button",{onClick:()=>M(k),className:"mt-3 w-full rounded-lg bg-rose-500/20 px-3 py-2 text-xs font-semibold text-rose-300 ring-1 ring-rose-500/40 hover:bg-rose-500/30",children:"Start Challenge"}),ne&&e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx(je,{value:f,onChange:g,onApply:K}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(O,{label:"Your Moves",value:H}),e.jsx(O,{label:"Target",value:k.targetMoves})]}),N&&e.jsxs("div",{className:"rounded-lg bg-emerald-500/10 px-3 py-2 text-xs text-emerald-300 ring-1 ring-emerald-500/30",children:["Solved in ",H," moves."]})]})]}),e.jsxs(B,{title:"Solver",children:[e.jsxs("div",{className:"space-y-2 text-[11px] text-slate-400",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-slate-500",children:"Scramble:"})," ",R(l)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-slate-500",children:"History:"})," ",R(a.slice(-12))]})]}),e.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Playback"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:re.label})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Se,{label:"Manual Step",active:d==="manual",disabled:S||r.length===0,onClick:J}),e.jsx(Se,{label:"Auto",active:d==="auto",disabled:S||r.length===0&&a.length===0,onClick:D})]}),e.jsx("input",{type:"range",min:0,max:z.length-1,step:1,value:u,onChange:b=>{const m=z[Number(b.target.value)]?.id;m&&A(m)},className:"mt-3 w-full accent-indigo-400","aria-label":"Solver auto playback speed"}),e.jsx("div",{className:"mt-1 flex justify-between",children:z.map(b=>e.jsx("span",{className:`text-[9px] uppercase tracking-wide ${b.id===x?"text-indigo-300":"text-slate-600"}`,children:b.label},b.id))})]}),r.length>0&&e.jsx("div",{className:"mt-3 max-h-28 overflow-y-auto rounded-lg bg-slate-950/50 p-2",children:r.map((b,m)=>e.jsxs("div",{className:`flex items-center gap-2 rounded px-2 py-1 text-[11px] ${mY(!V),className:`inline-flex w-full items-center justify-center gap-2 rounded-lg px-3 py-2 text-xs font-semibold ring-1 ${V?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[V?e.jsx(Ge,{size:14}):e.jsx(Xe,{size:14}),V?"Sound On":"Sound Off"]})})]})}function B({title:t,children:s}){return e.jsxs("section",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"mb-3 text-[11px] font-semibold uppercase tracking-wider text-slate-400",children:t}),s]})}function O({label:t,value:s}){return e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2.5 py-2 ring-1 ring-slate-700/40",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:t}),e.jsx("div",{className:"text-sm font-mono text-slate-100",children:s})]})}function T({label:t,icon:s,disabled:a,onClick:l}){return e.jsxs("button",{onClick:l,disabled:a,className:"inline-flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/70 px-3 py-2 text-[11px] font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70 disabled:cursor-not-allowed disabled:opacity-40",children:[s,t]})}function Se({label:t,active:s,disabled:a,onClick:l}){return e.jsx("button",{onClick:l,disabled:a,className:`rounded-lg px-3 py-2 text-[11px] font-semibold ring-1 transition-all disabled:cursor-not-allowed disabled:opacity-40 ${s?"bg-indigo-500/20 text-indigo-300 ring-indigo-500/40":"bg-slate-800/70 text-slate-300 ring-slate-700/50 hover:bg-slate-700/70"}`,children:t})}function je({value:t,onChange:s,onApply:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Move notation"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("input",{value:t,onChange:l=>s(l.target.value),onKeyDown:l=>{l.key==="Enter"&&a()},placeholder:"R, U', F2",className:"min-w-0 flex-1 rounded-lg bg-slate-950/70 px-3 py-2 text-sm font-mono text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-cyan-500/50"}),e.jsx("button",{onClick:a,className:"rounded-lg bg-cyan-500/20 px-3 py-2 text-xs font-semibold text-cyan-300 ring-1 ring-cyan-500/40 hover:bg-cyan-500/30",children:"Apply"})]})]})}const pt=o.memo(xt);function gt(){const t=o.useRef(!0),[s,a]=o.useState(!0),l=o.useCallback(()=>Ye(),[]),r=o.useCallback((v,p,i="sine",C=.045)=>{if(!t.current)return;const h=l();if(!h)return;const w=h.createOscillator(),k=h.createGain();w.type=i,w.frequency.setValueAtTime(v,h.currentTime),k.gain.setValueAtTime(C,h.currentTime),k.gain.exponentialRampToValueAtTime(.001,h.currentTime+p),w.connect(k),k.connect(h.destination),w.start(h.currentTime),w.stop(h.currentTime+p)},[l]),c=o.useCallback(v=>{const p=[261.63,293.66,329.63,392,440,523.25];r(p[v%p.length],.08,"triangle",.035)},[r]),S=o.useCallback(()=>{r(196,.12,"sawtooth",.03),setTimeout(()=>r(246.94,.12,"sawtooth",.03),80)},[r]),d=o.useCallback(()=>{[392,493.88,587.33,783.99].forEach((v,p)=>{setTimeout(()=>r(v,.12,"sine",.05),p*75)})},[r]),x=o.useCallback(()=>{r(164.81,.18,"sawtooth",.035)},[r]),f=o.useCallback(v=>{t.current=v,a(v)},[]);return{soundEnabled:s,toggleSound:f,playMove:c,playScramble:S,playSolved:d,playError:x}}const ye=["Start from a solved cube and watch what a single R turn does.","Scramble the cube with a short sequence.","Ask the solver for the inverse sequence.","Step through solution moves and watch the cube return to solved state."];function Ce(t){return z.find(s=>s.id===t)?.delayMs??450}function bt(){const[t,s]=o.useState("guided"),[a,l]=o.useState(U),[r,c]=o.useState([]),[S,d]=o.useState([]),[x,f]=o.useState([]),[v,p]=o.useState(0),[i,C]=o.useState("R"),[h,w]=o.useState("R U R' U'"),[k,ne]=o.useState(10),[H,N]=o.useState(null),[V,g]=o.useState("Choose a mode and start turning the cube."),[ae,j]=o.useState("manual"),[K,Q]=o.useState("normal"),[$,G]=o.useState(0),[_,J]=o.useState(fe[0]),[D,A]=o.useState(!1),[oe,L]=o.useState(0),[X,F]=o.useState(!1),M=o.useRef(null),Y=o.useRef("normal"),u=gt(),re=o.useMemo(()=>te(a),[a]),b=x.length>0&&v>=x.length,m=o.useCallback(()=>{M.current&&(window.clearInterval(M.current),M.current=null)},[]);o.useEffect(()=>m,[m]);const Me=o.useCallback(n=>{Y.current=n,Q(n)},[]),Re=o.useCallback(()=>{m(),l(U()),c([]),d([]),f([]),p(0),N(null),j("manual"),G(0),A(!1),L(0),F(!1),g("Cube reset to solved state.")},[m]),Le=o.useCallback(n=>{s(n),m(),l(U()),c([]),d([]),f([]),p(0),N(null),j("manual"),G(0),A(!1),L(0),F(!1),g(n==="guided"?"Guided mode: follow the walkthrough to understand cube moves and solving.":n==="freeplay"?"Freeplay mode: scramble, turn, and solve however you like.":"Challenge mode: solve the scramble in as few moves as possible.")},[m]),q=o.useCallback((n,y=!0)=>{m(),j("manual"),l(E=>{const I=se(E,n);return y&&(c(P=>[...P,n]),t==="challenge"&&D&&!X&&(L(P=>P+1),te(I)&&(F(!0),g("Challenge solved! Compare your move count with the target."),u.playSolved()))),I}),f([]),p(0),N(null),u.playMove(n.charCodeAt(0))},[X,D,m,t,u]),Fe=o.useCallback((n=12)=>{m();const y=Ne(n);l(Z(U(),y)),c(y),d(y),f([]),p(0),j("manual"),A(!1),L(0),F(!1),g(`Scrambled with: ${R(y)}`),u.playScramble()},[m,u]),Ue=o.useCallback(()=>{m();const n=ut(h);if(!n){g("Invalid scramble. Use moves like: R U R' U' or Ri U R U2."),u.playError();return}l(Z(U(),n)),c(n),d(n),f([]),p(0),N(null),j("manual"),A(!1),L(0),F(!1),g(`Custom scramble applied: ${R(n)}`),u.playScramble()},[m,h,u]),Te=o.useCallback((n=_)=>{m(),J(n),l(Z(U(),n.scramble)),c(n.scramble),d(n.scramble),f([]),p(0),N(null),j("manual"),A(!0),L(0),F(!1),g(`Challenge started. Scramble: ${R(n.scramble)}`),u.playScramble()},[m,_,u]),$e=o.useCallback(()=>{m();const n=le(r);f(n),p(0),N(null),j("manual"),g(n.length>0?`Solver found ${n.length} inverse move${n.length===1?"":"s"}.`:"Cube is already solved."),n.length===0&&u.playSolved()},[m,r,u]),ie=o.useCallback(()=>{m(),j("manual");const n=x[v];n&&(l(y=>{const E=se(y,n.move);return te(E)?(g("Solved! The inverse sequence returned the cube to its original state."),u.playSolved()):g(n.description),E}),p(y=>y+1),u.playMove(v))},[m,x,v,u]),De=o.useCallback(()=>{m();const n=x.length>0?x:le(r),y=x.length>0?v:0;if(n.length===0){f([]),p(0),j("manual"),g("Cube is already solved."),u.playSolved();return}if(y>=n.length){j("manual"),g("Solution playback is already complete.");return}x.length===0&&(f(n),p(0)),N(null),j("auto"),g(`Auto-solving ${n.length-y} remaining move${n.length-y===1?"":"s"}.`);const E=()=>{p(I=>{const P=n[I];if(!P)return M.current=null,j("manual"),I;l(Be=>{const me=se(Be,P.move);return te(me)?(g("Auto-solve complete."),u.playSolved()):(g(P.description),u.playMove(I)),me});const ue=I+1;return ue{const n=we(i);if(!n){g("Invalid move. Use notation like R, U', F2, or L'."),u.playError();return}q(n),g(`Applied ${n}.`)},[q,i,u]),Ee=o.useCallback(()=>{const n=mt(k);N(n),g(`Ran ${n.runs} simulated solves. Best: ${n.best.solutionLength} moves, worst: ${n.worst.solutionLength} moves.`)},[k]),Ie=o.useCallback(()=>{const n=r.slice(0,-1);c(n),l(Z(U(),n)),f([]),p(0),j("manual"),g("Undid the last recorded move.")},[r]),Pe=o.useCallback(()=>{if($===0)q("R"),g("R turns the right face clockwise. Notice the side stickers move too.");else if($===1){const n=["R","U","R'","U'"];l(Z(U(),n)),c(n),d(n),g(`Short scramble applied: ${R(n)}`),u.playScramble()}else if($===2){const n=le(r);f(n),p(0),g(`The solver reverses the scramble: ${R(n.map(y=>y.move))}`)}else ie();G(n=>Math.min(n+1,ye.length-1))},[$,q,r,u,ie]);return{mode:t,cube:a,solved:re,moveHistory:r,scrambleMoves:S,solution:x,solutionIndex:v,solutionDone:b,solverPlaybackMode:ae,solverSpeed:K,setSolverSpeed:Me,manualMove:i,setManualMove:C,customScramble:h,setCustomScramble:w,simulationRuns:k,setSimulationRuns:ne,simulationResult:H,message:V,guidedStep:$,guidedScript:ye,selectedChallenge:_,setSelectedChallenge:J,challenges:fe,challengeStarted:D,challengeMoves:oe,challengeSolved:X,soundEnabled:u.soundEnabled,toggleSound:u.toggleSound,switchMode:Le,resetCube:Re,makeMove:q,runScramble:Fe,runCustomScramble:Ue,generateSolution:$e,stepSolution:ie,autoSolve:De,applyManualMove:Ae,undoLastMove:Ie,startChallenge:Te,nextGuidedStep:Pe,simulateSolves:Ee}}const ht=[{id:"guided",label:"Guided Mode",icon:e.jsx(Ve,{size:14})},{id:"freeplay",label:"Freeplay Mode",icon:e.jsx(ze,{size:14})},{id:"challenge",label:"Challenge Mode",icon:e.jsx(qe,{size:14})}];function Nt(){const t=bt();return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("div",{className:"shrink-0 border-b border-slate-700/50 bg-slate-900/40 px-4 pt-3 backdrop-blur-sm md:px-6",children:e.jsx("div",{className:"flex gap-1 overflow-x-auto",children:ht.map(s=>e.jsxs("button",{onClick:()=>t.switchMode(s.id),className:`flex items-center gap-1.5 whitespace-nowrap rounded-t-lg px-4 py-2.5 text-xs font-medium transition-all md:text-sm ${t.mode===s.id?"bg-slate-800/80 text-indigo-300 border border-b-0 border-slate-700/50 -mb-px":"text-slate-500 hover:bg-slate-800/30 hover:text-slate-300"}`,children:[s.icon,s.label]},s.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-6",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col gap-4 md:flex-row md:gap-6",children:[e.jsxs("main",{className:"order-last flex min-w-0 flex-1 flex-col gap-4 md:order-first",children:[e.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm md:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-white md:text-xl",children:"Rubik's Cube Solver"}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-400",children:"Manipulate a 3D Rubik's Cube, generate or enter scrambles, and watch a CFOP-inspired solve sequence step by step."})]}),e.jsx("div",{className:"rounded-full bg-violet-500/10 px-3 py-1 text-[10px] font-semibold text-violet-300 ring-1 ring-violet-500/30",children:"3D Cube"})]}),e.jsx("div",{className:"mt-3 rounded-xl bg-indigo-500/5 px-3 py-2 ring-1 ring-indigo-500/15",children:e.jsxs("p",{className:"text-[11px] leading-relaxed text-slate-300",children:["Move notation: ",e.jsx("span",{className:"font-mono text-cyan-300",children:"R"})," turns a face clockwise,",e.jsx("span",{className:"font-mono text-cyan-300",children:" R'"})," turns it counter-clockwise, and",e.jsx("span",{className:"font-mono text-cyan-300",children:" R2"})," turns it twice. The inverse shorthand",e.jsx("span",{className:"font-mono text-cyan-300",children:" Ri"})," is also accepted."]})})]}),e.jsx(et,{cube:t.cube,solved:t.solved,onMove:t.makeMove})]}),e.jsx(pt,{mode:t.mode,message:t.message,moveHistory:t.moveHistory,scrambleMoves:t.scrambleMoves,solution:t.solution,solutionIndex:t.solutionIndex,solutionDone:t.solutionDone,solverPlaybackMode:t.solverPlaybackMode,solverSpeed:t.solverSpeed,manualMove:t.manualMove,customScramble:t.customScramble,simulationRuns:t.simulationRuns,simulationResult:t.simulationResult,guidedStep:t.guidedStep,guidedScript:t.guidedScript,challenges:t.challenges,selectedChallenge:t.selectedChallenge,challengeStarted:t.challengeStarted,challengeMoves:t.challengeMoves,challengeSolved:t.challengeSolved,soundEnabled:t.soundEnabled,onManualMoveChange:t.setManualMove,onCustomScrambleChange:t.setCustomScramble,onSimulationRunsChange:t.setSimulationRuns,onApplyManualMove:t.applyManualMove,onScramble:t.runScramble,onApplyCustomScramble:t.runCustomScramble,onSimulateSolves:t.simulateSolves,onGenerateSolution:t.generateSolution,onStepSolution:t.stepSolution,onAutoSolve:t.autoSolve,onSolverSpeedChange:t.setSolverSpeed,onUndo:t.undoLastMove,onReset:t.resetCube,onNextGuidedStep:t.nextGuidedStep,onSelectChallenge:t.setSelectedChallenge,onStartChallenge:t.startChallenge,onToggleSound:t.toggleSound})]})})]})}export{Nt as default}; +import{c as Oe,r as o,j as e,B as ze,g as Ve}from"./index-DBkLeWDs.js";import{S as xe}from"./shuffle-Dlr-c52A.js";import{S as pe}from"./skip-forward-C79KMIOU.js";import{R as _e}from"./rotate-ccw-7GTUOPy4.js";import{V as Ge,a as Xe}from"./volume-x-BSx9gxSg.js";import{g as Ye}from"./audioContext-NbgqvQGz.js";import{T as qe}from"./trophy-C1QWh03u.js";const We=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],ge=Oe("wand-sparkles",We),z=[{id:"slow",label:"Slow",delayMs:900},{id:"normal",label:"Normal",delayMs:450},{id:"fast",label:"Fast",delayMs:160}],Ze={U:"Up",D:"Down",F:"Front",B:"Back",L:"Left",R:"Right"},He={white:"#f8fafc",yellow:"#facc15",green:"#22c55e",blue:"#3b82f6",orange:"#f97316",red:"#ef4444"},ce=["U","U'","U2","D","D'","D2","F","F'","F2","B","B'","B2","L","L'","L2","R","R'","R2"],Ke={F:"translateZ(72px)",B:"rotateY(180deg) translateZ(72px)",R:"rotateY(90deg) translateZ(72px)",L:"rotateY(-90deg) translateZ(72px)",U:"rotateX(90deg) translateZ(72px)",D:"rotateX(-90deg) translateZ(72px)"},Qe=["F","R","U","L","D","B"],be={x:-24,y:38},ee=18;function Je({cube:t,solved:s,onMove:a}){const[l,r]=o.useState(be),[c,S]=o.useState(null),d=o.useCallback((i,C)=>{r(h=>({x:he(h.x+i),y:h.y+C}))},[]),x=o.useCallback(()=>{r(be)},[]),f=o.useCallback(i=>{i.currentTarget.setPointerCapture(i.pointerId),S({pointerId:i.pointerId,startX:i.clientX,startY:i.clientY,rotation:l})},[l]),v=o.useCallback(i=>{if(!c||c.pointerId!==i.pointerId)return;const C=i.clientX-c.startX,h=i.clientY-c.startY;r({x:he(c.rotation.x-h*.35),y:c.rotation.y+C*.35})},[c]),p=o.useCallback(i=>{!c||c.pointerId!==i.pointerId||(i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId),S(null))},[c]);return e.jsxs("div",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 md:p-5 backdrop-blur-sm",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-white",children:"Cube State"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Drag the 3D cube to rotate the view"})]}),e.jsx("span",{className:`rounded-full px-2.5 py-1 text-[10px] font-semibold ring-1 ${s?"bg-emerald-500/15 text-emerald-300 ring-emerald-500/30":"bg-amber-500/15 text-amber-300 ring-amber-500/30"}`,children:s?"Solved":"Scrambled"})]}),e.jsx("div",{className:"flex min-h-[290px] touch-none cursor-grab items-center justify-center overflow-hidden rounded-xl bg-slate-950/40 ring-1 ring-slate-800/60 active:cursor-grabbing",role:"img","aria-label":"Interactive 3D Rubik's Cube view. Drag to rotate the cube.",onPointerDown:f,onPointerMove:v,onPointerUp:p,onPointerCancel:p,children:e.jsxs("div",{className:"relative h-56 w-56",style:{perspective:"900px"},children:[e.jsx("div",{className:`absolute left-1/2 top-1/2 h-36 w-36 ${c?"":"transition-transform duration-500"}`,style:{transformStyle:"preserve-3d",transform:`translate(-50%, -50%) rotateX(${l.x}deg) rotateY(${l.y}deg) rotateZ(0deg)`},children:Qe.map(i=>e.jsxs("div",{className:"absolute left-0 top-0 grid h-36 w-36 grid-cols-3 gap-1 rounded-xl border border-slate-950/70 bg-slate-950/90 p-1.5 shadow-2xl",style:{transform:Ke[i],backfaceVisibility:"hidden"},"aria-label":`${Ze[i]} face`,children:[t[i].map((C,h)=>e.jsx("div",{className:"rounded-md border border-slate-950/50 shadow-inner transition-colors duration-300",style:{backgroundColor:He[C]}},`${i}-${h}`)),e.jsx("span",{className:"pointer-events-none absolute left-2 top-1 text-[10px] font-black text-slate-950/50",children:i})]},i))}),e.jsx("div",{className:"absolute bottom-2 left-1/2 h-8 w-40 -translate-x-1/2 rounded-full bg-black/30 blur-xl"})]})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{className:"text-[10px] text-slate-500",children:["View angle: X ",Math.round(l.x),"deg / Y ",Math.round(l.y),"deg"]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(W,{label:"Up",onClick:()=>d(-ee,0)}),e.jsx(W,{label:"Down",onClick:()=>d(ee,0)}),e.jsx(W,{label:"Left",onClick:()=>d(0,-ee)}),e.jsx(W,{label:"Right",onClick:()=>d(0,ee)}),e.jsx(W,{label:"Reset View",onClick:x})]})]}),e.jsxs("div",{className:"mt-5",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Quick Turns"}),e.jsx("span",{className:"text-[10px] text-slate-600",children:"Clockwise / inverse / double"})]}),e.jsx("div",{className:"grid grid-cols-6 gap-1.5 sm:grid-cols-9",children:ce.map(i=>e.jsx("button",{onClick:()=>a(i),className:"rounded-lg bg-slate-800/70 px-2 py-1.5 text-[11px] font-semibold text-slate-300 ring-1 ring-slate-700/40 transition-all hover:bg-indigo-500/15 hover:text-indigo-300 hover:ring-indigo-500/30",children:i},i))})]})]})}function he(t){return Math.max(-75,Math.min(75,t))}function W({label:t,onClick:s}){return e.jsx("button",{onClick:s,className:"rounded-md bg-slate-800/70 px-2 py-1 text-[10px] font-semibold text-slate-400 ring-1 ring-slate-700/40 transition-all hover:bg-indigo-500/15 hover:text-indigo-300 hover:ring-indigo-500/30",children:t})}const et=o.memo(Je),tt={U:"white",D:"yellow",F:"green",B:"blue",L:"orange",R:"red"},de=["U","D","F","B","L","R"],st={U:[["F",[0,1,2]],["R",[0,1,2]],["B",[0,1,2]],["L",[0,1,2]]],D:[["F",[6,7,8]],["L",[6,7,8]],["B",[6,7,8]],["R",[6,7,8]]],F:[["U",[6,7,8]],["R",[0,3,6]],["D",[2,1,0]],["L",[8,5,2]]],B:[["U",[2,1,0]],["L",[0,3,6]],["D",[6,7,8]],["R",[8,5,2]]],L:[["U",[0,3,6]],["F",[0,3,6]],["D",[0,3,6]],["B",[8,5,2]]],R:[["U",[8,5,2]],["B",[0,3,6]],["D",[8,5,2]],["F",[8,5,2]]]};function U(){return de.reduce((t,s)=>(t[s]=Array(9).fill(tt[s]),t),{})}function ke(t){return de.reduce((s,a)=>(s[a]=[...t[a]],s),{})}function te(t){return de.every(s=>t[s].every(a=>a===t[s][4]))}function Z(t,s){return s.reduce((a,l)=>se(a,l),t)}function se(t,s){const a=s[0],l=s.endsWith("2")?2:s.endsWith("'")?3:1;let r=ke(t);for(let c=0;c{const r=ct(l,s.length);return{move:a,phase:r,description:`${r}: apply ${a} as part of the inverse solve sequence.`}})}function at(t,s){const a=ke(t);a[s]=ot(t[s]);const l=st[s],r=l.map(([c,S])=>S.map(d=>t[c][d]));return l.forEach(([c,S],d)=>{const x=r[(d+l.length-1)%l.length];S.forEach((f,v)=>{a[c][f]=x[v]})}),a}function ot(t){return[t[6],t[3],t[0],t[7],t[4],t[1],t[8],t[5],t[2]]}function rt(t){const s=[];for(const a of t){const l=s[s.length-1];if(!l||l[0]!==a[0]){s.push(a);continue}const r=(ve(l)+ve(a))%4;s.pop(),r!==0&&s.push(it(a[0],r))}return s}function ve(t){return t.endsWith("2")?2:t.endsWith("'")?3:1}function it(t,s){return s===2?`${t}2`:s===3?`${t}'`:t}function ct(t,s){if(s<=4)return["Cross","F2L","2-Look OLL","2-Look PLL"][t%4];const a=t/s;return a<.25?"Cross":a<.62?"F2L":a<.82?"2-Look OLL":"2-Look PLL"}const dt=["U","D","F","B","L","R"],fe=[{id:"starter-cross",title:"Starter Scramble",description:"A short scramble for practicing move notation and inverse solving.",scramble:["R","U","R'","U'"],targetMoves:4},{id:"six-move",title:"Six Move Sprint",description:"Solve a slightly longer scramble with clean inverse turns.",scramble:["F","R","U","R'","U'","F'"],targetMoves:6},{id:"middle-layer",title:"Middle Layer Drill",description:"A medium scramble that touches side faces and top-layer turns.",scramble:["L","U2","F","R'","D","B2","L'"],targetMoves:7},{id:"full-cube",title:"Full Cube Challenge",description:"A longer scramble that rewards using the solver and reading move notation.",scramble:["R","U","F2","L'","D","B","R2","U'","F","D'"],targetMoves:10}];function Ne(t){const s=[];let a="";for(;s.length0?t.join(" "):"None"}function we(t){const s=t.trim().toUpperCase().replace("’","'").replace(/I$/,"'");if(!s)return null;const a=s[0],l=s.slice(1);return!dt.includes(a)||l!==""&&l!=="'"&&l!=="2"?null:`${a}${l}`}function ut(t){const s=t.split(/[\s,]+/).map(l=>l.trim()).filter(Boolean);if(s.length===0)return null;const a=s.map(we);return a.some(l=>l===null)?null:a}function mt(t,s=25){const a=Math.max(1,Math.min(t,100)),l=Array.from({length:a},()=>{const d=Ne(s);return{scramble:d,solutionLength:le(d).length}}),r=l.reduce((d,x)=>x.solutionLengthx.solutionLength>d.solutionLength?x:d,l[0]),S=l.reduce((d,x)=>d+x.solutionLength,0)/l.length;return{runs:a,best:r,worst:c,averageLength:S}}function xt({mode:t,message:s,moveHistory:a,scrambleMoves:l,solution:r,solutionIndex:c,solutionDone:S,solverPlaybackMode:d,solverSpeed:x,manualMove:f,customScramble:v,simulationRuns:p,simulationResult:i,guidedStep:C,guidedScript:h,challenges:w,selectedChallenge:k,challengeStarted:ne,challengeMoves:H,challengeSolved:N,soundEnabled:V,onManualMoveChange:g,onCustomScrambleChange:ae,onSimulationRunsChange:j,onApplyManualMove:K,onScramble:Q,onApplyCustomScramble:$,onSimulateSolves:G,onGenerateSolution:_,onStepSolution:J,onAutoSolve:D,onSolverSpeedChange:A,onUndo:oe,onReset:L,onNextGuidedStep:X,onSelectChallenge:F,onStartChallenge:M,onToggleSound:Y}){const u=Math.max(0,z.findIndex(b=>b.id===x)),re=z[u]??z[1];return e.jsxs("aside",{className:"w-full space-y-4 md:w-80 md:shrink-0",children:[e.jsxs(B,{title:"Status",children:[e.jsx("p",{className:"text-xs leading-relaxed text-slate-300",children:s}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[e.jsx(O,{label:"Moves",value:a.length}),e.jsx(O,{label:"Solution",value:r.length>0?`${c}/${r.length}`:"-"})]})]}),t==="guided"&&e.jsxs(B,{title:"Guided Mode",children:[e.jsx("p",{className:"text-[11px] leading-relaxed text-slate-400",children:"Learn notation, scrambling, and CFOP-inspired phase labels step by step."}),e.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:"Reference style: Cross → F2L → 2-Look OLL → 2-Look PLL."}),e.jsxs("div",{className:"mt-3 rounded-xl border border-amber-500/20 bg-amber-500/5 p-3",children:[e.jsxs("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-300",children:["Step ",C+1," / ",h.length]}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-300",children:h[C]})]}),e.jsx("button",{onClick:X,className:"mt-3 w-full rounded-lg bg-amber-500/20 px-3 py-2 text-xs font-semibold text-amber-300 ring-1 ring-amber-500/40 hover:bg-amber-500/30",children:"Continue Guided Step"})]}),t==="freeplay"&&e.jsxs(B,{title:"Freeplay Mode",children:[e.jsx(je,{value:f,onChange:g,onApply:K}),e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Custom scramble"}),e.jsx("textarea",{value:v,onChange:b=>ae(b.target.value),rows:2,placeholder:"R U R' U' or Ri U R U2",className:"mt-1 w-full resize-none rounded-lg bg-slate-950/70 px-3 py-2 text-xs font-mono text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-cyan-500/50"}),e.jsx("button",{onClick:$,className:"mt-2 w-full rounded-lg bg-violet-500/20 px-3 py-2 text-xs font-semibold text-violet-300 ring-1 ring-violet-500/40 hover:bg-violet-500/30",children:"Apply Custom Scramble"})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[e.jsx(T,{onClick:()=>Q(12),icon:e.jsx(xe,{size:13}),label:"12-Move Scramble"}),e.jsx(T,{onClick:()=>Q(25),icon:e.jsx(xe,{size:13}),label:"25-Move Scramble"}),e.jsx(T,{onClick:_,icon:e.jsx(ge,{size:13}),label:"Find Solution"}),e.jsx(T,{onClick:D,icon:e.jsx(pe,{size:13}),label:"Auto Run"}),e.jsx(T,{onClick:oe,label:"Undo"}),e.jsx(T,{onClick:L,icon:e.jsx(_e,{size:13}),label:"Reset"})]}),e.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Simulation runs"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("input",{type:"number",min:1,max:100,value:p,onChange:b=>j(Number(b.target.value)||1),className:"min-w-0 flex-1 rounded-lg bg-slate-950/70 px-3 py-2 text-sm font-mono text-slate-200 ring-1 ring-slate-700/50"}),e.jsx("button",{onClick:G,className:"rounded-lg bg-slate-800/70 px-3 py-2 text-xs font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70",children:"Run"})]})]})]}),t==="challenge"&&e.jsxs(B,{title:"Challenge Mode",children:[e.jsx("div",{className:"space-y-2",children:w.map(b=>e.jsxs("button",{onClick:()=>F(b),className:`w-full rounded-lg px-3 py-2 text-left ring-1 transition-all ${k.id===b.id?"bg-rose-500/15 text-rose-200 ring-rose-500/40":"bg-slate-800/50 text-slate-400 ring-slate-700/40 hover:bg-slate-700/50"}`,children:[e.jsx("div",{className:"text-xs font-semibold",children:b.title}),e.jsx("div",{className:"mt-0.5 text-[10px] text-slate-500",children:b.description})]},b.id))}),e.jsx("button",{onClick:()=>M(k),className:"mt-3 w-full rounded-lg bg-rose-500/20 px-3 py-2 text-xs font-semibold text-rose-300 ring-1 ring-rose-500/40 hover:bg-rose-500/30",children:"Start Challenge"}),ne&&e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx(je,{value:f,onChange:g,onApply:K}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(O,{label:"Your Moves",value:H}),e.jsx(O,{label:"Target",value:k.targetMoves})]}),N&&e.jsxs("div",{className:"rounded-lg bg-emerald-500/10 px-3 py-2 text-xs text-emerald-300 ring-1 ring-emerald-500/30",children:["Solved in ",H," moves."]})]})]}),e.jsxs(B,{title:"Solver",children:[e.jsxs("div",{className:"space-y-2 text-[11px] text-slate-400",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-slate-500",children:"Scramble:"})," ",R(l)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-slate-500",children:"History:"})," ",R(a.slice(-12))]})]}),e.jsxs("div",{className:"mt-3 rounded-xl border border-slate-700/40 bg-slate-950/40 p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Playback"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:re.label})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(Se,{label:"Manual Step",active:d==="manual",disabled:S||r.length===0,onClick:J}),e.jsx(Se,{label:"Auto",active:d==="auto",disabled:S||r.length===0&&a.length===0,onClick:D})]}),e.jsx("input",{type:"range",min:0,max:z.length-1,step:1,value:u,onChange:b=>{const m=z[Number(b.target.value)]?.id;m&&A(m)},className:"mt-3 w-full accent-indigo-400","aria-label":"Solver auto playback speed"}),e.jsx("div",{className:"mt-1 flex justify-between",children:z.map(b=>e.jsx("span",{className:`text-[9px] uppercase tracking-wide ${b.id===x?"text-indigo-300":"text-slate-600"}`,children:b.label},b.id))})]}),r.length>0&&e.jsx("div",{className:"mt-3 max-h-28 overflow-y-auto rounded-lg bg-slate-950/50 p-2",children:r.map((b,m)=>e.jsxs("div",{className:`flex items-center gap-2 rounded px-2 py-1 text-[11px] ${mY(!V),className:`inline-flex w-full items-center justify-center gap-2 rounded-lg px-3 py-2 text-xs font-semibold ring-1 ${V?"bg-indigo-500/15 text-indigo-300 ring-indigo-500/30":"bg-slate-800/70 text-slate-400 ring-slate-700/40"}`,children:[V?e.jsx(Ge,{size:14}):e.jsx(Xe,{size:14}),V?"Sound On":"Sound Off"]})})]})}function B({title:t,children:s}){return e.jsxs("section",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"mb-3 text-[11px] font-semibold uppercase tracking-wider text-slate-400",children:t}),s]})}function O({label:t,value:s}){return e.jsxs("div",{className:"rounded-lg bg-slate-800/50 px-2.5 py-2 ring-1 ring-slate-700/40",children:[e.jsx("div",{className:"text-[10px] text-slate-500",children:t}),e.jsx("div",{className:"text-sm font-mono text-slate-100",children:s})]})}function T({label:t,icon:s,disabled:a,onClick:l}){return e.jsxs("button",{onClick:l,disabled:a,className:"inline-flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/70 px-3 py-2 text-[11px] font-semibold text-slate-300 ring-1 ring-slate-700/50 hover:bg-slate-700/70 disabled:cursor-not-allowed disabled:opacity-40",children:[s,t]})}function Se({label:t,active:s,disabled:a,onClick:l}){return e.jsx("button",{onClick:l,disabled:a,className:`rounded-lg px-3 py-2 text-[11px] font-semibold ring-1 transition-all disabled:cursor-not-allowed disabled:opacity-40 ${s?"bg-indigo-500/20 text-indigo-300 ring-indigo-500/40":"bg-slate-800/70 text-slate-300 ring-slate-700/50 hover:bg-slate-700/70"}`,children:t})}function je({value:t,onChange:s,onApply:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] text-slate-400",children:"Move notation"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("input",{value:t,onChange:l=>s(l.target.value),onKeyDown:l=>{l.key==="Enter"&&a()},placeholder:"R, U', F2",className:"min-w-0 flex-1 rounded-lg bg-slate-950/70 px-3 py-2 text-sm font-mono text-slate-200 ring-1 ring-slate-700/50 outline-none focus:ring-cyan-500/50"}),e.jsx("button",{onClick:a,className:"rounded-lg bg-cyan-500/20 px-3 py-2 text-xs font-semibold text-cyan-300 ring-1 ring-cyan-500/40 hover:bg-cyan-500/30",children:"Apply"})]})]})}const pt=o.memo(xt);function gt(){const t=o.useRef(!0),[s,a]=o.useState(!0),l=o.useCallback(()=>Ye(),[]),r=o.useCallback((v,p,i="sine",C=.045)=>{if(!t.current)return;const h=l();if(!h)return;const w=h.createOscillator(),k=h.createGain();w.type=i,w.frequency.setValueAtTime(v,h.currentTime),k.gain.setValueAtTime(C,h.currentTime),k.gain.exponentialRampToValueAtTime(.001,h.currentTime+p),w.connect(k),k.connect(h.destination),w.start(h.currentTime),w.stop(h.currentTime+p)},[l]),c=o.useCallback(v=>{const p=[261.63,293.66,329.63,392,440,523.25];r(p[v%p.length],.08,"triangle",.035)},[r]),S=o.useCallback(()=>{r(196,.12,"sawtooth",.03),setTimeout(()=>r(246.94,.12,"sawtooth",.03),80)},[r]),d=o.useCallback(()=>{[392,493.88,587.33,783.99].forEach((v,p)=>{setTimeout(()=>r(v,.12,"sine",.05),p*75)})},[r]),x=o.useCallback(()=>{r(164.81,.18,"sawtooth",.035)},[r]),f=o.useCallback(v=>{t.current=v,a(v)},[]);return{soundEnabled:s,toggleSound:f,playMove:c,playScramble:S,playSolved:d,playError:x}}const ye=["Start from a solved cube and watch what a single R turn does.","Scramble the cube with a short sequence.","Ask the solver for the inverse sequence.","Step through solution moves and watch the cube return to solved state."];function Ce(t){return z.find(s=>s.id===t)?.delayMs??450}function bt(){const[t,s]=o.useState("guided"),[a,l]=o.useState(U),[r,c]=o.useState([]),[S,d]=o.useState([]),[x,f]=o.useState([]),[v,p]=o.useState(0),[i,C]=o.useState("R"),[h,w]=o.useState("R U R' U'"),[k,ne]=o.useState(10),[H,N]=o.useState(null),[V,g]=o.useState("Choose a mode and start turning the cube."),[ae,j]=o.useState("manual"),[K,Q]=o.useState("normal"),[$,G]=o.useState(0),[_,J]=o.useState(fe[0]),[D,A]=o.useState(!1),[oe,L]=o.useState(0),[X,F]=o.useState(!1),M=o.useRef(null),Y=o.useRef("normal"),u=gt(),re=o.useMemo(()=>te(a),[a]),b=x.length>0&&v>=x.length,m=o.useCallback(()=>{M.current&&(window.clearInterval(M.current),M.current=null)},[]);o.useEffect(()=>m,[m]);const Me=o.useCallback(n=>{Y.current=n,Q(n)},[]),Re=o.useCallback(()=>{m(),l(U()),c([]),d([]),f([]),p(0),N(null),j("manual"),G(0),A(!1),L(0),F(!1),g("Cube reset to solved state.")},[m]),Le=o.useCallback(n=>{s(n),m(),l(U()),c([]),d([]),f([]),p(0),N(null),j("manual"),G(0),A(!1),L(0),F(!1),g(n==="guided"?"Guided mode: follow the walkthrough to understand cube moves and solving.":n==="freeplay"?"Freeplay mode: scramble, turn, and solve however you like.":"Challenge mode: solve the scramble in as few moves as possible.")},[m]),q=o.useCallback((n,y=!0)=>{m(),j("manual"),l(E=>{const I=se(E,n);return y&&(c(P=>[...P,n]),t==="challenge"&&D&&!X&&(L(P=>P+1),te(I)&&(F(!0),g("Challenge solved! Compare your move count with the target."),u.playSolved()))),I}),f([]),p(0),N(null),u.playMove(n.charCodeAt(0))},[X,D,m,t,u]),Fe=o.useCallback((n=12)=>{m();const y=Ne(n);l(Z(U(),y)),c(y),d(y),f([]),p(0),j("manual"),A(!1),L(0),F(!1),g(`Scrambled with: ${R(y)}`),u.playScramble()},[m,u]),Ue=o.useCallback(()=>{m();const n=ut(h);if(!n){g("Invalid scramble. Use moves like: R U R' U' or Ri U R U2."),u.playError();return}l(Z(U(),n)),c(n),d(n),f([]),p(0),N(null),j("manual"),A(!1),L(0),F(!1),g(`Custom scramble applied: ${R(n)}`),u.playScramble()},[m,h,u]),Te=o.useCallback((n=_)=>{m(),J(n),l(Z(U(),n.scramble)),c(n.scramble),d(n.scramble),f([]),p(0),N(null),j("manual"),A(!0),L(0),F(!1),g(`Challenge started. Scramble: ${R(n.scramble)}`),u.playScramble()},[m,_,u]),$e=o.useCallback(()=>{m();const n=le(r);f(n),p(0),N(null),j("manual"),g(n.length>0?`Solver found ${n.length} inverse move${n.length===1?"":"s"}.`:"Cube is already solved."),n.length===0&&u.playSolved()},[m,r,u]),ie=o.useCallback(()=>{m(),j("manual");const n=x[v];n&&(l(y=>{const E=se(y,n.move);return te(E)?(g("Solved! The inverse sequence returned the cube to its original state."),u.playSolved()):g(n.description),E}),p(y=>y+1),u.playMove(v))},[m,x,v,u]),De=o.useCallback(()=>{m();const n=x.length>0?x:le(r),y=x.length>0?v:0;if(n.length===0){f([]),p(0),j("manual"),g("Cube is already solved."),u.playSolved();return}if(y>=n.length){j("manual"),g("Solution playback is already complete.");return}x.length===0&&(f(n),p(0)),N(null),j("auto"),g(`Auto-solving ${n.length-y} remaining move${n.length-y===1?"":"s"}.`);const E=()=>{p(I=>{const P=n[I];if(!P)return M.current=null,j("manual"),I;l(Be=>{const me=se(Be,P.move);return te(me)?(g("Auto-solve complete."),u.playSolved()):(g(P.description),u.playMove(I)),me});const ue=I+1;return ue{const n=we(i);if(!n){g("Invalid move. Use notation like R, U', F2, or L'."),u.playError();return}q(n),g(`Applied ${n}.`)},[q,i,u]),Ee=o.useCallback(()=>{const n=mt(k);N(n),g(`Ran ${n.runs} simulated solves. Best: ${n.best.solutionLength} moves, worst: ${n.worst.solutionLength} moves.`)},[k]),Ie=o.useCallback(()=>{const n=r.slice(0,-1);c(n),l(Z(U(),n)),f([]),p(0),j("manual"),g("Undid the last recorded move.")},[r]),Pe=o.useCallback(()=>{if($===0)q("R"),g("R turns the right face clockwise. Notice the side stickers move too.");else if($===1){const n=["R","U","R'","U'"];l(Z(U(),n)),c(n),d(n),g(`Short scramble applied: ${R(n)}`),u.playScramble()}else if($===2){const n=le(r);f(n),p(0),g(`The solver reverses the scramble: ${R(n.map(y=>y.move))}`)}else ie();G(n=>Math.min(n+1,ye.length-1))},[$,q,r,u,ie]);return{mode:t,cube:a,solved:re,moveHistory:r,scrambleMoves:S,solution:x,solutionIndex:v,solutionDone:b,solverPlaybackMode:ae,solverSpeed:K,setSolverSpeed:Me,manualMove:i,setManualMove:C,customScramble:h,setCustomScramble:w,simulationRuns:k,setSimulationRuns:ne,simulationResult:H,message:V,guidedStep:$,guidedScript:ye,selectedChallenge:_,setSelectedChallenge:J,challenges:fe,challengeStarted:D,challengeMoves:oe,challengeSolved:X,soundEnabled:u.soundEnabled,toggleSound:u.toggleSound,switchMode:Le,resetCube:Re,makeMove:q,runScramble:Fe,runCustomScramble:Ue,generateSolution:$e,stepSolution:ie,autoSolve:De,applyManualMove:Ae,undoLastMove:Ie,startChallenge:Te,nextGuidedStep:Pe,simulateSolves:Ee}}const ht=[{id:"guided",label:"Guided Mode",icon:e.jsx(ze,{size:14})},{id:"freeplay",label:"Freeplay Mode",icon:e.jsx(Ve,{size:14})},{id:"challenge",label:"Challenge Mode",icon:e.jsx(qe,{size:14})}];function Nt(){const t=bt();return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("div",{className:"shrink-0 border-b border-slate-700/50 bg-slate-900/40 px-4 pt-3 backdrop-blur-sm md:px-6",children:e.jsx("div",{className:"flex gap-1 overflow-x-auto",children:ht.map(s=>e.jsxs("button",{onClick:()=>t.switchMode(s.id),className:`flex items-center gap-1.5 whitespace-nowrap rounded-t-lg px-4 py-2.5 text-xs font-medium transition-all md:text-sm ${t.mode===s.id?"bg-slate-800/80 text-indigo-300 border border-b-0 border-slate-700/50 -mb-px":"text-slate-500 hover:bg-slate-800/30 hover:text-slate-300"}`,children:[s.icon,s.label]},s.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-6",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col gap-4 md:flex-row md:gap-6",children:[e.jsxs("main",{className:"order-last flex min-w-0 flex-1 flex-col gap-4 md:order-first",children:[e.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm md:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-white md:text-xl",children:"Rubik's Cube Solver"}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-400",children:"Manipulate a 3D Rubik's Cube, generate or enter scrambles, and watch a CFOP-inspired solve sequence step by step."})]}),e.jsx("div",{className:"rounded-full bg-violet-500/10 px-3 py-1 text-[10px] font-semibold text-violet-300 ring-1 ring-violet-500/30",children:"3D Cube"})]}),e.jsx("div",{className:"mt-3 rounded-xl bg-indigo-500/5 px-3 py-2 ring-1 ring-indigo-500/15",children:e.jsxs("p",{className:"text-[11px] leading-relaxed text-slate-300",children:["Move notation: ",e.jsx("span",{className:"font-mono text-cyan-300",children:"R"})," turns a face clockwise,",e.jsx("span",{className:"font-mono text-cyan-300",children:" R'"})," turns it counter-clockwise, and",e.jsx("span",{className:"font-mono text-cyan-300",children:" R2"})," turns it twice. The inverse shorthand",e.jsx("span",{className:"font-mono text-cyan-300",children:" Ri"})," is also accepted."]})})]}),e.jsx(et,{cube:t.cube,solved:t.solved,onMove:t.makeMove})]}),e.jsx(pt,{mode:t.mode,message:t.message,moveHistory:t.moveHistory,scrambleMoves:t.scrambleMoves,solution:t.solution,solutionIndex:t.solutionIndex,solutionDone:t.solutionDone,solverPlaybackMode:t.solverPlaybackMode,solverSpeed:t.solverSpeed,manualMove:t.manualMove,customScramble:t.customScramble,simulationRuns:t.simulationRuns,simulationResult:t.simulationResult,guidedStep:t.guidedStep,guidedScript:t.guidedScript,challenges:t.challenges,selectedChallenge:t.selectedChallenge,challengeStarted:t.challengeStarted,challengeMoves:t.challengeMoves,challengeSolved:t.challengeSolved,soundEnabled:t.soundEnabled,onManualMoveChange:t.setManualMove,onCustomScrambleChange:t.setCustomScramble,onSimulationRunsChange:t.setSimulationRuns,onApplyManualMove:t.applyManualMove,onScramble:t.runScramble,onApplyCustomScramble:t.runCustomScramble,onSimulateSolves:t.simulateSolves,onGenerateSolution:t.generateSolution,onStepSolution:t.stepSolution,onAutoSolve:t.autoSolve,onSolverSpeedChange:t.setSolverSpeed,onUndo:t.undoLastMove,onReset:t.resetCube,onNextGuidedStep:t.nextGuidedStep,onSelectChallenge:t.setSelectedChallenge,onStartChallenge:t.startChallenge,onToggleSound:t.toggleSound})]})})]})}export{Nt as default}; diff --git a/docs/assets/SortingPage-CM1b7Xid.js b/docs/assets/SortingPage-R3xRGgbf.js similarity index 74% rename from docs/assets/SortingPage-CM1b7Xid.js rename to docs/assets/SortingPage-R3xRGgbf.js index 484a4fe..f0f8cca 100644 --- a/docs/assets/SortingPage-CM1b7Xid.js +++ b/docs/assets/SortingPage-R3xRGgbf.js @@ -1,11 +1,11 @@ -import{r as n,j as e,d as _}from"./index-eCXyAnHs.js";import{V as H,a as L}from"./volume-x-CTbtCvt-.js";import{S as Q}from"./square-CEHTCuQK.js";import{S as W}from"./shuffle-CdKU4ZYx.js";import{r as X}from"./index-iw_6MvvU.js";import{g as J}from"./audioContext-NbgqvQGz.js";function K(s,d,o,y){return o&&(s===o[0]||s===o[1])?"bg-rose-500 shadow-lg shadow-rose-500/30":d&&(s===d[0]||s===d[1])?"bg-amber-400 shadow-lg shadow-amber-400/20":y.includes(s)?"bg-emerald-500":"bg-indigo-400/80"}function Y({array:s,comparing:d,swapping:o,sortedIndices:y}){const g=Math.max(...s,1),x=Math.max(2,Math.min(20,Math.floor(900/s.length)-1));return e.jsx("div",{className:"flex h-[500px] items-end justify-center gap-[1px] rounded-xl border border-slate-700/50 bg-slate-950/80 p-6 backdrop-blur-sm shadow-2xl",children:s.map((a,r)=>{const h=a/g*100,t=K(r,d,o,y);return e.jsx("div",{className:`transition-all duration-75 rounded-t-sm ${t}`,style:{height:`${h}%`,width:`${x}px`}},r)})})}const Z=n.memo(Y),ee={slow:100,medium:30,fast:8,instant:0},R={bubble:{name:"Bubble Sort",description:"Repeatedly swaps adjacent elements if they are in the wrong order. Simple but inefficient for large datasets.",timeComplexity:"O(n²)",spaceComplexity:"O(1)",stable:!0},selection:{name:"Selection Sort",description:"Finds the minimum element and places it at the beginning. Performs well on small arrays.",timeComplexity:"O(n²)",spaceComplexity:"O(1)",stable:!1},insertion:{name:"Insertion Sort",description:"Builds the sorted array one element at a time by inserting each into its correct position.",timeComplexity:"O(n²)",spaceComplexity:"O(1)",stable:!0},quick:{name:"Quick Sort",description:"Divides the array using a pivot and recursively sorts the partitions. Very efficient in practice.",timeComplexity:"O(n log n)",spaceComplexity:"O(log n)",stable:!1},heap:{name:"Heap Sort",description:"Builds a max-heap then repeatedly extracts the maximum to build the sorted array.",timeComplexity:"O(n log n)",spaceComplexity:"O(1)",stable:!1},merge:{name:"Merge Sort",description:"Divides the array in half, recursively sorts, then merges. Guarantees consistent performance.",timeComplexity:"O(n log n)",spaceComplexity:"O(n)",stable:!0}},te=["bubble","selection","insertion","quick","heap","merge"],se=["slow","medium","fast","instant"];function ae({algorithm:s,setAlgorithm:d,speed:o,setSpeed:y,arraySize:g,changeArraySize:x,isRunning:a,isFinished:r,currentStep:h,totalSteps:t,soundEnabled:u,onToggleSound:i,onVisualize:f,onStop:c,onGenerateNewArray:S}){const p=R[s];return e.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Algorithm"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:te.map(l=>e.jsx("button",{onClick:()=>!a&&d(l),disabled:a,className:` +import{r as n,j as e}from"./index-DBkLeWDs.js";import{V as _,a as H}from"./volume-x-BSx9gxSg.js";import{S as L}from"./sparkles-3Zw4K66N.js";import{S as Q}from"./square-Bc_q5e3l.js";import{S as W}from"./shuffle-Dlr-c52A.js";import{r as X}from"./index-iw_6MvvU.js";import{g as J}from"./audioContext-NbgqvQGz.js";function K(s,d,o,y){return o&&(s===o[0]||s===o[1])?"bg-rose-500 shadow-lg shadow-rose-500/30":d&&(s===d[0]||s===d[1])?"bg-amber-400 shadow-lg shadow-amber-400/20":y.includes(s)?"bg-emerald-500":"bg-indigo-400/80"}function Y({array:s,comparing:d,swapping:o,sortedIndices:y}){const g=Math.max(...s,1),x=Math.max(2,Math.min(20,Math.floor(900/s.length)-1));return e.jsx("div",{className:"flex h-[500px] items-end justify-center gap-[1px] rounded-xl border border-slate-700/50 bg-slate-950/80 p-6 backdrop-blur-sm shadow-2xl",children:s.map((a,r)=>{const h=a/g*100,t=K(r,d,o,y);return e.jsx("div",{className:`transition-all duration-75 rounded-t-sm ${t}`,style:{height:`${h}%`,width:`${x}px`}},r)})})}const Z=n.memo(Y),ee={slow:100,medium:30,fast:8,instant:0},R={bubble:{name:"Bubble Sort",description:"Repeatedly swaps adjacent elements if they are in the wrong order. Simple but inefficient for large datasets.",timeComplexity:"O(n²)",spaceComplexity:"O(1)",stable:!0},selection:{name:"Selection Sort",description:"Finds the minimum element and places it at the beginning. Performs well on small arrays.",timeComplexity:"O(n²)",spaceComplexity:"O(1)",stable:!1},insertion:{name:"Insertion Sort",description:"Builds the sorted array one element at a time by inserting each into its correct position.",timeComplexity:"O(n²)",spaceComplexity:"O(1)",stable:!0},quick:{name:"Quick Sort",description:"Divides the array using a pivot and recursively sorts the partitions. Very efficient in practice.",timeComplexity:"O(n log n)",spaceComplexity:"O(log n)",stable:!1},heap:{name:"Heap Sort",description:"Builds a max-heap then repeatedly extracts the maximum to build the sorted array.",timeComplexity:"O(n log n)",spaceComplexity:"O(1)",stable:!1},merge:{name:"Merge Sort",description:"Divides the array in half, recursively sorts, then merges. Guarantees consistent performance.",timeComplexity:"O(n log n)",spaceComplexity:"O(n)",stable:!0}},te=["bubble","selection","insertion","quick","heap","merge"],se=["slow","medium","fast","instant"];function ae({algorithm:s,setAlgorithm:d,speed:o,setSpeed:y,arraySize:g,changeArraySize:x,isRunning:a,isFinished:r,currentStep:h,totalSteps:t,soundEnabled:u,onToggleSound:i,onVisualize:f,onStop:c,onGenerateNewArray:S}){const p=R[s];return e.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Algorithm"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:te.map(l=>e.jsx("button",{onClick:()=>!a&&d(l),disabled:a,className:` rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200 ${s===l?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 shadow-lg shadow-indigo-500/10":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} disabled:opacity-50 disabled:cursor-not-allowed `,children:R[l].name},l))}),e.jsxs("div",{className:"mt-3 rounded-lg bg-slate-800/40 p-3",children:[e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:p.description}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsxs("span",{className:"inline-flex items-center rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-400 ring-1 ring-violet-500/20",children:["Time: ",p.timeComplexity]}),e.jsxs("span",{className:"inline-flex items-center rounded-full bg-cyan-500/10 px-2 py-0.5 text-[10px] font-medium text-cyan-400 ring-1 ring-cyan-500/20",children:["Space: ",p.spaceComplexity]}),p.stable&&e.jsx("span",{className:"inline-flex items-center rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-400 ring-1 ring-emerald-500/20",children:"Stable"})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Speed"}),e.jsxs("button",{onClick:()=>i(!u),className:` flex items-center gap-1.5 rounded-lg px-2 py-1 text-xs font-medium transition-all duration-200 ${u?"bg-emerald-500/15 text-emerald-400 ring-1 ring-emerald-500/30":"bg-slate-800/50 text-slate-500 hover:text-slate-400"} - `,title:u?"Mute sound":"Unmute sound",children:[u?e.jsx(H,{size:12}):e.jsx(L,{size:12}),u?"Sound On":"Sound Off"]})]}),e.jsx("div",{className:"flex gap-1",children:se.map(l=>e.jsx("button",{onClick:()=>y(l),className:` + `,title:u?"Mute sound":"Unmute sound",children:[u?e.jsx(_,{size:12}):e.jsx(H,{size:12}),u?"Sound On":"Sound Off"]})]}),e.jsx("div",{className:"flex gap-1",children:se.map(l=>e.jsx("button",{onClick:()=>y(l),className:` flex-1 rounded-lg px-2 py-1.5 text-xs font-medium capitalize transition-all duration-200 ${o===l?"bg-violet-500/20 text-violet-300 ring-1 ring-violet-500/40":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} - `,children:l},l))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Array Size"}),e.jsx("span",{className:"text-xs font-mono text-slate-400",children:g})]}),e.jsx("input",{type:"range",min:"10",max:"150",value:g,onChange:l=>!a&&x(Number(l.target.value)),disabled:a,className:"w-full accent-indigo-500 disabled:opacity-50"}),e.jsxs("div",{className:"flex justify-between mt-1",children:[e.jsx("span",{className:"text-[10px] text-slate-600",children:"10"}),e.jsx("span",{className:"text-[10px] text-slate-600",children:"150"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[a?e.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500 to-pink-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-rose-500/25 transition-all duration-200 hover:brightness-110 active:scale-[0.98]",children:[e.jsx(Q,{size:16}),"Stop"]}):e.jsxs("button",{onClick:f,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-500/25 transition-all duration-200 hover:shadow-xl hover:shadow-indigo-500/30 hover:brightness-110 active:scale-[0.98]",children:[e.jsx(_,{size:16}),"Visualize ",p.name]}),e.jsxs("button",{onClick:S,disabled:a,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(W,{size:12}),"Generate New Array"]})]}),(a||r)&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Statistics"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Operations"}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-indigo-400",children:[h," / ",t]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Array Size"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-amber-400",children:g})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Status"}),e.jsx("span",{className:`text-xs font-semibold ${r?"text-emerald-400":"text-violet-400"}`,children:r?"Sorted":"Sorting..."})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Legend"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-indigo-400/80"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Unsorted"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-amber-400"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Comparing"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-rose-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Swapping"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-emerald-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Sorted"})]})]})]})]})}const ne={slow:.15,medium:.08,fast:.04,instant:0},le={slow:.07,medium:.05,fast:.035,instant:0};function re(){const s=n.useRef(!0),d=n.useCallback(()=>J(),[]),o=n.useCallback((x,a,r,h)=>{if(!s.current||r==="instant")return;const t=d();if(!t)return;const u=ne[r],i=le[r],f=x/a,c=200,p=c+f*(800-c),l=t.createOscillator(),b=t.createGain();h==="compare"?l.type="sine":h==="swap"?l.type="triangle":l.type="sine",l.frequency.setValueAtTime(p,t.currentTime);const v=h==="sorted"?i*1.5:i;b.gain.setValueAtTime(v,t.currentTime),b.gain.exponentialRampToValueAtTime(.001,t.currentTime+u),l.connect(b),b.connect(t.destination),l.start(t.currentTime),l.stop(t.currentTime+u)},[d]),y=n.useCallback(x=>{if(!s.current)return;const a=d();if(!a)return;const r=200,h=800;for(let t=0;t{s.current=x},[]);return{playTone:o,playCompleteSweep:y,setEnabled:g}}function V(s){return Array.from({length:s},()=>Math.floor(Math.random()*95)+5)}function ie(){const[s,d]=n.useState("bubble"),[o,y]=n.useState("fast"),[g,x]=n.useState(50),[a,r]=n.useState(()=>V(50)),[h,t]=n.useState(null),[u,i]=n.useState(null),[f,c]=n.useState([]),[S,p]=n.useState(!1),[l,b]=n.useState(!1),[v,w]=n.useState(0),[E,C]=n.useState(0),[F,G]=n.useState(!0),k=n.useRef([]),{playTone:A,playCompleteSweep:T,setEnabled:q}=re(),$=n.useCallback(m=>{G(m),q(m)},[q]),B=n.useCallback(()=>{r(V(g)),t(null),i(null),c([]),b(!1),w(0),C(0)},[g]),P=n.useCallback(m=>{x(m),r(V(m)),t(null),i(null),c([]),b(!1),w(0),C(0)},[]),O=n.useCallback(()=>{k.current.forEach(m=>clearTimeout(m)),k.current=[],p(!1),t(null),i(null)},[]),D=n.useCallback(()=>{O(),b(!1),t(null),i(null),c([]),w(0);const m=X(s,a);if(C(m.length),m.length===0){b(!0);return}const M=ee[o],I=Math.max(...a);if(p(!0),M===0){const N=m[m.length-1];r(N.array),c(N.sorted),t(null),i(null),w(m.length),p(!1),b(!0),T(N.array.length);return}for(let N=0;N{const j=m[N];if(r(j.array),t(j.comparing),i(j.swapping),c(j.sorted),w(N+1),j.comparing){const z=j.comparing[0];A(j.array[z],I,o,"compare")}if(j.swapping){const z=j.swapping[0];A(j.array[z],I,o,"swap")}N===m.length-1&&(p(!1),b(!0),t(null),i(null),T(j.array.length))},M*N);k.current.push(U)}},[s,a,o,O,A,T]);return{algorithm:s,setAlgorithm:d,speed:o,setSpeed:y,arraySize:g,changeArraySize:P,array:a,comparing:h,swapping:u,sortedIndices:f,isRunning:S,isFinished:l,currentStep:v,totalSteps:E,soundEnabled:F,toggleSound:$,generateNewArray:B,visualize:D,stopVisualization:O}}function pe(){const{algorithm:s,setAlgorithm:d,speed:o,setSpeed:y,arraySize:g,changeArraySize:x,array:a,comparing:r,swapping:h,sortedIndices:t,isRunning:u,isFinished:i,currentStep:f,totalSteps:c,soundEnabled:S,toggleSound:p,generateNewArray:l,visualize:b,stopVisualization:v}=ie();return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsx("div",{className:"order-last md:order-first flex md:flex-1 flex-col items-center justify-center gap-3 min-h-[40vh] md:min-h-0 max-h-[50vh] md:max-h-none overflow-auto",children:e.jsx(Z,{array:a,comparing:r,swapping:h,sortedIndices:t})}),e.jsx(ae,{algorithm:s,setAlgorithm:d,speed:o,setSpeed:y,arraySize:g,changeArraySize:x,isRunning:u,isFinished:i,currentStep:f,totalSteps:c,soundEnabled:S,onToggleSound:p,onVisualize:b,onStop:v,onGenerateNewArray:l})]})}export{pe as default}; + `,children:l},l))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Array Size"}),e.jsx("span",{className:"text-xs font-mono text-slate-400",children:g})]}),e.jsx("input",{type:"range",min:"10",max:"150",value:g,onChange:l=>!a&&x(Number(l.target.value)),disabled:a,className:"w-full accent-indigo-500 disabled:opacity-50"}),e.jsxs("div",{className:"flex justify-between mt-1",children:[e.jsx("span",{className:"text-[10px] text-slate-600",children:"10"}),e.jsx("span",{className:"text-[10px] text-slate-600",children:"150"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[a?e.jsxs("button",{onClick:c,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-rose-500 to-pink-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-rose-500/25 transition-all duration-200 hover:brightness-110 active:scale-[0.98]",children:[e.jsx(Q,{size:16}),"Stop"]}):e.jsxs("button",{onClick:f,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-500/25 transition-all duration-200 hover:shadow-xl hover:shadow-indigo-500/30 hover:brightness-110 active:scale-[0.98]",children:[e.jsx(L,{size:16}),"Visualize ",p.name]}),e.jsxs("button",{onClick:S,disabled:a,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(W,{size:12}),"Generate New Array"]})]}),(a||r)&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Statistics"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Operations"}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-indigo-400",children:[h," / ",t]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Array Size"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-amber-400",children:g})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Status"}),e.jsx("span",{className:`text-xs font-semibold ${r?"text-emerald-400":"text-violet-400"}`,children:r?"Sorted":"Sorting..."})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Legend"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-indigo-400/80"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Unsorted"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-amber-400"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Comparing"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-rose-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Swapping"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-emerald-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Sorted"})]})]})]})]})}const ne={slow:.15,medium:.08,fast:.04,instant:0},le={slow:.07,medium:.05,fast:.035,instant:0};function re(){const s=n.useRef(!0),d=n.useCallback(()=>J(),[]),o=n.useCallback((x,a,r,h)=>{if(!s.current||r==="instant")return;const t=d();if(!t)return;const u=ne[r],i=le[r],f=x/a,c=200,p=c+f*(800-c),l=t.createOscillator(),b=t.createGain();h==="compare"?l.type="sine":h==="swap"?l.type="triangle":l.type="sine",l.frequency.setValueAtTime(p,t.currentTime);const v=h==="sorted"?i*1.5:i;b.gain.setValueAtTime(v,t.currentTime),b.gain.exponentialRampToValueAtTime(.001,t.currentTime+u),l.connect(b),b.connect(t.destination),l.start(t.currentTime),l.stop(t.currentTime+u)},[d]),y=n.useCallback(x=>{if(!s.current)return;const a=d();if(!a)return;const r=200,h=800;for(let t=0;t{s.current=x},[]);return{playTone:o,playCompleteSweep:y,setEnabled:g}}function V(s){return Array.from({length:s},()=>Math.floor(Math.random()*95)+5)}function ie(){const[s,d]=n.useState("bubble"),[o,y]=n.useState("fast"),[g,x]=n.useState(50),[a,r]=n.useState(()=>V(50)),[h,t]=n.useState(null),[u,i]=n.useState(null),[f,c]=n.useState([]),[S,p]=n.useState(!1),[l,b]=n.useState(!1),[v,w]=n.useState(0),[E,C]=n.useState(0),[F,G]=n.useState(!0),k=n.useRef([]),{playTone:A,playCompleteSweep:T,setEnabled:q}=re(),$=n.useCallback(m=>{G(m),q(m)},[q]),B=n.useCallback(()=>{r(V(g)),t(null),i(null),c([]),b(!1),w(0),C(0)},[g]),P=n.useCallback(m=>{x(m),r(V(m)),t(null),i(null),c([]),b(!1),w(0),C(0)},[]),O=n.useCallback(()=>{k.current.forEach(m=>clearTimeout(m)),k.current=[],p(!1),t(null),i(null)},[]),D=n.useCallback(()=>{O(),b(!1),t(null),i(null),c([]),w(0);const m=X(s,a);if(C(m.length),m.length===0){b(!0);return}const M=ee[o],I=Math.max(...a);if(p(!0),M===0){const N=m[m.length-1];r(N.array),c(N.sorted),t(null),i(null),w(m.length),p(!1),b(!0),T(N.array.length);return}for(let N=0;N{const j=m[N];if(r(j.array),t(j.comparing),i(j.swapping),c(j.sorted),w(N+1),j.comparing){const z=j.comparing[0];A(j.array[z],I,o,"compare")}if(j.swapping){const z=j.swapping[0];A(j.array[z],I,o,"swap")}N===m.length-1&&(p(!1),b(!0),t(null),i(null),T(j.array.length))},M*N);k.current.push(U)}},[s,a,o,O,A,T]);return{algorithm:s,setAlgorithm:d,speed:o,setSpeed:y,arraySize:g,changeArraySize:P,array:a,comparing:h,swapping:u,sortedIndices:f,isRunning:S,isFinished:l,currentStep:v,totalSteps:E,soundEnabled:F,toggleSound:$,generateNewArray:B,visualize:D,stopVisualization:O}}function ge(){const{algorithm:s,setAlgorithm:d,speed:o,setSpeed:y,arraySize:g,changeArraySize:x,array:a,comparing:r,swapping:h,sortedIndices:t,isRunning:u,isFinished:i,currentStep:f,totalSteps:c,soundEnabled:S,toggleSound:p,generateNewArray:l,visualize:b,stopVisualization:v}=ie();return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsx("div",{className:"order-last md:order-first flex md:flex-1 flex-col items-center justify-center gap-3 min-h-[40vh] md:min-h-0 max-h-[50vh] md:max-h-none overflow-auto",children:e.jsx(Z,{array:a,comparing:r,swapping:h,sortedIndices:t})}),e.jsx(ae,{algorithm:s,setAlgorithm:d,speed:o,setSpeed:y,arraySize:g,changeArraySize:x,isRunning:u,isFinished:i,currentStep:f,totalSteps:c,soundEnabled:S,onToggleSound:p,onVisualize:b,onStop:v,onGenerateNewArray:l})]})}export{ge as default}; diff --git a/docs/assets/StackPage-pml9_y3A.js b/docs/assets/StackPage-0M1nrFIi.js similarity index 97% rename from docs/assets/StackPage-pml9_y3A.js rename to docs/assets/StackPage-0M1nrFIi.js index bc3277a..b2f3373 100644 --- a/docs/assets/StackPage-pml9_y3A.js +++ b/docs/assets/StackPage-0M1nrFIi.js @@ -1,4 +1,4 @@ -import{r as l,j as e,E as W}from"./index-eCXyAnHs.js";import{u as _}from"./useDSSound-CIDAFkgj.js";import{P as X}from"./plus-CffLiizr.js";import{T as q}from"./trash-2-DQ8BZrIf.js";import{R as B}from"./rotate-ccw-B8GZP3d7.js";import{S as J}from"./shuffle-CdKU4ZYx.js";import{V as Q,a as U}from"./volume-x-CTbtCvt-.js";import{C as Y,a as Z}from"./chevron-right-BZqZw4c2.js";import"./audioContext-NbgqvQGz.js";let P=1;const ee=[{id:P++,value:3},{id:P++,value:7},{id:P++,value:1}];function te(){const[i,d]=l.useState(ee),[n,u]=l.useState([]),[r,o]=l.useState(-1),[b,j]=l.useState(""),[k,v]=l.useState([]),[h,T]=l.useState(400),[y,p]=l.useState(!1),x=l.useRef(null),w=l.useRef(h),f=l.useRef(!1),{soundEnabled:$,toggleSound:z,playInsert:m,playDelete:N,playAccess:S,playTraverse:I}=_(),a=l.useRef(()=>{});l.useEffect(()=>{w.current=h},[h]),l.useEffect(()=>{if(!f.current||n.length===0)return;f.current=!1,x.current&&clearTimeout(x.current),p(!0);let t=0;const s=()=>{if(t>=n.length-1){p(!1);return}t++,o(t),a.current(t,n),x.current=setTimeout(s,w.current)};x.current=setTimeout(s,w.current)},[n]);const g=l.useCallback((t,s)=>{const c=s[t];c&&(c.highlightColor==="green"?m():c.highlightColor==="red"?N():c.highlightColor==="yellow"&&I(t,s.length))},[m,N,I]);l.useEffect(()=>{a.current=g},[g]);const O=r>=0&&n[r]?n[r].stack:i,L=r>=0?n[r]:null,C=t=>v(s=>[t,...s].slice(0,20)),M=l.useCallback(t=>{const s={id:P++,value:t},c=[];d(E=>{c.push({description:`Pushing ${t} onto the stack...`,stack:E,highlightIndex:null,highlightColor:null});const R=[...E,s];return c.push({description:`${t} placed on top of the stack. Stack size: ${R.length}`,stack:R,highlightIndex:R.length-1,highlightColor:"green"}),u(c),o(0),f.current=!0,m(),C(`Push ${t}`),R})},[m]),H=l.useCallback(()=>{d(t=>{if(t.length===0)return t;const s=t[t.length-1],c=[{description:`Peeking at top element: ${s.value}`,stack:t,highlightIndex:t.length-1,highlightColor:"yellow"},{description:`Popping ${s.value} from the top of the stack.`,stack:t,highlightIndex:t.length-1,highlightColor:"red"},{description:`${s.value} removed. Stack size: ${t.length-1}`,stack:t.slice(0,-1),highlightIndex:null,highlightColor:null}];return u(c),o(0),f.current=!0,N(),C(`Pop → ${s.value}`),t.slice(0,-1)})},[N]),V=l.useCallback(()=>{d(t=>{if(t.length===0)return t;const s=t[t.length-1],c=[{description:"Peek: reading the top element without removing it.",stack:t,highlightIndex:t.length-1,highlightColor:"yellow"},{description:`Top element is ${s.value}.`,stack:t,highlightIndex:t.length-1,highlightColor:"yellow"}];return u(c),o(0),f.current=!0,S(),C(`Peek → ${s.value}`),t})},[S]),A=l.useCallback(()=>{d([]),u([]),o(-1),C("Clear stack")},[]),G=l.useCallback(()=>{const t=Math.floor(Math.random()*5)+3,s=Array.from({length:t},()=>({id:P++,value:Math.floor(Math.random()*90)+1}));d(s),u([]),o(-1),C("Random stack")},[]),D=l.useCallback(()=>{o(t=>{const s=Math.min(t+1,n.length-1);return g(s,n),s})},[n,g]),F=l.useCallback(()=>{o(t=>Math.max(t-1,0))},[]),K=l.useCallback(()=>{if(y){p(!1),x.current&&clearTimeout(x.current);return}p(!0);let t=r;const s=()=>{if(t>=n.length-1){p(!1);return}t++,o(t),g(t,n),x.current=setTimeout(s,h)};x.current=setTimeout(s,h)},[y,r,n,h,g]);return{stack:i,displayStack:O,steps:n,stepIndex:r,currentStep:L,inputValue:b,setInputValue:j,history:k,speed:h,setSpeed:T,isPlaying:y,push:M,pop:H,peek:V,clear:A,generateRandom:G,nextStep:D,prevStep:F,autoPlay:K,soundEnabled:$,toggleSound:z,canGoNext:r0}}const se={green:"border-emerald-400 bg-emerald-500/20 text-emerald-300",red:"border-rose-400 bg-rose-500/20 text-rose-300",yellow:"border-amber-400 bg-amber-500/20 text-amber-300"};function le({stack:i,currentStep:d}){const n=i.slice(-12),u=d?.highlightIndex??null,r=d?.highlightColor??null;return e.jsxs("div",{className:"flex flex-col items-center justify-end w-full h-full min-h-[300px] md:min-h-[400px] gap-1 pb-6",children:[i.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 text-slate-600",children:[e.jsx("div",{className:"w-32 h-24 border-2 border-dashed border-slate-700 rounded-lg flex items-center justify-center",children:e.jsx("span",{className:"text-xs",children:"Empty Stack"})}),e.jsx("div",{className:"w-32 border-b-2 border-slate-600"})]}),e.jsx("div",{className:"flex flex-col-reverse items-center gap-1.5 w-full max-w-[200px]",children:n.map((o,b)=>{const j=i.length-n.length+b,k=j===u,v=j===i.length-1;return e.jsxs("div",{className:"relative flex items-center gap-2 w-full",children:[v&&e.jsx("span",{className:"absolute -right-14 text-xs font-mono text-indigo-400 whitespace-nowrap",children:"← top"}),e.jsx("div",{className:` +import{r as l,j as e,E as W}from"./index-DBkLeWDs.js";import{u as _}from"./useDSSound-KKipmh13.js";import{P as X}from"./plus-DVazsZHX.js";import{T as q}from"./trash-2-C6_cMdiI.js";import{R as B}from"./rotate-ccw-7GTUOPy4.js";import{S as J}from"./shuffle-Dlr-c52A.js";import{V as Q,a as U}from"./volume-x-BSx9gxSg.js";import{C as Y,a as Z}from"./chevron-right-CFBAUJsk.js";import"./audioContext-NbgqvQGz.js";let P=1;const ee=[{id:P++,value:3},{id:P++,value:7},{id:P++,value:1}];function te(){const[i,d]=l.useState(ee),[n,u]=l.useState([]),[r,o]=l.useState(-1),[b,j]=l.useState(""),[k,v]=l.useState([]),[h,T]=l.useState(400),[y,p]=l.useState(!1),x=l.useRef(null),w=l.useRef(h),f=l.useRef(!1),{soundEnabled:$,toggleSound:z,playInsert:m,playDelete:N,playAccess:S,playTraverse:I}=_(),a=l.useRef(()=>{});l.useEffect(()=>{w.current=h},[h]),l.useEffect(()=>{if(!f.current||n.length===0)return;f.current=!1,x.current&&clearTimeout(x.current),p(!0);let t=0;const s=()=>{if(t>=n.length-1){p(!1);return}t++,o(t),a.current(t,n),x.current=setTimeout(s,w.current)};x.current=setTimeout(s,w.current)},[n]);const g=l.useCallback((t,s)=>{const c=s[t];c&&(c.highlightColor==="green"?m():c.highlightColor==="red"?N():c.highlightColor==="yellow"&&I(t,s.length))},[m,N,I]);l.useEffect(()=>{a.current=g},[g]);const O=r>=0&&n[r]?n[r].stack:i,L=r>=0?n[r]:null,C=t=>v(s=>[t,...s].slice(0,20)),M=l.useCallback(t=>{const s={id:P++,value:t},c=[];d(E=>{c.push({description:`Pushing ${t} onto the stack...`,stack:E,highlightIndex:null,highlightColor:null});const R=[...E,s];return c.push({description:`${t} placed on top of the stack. Stack size: ${R.length}`,stack:R,highlightIndex:R.length-1,highlightColor:"green"}),u(c),o(0),f.current=!0,m(),C(`Push ${t}`),R})},[m]),H=l.useCallback(()=>{d(t=>{if(t.length===0)return t;const s=t[t.length-1],c=[{description:`Peeking at top element: ${s.value}`,stack:t,highlightIndex:t.length-1,highlightColor:"yellow"},{description:`Popping ${s.value} from the top of the stack.`,stack:t,highlightIndex:t.length-1,highlightColor:"red"},{description:`${s.value} removed. Stack size: ${t.length-1}`,stack:t.slice(0,-1),highlightIndex:null,highlightColor:null}];return u(c),o(0),f.current=!0,N(),C(`Pop → ${s.value}`),t.slice(0,-1)})},[N]),V=l.useCallback(()=>{d(t=>{if(t.length===0)return t;const s=t[t.length-1],c=[{description:"Peek: reading the top element without removing it.",stack:t,highlightIndex:t.length-1,highlightColor:"yellow"},{description:`Top element is ${s.value}.`,stack:t,highlightIndex:t.length-1,highlightColor:"yellow"}];return u(c),o(0),f.current=!0,S(),C(`Peek → ${s.value}`),t})},[S]),A=l.useCallback(()=>{d([]),u([]),o(-1),C("Clear stack")},[]),G=l.useCallback(()=>{const t=Math.floor(Math.random()*5)+3,s=Array.from({length:t},()=>({id:P++,value:Math.floor(Math.random()*90)+1}));d(s),u([]),o(-1),C("Random stack")},[]),D=l.useCallback(()=>{o(t=>{const s=Math.min(t+1,n.length-1);return g(s,n),s})},[n,g]),F=l.useCallback(()=>{o(t=>Math.max(t-1,0))},[]),K=l.useCallback(()=>{if(y){p(!1),x.current&&clearTimeout(x.current);return}p(!0);let t=r;const s=()=>{if(t>=n.length-1){p(!1);return}t++,o(t),g(t,n),x.current=setTimeout(s,h)};x.current=setTimeout(s,h)},[y,r,n,h,g]);return{stack:i,displayStack:O,steps:n,stepIndex:r,currentStep:L,inputValue:b,setInputValue:j,history:k,speed:h,setSpeed:T,isPlaying:y,push:M,pop:H,peek:V,clear:A,generateRandom:G,nextStep:D,prevStep:F,autoPlay:K,soundEnabled:$,toggleSound:z,canGoNext:r0}}const se={green:"border-emerald-400 bg-emerald-500/20 text-emerald-300",red:"border-rose-400 bg-rose-500/20 text-rose-300",yellow:"border-amber-400 bg-amber-500/20 text-amber-300"};function le({stack:i,currentStep:d}){const n=i.slice(-12),u=d?.highlightIndex??null,r=d?.highlightColor??null;return e.jsxs("div",{className:"flex flex-col items-center justify-end w-full h-full min-h-[300px] md:min-h-[400px] gap-1 pb-6",children:[i.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 text-slate-600",children:[e.jsx("div",{className:"w-32 h-24 border-2 border-dashed border-slate-700 rounded-lg flex items-center justify-center",children:e.jsx("span",{className:"text-xs",children:"Empty Stack"})}),e.jsx("div",{className:"w-32 border-b-2 border-slate-600"})]}),e.jsx("div",{className:"flex flex-col-reverse items-center gap-1.5 w-full max-w-[200px]",children:n.map((o,b)=>{const j=i.length-n.length+b,k=j===u,v=j===i.length-1;return e.jsxs("div",{className:"relative flex items-center gap-2 w-full",children:[v&&e.jsx("span",{className:"absolute -right-14 text-xs font-mono text-indigo-400 whitespace-nowrap",children:"← top"}),e.jsx("div",{className:` flex-1 flex items-center justify-center rounded-lg border-2 h-12 font-bold text-lg transition-all duration-300 ${k&&r?se[r]:"border-slate-600 bg-slate-800/60 text-slate-200"} diff --git a/docs/assets/SudokuPage-C5NKtd3W.js b/docs/assets/SudokuPage-C5NKtd3W.js new file mode 100644 index 0000000..c868236 --- /dev/null +++ b/docs/assets/SudokuPage-C5NKtd3W.js @@ -0,0 +1,13 @@ +import{c as E,r as f,j as e,C as z}from"./index-DBkLeWDs.js";import{C as ee,a as te}from"./chevron-right-CFBAUJsk.js";import{Z as se}from"./zap-CUITaKA-.js";import{S as re}from"./shuffle-Dlr-c52A.js";import{R as le}from"./rotate-ccw-7GTUOPy4.js";const ne=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],oe=E("loader-circle",ne);const ae=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ie=E("lock",ae);const ce=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],de=E("pen-line",ce);const ue=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],xe=E("pencil",ue),I={4:{label:"4×4",boxRows:2,boxCols:2,difficulty:"Easy"},9:{label:"9×9",boxRows:3,boxCols:3,difficulty:"Standard"},16:{label:"16×16",boxRows:4,boxCols:4,difficulty:"Hard"}};function $(s){return I[s]}function fe(s){return s===4?"w-16 h-16 text-2xl":s===9?"w-12 h-12 text-lg":"w-8 h-8 text-[11px]"}function me(s,t){return s===null?"":t<=9?String(s):s.toString(16).toUpperCase()}function pe({grid:s,gridSize:t,isEditing:n,selectedCell:r,onCellClick:l,onCellValueChange:o}){const{boxRows:i,boxCols:a}=$(t),d=fe(t),c=f.useRef(null),h=f.useCallback(b=>{if(!n||!r)return;const{row:p,col:m}=r;if(b.key==="Backspace"||b.key==="Delete"||b.key==="0"){o(p,m,null);return}if(b.key==="ArrowUp"&&p>0){l(p-1,m);return}if(b.key==="ArrowDown"&&p0){l(p,m-1);return}if(b.key==="ArrowRight"&&m=1&&x<=t&&o(p,m,x)}else{const x=parseInt(b.key,16);!isNaN(x)&&x>=1&&x<=t&&o(p,m,x)}},[n,r,t,l,o]);f.useEffect(()=>(window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)),[h]),f.useEffect(()=>{n&&r&&c.current&&c.current.focus()},[n,r]);const g=f.useCallback(b=>{if(!n||!r)return;const p=b.currentTarget.value;if(b.currentTarget.value="",!p)return;const m=p.slice(-1);if(m==="0"){o(r.row,r.col,null);return}if(t<=9){const x=parseInt(m);!isNaN(x)&&x>=1&&x<=t&&o(r.row,r.col,x)}else{const x=parseInt(m,16);!isNaN(x)&&x>=1&&x<=t&&o(r.row,r.col,x)}},[n,r,t,o]),S=f.useCallback((b,p)=>{n&&(l(b,p),setTimeout(()=>c.current?.focus(),0))},[n,l]);return e.jsxs("div",{className:"relative",children:[n&&e.jsx("input",{ref:c,type:"text",inputMode:"numeric",autoComplete:"off",className:"absolute opacity-0 w-0 h-0 pointer-events-none",onInput:g,"aria-label":"Sudoku cell input"}),e.jsx("div",{className:"inline-grid rounded-xl border-2 border-slate-500/60 bg-slate-950/80 backdrop-blur-sm shadow-2xl overflow-hidden",style:{gridTemplateColumns:`repeat(${t}, 1fr)`},children:s.map((b,p)=>b.map((m,x)=>{const N=(x+1)%a===0&&xS(p,x),className:` + ${d} flex items-center justify-center + border border-slate-800/40 + ${N?"border-r-2 border-r-slate-500/60":""} + ${k?"border-b-2 border-b-slate-500/60":""} + ${w} ${C} + transition-all duration-150 select-none + ${n?"cursor-pointer hover:bg-slate-800/60":""} + `,children:me(m.value,t)},`${p}-${x}`)}))})]})}const be=f.memo(pe),he=[4,9,16];function ge({gridSize:s,stepIndex:t,totalSteps:n,isSolved:r,isGenerating:l,isEditing:o,canGoNext:i,canGoPrev:a,evaluationResult:d,onGenerate:c,onNextStep:h,onPrevStep:g,onSolveComplete:S,onEvaluate:b,onReset:p,onStartCustom:m,onEditCurrent:x,onLockCustom:N}){return e.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Grid Size"}),e.jsx("div",{className:"flex gap-2",children:he.map(k=>{const j=I[k];return e.jsxs("button",{onClick:()=>c(k),disabled:l,className:` + flex-1 flex flex-col items-center gap-1 rounded-lg px-3 py-3 transition-all duration-200 + ${s===k?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 shadow-lg shadow-indigo-500/10":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} + disabled:opacity-50 disabled:cursor-not-allowed + `,children:[e.jsx("span",{className:"text-sm font-semibold",children:j.label}),e.jsx("span",{className:"text-[10px] opacity-70",children:j.difficulty})]},k)})})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Custom Puzzle"}),o?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-amber-300/80 leading-relaxed",children:["Click a cell, then type a number (1–",s,"). Use arrow keys to navigate. Press Backspace to clear."]}),e.jsxs("button",{onClick:N,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-emerald-500/15 px-3 py-2.5 text-sm font-medium text-emerald-300 ring-1 ring-emerald-500/30 transition-all hover:bg-emerald-500/25",children:[e.jsx(ie,{size:14}),"Lock Puzzle & Solve"]}),e.jsxs("button",{onClick:b,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-indigo-500/15 px-3 py-2.5 text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/25",children:[e.jsx(z,{size:14}),"Evaluate"]}),d&&e.jsxs("div",{className:`rounded-lg px-3 py-2 text-xs font-medium text-center ${d==="correct"?"bg-emerald-500/15 text-emerald-300 ring-1 ring-emerald-500/30":d==="incomplete"?"bg-amber-500/15 text-amber-300 ring-1 ring-amber-500/30":"bg-rose-500/15 text-rose-300 ring-1 ring-rose-500/30"}`,children:[d==="correct"&&"Solved correctly!",d==="incomplete"&&"Some cells are still empty.",d==="errors"&&"There are conflicts in your solution."]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:m,disabled:l,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-amber-500/15 px-3 py-2.5 text-sm font-medium text-amber-300 ring-1 ring-amber-500/30 transition-all hover:bg-amber-500/25 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(de,{size:14}),"Start From Blank"]}),e.jsxs("button",{onClick:x,disabled:l,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-sky-500/15 px-3 py-2.5 text-sm font-medium text-sky-300 ring-1 ring-sky-500/30 transition-all hover:bg-sky-500/25 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(xe,{size:14}),"Edit Current Puzzle"]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"About"}),e.jsxs("div",{className:"rounded-lg bg-slate-800/40 p-3",children:[e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:"Uses a backtracking algorithm to solve the puzzle. Step through each decision the solver makes — placing a number (green) or backtracking when stuck (red)."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("span",{className:"inline-flex items-center rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-400 ring-1 ring-violet-500/20",children:"Backtracking"}),e.jsx("span",{className:"inline-flex items-center rounded-full bg-cyan-500/10 px-2 py-0.5 text-[10px] font-medium text-cyan-400 ring-1 ring-cyan-500/20",children:"Constraint Propagation"})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Step Controls"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:g,disabled:!a||l,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(ee,{size:16}),"Prev"]}),e.jsxs("button",{onClick:h,disabled:!i||r||l,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:["Next",e.jsx(te,{size:16})]})]}),n>0&&e.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Step"}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-indigo-400",children:[Math.max(0,t+1)," / ",n]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("button",{onClick:S,disabled:r||l,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-500/25 transition-all duration-200 hover:shadow-xl hover:shadow-indigo-500/30 hover:brightness-110 active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed",children:l?e.jsxs(e.Fragment,{children:[e.jsx(oe,{size:16,className:"animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(se,{size:16}),"Solve Complete"]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:()=>c(s),disabled:l,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(re,{size:12}),"New Puzzle"]}),e.jsxs("button",{onClick:p,disabled:l,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(le,{size:12}),"Reset"]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Status"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Grid"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-slate-300",children:I[s].label})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"State"}),e.jsx("span",{className:`text-xs font-semibold ${r?"text-emerald-400":t>=0?"text-violet-400":"text-slate-500"}`,children:r?"Solved!":t>=0?"Stepping...":"Ready"})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Legend"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-slate-900/60 ring-1 ring-slate-700"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Empty Cell"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-white/20"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Original Clue"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-emerald-500/25 ring-1 ring-emerald-400/50"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Placing Number"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-rose-500/20 ring-1 ring-rose-400/40"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Backtracking"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-indigo-400/40"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Solver Filled"})]})]})]})]})}function ve(s,t,n,r,l){for(let c=0;c[...t])}function ke(s,t){const n=M(s),r=[];function l(){const o=je(n,t);if(!o)return r.push({grid:M(n),row:-1,col:-1,value:null,action:"solved"}),!0;const[i,a]=o;for(let d=1;d<=t;d++)if(ve(n,i,a,d,t)){if(n[i][a]=d,r.push({grid:M(n),row:i,col:a,value:d,action:"place"}),l())return!0;n[i][a]=null,r.push({grid:M(n),row:i,col:a,value:null,action:"remove"})}return!1}return l(),r}function G(s,t,n,r,l){for(let c=0;c0;n--){const r=Math.floor(Math.random()*(n+1));[t[n],t[r]]=[t[r],t[n]]}return t}function ye(s){const t=Array.from({length:s},()=>Array(s).fill(null));function n(r){if(r===s*s)return!0;const l=Math.floor(r/s),o=r%s,i=F(Array.from({length:s},(a,d)=>d+1));for(const a of i)if(G(t,l,o,a,s)){if(t[l][o]=a,n(r+1))return!0;t[l][o]=null}return!1}return n(0)?t:null}function Ne(s,t,n){let r=0;function l(){if(r>=n)return;let o=-1,i=-1;e:for(let a=0;a=n))return}return l(),r}const we={4:6,9:30,16:100},Se={4:!0,9:!0,16:!1};function A(s){const t=ye(s);if(!t)throw new Error("Failed to generate sudoku grid");const n=t.map(c=>[...c]),r=s*s,l=we[s],o=r-l,i=Se[s],a=F(Array.from({length:r},(c,h)=>h));let d=0;for(const c of a){if(d>=o)break;const h=Math.floor(c/s),g=c%s,S=n[h][g];if(n[h][g]=null,i){const b=n.map(p=>[...p]);if(Ne(b,s,2)!==1){n[h][g]=S;continue}}d++}return{puzzle:n,solution:t}}function Ce(s,t){for(let l=0;ll.map((i,a)=>({value:i,isOriginal:t[o][a]!==null,isHighlighted:r?r.row===o&&r.col===a:!1,isError:!1,isCurrent:n?n.row===o&&n.col===a:!1})))}function Pe(){const[s,t]=f.useState(9),[n,r]=f.useState(()=>{const{puzzle:u}=A(9);return u}),[l,o]=f.useState(()=>n.map(u=>[...u])),[i,a]=f.useState([]),[d,c]=f.useState(-1),[h,g]=f.useState(!1),[S,b]=f.useState(null),[p,m]=f.useState(!1),[x,N]=f.useState(!1),[k,j]=f.useState(null),w=d>=0&&dw&&w.action!=="solved"?B(w.grid,l,w,k):B(n,l,void 0,k),[n,l,w,k]),T=f.useCallback(u=>{m(!0),t(u),a([]),c(-1),g(!1),N(!1),j(null),setTimeout(()=>{const{puzzle:v}=A(u);r(v),o(v.map(y=>[...y])),m(!1)},10)},[]),U=f.useCallback(()=>{const u=Array.from({length:s},()=>Array(s).fill(null));r(u),o(u.map(v=>[...v])),a([]),c(-1),g(!1),N(!0),j(null)},[s]),O=f.useCallback(()=>{a([]),c(-1),g(!1),N(!0),j(null)},[]),D=f.useCallback(()=>{o(n.map(u=>[...u])),N(!1),j(null),a([]),c(-1),g(!1)},[n]),V=f.useCallback((u,v,y)=>{x&&(b(null),r(P=>{const _=P.map(Y=>[...Y]);return _[u][v]=y,_}))},[x]),H=f.useCallback((u,v)=>{j(y=>y&&y.row===u&&y.col===v?null:{row:u,col:v})},[]),R=f.useCallback(()=>{if(i.length>0)return i;const u=ke(l,s);return a(u),u},[i,l,s]),Z=f.useCallback(()=>{const u=R();u.length!==0&&c(v=>{const y=v+1;if(y>=u.length)return v;const P=u[y];return P.action==="solved"?(r(P.grid),g(!0)):r(P.grid),y})},[R]),K=f.useCallback(()=>{d<=0||c(u=>{const v=u-1;if(v<0)return r(l.map(P=>[...P])),-1;const y=i[v];return r(y.grid),g(!1),v})},[d,i,l]),q=f.useCallback(()=>{const u=R();if(u.length===0)return;const v=u[u.length-1];r(v.grid),c(u.length-1),g(v.action==="solved")},[R]),Q=f.useCallback(()=>{const u=Ce(n,s);b(u),u==="correct"&&(g(!0),N(!1),j(null))},[n,s]),W=f.useCallback(()=>{r(l.map(u=>[...u])),a([]),c(-1),g(!1),N(!1),j(null),b(null)},[l]),L=i.length,J=d0;return{gridSize:s,grid:C,stepIndex:d,totalSteps:L,isSolved:h,isGenerating:p,isEditing:x,selectedCell:k,canGoNext:J,canGoPrev:X,generate:T,nextStep:Z,prevStep:K,evaluationResult:S,solveComplete:q,evaluate:Q,reset:W,startCustomPuzzle:U,editCurrentPuzzle:O,lockCustomPuzzle:D,setCellValue:V,selectCell:H}}function Le(){const{gridSize:s,grid:t,stepIndex:n,totalSteps:r,isSolved:l,isGenerating:o,isEditing:i,selectedCell:a,canGoNext:d,canGoPrev:c,generate:h,nextStep:g,prevStep:S,solveComplete:b,reset:p,startCustomPuzzle:m,editCurrentPuzzle:x,lockCustomPuzzle:N,setCellValue:k,selectCell:j,evaluationResult:w,evaluate:C}=Pe();return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col items-center justify-center gap-3 min-h-[40vh] md:min-h-0 max-h-[50vh] md:max-h-none overflow-auto",children:[e.jsx(be,{grid:t,gridSize:s,isEditing:i,selectedCell:a,onCellClick:j,onCellValueChange:k}),i&&e.jsx("p",{className:"text-xs text-amber-300/60 animate-pulse",children:"Editing mode — click cells and type numbers"})]}),e.jsx(ge,{gridSize:s,stepIndex:n,totalSteps:r,isSolved:l,isGenerating:o,isEditing:i,canGoNext:d,canGoPrev:c,evaluationResult:w,onGenerate:h,onNextStep:g,onPrevStep:S,onSolveComplete:b,onEvaluate:C,onReset:p,onStartCustom:m,onEditCurrent:x,onLockCustom:N})]})}export{Le as default}; diff --git a/docs/assets/SudokuPage-SBA-_ued.js b/docs/assets/SudokuPage-SBA-_ued.js deleted file mode 100644 index 925e45a..0000000 --- a/docs/assets/SudokuPage-SBA-_ued.js +++ /dev/null @@ -1,13 +0,0 @@ -import{c as R,r as m,j as e}from"./index-eCXyAnHs.js";import{C as Y,a as ee}from"./chevron-right-BZqZw4c2.js";import{Z as te}from"./zap-DNziIfcU.js";import{S as se}from"./shuffle-CdKU4ZYx.js";import{R as re}from"./rotate-ccw-B8GZP3d7.js";const le=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ne=R("circle-check",le);const oe=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ae=R("loader-circle",oe);const ie=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ce=R("lock",ie);const de=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],ue=R("pen-line",de);const xe=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],me=R("pencil",xe),I={4:{label:"4×4",boxRows:2,boxCols:2,difficulty:"Easy"},9:{label:"9×9",boxRows:3,boxCols:3,difficulty:"Standard"},16:{label:"16×16",boxRows:4,boxCols:4,difficulty:"Hard"}};function E(s){return I[s]}function fe(s){return s===4?"w-16 h-16 text-2xl":s===9?"w-12 h-12 text-lg":"w-8 h-8 text-[11px]"}function pe(s,t){return s===null?"":t<=9?String(s):s.toString(16).toUpperCase()}function be({grid:s,gridSize:t,isEditing:n,selectedCell:r,onCellClick:l,onCellValueChange:o}){const{boxRows:i,boxCols:a}=E(t),d=fe(t),c=m.useRef(null),h=m.useCallback(b=>{if(!n||!r)return;const{row:p,col:f}=r;if(b.key==="Backspace"||b.key==="Delete"||b.key==="0"){o(p,f,null);return}if(b.key==="ArrowUp"&&p>0){l(p-1,f);return}if(b.key==="ArrowDown"&&p0){l(p,f-1);return}if(b.key==="ArrowRight"&&f=1&&x<=t&&o(p,f,x)}else{const x=parseInt(b.key,16);!isNaN(x)&&x>=1&&x<=t&&o(p,f,x)}},[n,r,t,l,o]);m.useEffect(()=>(window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)),[h]),m.useEffect(()=>{n&&r&&c.current&&c.current.focus()},[n,r]);const g=m.useCallback(b=>{if(!n||!r)return;const p=b.currentTarget.value;if(b.currentTarget.value="",!p)return;const f=p.slice(-1);if(f==="0"){o(r.row,r.col,null);return}if(t<=9){const x=parseInt(f);!isNaN(x)&&x>=1&&x<=t&&o(r.row,r.col,x)}else{const x=parseInt(f,16);!isNaN(x)&&x>=1&&x<=t&&o(r.row,r.col,x)}},[n,r,t,o]),S=m.useCallback((b,p)=>{n&&(l(b,p),setTimeout(()=>c.current?.focus(),0))},[n,l]);return e.jsxs("div",{className:"relative",children:[n&&e.jsx("input",{ref:c,type:"text",inputMode:"numeric",autoComplete:"off",className:"absolute opacity-0 w-0 h-0 pointer-events-none",onInput:g,"aria-label":"Sudoku cell input"}),e.jsx("div",{className:"inline-grid rounded-xl border-2 border-slate-500/60 bg-slate-950/80 backdrop-blur-sm shadow-2xl overflow-hidden",style:{gridTemplateColumns:`repeat(${t}, 1fr)`},children:s.map((b,p)=>b.map((f,x)=>{const N=(x+1)%a===0&&xS(p,x),className:` - ${d} flex items-center justify-center - border border-slate-800/40 - ${N?"border-r-2 border-r-slate-500/60":""} - ${k?"border-b-2 border-b-slate-500/60":""} - ${w} ${C} - transition-all duration-150 select-none - ${n?"cursor-pointer hover:bg-slate-800/60":""} - `,children:pe(f.value,t)},`${p}-${x}`)}))})]})}const he=m.memo(be),ge=[4,9,16];function ve({gridSize:s,stepIndex:t,totalSteps:n,isSolved:r,isGenerating:l,isEditing:o,canGoNext:i,canGoPrev:a,evaluationResult:d,onGenerate:c,onNextStep:h,onPrevStep:g,onSolveComplete:S,onEvaluate:b,onReset:p,onStartCustom:f,onEditCurrent:x,onLockCustom:N}){return e.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Grid Size"}),e.jsx("div",{className:"flex gap-2",children:ge.map(k=>{const j=I[k];return e.jsxs("button",{onClick:()=>c(k),disabled:l,className:` - flex-1 flex flex-col items-center gap-1 rounded-lg px-3 py-3 transition-all duration-200 - ${s===k?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 shadow-lg shadow-indigo-500/10":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} - disabled:opacity-50 disabled:cursor-not-allowed - `,children:[e.jsx("span",{className:"text-sm font-semibold",children:j.label}),e.jsx("span",{className:"text-[10px] opacity-70",children:j.difficulty})]},k)})})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Custom Puzzle"}),o?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-amber-300/80 leading-relaxed",children:["Click a cell, then type a number (1–",s,"). Use arrow keys to navigate. Press Backspace to clear."]}),e.jsxs("button",{onClick:N,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-emerald-500/15 px-3 py-2.5 text-sm font-medium text-emerald-300 ring-1 ring-emerald-500/30 transition-all hover:bg-emerald-500/25",children:[e.jsx(ce,{size:14}),"Lock Puzzle & Solve"]}),e.jsxs("button",{onClick:b,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-indigo-500/15 px-3 py-2.5 text-sm font-medium text-indigo-300 ring-1 ring-indigo-500/30 transition-all hover:bg-indigo-500/25",children:[e.jsx(ne,{size:14}),"Evaluate"]}),d&&e.jsxs("div",{className:`rounded-lg px-3 py-2 text-xs font-medium text-center ${d==="correct"?"bg-emerald-500/15 text-emerald-300 ring-1 ring-emerald-500/30":d==="incomplete"?"bg-amber-500/15 text-amber-300 ring-1 ring-amber-500/30":"bg-rose-500/15 text-rose-300 ring-1 ring-rose-500/30"}`,children:[d==="correct"&&"Solved correctly!",d==="incomplete"&&"Some cells are still empty.",d==="errors"&&"There are conflicts in your solution."]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:f,disabled:l,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-amber-500/15 px-3 py-2.5 text-sm font-medium text-amber-300 ring-1 ring-amber-500/30 transition-all hover:bg-amber-500/25 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(ue,{size:14}),"Start From Blank"]}),e.jsxs("button",{onClick:x,disabled:l,className:"w-full flex items-center justify-center gap-2 rounded-lg bg-sky-500/15 px-3 py-2.5 text-sm font-medium text-sky-300 ring-1 ring-sky-500/30 transition-all hover:bg-sky-500/25 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(me,{size:14}),"Edit Current Puzzle"]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"About"}),e.jsxs("div",{className:"rounded-lg bg-slate-800/40 p-3",children:[e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:"Uses a backtracking algorithm to solve the puzzle. Step through each decision the solver makes — placing a number (green) or backtracking when stuck (red)."}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("span",{className:"inline-flex items-center rounded-full bg-violet-500/10 px-2 py-0.5 text-[10px] font-medium text-violet-400 ring-1 ring-violet-500/20",children:"Backtracking"}),e.jsx("span",{className:"inline-flex items-center rounded-full bg-cyan-500/10 px-2 py-0.5 text-[10px] font-medium text-cyan-400 ring-1 ring-cyan-500/20",children:"Constraint Propagation"})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Step Controls"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:g,disabled:!a||l,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(Y,{size:16}),"Prev"]}),e.jsxs("button",{onClick:h,disabled:!i||r||l,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2.5 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:["Next",e.jsx(ee,{size:16})]})]}),n>0&&e.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Step"}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-indigo-400",children:[Math.max(0,t+1)," / ",n]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("button",{onClick:S,disabled:r||l,className:"flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-indigo-500 to-violet-500 px-4 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-500/25 transition-all duration-200 hover:shadow-xl hover:shadow-indigo-500/30 hover:brightness-110 active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed",children:l?e.jsxs(e.Fragment,{children:[e.jsx(ae,{size:16,className:"animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(te,{size:16}),"Solve Complete"]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:()=>c(s),disabled:l,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(se,{size:12}),"New Puzzle"]}),e.jsxs("button",{onClick:p,disabled:l,className:"flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(re,{size:12}),"Reset"]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Status"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Grid"}),e.jsx("span",{className:"text-sm font-mono font-semibold text-slate-300",children:I[s].label})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"State"}),e.jsx("span",{className:`text-xs font-semibold ${r?"text-emerald-400":t>=0?"text-violet-400":"text-slate-500"}`,children:r?"Solved!":t>=0?"Stepping...":"Ready"})]})]})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Legend"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-slate-900/60 ring-1 ring-slate-700"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Empty Cell"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-white/20"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Original Clue"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-emerald-500/25 ring-1 ring-emerald-400/50"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Placing Number"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-rose-500/20 ring-1 ring-rose-400/40"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Backtracking"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-5 rounded-sm bg-indigo-400/40"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Solver Filled"})]})]})]})]})}function je(s,t,n,r,l){for(let c=0;c[...t])}function ye(s,t){const n=$(s),r=[];function l(){const o=ke(n,t);if(!o)return r.push({grid:$(n),row:-1,col:-1,value:null,action:"solved"}),!0;const[i,a]=o;for(let d=1;d<=t;d++)if(je(n,i,a,d,t)){if(n[i][a]=d,r.push({grid:$(n),row:i,col:a,value:d,action:"place"}),l())return!0;n[i][a]=null,r.push({grid:$(n),row:i,col:a,value:null,action:"remove"})}return!1}return l(),r}function G(s,t,n,r,l){for(let c=0;c0;n--){const r=Math.floor(Math.random()*(n+1));[t[n],t[r]]=[t[r],t[n]]}return t}function Ne(s){const t=Array.from({length:s},()=>Array(s).fill(null));function n(r){if(r===s*s)return!0;const l=Math.floor(r/s),o=r%s,i=F(Array.from({length:s},(a,d)=>d+1));for(const a of i)if(G(t,l,o,a,s)){if(t[l][o]=a,n(r+1))return!0;t[l][o]=null}return!1}return n(0)?t:null}function we(s,t,n){let r=0;function l(){if(r>=n)return;let o=-1,i=-1;e:for(let a=0;a=n))return}return l(),r}const Se={4:6,9:30,16:100},Ce={4:!0,9:!0,16:!1};function A(s){const t=Ne(s);if(!t)throw new Error("Failed to generate sudoku grid");const n=t.map(c=>[...c]),r=s*s,l=Se[s],o=r-l,i=Ce[s],a=F(Array.from({length:r},(c,h)=>h));let d=0;for(const c of a){if(d>=o)break;const h=Math.floor(c/s),g=c%s,S=n[h][g];if(n[h][g]=null,i){const b=n.map(p=>[...p]);if(we(b,s,2)!==1){n[h][g]=S;continue}}d++}return{puzzle:n,solution:t}}function Pe(s,t){for(let l=0;ll.map((i,a)=>({value:i,isOriginal:t[o][a]!==null,isHighlighted:r?r.row===o&&r.col===a:!1,isError:!1,isCurrent:n?n.row===o&&n.col===a:!1})))}function Re(){const[s,t]=m.useState(9),[n,r]=m.useState(()=>{const{puzzle:u}=A(9);return u}),[l,o]=m.useState(()=>n.map(u=>[...u])),[i,a]=m.useState([]),[d,c]=m.useState(-1),[h,g]=m.useState(!1),[S,b]=m.useState(null),[p,f]=m.useState(!1),[x,N]=m.useState(!1),[k,j]=m.useState(null),w=d>=0&&dw&&w.action!=="solved"?B(w.grid,l,w,k):B(n,l,void 0,k),[n,l,w,k]),T=m.useCallback(u=>{f(!0),t(u),a([]),c(-1),g(!1),N(!1),j(null),setTimeout(()=>{const{puzzle:v}=A(u);r(v),o(v.map(y=>[...y])),f(!1)},10)},[]),U=m.useCallback(()=>{const u=Array.from({length:s},()=>Array(s).fill(null));r(u),o(u.map(v=>[...v])),a([]),c(-1),g(!1),N(!0),j(null)},[s]),O=m.useCallback(()=>{a([]),c(-1),g(!1),N(!0),j(null)},[]),D=m.useCallback(()=>{o(n.map(u=>[...u])),N(!1),j(null),a([]),c(-1),g(!1)},[n]),V=m.useCallback((u,v,y)=>{x&&(b(null),r(P=>{const L=P.map(X=>[...X]);return L[u][v]=y,L}))},[x]),H=m.useCallback((u,v)=>{j(y=>y&&y.row===u&&y.col===v?null:{row:u,col:v})},[]),M=m.useCallback(()=>{if(i.length>0)return i;const u=ye(l,s);return a(u),u},[i,l,s]),Z=m.useCallback(()=>{const u=M();u.length!==0&&c(v=>{const y=v+1;if(y>=u.length)return v;const P=u[y];return P.action==="solved"?(r(P.grid),g(!0)):r(P.grid),y})},[M]),K=m.useCallback(()=>{d<=0||c(u=>{const v=u-1;if(v<0)return r(l.map(P=>[...P])),-1;const y=i[v];return r(y.grid),g(!1),v})},[d,i,l]),q=m.useCallback(()=>{const u=M();if(u.length===0)return;const v=u[u.length-1];r(v.grid),c(u.length-1),g(v.action==="solved")},[M]),Q=m.useCallback(()=>{const u=Pe(n,s);b(u),u==="correct"&&(g(!0),N(!1),j(null))},[n,s]),W=m.useCallback(()=>{r(l.map(u=>[...u])),a([]),c(-1),g(!1),N(!1),j(null),b(null)},[l]),_=i.length,z=d<_-1||i.length===0&&!h,J=d>0;return{gridSize:s,grid:C,stepIndex:d,totalSteps:_,isSolved:h,isGenerating:p,isEditing:x,selectedCell:k,canGoNext:z,canGoPrev:J,generate:T,nextStep:Z,prevStep:K,evaluationResult:S,solveComplete:q,evaluate:Q,reset:W,startCustomPuzzle:U,editCurrentPuzzle:O,lockCustomPuzzle:D,setCellValue:V,selectCell:H}}function Le(){const{gridSize:s,grid:t,stepIndex:n,totalSteps:r,isSolved:l,isGenerating:o,isEditing:i,selectedCell:a,canGoNext:d,canGoPrev:c,generate:h,nextStep:g,prevStep:S,solveComplete:b,reset:p,startCustomPuzzle:f,editCurrentPuzzle:x,lockCustomPuzzle:N,setCellValue:k,selectCell:j,evaluationResult:w,evaluate:C}=Re();return e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsxs("div",{className:"order-last md:order-first flex md:flex-1 flex-col items-center justify-center gap-3 min-h-[40vh] md:min-h-0 max-h-[50vh] md:max-h-none overflow-auto",children:[e.jsx(he,{grid:t,gridSize:s,isEditing:i,selectedCell:a,onCellClick:j,onCellValueChange:k}),i&&e.jsx("p",{className:"text-xs text-amber-300/60 animate-pulse",children:"Editing mode — click cells and type numbers"})]}),e.jsx(ve,{gridSize:s,stepIndex:n,totalSteps:r,isSolved:l,isGenerating:o,isEditing:i,canGoNext:d,canGoPrev:c,evaluationResult:w,onGenerate:h,onNextStep:g,onPrevStep:S,onSolveComplete:b,onEvaluate:C,onReset:p,onStartCustom:f,onEditCurrent:x,onLockCustom:N})]})}export{Le as default}; diff --git a/docs/assets/TreeTraversalPage-D_fmsx8X.js b/docs/assets/TreeTraversalPage-B0ns8Kv6.js similarity index 97% rename from docs/assets/TreeTraversalPage-D_fmsx8X.js rename to docs/assets/TreeTraversalPage-B0ns8Kv6.js index ac05fa0..a5a3f3b 100644 --- a/docs/assets/TreeTraversalPage-D_fmsx8X.js +++ b/docs/assets/TreeTraversalPage-B0ns8Kv6.js @@ -1,4 +1,4 @@ -import{r as a,j as e}from"./index-eCXyAnHs.js";import{V as oe,a as ce}from"./volume-x-CTbtCvt-.js";import{C as de,a as ue}from"./chevron-right-BZqZw4c2.js";import{P as xe}from"./play-BqZilH6N.js";import{S as me}from"./square-CEHTCuQK.js";import{S as fe}from"./shuffle-CdKU4ZYx.js";import{R as pe}from"./rotate-ccw-B8GZP3d7.js";import{g as he}from"./audioContext-NbgqvQGz.js";let H=0;function J(t){return{id:H++,value:t,left:null,right:null,x:0,y:0}}function L(t,s){return t?(Math.random()<.5?t.left=L(t.left,s):t.right=L(t.right,s),t):J(s)}function _(t){if(H=0,t<=0)return null;const s=Array.from({length:t},(r,m)=>m+1);for(let r=s.length-1;r>0;r--){const m=Math.floor(Math.random()*(r+1));[s[r],s[m]]=[s[m],s[r]]}let n=null;for(const r of s)n?n=L(n,r):n=J(r);return n&&q(n,0,0,300),n}function q(t,s,n,r){t&&(t.x=n,t.y=s*70,q(t.left,s+1,n-r,r*.55),q(t.right,s+1,n+r,r*.55))}function K(t){const s=[];function n(r){r&&(s.push(r),n(r.left),n(r.right))}return n(t),s}function ge(t){const s=[];function n(r){r&&(r.left&&(s.push({from:r,to:r.left}),n(r.left)),r.right&&(s.push({from:r,to:r.right}),n(r.right)))}return n(t),s}function be({root:t,visitedIds:s,processedIds:n,currentId:r,processOrder:m}){const v=a.useMemo(()=>K(t),[t]),c=a.useMemo(()=>ge(t),[t]),x=Math.min(...v.map(l=>l.x),0)-40,i=Math.max(...v.map(l=>l.x),0)+40,f=Math.max(...v.map(l=>l.y),0)+40,d=i-x+80,u=f+80;return t?e.jsx("div",{className:"flex-1 w-full rounded-xl border border-slate-700/50 bg-slate-950/80 p-4 shadow-2xl backdrop-blur-sm overflow-auto",children:e.jsxs("svg",{viewBox:`${x-40} -20 ${d} ${u}`,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[c.map((l,p)=>e.jsx("line",{x1:l.from.x,y1:l.from.y,x2:l.to.x,y2:l.to.y,stroke:n.has(l.from.id)&&n.has(l.to.id)?"#818cf8":s.has(l.from.id)&&s.has(l.to.id)?"#64748b":"#334155",strokeWidth:2,strokeOpacity:.6},p)),v.map(l=>{const p=l.id===r,S=n.has(l.id),y=s.has(l.id),k=m.indexOf(l.id);let j="#1e293b",N="#475569",w="#94a3b8";return p?(j="#fbbf24",N="#f59e0b",w="#1e293b"):S?(j="#6366f1",N="#818cf8",w="#ffffff"):y&&(j="#334155",N="#64748b",w="#cbd5e1"),e.jsxs("g",{children:[e.jsx("circle",{cx:l.x,cy:l.y,r:22,fill:j,stroke:N,strokeWidth:2.5,className:"transition-all duration-200"}),e.jsx("text",{x:l.x,y:l.y+1,textAnchor:"middle",dominantBaseline:"central",fill:w,fontSize:12,fontWeight:600,fontFamily:"ui-monospace, monospace",children:l.value}),k>=0&&e.jsx("text",{x:l.x+18,y:l.y-18,textAnchor:"middle",dominantBaseline:"central",fill:"#a5b4fc",fontSize:9,fontWeight:700,fontFamily:"ui-monospace, monospace",children:k+1})]},l.id)})]})}):e.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center rounded-xl border border-slate-700/50 bg-slate-950/80 text-slate-500",children:"No tree generated"})}const D={inorder:{name:"In-Order",description:"Visits left subtree, then root, then right subtree. Produces sorted output for BSTs.",order:"Left → Root → Right"},preorder:{name:"Pre-Order",description:"Visits root first, then left subtree, then right subtree. Useful for copying trees.",order:"Root → Left → Right"},postorder:{name:"Post-Order",description:"Visits left subtree, then right subtree, then root. Useful for deleting trees.",order:"Left → Right → Root"},levelorder:{name:"Level-Order",description:"Visits nodes level by level from top to bottom, left to right. Also known as BFS.",order:"Top → Bottom, Left → Right"}},ve=["inorder","preorder","postorder","levelorder"],je=[{label:"Slow",value:600},{label:"Medium",value:300},{label:"Fast",value:100}];function Ne({traversalType:t,setTraversalType:s,nodeCount:n,stepIndex:r,totalSteps:m,processOrder:v,isPlaying:c,isFinished:x,speed:i,setSpeed:f,soundEnabled:d,onToggleSound:u,canGoNext:l,canGoPrev:p,onGenerate:S,onNextStep:y,onPrevStep:k,onPlay:j,onStop:N,onReset:w}){const g=D[t];return e.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Traversal"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ve.map(h=>e.jsx("button",{onClick:()=>s(h),disabled:c,className:` +import{r as a,j as e}from"./index-DBkLeWDs.js";import{V as oe,a as ce}from"./volume-x-BSx9gxSg.js";import{C as de,a as ue}from"./chevron-right-CFBAUJsk.js";import{P as xe}from"./play-mcIZClKO.js";import{S as me}from"./square-Bc_q5e3l.js";import{S as fe}from"./shuffle-Dlr-c52A.js";import{R as pe}from"./rotate-ccw-7GTUOPy4.js";import{g as he}from"./audioContext-NbgqvQGz.js";let H=0;function J(t){return{id:H++,value:t,left:null,right:null,x:0,y:0}}function L(t,s){return t?(Math.random()<.5?t.left=L(t.left,s):t.right=L(t.right,s),t):J(s)}function _(t){if(H=0,t<=0)return null;const s=Array.from({length:t},(r,m)=>m+1);for(let r=s.length-1;r>0;r--){const m=Math.floor(Math.random()*(r+1));[s[r],s[m]]=[s[m],s[r]]}let n=null;for(const r of s)n?n=L(n,r):n=J(r);return n&&q(n,0,0,300),n}function q(t,s,n,r){t&&(t.x=n,t.y=s*70,q(t.left,s+1,n-r,r*.55),q(t.right,s+1,n+r,r*.55))}function K(t){const s=[];function n(r){r&&(s.push(r),n(r.left),n(r.right))}return n(t),s}function ge(t){const s=[];function n(r){r&&(r.left&&(s.push({from:r,to:r.left}),n(r.left)),r.right&&(s.push({from:r,to:r.right}),n(r.right)))}return n(t),s}function be({root:t,visitedIds:s,processedIds:n,currentId:r,processOrder:m}){const v=a.useMemo(()=>K(t),[t]),c=a.useMemo(()=>ge(t),[t]),x=Math.min(...v.map(l=>l.x),0)-40,i=Math.max(...v.map(l=>l.x),0)+40,f=Math.max(...v.map(l=>l.y),0)+40,d=i-x+80,u=f+80;return t?e.jsx("div",{className:"flex-1 w-full rounded-xl border border-slate-700/50 bg-slate-950/80 p-4 shadow-2xl backdrop-blur-sm overflow-auto",children:e.jsxs("svg",{viewBox:`${x-40} -20 ${d} ${u}`,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[c.map((l,p)=>e.jsx("line",{x1:l.from.x,y1:l.from.y,x2:l.to.x,y2:l.to.y,stroke:n.has(l.from.id)&&n.has(l.to.id)?"#818cf8":s.has(l.from.id)&&s.has(l.to.id)?"#64748b":"#334155",strokeWidth:2,strokeOpacity:.6},p)),v.map(l=>{const p=l.id===r,S=n.has(l.id),y=s.has(l.id),k=m.indexOf(l.id);let j="#1e293b",N="#475569",w="#94a3b8";return p?(j="#fbbf24",N="#f59e0b",w="#1e293b"):S?(j="#6366f1",N="#818cf8",w="#ffffff"):y&&(j="#334155",N="#64748b",w="#cbd5e1"),e.jsxs("g",{children:[e.jsx("circle",{cx:l.x,cy:l.y,r:22,fill:j,stroke:N,strokeWidth:2.5,className:"transition-all duration-200"}),e.jsx("text",{x:l.x,y:l.y+1,textAnchor:"middle",dominantBaseline:"central",fill:w,fontSize:12,fontWeight:600,fontFamily:"ui-monospace, monospace",children:l.value}),k>=0&&e.jsx("text",{x:l.x+18,y:l.y-18,textAnchor:"middle",dominantBaseline:"central",fill:"#a5b4fc",fontSize:9,fontWeight:700,fontFamily:"ui-monospace, monospace",children:k+1})]},l.id)})]})}):e.jsx("div",{className:"flex flex-1 w-full h-full items-center justify-center rounded-xl border border-slate-700/50 bg-slate-950/80 text-slate-500",children:"No tree generated"})}const D={inorder:{name:"In-Order",description:"Visits left subtree, then root, then right subtree. Produces sorted output for BSTs.",order:"Left → Root → Right"},preorder:{name:"Pre-Order",description:"Visits root first, then left subtree, then right subtree. Useful for copying trees.",order:"Root → Left → Right"},postorder:{name:"Post-Order",description:"Visits left subtree, then right subtree, then root. Useful for deleting trees.",order:"Left → Right → Root"},levelorder:{name:"Level-Order",description:"Visits nodes level by level from top to bottom, left to right. Also known as BFS.",order:"Top → Bottom, Left → Right"}},ve=["inorder","preorder","postorder","levelorder"],je=[{label:"Slow",value:600},{label:"Medium",value:300},{label:"Fast",value:100}];function Ne({traversalType:t,setTraversalType:s,nodeCount:n,stepIndex:r,totalSteps:m,processOrder:v,isPlaying:c,isFinished:x,speed:i,setSpeed:f,soundEnabled:d,onToggleSound:u,canGoNext:l,canGoPrev:p,onGenerate:S,onNextStep:y,onPrevStep:k,onPlay:j,onStop:N,onReset:w}){const g=D[t];return e.jsxs("div",{className:"flex flex-col gap-5 w-full md:w-72 shrink-0 overflow-y-auto max-h-full pr-1",children:[e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Traversal"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ve.map(h=>e.jsx("button",{onClick:()=>s(h),disabled:c,className:` rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200 ${t===h?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 shadow-lg shadow-indigo-500/10":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} disabled:opacity-50 disabled:cursor-not-allowed diff --git a/docs/assets/TriePage-j3idk4E6.js b/docs/assets/TriePage-CjYcQVOU.js similarity index 97% rename from docs/assets/TriePage-j3idk4E6.js rename to docs/assets/TriePage-CjYcQVOU.js index d03e3bb..22a01d6 100644 --- a/docs/assets/TriePage-j3idk4E6.js +++ b/docs/assets/TriePage-CjYcQVOU.js @@ -1,4 +1,4 @@ -import{c as B,r as d,j as e,e as D,X as K}from"./index-eCXyAnHs.js";import{C as Q,a as H}from"./chevron-right-BZqZw4c2.js";import{P as J}from"./play-BqZilH6N.js";import{S as U}from"./square-CEHTCuQK.js";import{R as Z}from"./rotate-ccw-B8GZP3d7.js";import{P as ee}from"./plus-CffLiizr.js";import{V as te,a as se}from"./volume-x-CTbtCvt-.js";import{g as ne}from"./audioContext-NbgqvQGz.js";const re=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ae=B("refresh-cw",re);function ie({layout:a,matchedNodeIds:r,currentStepNodeId:o}){const{viewBox:u,edges:l}=d.useMemo(()=>{if(a.length===0)return{viewBox:"0 0 100 100",edges:[]};let s=1/0,n=-1/0,t=1/0,i=-1/0;for(const g of a)s=Math.min(s,g.x),n=Math.max(n,g.x),t=Math.min(t,g.y),i=Math.max(i,g.y);const h=40,x=`${s-h} ${t-h} ${n-s+h*2} ${i-t+h*2}`,c=new Map;for(const g of a)c.set(g.id,g);const m=[];for(const g of a)if(g.parentId&&c.has(g.parentId)){const y=c.get(g.parentId),S=r.has(g.id)&&r.has(y.id);m.push({x1:y.x,y1:y.y,x2:g.x,y2:g.y,highlighted:S})}return{viewBox:x,edges:m}},[a,r]);return a.length===0?e.jsx("div",{className:"flex flex-1 w-full min-h-[200px] items-center justify-center rounded-xl border border-slate-700/50 bg-slate-950/80 text-slate-500 text-sm",children:"Add words to build the trie"}):e.jsx("div",{className:"flex-1 w-full min-h-[200px] rounded-xl border border-slate-700/50 bg-slate-950/80 p-2 shadow-2xl backdrop-blur-sm overflow-hidden",children:e.jsxs("svg",{viewBox:u,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[l.map((s,n)=>e.jsx("line",{x1:s.x1,y1:s.y1,x2:s.x2,y2:s.y2,stroke:s.highlighted?"#818cf8":"#334155",strokeWidth:s.highlighted?2.5:1.5,strokeOpacity:s.highlighted?1:.5},n)),a.map(s=>{const n=r.has(s.id),t=o===s.id,i=s.depth===0;let h="#1e293b",x="#475569",c="#94a3b8";t?(h="#312e81",x="#818cf8",c="#e0e7ff"):n&&(h="#1e1b4b",x="#6366f1",c="#c7d2fe"),s.isEndOfWord&&!t&&(x=n?"#34d399":"#059669");const m=i?16:14;return e.jsxs("g",{children:[e.jsx("circle",{cx:s.x,cy:s.y,r:m,fill:h,stroke:x,strokeWidth:t?3:2}),t&&e.jsx("circle",{cx:s.x,cy:s.y,r:m+4,fill:"none",stroke:"#818cf8",strokeWidth:1.5,strokeOpacity:.4,className:"animate-pulse"}),e.jsx("text",{x:s.x,y:s.y,textAnchor:"middle",dominantBaseline:"central",fill:c,fontSize:i?10:12,fontWeight:700,fontFamily:"ui-monospace, monospace",children:i?"root":s.char}),s.isEndOfWord&&e.jsx("circle",{cx:s.x+m-2,cy:s.y-m+2,r:4,fill:"#34d399",stroke:"#064e3b",strokeWidth:1})]},s.id)})]})})}function oe({words:a,searchMode:r,setSearchMode:o,query:u,setQuery:l,steps:s,stepIndex:n,searchResults:t,isPlaying:i,canGoNext:h,canGoPrev:x,onSearch:c,onNextStep:m,onPrevStep:g,onPlay:y,onStop:S,onReset:W,newWord:v,setNewWord:M,onAddWord:T,onRemoveWord:N,onLoadSample:C,soundEnabled:k,onToggleSound:P}){const w=n>=0&&ne.jsx("button",{onClick:()=>o(p),className:` +import{c as B,r as d,j as e,d as D,X as K}from"./index-DBkLeWDs.js";import{C as Q,a as H}from"./chevron-right-CFBAUJsk.js";import{P as J}from"./play-mcIZClKO.js";import{S as U}from"./square-Bc_q5e3l.js";import{R as Z}from"./rotate-ccw-7GTUOPy4.js";import{P as ee}from"./plus-DVazsZHX.js";import{V as te,a as se}from"./volume-x-BSx9gxSg.js";import{g as ne}from"./audioContext-NbgqvQGz.js";const re=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ae=B("refresh-cw",re);function ie({layout:a,matchedNodeIds:r,currentStepNodeId:o}){const{viewBox:u,edges:l}=d.useMemo(()=>{if(a.length===0)return{viewBox:"0 0 100 100",edges:[]};let s=1/0,n=-1/0,t=1/0,i=-1/0;for(const g of a)s=Math.min(s,g.x),n=Math.max(n,g.x),t=Math.min(t,g.y),i=Math.max(i,g.y);const h=40,x=`${s-h} ${t-h} ${n-s+h*2} ${i-t+h*2}`,c=new Map;for(const g of a)c.set(g.id,g);const m=[];for(const g of a)if(g.parentId&&c.has(g.parentId)){const y=c.get(g.parentId),S=r.has(g.id)&&r.has(y.id);m.push({x1:y.x,y1:y.y,x2:g.x,y2:g.y,highlighted:S})}return{viewBox:x,edges:m}},[a,r]);return a.length===0?e.jsx("div",{className:"flex flex-1 w-full min-h-[200px] items-center justify-center rounded-xl border border-slate-700/50 bg-slate-950/80 text-slate-500 text-sm",children:"Add words to build the trie"}):e.jsx("div",{className:"flex-1 w-full min-h-[200px] rounded-xl border border-slate-700/50 bg-slate-950/80 p-2 shadow-2xl backdrop-blur-sm overflow-hidden",children:e.jsxs("svg",{viewBox:u,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[l.map((s,n)=>e.jsx("line",{x1:s.x1,y1:s.y1,x2:s.x2,y2:s.y2,stroke:s.highlighted?"#818cf8":"#334155",strokeWidth:s.highlighted?2.5:1.5,strokeOpacity:s.highlighted?1:.5},n)),a.map(s=>{const n=r.has(s.id),t=o===s.id,i=s.depth===0;let h="#1e293b",x="#475569",c="#94a3b8";t?(h="#312e81",x="#818cf8",c="#e0e7ff"):n&&(h="#1e1b4b",x="#6366f1",c="#c7d2fe"),s.isEndOfWord&&!t&&(x=n?"#34d399":"#059669");const m=i?16:14;return e.jsxs("g",{children:[e.jsx("circle",{cx:s.x,cy:s.y,r:m,fill:h,stroke:x,strokeWidth:t?3:2}),t&&e.jsx("circle",{cx:s.x,cy:s.y,r:m+4,fill:"none",stroke:"#818cf8",strokeWidth:1.5,strokeOpacity:.4,className:"animate-pulse"}),e.jsx("text",{x:s.x,y:s.y,textAnchor:"middle",dominantBaseline:"central",fill:c,fontSize:i?10:12,fontWeight:700,fontFamily:"ui-monospace, monospace",children:i?"root":s.char}),s.isEndOfWord&&e.jsx("circle",{cx:s.x+m-2,cy:s.y-m+2,r:4,fill:"#34d399",stroke:"#064e3b",strokeWidth:1})]},s.id)})]})})}function oe({words:a,searchMode:r,setSearchMode:o,query:u,setQuery:l,steps:s,stepIndex:n,searchResults:t,isPlaying:i,canGoNext:h,canGoPrev:x,onSearch:c,onNextStep:m,onPrevStep:g,onPlay:y,onStop:S,onReset:W,newWord:v,setNewWord:M,onAddWord:T,onRemoveWord:N,onLoadSample:C,soundEnabled:k,onToggleSound:P}){const w=n>=0&&ne.jsx("button",{onClick:()=>o(p),className:` flex-1 rounded-lg px-3 py-2.5 text-sm font-medium transition-all duration-200 ${r===p?"bg-indigo-500/20 text-indigo-300 ring-1 ring-indigo-500/40 shadow-lg shadow-indigo-500/10":"bg-slate-800/50 text-slate-400 hover:bg-slate-700/50 hover:text-slate-300"} `,children:p==="prefix"?"Prefix":"Full Word"},p))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Search"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:u,onChange:p=>l(p.target.value),onKeyDown:p=>p.key==="Enter"&&c(),placeholder:r==="prefix"?"Type a prefix...":"Type a word...",className:"flex-1 rounded-lg bg-slate-800/60 px-3 py-2 text-sm text-white placeholder-slate-500 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50"}),e.jsx("button",{onClick:c,disabled:!u.trim(),className:"flex items-center justify-center rounded-lg bg-indigo-500/20 px-3 py-2 text-indigo-300 ring-1 ring-indigo-500/40 transition-all hover:bg-indigo-500/30 disabled:opacity-40 disabled:cursor-not-allowed",children:e.jsx(D,{size:16})})]})]}),s.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Steps"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("button",{onClick:g,disabled:!x||i,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:[e.jsx(Q,{size:16})," Prev"]}),i?e.jsx("button",{onClick:S,className:"flex items-center justify-center rounded-lg bg-rose-500/15 px-3 py-2 text-rose-300 ring-1 ring-rose-500/30 transition-all hover:bg-rose-500/25",children:e.jsx(U,{size:14})}):e.jsx("button",{onClick:y,disabled:s.length===0,className:"flex items-center justify-center rounded-lg bg-emerald-500/15 px-3 py-2 text-emerald-300 ring-1 ring-emerald-500/30 transition-all hover:bg-emerald-500/25 disabled:opacity-30 disabled:cursor-not-allowed",children:e.jsx(J,{size:16})}),e.jsxs("button",{onClick:m,disabled:!h||i,className:"flex-1 flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-sm font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300 disabled:opacity-30 disabled:cursor-not-allowed",children:["Next ",e.jsx(H,{size:16})]})]}),e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-slate-500",children:"Step"}),e.jsxs("span",{className:"text-sm font-mono font-semibold text-indigo-400",children:[Math.max(0,n+1)," / ",s.length]})]}),w&&e.jsx("div",{className:`rounded-lg px-3 py-2 text-xs font-medium ${w.action==="match"||w.action==="prefix-match"?"bg-emerald-500/15 text-emerald-300 ring-1 ring-emerald-500/30":w.action==="not-found"?"bg-rose-500/15 text-rose-300 ring-1 ring-rose-500/30":"bg-slate-800/60 text-slate-300 ring-1 ring-slate-700/50"}`,children:w.description}),e.jsxs("button",{onClick:W,className:"mt-2 w-full flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(Z,{size:12})," Clear Search"]})]}),t.length>0&&e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:["Results (",t.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-32 overflow-y-auto",children:t.map(p=>e.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2.5 py-0.5 text-[11px] font-medium text-emerald-300 ring-1 ring-emerald-500/20",children:p},p))})]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:["Words (",a.length,")"]}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsx("input",{type:"text",value:v,onChange:p=>M(p.target.value),onKeyDown:p=>p.key==="Enter"&&T(),placeholder:"Add a word...",className:"flex-1 rounded-lg bg-slate-800/60 px-3 py-2 text-sm text-white placeholder-slate-500 outline-none ring-1 ring-slate-700/50 focus:ring-indigo-500/50"}),e.jsx("button",{onClick:T,disabled:!v.trim(),className:"flex items-center justify-center rounded-lg bg-emerald-500/15 px-3 py-2 text-emerald-300 ring-1 ring-emerald-500/30 transition-all hover:bg-emerald-500/25 disabled:opacity-40 disabled:cursor-not-allowed",children:e.jsx(ee,{size:16})})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-40 overflow-y-auto",children:a.map(p=>e.jsxs("span",{className:"group inline-flex items-center gap-1 rounded-full bg-slate-800/60 px-2.5 py-0.5 text-[11px] font-medium text-slate-400 ring-1 ring-slate-700/40",children:[p,e.jsx("button",{onClick:()=>N(p),className:"opacity-0 group-hover:opacity-100 transition-opacity text-slate-500 hover:text-rose-400",children:e.jsx(K,{size:10})})]},p))}),e.jsxs("button",{onClick:C,className:"mt-3 w-full flex items-center justify-center gap-1.5 rounded-lg bg-slate-800/60 px-3 py-2 text-xs font-medium text-slate-400 transition-all hover:bg-slate-700/60 hover:text-slate-300",children:[e.jsx(ae,{size:12})," Load Sample Words"]})]}),e.jsxs("button",{onClick:P,className:`flex items-center justify-center gap-2 rounded-xl px-4 py-2.5 text-sm font-medium transition-all ${k?"bg-indigo-500/15 text-indigo-300 ring-1 ring-indigo-500/30 hover:bg-indigo-500/25":"bg-slate-800/60 text-slate-500 ring-1 ring-slate-700/40 hover:bg-slate-700/60"}`,children:[k?e.jsx(te,{size:16}):e.jsx(se,{size:16}),k?"Sound On":"Sound Off"]}),e.jsxs("div",{className:"rounded-xl border border-slate-700/50 bg-slate-900/60 p-4 backdrop-blur-sm",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400 mb-3",children:"Legend"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-slate-700 ring-1 ring-slate-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Normal Node"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-indigo-900 ring-1 ring-indigo-500"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Matched Path"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-3 w-3 rounded-full bg-indigo-900 ring-2 ring-indigo-400"}),e.jsx("span",{className:"text-xs text-slate-400",children:"Current Step"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"relative h-3 w-3 rounded-full bg-slate-700 ring-1 ring-emerald-500",children:e.jsx("div",{className:"absolute -top-0.5 -right-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400"})}),e.jsx("span",{className:"text-xs text-slate-400",children:"End of Word"})]})]})]})]})}let F=0;function X(a,r){return{id:`node-${F++}`,char:a,children:new Map,isEndOfWord:!1,depth:r}}function le(){F=0}function ce(a,r){let o=a;for(let u=0;uc[0].localeCompare(m[0]));for(const[,c]of h){const m=u;s(c,n.id),i.push((m+u-1)/2)}const x=i.reduce((c,m)=>c+m,0)/i.length;r.push({id:n.id,char:n.char,isEndOfWord:n.isEndOfWord,x:x*l,y:n.depth*70,parentId:t,depth:n.depth})}return s(a,null),r}const $=["apple","app","ape","apply","bat","ball","ban","cat","car","card","care","dog","do","dot"];function O(a){le();const r=X("",0);for(const o of a)ce(r,o);return r}function he(){const[a,r]=d.useState($),[o,u]=d.useState(()=>O($)),[l,s]=d.useState("prefix"),[n,t]=d.useState(""),[i,h]=d.useState([]),[x,c]=d.useState(-1),[m,g]=d.useState(new Set),[y,S]=d.useState([]),[W,v]=d.useState(!1),[M,T]=d.useState(500),[N,C]=d.useState(""),k=d.useMemo(()=>xe(o),[o]),P=x>=0&&x{if(!n.trim())return;const f=n.trim().toLowerCase(),{result:b,steps:q}=l==="word"?de(o,f):ue(o,f);h(q),c(-1),g(new Set(b.matchedPath)),S(b.matches),v(!1)},[n,l,o]),p=d.useCallback(()=>{c(f=>f{c(f=>f>0?f-1:f)},[]),E=d.useCallback(()=>{i.length!==0&&(v(!0),c(0))},[i]),R=d.useCallback(()=>{v(!1)},[]),j=d.useCallback(()=>{h([]),c(-1),g(new Set),S([]),v(!1)},[]),z=d.useCallback(()=>{const f=N.trim().toLowerCase();if(!f||a.includes(f))return;const b=[...a,f];r(b),u(O(b)),C(""),j()},[N,a,j]),A=d.useCallback(f=>{const b=a.filter(q=>q!==f);r(b),u(O(b)),j()},[a,j]),G=d.useCallback(()=>{r($),u(O($)),C(""),j()},[j]),V=x0;return{words:a,root:o,layout:k,searchMode:l,setSearchMode:s,query:n,setQuery:t,steps:i,stepIndex:x,currentStepNodeId:P,matchedNodeIds:m,searchResults:y,isPlaying:W,speed:M,setSpeed:T,canGoNext:V,canGoPrev:I,search:w,nextStep:p,prevStep:L,play:E,stopPlaying:R,resetSearch:j,newWord:N,setNewWord:C,addWord:z,removeWord:A,loadSampleWords:G}}const _=[261.63,293.66,329.63,392,440,523.25,587.33,659.25];function me(){const a=d.useRef(!0),r=d.useCallback(()=>ne(),[]),o=d.useCallback(t=>{a.current=t},[]),u=d.useCallback(()=>a.current,[]),l=d.useCallback(t=>{if(!a.current)return;const i=r();if(!i)return;const h=_[t%_.length],x=i.createOscillator(),c=i.createGain();x.type="sine",x.frequency.value=h,c.gain.setValueAtTime(.08,i.currentTime),c.gain.exponentialRampToValueAtTime(.001,i.currentTime+.15),x.connect(c),c.connect(i.destination),x.start(),x.stop(i.currentTime+.15)},[r]),s=d.useCallback(()=>{if(!a.current)return;const t=r();if(!t)return;[523.25,659.25,783.99].forEach((h,x)=>{const c=t.createOscillator(),m=t.createGain();c.type="sine",c.frequency.value=h,m.gain.setValueAtTime(.1,t.currentTime+x*.1),m.gain.exponentialRampToValueAtTime(.001,t.currentTime+x*.1+.15),c.connect(m),m.connect(t.destination),c.start(t.currentTime+x*.1),c.stop(t.currentTime+x*.1+.15)})},[r]),n=d.useCallback(()=>{if(!a.current)return;const t=r();if(!t)return;const i=t.createOscillator(),h=t.createGain();i.type="sine",i.frequency.value=350,i.frequency.setValueAtTime(350,t.currentTime),i.frequency.linearRampToValueAtTime(220,t.currentTime+.25),h.gain.setValueAtTime(.08,t.currentTime),h.gain.exponentialRampToValueAtTime(.001,t.currentTime+.3),i.connect(h),h.connect(t.destination),i.start(),i.stop(t.currentTime+.3)},[r]);return{playTraverseTone:l,playMatchTone:s,playNotFoundTone:n,setEnabled:o,isEnabled:u}}function we(){const{words:a,layout:r,searchMode:o,setSearchMode:u,query:l,setQuery:s,steps:n,stepIndex:t,currentStepNodeId:i,matchedNodeIds:h,searchResults:x,isPlaying:c,speed:m,setSpeed:g,canGoNext:y,canGoPrev:S,search:W,nextStep:v,prevStep:M,play:T,stopPlaying:N,resetSearch:C,newWord:k,setNewWord:P,addWord:w,removeWord:p,loadSampleWords:L}=he(),{playTraverseTone:E,playMatchTone:R,playNotFoundTone:j,setEnabled:z}=me(),[A,G]=d.useState(!0),V=()=>{const b=!A;G(b),z(b)},I=d.useRef(t);d.useEffect(()=>{if(t<0||t===I.current){I.current=t;return}I.current=t;const b=n[t];b&&(b.action==="visit"?E(b.char?b.char.charCodeAt(0)%8:0):b.action==="match"||b.action==="prefix-match"?R():b.action==="not-found"&&j())},[t,n,E,R,j]);const f=d.useRef(null);return d.useEffect(()=>{if(!c){f.current&&clearTimeout(f.current);return}if(!y){N();return}return f.current=setTimeout(()=>{v()},m),()=>{f.current&&clearTimeout(f.current)}},[c,t,y,m,v,N]),e.jsxs("div",{className:"flex flex-1 flex-col md:flex-row gap-4 md:gap-6 overflow-auto p-4 md:p-6",children:[e.jsx(oe,{words:a,searchMode:o,setSearchMode:u,query:l,setQuery:s,steps:n,stepIndex:t,searchResults:x,isPlaying:c,speed:m,setSpeed:g,canGoNext:y,canGoPrev:S,onSearch:W,onNextStep:v,onPrevStep:M,onPlay:T,onStop:N,onReset:C,newWord:k,setNewWord:P,onAddWord:w,onRemoveWord:p,onLoadSample:L,soundEnabled:A,onToggleSound:V}),e.jsx("div",{className:"order-last md:order-first flex md:flex-1 flex-col items-center justify-center gap-3 min-h-[40vh] md:min-h-0 max-h-[50vh] md:max-h-none overflow-auto",children:e.jsx(ie,{layout:r,matchedNodeIds:h,currentStepNodeId:i})})]})}export{we as default}; diff --git a/docs/assets/WorldMapGamePage-DO28xRb9.js b/docs/assets/WorldMapGamePage-Dd7brX_d.js similarity index 99% rename from docs/assets/WorldMapGamePage-DO28xRb9.js rename to docs/assets/WorldMapGamePage-Dd7brX_d.js index 314376d..42c09ab 100644 --- a/docs/assets/WorldMapGamePage-DO28xRb9.js +++ b/docs/assets/WorldMapGamePage-Dd7brX_d.js @@ -1 +1 @@ -import{c as te,r as b,j as t,P as se}from"./index-eCXyAnHs.js";import{S as ae}from"./shuffle-CdKU4ZYx.js";import{C as oe,a as ne}from"./chevron-right-BZqZw4c2.js";import{P as re}from"./play-BqZilH6N.js";import{R as ie}from"./route-CjoQmFsM.js";import{V as le,a as ce}from"./volume-x-CTbtCvt-.js";import{g as de}from"./audioContext-NbgqvQGz.js";const ue=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],he=te("radar",ue),pe=[{name:"North America",path:"M45 82C82 46 145 49 196 75C229 59 287 72 331 102C366 126 369 165 337 188C312 207 287 210 264 235C232 268 178 250 149 222C118 192 78 187 56 150C38 119 28 99 45 82Z",fill:"#14532d"},{name:"Greenland",path:"M285 42C332 20 390 35 404 75C388 111 325 119 286 92C267 78 265 55 285 42Z",fill:"#475569"},{name:"Central America",path:"M246 230C277 232 307 242 329 263C307 276 273 267 246 249C232 240 232 231 246 230Z",fill:"#166534"},{name:"South America",path:"M308 264C352 270 383 315 372 374C364 424 334 474 296 483C281 443 259 405 264 359C269 314 281 281 308 264Z",fill:"#15803d"},{name:"Europe",path:"M438 122C470 96 535 91 575 117C602 137 593 166 558 176C522 186 489 177 454 165C427 156 416 139 438 122Z",fill:"#0f766e"},{name:"Africa",path:"M498 202C553 184 612 223 627 283C640 336 608 409 552 425C514 397 484 340 482 283C480 244 482 216 498 202Z",fill:"#166534"},{name:"Middle East",path:"M572 188C615 178 657 196 674 226C648 245 603 239 580 217C568 206 565 194 572 188Z",fill:"#3f6212"},{name:"Asia",path:"M600 111C683 52 842 83 927 168C910 223 836 246 775 229C728 216 703 257 655 244C611 232 566 159 600 111Z",fill:"#164e63"},{name:"Southeast Asia",path:"M728 252C772 247 824 281 833 322C800 335 755 317 728 287C714 271 714 258 728 252Z",fill:"#0f766e"},{name:"Australia",path:"M794 350C850 316 932 335 949 394C897 437 813 426 774 381C760 365 771 354 794 350Z",fill:"#15803d"},{name:"New Zealand",path:"M958 420C979 425 987 448 970 461C951 456 941 432 958 420Z",fill:"#15803d"}],xe=["M186 78C184 128 197 172 230 214","M126 172C171 164 216 173 260 190","M231 237C262 244 292 252 323 263","M303 280C329 305 342 335 335 374","M336 312C350 304 362 304 376 318","M451 140C482 132 515 134 548 149","M496 171C501 144 518 124 545 111","M529 196C540 236 540 277 530 321","M565 223C594 250 611 286 617 329","M591 190C613 203 639 212 671 221","M638 130C675 145 713 153 754 153","M690 184C729 192 768 201 808 216","M757 238C759 278 770 303 807 320","M835 153C841 191 832 219 808 236","M831 365C861 384 892 394 928 396"],me=[{text:"CANADA",x:160,y:118},{text:"UNITED STATES",x:190,y:178},{text:"MEXICO",x:250,y:222},{text:"BRAZIL",x:338,y:336},{text:"ARGENTINA",x:315,y:424},{text:"EUROPE",x:507,y:139},{text:"NORTH AFRICA",x:548,y:246},{text:"SOUTH AFRICA",x:560,y:390},{text:"MIDDLE EAST",x:632,y:210},{text:"INDIA",x:710,y:232},{text:"CHINA",x:779,y:173},{text:"JAPAN",x:890,y:161},{text:"SOUTHEAST ASIA",x:770,y:295},{text:"AUSTRALIA",x:860,y:390}];function ge({airports:s,routes:i,source:n,destination:l,currentStep:o,plan:u,flightProgress:c,onSelectSource:x,onSelectDestination:m}){const h=b.useMemo(()=>new Map(s.map(a=>[a.code,a])),[s]),j=new Set(o?.visited??[]),y=new Set((o?.frontier??[]).map(a=>a.code)),S=o?.route?.length?o.route:u.path,g=new Set(S.slice(0,-1).map((a,d)=>[a,S[d+1]].sort().join("-"))),p=o?.relaxedRoute?[o.relaxedRoute.from,o.relaxedRoute.to].sort().join("-"):null,k=b.useMemo(()=>{if(!c)return null;const a=h.get(c.from),d=h.get(c.to);if(!a||!d)return null;const f=Math.sin(c.progress*Math.PI)*-44;return{x:a.x+(d.x-a.x)*c.progress,y:a.y+(d.y-a.y)*c.progress+f,angle:Math.atan2(d.y-a.y,d.x-a.x)*(180/Math.PI)}},[h,c]);return t.jsxs("div",{className:"relative min-h-[620px] flex-1 overflow-hidden rounded-[1.75rem] border border-slate-700/50 bg-slate-950/90 shadow-2xl shadow-black/40",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_18%_22%,rgba(14,165,233,0.16),transparent_28%),radial-gradient(circle_at_78%_72%,rgba(59,130,246,0.12),transparent_30%)]"}),t.jsxs("div",{className:"absolute left-5 top-5 z-20 rounded-2xl border border-slate-700/60 bg-slate-950/85 p-4 shadow-xl shadow-black/30 backdrop-blur-sm",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-sky-400",children:"Global Air Traffic Network"}),t.jsxs("div",{className:"mt-2 flex gap-4 text-xs text-slate-300",children:[t.jsxs("span",{children:[t.jsx("strong",{className:"font-mono text-white",children:s.length})," airports"]}),t.jsxs("span",{children:[t.jsx("strong",{className:"font-mono text-white",children:i.length})," routes"]}),t.jsxs("span",{children:[t.jsx("strong",{className:"font-mono text-white",children:u.path.length||0})," hops"]})]})]}),o&&t.jsxs("div",{className:"absolute bottom-5 left-5 z-20 max-w-md rounded-2xl border border-slate-700/60 bg-slate-950/90 p-4 shadow-xl shadow-black/35 backdrop-blur-sm",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-indigo-300",children:"Algorithm Radar"}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-300",children:o.description}),o.frontier.length>0&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:o.frontier.slice(0,7).map(a=>t.jsxs("span",{className:"rounded-full bg-sky-500/10 px-2 py-1 text-[10px] font-mono font-semibold text-sky-300 ring-1 ring-sky-500/25",children:[a.code,": ",Number.isFinite(a.priority)?a.priority:"∞"]},`${a.code}-${a.priority}`))})]}),t.jsxs("svg",{viewBox:"0 0 1000 520",className:"relative z-10 h-full w-full",preserveAspectRatio:"xMidYMid meet",children:[t.jsxs("defs",{children:[t.jsxs("filter",{id:"world-glow",x:"-40%",y:"-40%",width:"180%",height:"180%",children:[t.jsx("feGaussianBlur",{stdDeviation:"4",result:"blur"}),t.jsxs("feMerge",{children:[t.jsx("feMergeNode",{in:"blur"}),t.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),t.jsx("filter",{id:"world-shadow",x:"-60%",y:"-60%",width:"220%",height:"220%",children:t.jsx("feDropShadow",{dx:"0",dy:"8",stdDeviation:"6",floodColor:"#020617",floodOpacity:"0.7"})}),t.jsxs("linearGradient",{id:"ocean",x1:"0",x2:"1",y1:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:"#07111f"}),t.jsx("stop",{offset:"55%",stopColor:"#082f49"}),t.jsx("stop",{offset:"100%",stopColor:"#020617"})]})]}),t.jsx("rect",{width:"1000",height:"520",rx:"28",fill:"url(#ocean)"}),[130,260,390].map(a=>t.jsx("path",{d:`M0 ${a}H1000`,stroke:"#38bdf8",strokeOpacity:"0.1",strokeDasharray:"7 10"},`lat-${a}`)),[125,250,375,500,625,750,875].map(a=>t.jsx("path",{d:`M${a} 0V520`,stroke:"#38bdf8",strokeOpacity:"0.08",strokeDasharray:"7 10"},`lon-${a}`)),t.jsx("path",{d:"M0 260H1000",stroke:"#67e8f9",strokeOpacity:"0.2",strokeDasharray:"8 9"}),t.jsx("path",{d:"M500 0V520",stroke:"#67e8f9",strokeOpacity:"0.14",strokeDasharray:"8 9"}),t.jsx("g",{filter:"url(#world-shadow)",children:pe.map(a=>t.jsx("path",{d:a.path,fill:a.fill,fillOpacity:"0.78",stroke:"#a7f3d0",strokeOpacity:"0.42",strokeWidth:"1.8"},a.name))}),t.jsx("g",{children:xe.map(a=>t.jsx("path",{d:a,fill:"none",stroke:"#d1fae5",strokeOpacity:"0.22",strokeWidth:"1",strokeDasharray:"4 5"},a))}),t.jsx("g",{children:me.map(a=>t.jsx("text",{x:a.x,y:a.y,textAnchor:"middle",fontSize:"11",fontWeight:"800",letterSpacing:"1.4",fill:"#e2e8f0",fillOpacity:"0.28",children:a.text},a.text))}),i.map(a=>{const d=h.get(a.source),f=h.get(a.destination);if(!d||!f)return null;const M=[a.source,a.destination].sort().join("-"),N=g.has(M),L=M===p,D=L?"#facc15":N?"#22c55e":"#334155",R=Math.min(120,Math.abs(d.x-f.x)*.12+28),I=(d.x+f.x)/2,K=(d.y+f.y)/2-R;return t.jsx("g",{children:t.jsx("path",{d:`M${d.x},${d.y} Q${I},${K} ${f.x},${f.y}`,fill:"none",stroke:D,strokeWidth:N||L?3:1.2,strokeOpacity:N||L?.92:.24,strokeDasharray:N?void 0:"5 8",filter:N||L?"url(#world-glow)":void 0})},a.id)}),s.map(a=>{const d=a.code===n,f=a.code===l,M=j.has(a.code),N=y.has(a.code),L=o?.airportCode===a.code,D=d||f||L||N||M||a.hubScore>=92,R=d?"#fde047":f?"#fb923c":L?"#38bdf8":M?"#22c55e":N?"#a78bfa":"#94a3b8";return t.jsxs("g",{className:"cursor-pointer",children:[t.jsxs("title",{children:[a.code," - ",a.city,", ",a.country]}),t.jsx("circle",{cx:a.x,cy:a.y,r:d||f?12:8,fill:"#020617",stroke:"#0f172a",strokeWidth:7,filter:"url(#world-shadow)"}),t.jsx("circle",{cx:a.x,cy:a.y,r:d||f?9:6,fill:R,fillOpacity:d||f||M||N||L?.96:.58,stroke:R,strokeWidth:L?4:2,onClick:I=>{I.shiftKey?m(a.code):x(a.code)}}),D&&t.jsx("text",{x:a.x,y:a.y-14,textAnchor:"middle",fontSize:"10",fontWeight:"800",fontFamily:"ui-monospace, monospace",fill:R,children:a.code})]},a.code)}),k&&t.jsxs("g",{transform:`translate(${k.x} ${k.y}) rotate(${k.angle})`,filter:"url(#world-glow)",children:[t.jsx("path",{d:"M-14 -5L18 0L-14 5L-8 0Z",fill:"#f8fafc",stroke:"#38bdf8",strokeWidth:"1.2"}),t.jsx("path",{d:"M-5 -3L-12 -13L2 -4Z",fill:"#bae6fd",opacity:"0.9"}),t.jsx("path",{d:"M-5 3L-12 13L2 4Z",fill:"#bae6fd",opacity:"0.9"})]})]}),t.jsxs("div",{className:"absolute bottom-5 right-5 z-20 hidden rounded-2xl border border-slate-700/60 bg-slate-950/85 p-4 text-[10px] text-slate-400 shadow-xl shadow-black/30 backdrop-blur-sm sm:block",children:[t.jsx("div",{className:"mb-2 font-semibold uppercase tracking-[0.24em] text-slate-500",children:"Tip"}),"Click an airport to set origin. Shift-click to set destination."]})]})}const O={dijkstra:{label:"Dijkstra",description:"Finds the lowest total travel time by relaxing routes through a priority queue.",metric:"Shortest time"},astar:{label:"A* Search",description:"Uses distance-to-destination as a heuristic to guide the priority queue.",metric:"Guided shortest path"},bfs:{label:"BFS",description:"Ignores weights and searches by fewest airport connections.",metric:"Fewest stops"},greedy:{label:"Greedy",description:"Always flies toward the airport geographically closest to the destination.",metric:"Nearest-looking route"}},fe=["dijkstra","astar","bfs","greedy"];function be({airports:s,scenarios:i,source:n,destination:l,algorithm:o,plan:u,currentStep:c,stepIndex:x,totalSteps:m,phase:h,isPlaying:j,soundEnabled:y,onSourceChange:S,onDestinationChange:g,onAlgorithmChange:p,onLoadScenario:k,onPlanRoute:a,onStepBack:d,onStepForward:f,onPlay:M,onFly:N,onToggleSound:L}){return t.jsxs("aside",{className:"flex w-full shrink-0 flex-col gap-4 overflow-y-auto xl:w-88",children:[t.jsxs("section",{className:"rounded-2xl border border-sky-500/20 bg-slate-950/75 p-4 shadow-2xl shadow-black/30 backdrop-blur-sm",children:[t.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-sky-500/15 text-sky-300 ring-1 ring-sky-500/30",children:t.jsx(se,{size:18})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-bold text-white",children:"World Flight Planner"}),t.jsx("p",{className:"text-[10px] text-slate-500",children:"Airport-code simulator inspired by public airport datasets."})]})]}),t.jsx("p",{className:"text-xs leading-relaxed text-slate-400",children:"Pick countries through their major airport codes, then compare how different algorithms choose routes across global hubs."})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Travel Request"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(X,{label:"Origin",value:n,airports:s,onChange:S}),t.jsx(X,{label:"Destination",value:l,airports:s,onChange:g})]}),t.jsxs("button",{onClick:a,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-xl bg-sky-500/15 px-3 py-2 text-xs font-semibold text-sky-300 ring-1 ring-sky-500/30 transition hover:bg-sky-500/25",children:[t.jsx(he,{size:13})," Recalculate route"]})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Algorithms"}),t.jsx("div",{className:"grid gap-2",children:fe.map(D=>t.jsxs("button",{onClick:()=>p(D),className:`rounded-xl p-3 text-left transition ${o===D?"bg-indigo-500/15 text-indigo-200 ring-1 ring-indigo-500/35":"bg-slate-900/70 text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80"}`,children:[t.jsxs("span",{className:"flex items-center justify-between text-xs font-bold",children:[O[D].label,t.jsx("span",{className:"text-[9px] uppercase tracking-wider opacity-60",children:O[D].metric})]}),t.jsx("span",{className:"mt-1 block text-[10px] leading-snug opacity-75",children:O[D].description})]},D))})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Preset Missions"}),t.jsx("div",{className:"grid gap-2",children:i.map(D=>t.jsxs("button",{onClick:()=>k(D.id),className:"rounded-xl bg-slate-900/70 p-3 text-left ring-1 ring-slate-800/80 transition hover:bg-slate-800/80",children:[t.jsxs("span",{className:"flex items-center gap-2 text-xs font-bold text-slate-200",children:[t.jsx(ae,{size:12})," ",D.title]}),t.jsx("span",{className:"mt-1 block text-[10px] leading-snug text-slate-500",children:D.description})]},D.id))})]}),t.jsxs("section",{className:"rounded-2xl border border-emerald-500/20 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Flight Plan"}),t.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[9px] font-bold uppercase tracking-wider text-emerald-300 ring-1 ring-emerald-500/25",children:h})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(H,{label:"Distance",value:`${u.totalDistanceKm.toLocaleString()} km`}),t.jsx(H,{label:"Duration",value:`${u.totalDurationHours}h`}),t.jsx(H,{label:"Stops",value:u.stops.toString()}),t.jsx(H,{label:"Est. Cost",value:`$${u.totalCostUsd.toLocaleString()}`})]}),t.jsxs("div",{className:"mt-3 rounded-xl bg-slate-900/70 p-3 ring-1 ring-slate-800/80",children:[t.jsx("p",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Route"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:u.path.map((D,R)=>t.jsx("span",{className:"rounded-md bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-mono font-semibold text-emerald-300 ring-1 ring-emerald-500/20",children:D},`${D}-${R}`))})]})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Simulation"}),t.jsxs("div",{className:"mb-3 flex items-center justify-between text-[10px] text-slate-500",children:[t.jsx("span",{children:"Step"}),t.jsxs("span",{className:"font-mono text-indigo-300",children:[Math.min(x+1,m)," / ",m]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsxs("button",{onClick:d,disabled:x<=0,className:"flex items-center justify-center gap-1 rounded-xl bg-slate-900/70 px-2 py-2 text-xs text-slate-400 ring-1 ring-slate-800/80 disabled:opacity-30",children:[t.jsx(oe,{size:13})," Back"]}),t.jsxs("button",{onClick:M,className:"flex items-center justify-center gap-1 rounded-xl bg-indigo-500/15 px-2 py-2 text-xs font-semibold text-indigo-300 ring-1 ring-indigo-500/30",children:[t.jsx(re,{size:13})," ",j?"Pause":"Play"]}),t.jsxs("button",{onClick:f,disabled:x>=m-1,className:"flex items-center justify-center gap-1 rounded-xl bg-slate-900/70 px-2 py-2 text-xs text-slate-400 ring-1 ring-slate-800/80 disabled:opacity-30",children:["Next ",t.jsx(ne,{size:13})]})]}),t.jsxs("button",{onClick:N,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-xl bg-emerald-500/15 px-3 py-2 text-xs font-semibold text-emerald-300 ring-1 ring-emerald-500/30 transition hover:bg-emerald-500/25",children:[t.jsx(ie,{size:13})," Animate airplane"]}),c&&t.jsx("p",{className:"mt-3 text-xs leading-relaxed text-slate-400",children:c.description})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Audio"}),t.jsxs("button",{onClick:()=>L(!y),className:`flex w-full items-center justify-center gap-2 rounded-xl px-3 py-2 text-xs font-semibold ring-1 transition ${y?"bg-sky-500/15 text-sky-300 ring-sky-500/30 hover:bg-sky-500/25":"bg-slate-900/70 text-slate-400 ring-slate-800/80 hover:bg-slate-800/80"}`,children:[y?t.jsx(le,{size:13}):t.jsx(ce,{size:13}),y?"Sound On":"Sound Off"]}),t.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:"Radar pings mark search steps, with takeoff, waypoint, and arrival tones during flight."})]})]})}function X({label:s,value:i,airports:n,onChange:l}){return t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:s}),t.jsx("select",{value:i,onChange:o=>l(o.target.value),className:"w-full rounded-xl border border-slate-700 bg-slate-900 px-3 py-2 text-xs font-mono text-slate-200 outline-none ring-sky-500/20 focus:ring-2",children:n.map(o=>t.jsxs("option",{value:o.code,children:[o.code," - ",o.city]},o.code))})]})}function H({label:s,value:i}){return t.jsxs("div",{className:"rounded-xl bg-slate-900/70 p-3 ring-1 ring-slate-800/80",children:[t.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-slate-500",children:s}),t.jsx("div",{className:"mt-1 font-mono text-sm font-black text-white",children:i})]})}function Ae(s,i){return{x:(s+180)/360*1e3,y:(90-i)/180*520}}function r(s,i,n,l,o,u,c){return{code:s,city:i,country:n,region:l,lat:o,lon:u,hubScore:c,...Ae(u,o)}}const F=[r("ATL","Atlanta","United States","North America",33.6407,-84.4277,98),r("ORD","Chicago","United States","North America",41.9742,-87.9073,96),r("DFW","Dallas-Fort Worth","United States","North America",32.8998,-97.0403,94),r("JFK","New York","United States","North America",40.6413,-73.7781,96),r("LAX","Los Angeles","United States","North America",33.9416,-118.4085,94),r("MIA","Miami","United States","North America",25.7959,-80.287,88),r("SEA","Seattle","United States","North America",47.4502,-122.3088,84),r("SFO","San Francisco","United States","North America",37.6213,-122.379,90),r("YVR","Vancouver","Canada","North America",49.1967,-123.1815,76),r("YYZ","Toronto","Canada","North America",43.6777,-79.6248,78),r("MEX","Mexico City","Mexico","North America",19.4361,-99.0719,76),r("BOG","Bogota","Colombia","South America",4.7016,-74.1469,78),r("LIM","Lima","Peru","South America",-12.0219,-77.1143,76),r("EZE","Buenos Aires","Argentina","South America",-34.8222,-58.5358,74),r("GRU","Sao Paulo","Brazil","South America",-23.4356,-46.4731,84),r("SCL","Santiago","Chile","South America",-33.3928,-70.7858,72),r("AMS","Amsterdam","Netherlands","Europe",52.3105,4.7683,93),r("ARN","Stockholm","Sweden","Europe",59.6498,17.9238,70),r("ATH","Athens","Greece","Europe",37.9364,23.9445,72),r("BCN","Barcelona","Spain","Europe",41.2974,2.0833,76),r("BRU","Brussels","Belgium","Europe",50.9014,4.4844,74),r("CPH","Copenhagen","Denmark","Europe",55.618,12.6561,74),r("LHR","London","United Kingdom","Europe",51.47,-.4543,98),r("CDG","Paris","France","Europe",49.0097,2.5479,94),r("DUB","Dublin","Ireland","Europe",53.4264,-6.2499,70),r("FCO","Rome","Italy","Europe",41.8003,12.2389,78),r("FRA","Frankfurt","Germany","Europe",50.0379,8.5622,96),r("HEL","Helsinki","Finland","Europe",60.3172,24.9633,70),r("LIS","Lisbon","Portugal","Europe",38.7742,-9.1342,70),r("MAD","Madrid","Spain","Europe",40.4983,-3.5676,82),r("MUC","Munich","Germany","Europe",48.3538,11.7861,84),r("VIE","Vienna","Austria","Europe",48.1103,16.5697,76),r("WAW","Warsaw","Poland","Europe",52.1657,20.9671,70),r("ZRH","Zurich","Switzerland","Europe",47.4581,8.5555,82),r("IST","Istanbul","Turkey","Europe/Asia",41.2753,28.7519,92),r("ADD","Addis Ababa","Ethiopia","Africa",8.9779,38.7993,82),r("CMN","Casablanca","Morocco","Africa",33.3675,-7.58997,74),r("CAI","Cairo","Egypt","Africa",30.112,31.4003,70),r("CPT","Cape Town","South Africa","Africa",-33.9715,18.6021,70),r("LOS","Lagos","Nigeria","Africa",6.5774,3.3212,72),r("JNB","Johannesburg","South Africa","Africa",-26.1337,28.242,80),r("NBO","Nairobi","Kenya","Africa",-1.3192,36.9278,68),r("AUH","Abu Dhabi","United Arab Emirates","Middle East",24.433,54.6511,82),r("DXB","Dubai","United Arab Emirates","Middle East",25.2532,55.3657,99),r("DOH","Doha","Qatar","Middle East",25.2731,51.6081,88),r("JED","Jeddah","Saudi Arabia","Middle East",21.6796,39.1565,78),r("RUH","Riyadh","Saudi Arabia","Middle East",24.9576,46.6988,76),r("TLV","Tel Aviv","Israel","Middle East",32.0114,34.8867,74),r("BKK","Bangkok","Thailand","Asia",13.69,100.7501,88),r("BLR","Bengaluru","India","Asia",13.1986,77.7066,76),r("BOM","Mumbai","India","Asia",19.0896,72.8656,84),r("CAN","Guangzhou","China","Asia",23.3924,113.2988,86),r("CGK","Jakarta","Indonesia","Asia",-6.1256,106.6559,82),r("DEL","Delhi","India","Asia",28.5562,77.1,86),r("HKG","Hong Kong","China","Asia",22.308,113.9185,92),r("SIN","Singapore","Singapore","Asia",1.3644,103.9915,96),r("ICN","Seoul","South Korea","Asia",37.4602,126.4407,94),r("KUL","Kuala Lumpur","Malaysia","Asia",2.7456,101.7072,82),r("MNL","Manila","Philippines","Asia",14.5086,121.0194,78),r("PEK","Beijing","China","Asia",40.0799,116.6031,90),r("PVG","Shanghai","China","Asia",31.1443,121.8083,92),r("TPE","Taipei","Taiwan","Asia",25.0797,121.2342,82),r("HND","Tokyo","Japan","Asia",35.5494,139.7798,95),r("BNE","Brisbane","Australia","Oceania",-27.3842,153.1175,70),r("MEL","Melbourne","Australia","Oceania",-37.669,144.841,78),r("PER","Perth","Australia","Oceania",-31.9403,115.9672,72),r("SYD","Sydney","Australia","Oceania",-33.9399,151.1753,84),r("AKL","Auckland","New Zealand","Oceania",-37.0082,174.785,66)],V=new Map(F.map(s=>[s.code,s]));function ye(s,i){const l=h=>h*Math.PI/180,o=l(i.lat-s.lat),u=l(i.lon-s.lon),c=l(s.lat),x=l(i.lat),m=Math.sin(o/2)**2+Math.cos(c)*Math.cos(x)*Math.sin(u/2)**2;return Math.round(2*6371*Math.asin(Math.sqrt(m)))}function e(s,i){const n=V.get(s),l=V.get(i);if(!n||!l)throw new Error(`Unknown airport route: ${s}-${i}`);const o=ye(n,l);return{id:`${s}-${i}`,source:s,destination:i,distanceKm:o,durationHours:Math.round((o/870+.65)*10)/10,costUsd:Math.round(o*.11+140)}}const B=[e("ATL","DFW"),e("ATL","JFK"),e("ATL","LAX"),e("ATL","MIA"),e("ATL","ORD"),e("ATL","YYZ"),e("ORD","DFW"),e("ORD","JFK"),e("ORD","LAX"),e("ORD","SEA"),e("ORD","SFO"),e("ORD","YYZ"),e("DFW","LAX"),e("DFW","MEX"),e("DFW","MIA"),e("DFW","SFO"),e("JFK","LAX"),e("JFK","YYZ"),e("JFK","LHR"),e("JFK","CDG"),e("JFK","AMS"),e("JFK","FRA"),e("JFK","MEX"),e("JFK","MIA"),e("JFK","SFO"),e("JFK","MAD"),e("JFK","DUB"),e("JFK","GRU"),e("LAX","HND"),e("LAX","ICN"),e("LAX","PVG"),e("LAX","SIN"),e("LAX","SYD"),e("LAX","MEX"),e("LAX","SFO"),e("LAX","SEA"),e("LAX","YVR"),e("YYZ","LHR"),e("YYZ","AMS"),e("YYZ","FRA"),e("YYZ","YVR"),e("MIA","BOG"),e("MIA","GRU"),e("MIA","LIM"),e("MIA","MEX"),e("SEA","YVR"),e("SEA","HND"),e("SEA","ICN"),e("SFO","HKG"),e("SFO","HND"),e("SFO","ICN"),e("SFO","SIN"),e("YVR","HND"),e("YVR","ICN"),e("MEX","BOG"),e("MEX","GRU"),e("MEX","LIM"),e("MEX","SCL"),e("BOG","GRU"),e("BOG","LIM"),e("BOG","MAD"),e("LIM","EZE"),e("LIM","SCL"),e("LIM","GRU"),e("EZE","GRU"),e("EZE","MAD"),e("EZE","SCL"),e("GRU","SCL"),e("GRU","MAD"),e("GRU","LIS"),e("GRU","CDG"),e("GRU","JNB"),e("SCL","AKL"),e("AMS","BRU"),e("AMS","CPH"),e("AMS","DUB"),e("AMS","FRA"),e("AMS","LHR"),e("AMS","ZRH"),e("ARN","CPH"),e("ARN","HEL"),e("ARN","LHR"),e("ATH","FCO"),e("ATH","IST"),e("ATH","VIE"),e("BCN","FCO"),e("BCN","LHR"),e("BCN","MAD"),e("BRU","CDG"),e("BRU","FRA"),e("CPH","FRA"),e("CPH","HEL"),e("CPH","LHR"),e("LHR","CDG"),e("LHR","MAD"),e("LHR","FRA"),e("LHR","ZRH"),e("LHR","DUB"),e("LHR","FCO"),e("LHR","DXB"),e("LHR","DOH"),e("LHR","SIN"),e("CDG","MAD"),e("CDG","FRA"),e("CDG","FCO"),e("CDG","IST"),e("CDG","DXB"),e("DUB","LIS"),e("FCO","IST"),e("FCO","MAD"),e("FRA","IST"),e("FRA","MUC"),e("FRA","VIE"),e("FRA","ZRH"),e("FRA","DXB"),e("HEL","WAW"),e("LIS","MAD"),e("MAD","CMN"),e("MAD","CAI"),e("MAD","DOH"),e("MUC","VIE"),e("MUC","ZRH"),e("VIE","WAW"),e("VIE","IST"),e("WAW","IST"),e("ZRH","VIE"),e("IST","ADD"),e("IST","CAI"),e("IST","DXB"),e("IST","DOH"),e("IST","TLV"),e("ADD","CAI"),e("ADD","JNB"),e("ADD","NBO"),e("ADD","DXB"),e("CMN","CAI"),e("CMN","LIS"),e("CMN","LOS"),e("CAI","JNB"),e("CAI","NBO"),e("CAI","JED"),e("CAI","RUH"),e("CAI","TLV"),e("CPT","JNB"),e("CPT","ADD"),e("CPT","DXB"),e("LOS","ADD"),e("LOS","JNB"),e("JNB","NBO"),e("JNB","SYD"),e("JNB","DXB"),e("NBO","DXB"),e("NBO","DOH"),e("AUH","BOM"),e("AUH","DEL"),e("AUH","JED"),e("AUH","LHR"),e("AUH","SIN"),e("DXB","DOH"),e("DXB","AUH"),e("DXB","DEL"),e("DXB","BOM"),e("DXB","BKK"),e("DXB","SIN"),e("DXB","HKG"),e("DXB","SYD"),e("DOH","BOM"),e("DOH","DEL"),e("DOH","JED"),e("DOH","SIN"),e("DOH","SYD"),e("JED","RUH"),e("JED","DEL"),e("RUH","DXB"),e("TLV","ATH"),e("TLV","DXB"),e("BKK","DEL"),e("BKK","HKG"),e("BKK","KUL"),e("BKK","SIN"),e("BKK","TPE"),e("BLR","BOM"),e("BLR","DEL"),e("BLR","SIN"),e("BOM","DEL"),e("BOM","SIN"),e("BOM","LHR"),e("CAN","HKG"),e("CAN","PEK"),e("CAN","PVG"),e("CAN","SIN"),e("CGK","KUL"),e("CGK","SIN"),e("CGK","SYD"),e("DEL","SIN"),e("DEL","HND"),e("DEL","HKG"),e("DEL","ICN"),e("HKG","ICN"),e("HKG","MNL"),e("HKG","PVG"),e("HKG","SIN"),e("HKG","TPE"),e("ICN","HND"),e("ICN","PEK"),e("ICN","PVG"),e("SIN","HND"),e("SIN","KUL"),e("SIN","MNL"),e("SIN","SYD"),e("KUL","MNL"),e("KUL","PER"),e("MNL","HND"),e("PEK","HND"),e("PEK","PVG"),e("PEK","SFO"),e("PVG","HND"),e("PVG","TPE"),e("TPE","HND"),e("HND","SYD"),e("HND","BNE"),e("BNE","SYD"),e("BNE","MEL"),e("MEL","SYD"),e("MEL","AKL"),e("PER","MEL"),e("PER","SYD"),e("PER","SIN"),e("SYD","AKL")],Y=[{id:"trans-atlantic",title:"New York to Tokyo",description:"Compare westbound Pacific hops against eastbound European and Gulf hub routes.",source:"JFK",destination:"HND",algorithm:"dijkstra"},{id:"southern-cross",title:"London to Sydney",description:"Route across Europe, the Gulf, Asia, and Oceania using weighted flight times.",source:"LHR",destination:"SYD",algorithm:"astar"},{id:"africa-to-americas",title:"Johannesburg to Los Angeles",description:"Study how different algorithms connect Africa to the Americas through major hubs.",source:"JNB",destination:"LAX",algorithm:"greedy"},{id:"fewest-stops",title:"Toronto to Singapore",description:"Use BFS to minimize the number of airport connections, ignoring flight duration.",source:"YYZ",destination:"SIN",algorithm:"bfs"}];function W(s){return new Map(s.map(i=>[i.code,i]))}function G(s,i){return s.flatMap(n=>n.source===i?[{code:n.destination,route:n}]:n.destination===i?[{code:n.source,route:n}]:[])}function _(s,i,n){return s.find(l=>l.source===i&&l.destination===n||l.source===n&&l.destination===i)??null}function J(s,i,n,l,o){return o==="bfs"?Ne(s,i,n,l):o==="greedy"?Ce(s,i,n,l):Se(s,i,n,l,o)}function Se(s,i,n,l,o){const u=W(s),c={},x={},m=new Set,h=[{code:n,priority:0}],j=[];for(const g of s)c[g.code]=g.code===n?0:1/0,x[g.code]=null;for(j.push(E("init",n,`Start at ${n}. Set its travel time to 0 and every other airport to infinity.`,m,h,c,x));h.length>0;){h.sort((p,k)=>p.priority-k.priority);const g=h.shift();if(!m.has(g.code)){if(m.add(g.code),j.push(E("select",g.code,`Select ${g.code}, the airport with the best current priority.`,m,h,c,x)),g.code===l)break;for(const p of G(i,g.code)){if(m.has(p.code))continue;const k=c[g.code]+p.route.durationHours;if(k ${p.code} improves the route to ${c[p.code]}h.`,m,h,c,x,{from:g.code,to:p.code}))}else j.push(E("dead-end",p.code,`${g.code} -> ${p.code} is slower than the best known route.`,m,h,c,x,{from:g.code,to:p.code}))}}}const y=U(x,n,l),S=$(i,y);return j.push(E("done",l,`Route complete: ${y.join(" -> ")}`,m,h,c,x,void 0,y)),{steps:j,plan:S}}function Ne(s,i,n,l){const o=new Set([n]),u={},c={},x=[{code:n,priority:0}],m=[];for(const y of s)u[y.code]=null,c[y.code]=y.code===n?0:1/0;for(m.push(E("init",n,`Start BFS at ${n}. Each edge counts as one airport hop.`,o,x,c,u));x.length>0;){const y=x.shift();if(m.push(E("select",y.code,`Visit ${y.code} and enqueue all unseen connected airports.`,o,x,c,u)),y.code===l)break;for(const S of G(i,y.code))o.has(S.code)||(o.add(S.code),u[S.code]=y.code,c[S.code]=c[y.code]+1,x.push({code:S.code,priority:c[S.code]}),m.push(E("enqueue",S.code,`Add ${S.code} to the BFS queue at hop ${c[S.code]}.`,o,x,c,u,{from:y.code,to:S.code})))}const h=U(u,n,l),j=$(i,h);return m.push(E("done",l,`Fewest-stop route complete: ${h.join(" -> ")}`,o,x,c,u,void 0,h)),{steps:m,plan:j}}function Ce(s,i,n,l){const o=W(s),u=new Set,c={},x={},m=[];let h=n;for(const S of s)c[S.code]=null,x[S.code]=S.code===n?0:1/0;for(m.push(E("init",n,`Start greedy routing at ${n}. Always choose the neighbor closest to ${l}.`,u,[{code:n,priority:0}],x,c));h!==l;){u.add(h);const S=G(i,h).filter(p=>!u.has(p.code)).sort((p,k)=>T(o.get(p.code),o.get(l))-T(o.get(k.code),o.get(l)));if(m.push(E("select",h,`From ${h}, compare nearby hubs by straight-line distance to ${l}.`,u,S.map(p=>({code:p.code,priority:Math.round(T(o.get(p.code),o.get(l))*10)/10})),x,c)),S.length===0)break;const g=S[0];x[g.code]=Math.round((x[h]+g.route.durationHours)*10)/10,c[g.code]=h,m.push(E("relax",g.code,`Greedy picks ${g.code} as the closest-looking next airport.`,u,[],x,c,{from:h,to:g.code})),h=g.code}const j=U(c,n,l),y=$(i,j);return m.push(E("done",l,`Greedy route complete: ${j.join(" -> ")}`,u,[],x,c,void 0,j)),{steps:m,plan:y}}function E(s,i,n,l,o,u,c,x,m){return{type:s,airportCode:i,description:n,visited:Array.from(l),frontier:o.map(h=>({code:h.code,priority:h.priority})),distances:{...u},previous:{...c},relaxedRoute:x,route:m}}function U(s,i,n){const l=[];let o=n;for(;o&&(l.unshift(o),o!==i);)o=s[o];return l[0]===i?l:[]}function $(s,i){let n=0,l=0,o=0;for(let u=0;ude(),[]),o=b.useCallback((p,k,a="sine",d=.045)=>{if(!s.current)return;const f=l();if(!f)return;const M=f.createOscillator(),N=f.createGain();M.type=a,M.frequency.setValueAtTime(p,f.currentTime),N.gain.setValueAtTime(d,f.currentTime),N.gain.exponentialRampToValueAtTime(.001,f.currentTime+k),M.connect(N),N.connect(f.destination),M.start(f.currentTime),M.stop(f.currentTime+k)},[l]),u=b.useCallback((p,k,a,d=.04)=>{if(!s.current)return;const f=l();f&&p.forEach((M,N)=>{const L=f.createOscillator(),D=f.createGain(),R=f.currentTime+N*a*.75;L.type=k,L.frequency.setValueAtTime(M,R),D.gain.setValueAtTime(d,R),D.gain.exponentialRampToValueAtTime(.001,R+a),L.connect(D),D.connect(f.destination),L.start(R),L.stop(R+a)})},[l]),c=b.useCallback(()=>{o(523.25,.08,"triangle",.035)},[o]),x=b.useCallback(()=>{u([392,523.25,659.25],"sine",.1,.045)},[u]),m=b.useCallback(p=>{o(Z[p%Z.length],.055,"sine",.025)},[o]),h=b.useCallback(()=>{u([196,246.94,329.63,392],"triangle",.09,.04)},[u]),j=b.useCallback(p=>{o(p%2===0?587.33:659.25,.09,"triangle",.035)},[o]),y=b.useCallback(()=>{u([523.25,659.25,783.99,1046.5],"sine",.11,.05)},[u]),S=b.useCallback(()=>{o(220,.08,"sawtooth",.025)},[o]),g=b.useCallback(p=>{s.current=p,n(p)},[]);return{soundEnabled:i,toggleSound:g,playAirportSelect:c,playRoutePlanned:x,playScanStep:m,playFlightStart:h,playWaypoint:j,playArrive:y,playPause:S}}function De(){const[s,i]=b.useState("JFK"),[n,l]=b.useState("HND"),[o,u]=b.useState("dijkstra"),[c,x]=b.useState(()=>J(F,B,"JFK","HND","dijkstra")),[m,h]=b.useState(0),[j,y]=b.useState("idle"),[S,g]=b.useState(!1),[p,k]=b.useState(null),a=b.useRef(null),d=Me(),f=c.steps[m]??null,M=b.useCallback(()=>{a.current&&(window.clearInterval(a.current),a.current=null)},[]);b.useEffect(()=>M,[M]);const N=b.useCallback((A=s,C=n,w=o)=>{M();const ee=J(F,B,A,C,w);x(ee),h(0),y("planning"),g(!1),k(null),d.playRoutePlanned()},[o,M,n,d,s]),L=b.useCallback(A=>{A!==n&&(d.playAirportSelect(),i(A),N(A,n,o))},[o,n,N,d]),D=b.useCallback(A=>{A!==s&&(d.playAirportSelect(),l(A),N(s,A,o))},[o,N,d,s]),R=b.useCallback(A=>{d.playAirportSelect(),u(A),N(s,n,A)},[n,N,d,s]),I=b.useCallback(A=>{const C=Y.find(w=>w.id===A);C&&(d.playAirportSelect(),i(C.source),l(C.destination),u(C.algorithm),N(C.source,C.destination,C.algorithm))},[N,d]),K=b.useCallback(()=>{y("planning"),h(A=>{const C=Math.min(A+1,c.steps.length-1);return C!==A&&d.playScanStep(C),C})},[c.steps.length,d]),z=b.useCallback(()=>{y("planning"),h(A=>{const C=Math.max(A-1,0);return C!==A&&d.playScanStep(C),C})},[d]),P=b.useCallback(()=>{M();const A=c.plan.path;if(A.length<2)return;y("flying"),g(!0),d.playFlightStart();let C=0,w=0;k({from:A[0],to:A[1],progress:0}),a.current=window.setInterval(()=>{if(w+=.045,w>=1){if(C+=1,w=0,C>=A.length-1){M(),k(null),g(!1),y("complete"),d.playArrive();return}d.playWaypoint(C)}k({from:A[C],to:A[C+1],progress:w})},80)},[M,c.plan.path,d]),q=b.useCallback(()=>{if(S){M(),g(!1),d.playPause();return}y("planning"),g(!0),d.playScanStep(m),a.current=window.setInterval(()=>{h(A=>{if(A>=c.steps.length-1)return M(),g(!1),P(),A;const C=A+1;return d.playScanStep(C),C})},420)},[P,M,S,c.steps.length,d,m]),Q=b.useMemo(()=>{const A=f?.route??c.plan.path;return A.slice(0,-1).map((C,w)=>_(B,C,A[w+1])).filter(Boolean)},[f?.route,c.plan.path]);return{airports:F,routes:B,scenarios:Y,source:s,destination:n,algorithm:o,result:c,currentStep:f,stepIndex:m,phase:j,isPlaying:S,flightProgress:p,activeRoute:Q,soundEnabled:d.soundEnabled,toggleSound:d.toggleSound,changeSource:L,changeDestination:D,changeAlgorithm:R,loadScenario:I,planRoute:N,stepForward:K,stepBack:z,playPlanning:q,animateFlight:P}}function He(){const s=De();return t.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_30%),radial-gradient(circle_at_bottom_right,rgba(59,130,246,0.14),transparent_28%)]",children:[t.jsx("div",{className:"border-b border-slate-800/70 bg-slate-950/75 px-4 py-3 shadow-lg shadow-black/20 backdrop-blur-sm md:px-6",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-sky-400",children:"Airport Network Algorithms"}),t.jsx("h2",{className:"text-lg font-bold text-white",children:"World Map Flight Simulator"})]}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[t.jsx(v,{label:"Algorithm",value:O[s.algorithm].label,tone:"indigo"}),t.jsx(v,{label:"Origin",value:s.source,tone:"sky"}),t.jsx(v,{label:"Destination",value:s.destination,tone:"emerald"}),t.jsx(v,{label:"Stops",value:s.result.plan.stops.toString(),tone:"amber"})]})]})}),t.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[t.jsx(ge,{airports:s.airports,routes:s.routes,source:s.source,destination:s.destination,currentStep:s.currentStep,plan:s.result.plan,flightProgress:s.flightProgress,onSelectSource:s.changeSource,onSelectDestination:s.changeDestination}),t.jsx(be,{airports:s.airports,scenarios:s.scenarios,source:s.source,destination:s.destination,algorithm:s.algorithm,plan:s.result.plan,currentStep:s.currentStep,stepIndex:s.stepIndex,totalSteps:s.result.steps.length,phase:s.phase,isPlaying:s.isPlaying,soundEnabled:s.soundEnabled,onSourceChange:s.changeSource,onDestinationChange:s.changeDestination,onAlgorithmChange:s.changeAlgorithm,onLoadScenario:s.loadScenario,onPlanRoute:()=>s.planRoute(),onStepBack:s.stepBack,onStepForward:s.stepForward,onPlay:s.playPlanning,onFly:s.animateFlight,onToggleSound:s.toggleSound})]})]})}function v({label:s,value:i,tone:n}){const l={indigo:"bg-indigo-500/10 text-indigo-200 ring-indigo-500/25",sky:"bg-sky-500/10 text-sky-200 ring-sky-500/25",emerald:"bg-emerald-500/10 text-emerald-200 ring-emerald-500/25",amber:"bg-amber-500/10 text-amber-200 ring-amber-500/25"};return t.jsxs("div",{className:`rounded-full px-3 py-1.5 text-[10px] ring-1 ${l[n]}`,children:[t.jsx("span",{className:"mr-1 uppercase tracking-wider opacity-60",children:s}),t.jsx("span",{className:"font-mono font-bold",children:i})]})}export{He as default}; +import{c as te,r as b,j as t,P as se}from"./index-DBkLeWDs.js";import{S as ae}from"./shuffle-Dlr-c52A.js";import{C as oe,a as ne}from"./chevron-right-CFBAUJsk.js";import{P as re}from"./play-mcIZClKO.js";import{R as ie}from"./route-C4zDL9m7.js";import{V as le,a as ce}from"./volume-x-BSx9gxSg.js";import{g as de}from"./audioContext-NbgqvQGz.js";const ue=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],he=te("radar",ue),pe=[{name:"North America",path:"M45 82C82 46 145 49 196 75C229 59 287 72 331 102C366 126 369 165 337 188C312 207 287 210 264 235C232 268 178 250 149 222C118 192 78 187 56 150C38 119 28 99 45 82Z",fill:"#14532d"},{name:"Greenland",path:"M285 42C332 20 390 35 404 75C388 111 325 119 286 92C267 78 265 55 285 42Z",fill:"#475569"},{name:"Central America",path:"M246 230C277 232 307 242 329 263C307 276 273 267 246 249C232 240 232 231 246 230Z",fill:"#166534"},{name:"South America",path:"M308 264C352 270 383 315 372 374C364 424 334 474 296 483C281 443 259 405 264 359C269 314 281 281 308 264Z",fill:"#15803d"},{name:"Europe",path:"M438 122C470 96 535 91 575 117C602 137 593 166 558 176C522 186 489 177 454 165C427 156 416 139 438 122Z",fill:"#0f766e"},{name:"Africa",path:"M498 202C553 184 612 223 627 283C640 336 608 409 552 425C514 397 484 340 482 283C480 244 482 216 498 202Z",fill:"#166534"},{name:"Middle East",path:"M572 188C615 178 657 196 674 226C648 245 603 239 580 217C568 206 565 194 572 188Z",fill:"#3f6212"},{name:"Asia",path:"M600 111C683 52 842 83 927 168C910 223 836 246 775 229C728 216 703 257 655 244C611 232 566 159 600 111Z",fill:"#164e63"},{name:"Southeast Asia",path:"M728 252C772 247 824 281 833 322C800 335 755 317 728 287C714 271 714 258 728 252Z",fill:"#0f766e"},{name:"Australia",path:"M794 350C850 316 932 335 949 394C897 437 813 426 774 381C760 365 771 354 794 350Z",fill:"#15803d"},{name:"New Zealand",path:"M958 420C979 425 987 448 970 461C951 456 941 432 958 420Z",fill:"#15803d"}],xe=["M186 78C184 128 197 172 230 214","M126 172C171 164 216 173 260 190","M231 237C262 244 292 252 323 263","M303 280C329 305 342 335 335 374","M336 312C350 304 362 304 376 318","M451 140C482 132 515 134 548 149","M496 171C501 144 518 124 545 111","M529 196C540 236 540 277 530 321","M565 223C594 250 611 286 617 329","M591 190C613 203 639 212 671 221","M638 130C675 145 713 153 754 153","M690 184C729 192 768 201 808 216","M757 238C759 278 770 303 807 320","M835 153C841 191 832 219 808 236","M831 365C861 384 892 394 928 396"],me=[{text:"CANADA",x:160,y:118},{text:"UNITED STATES",x:190,y:178},{text:"MEXICO",x:250,y:222},{text:"BRAZIL",x:338,y:336},{text:"ARGENTINA",x:315,y:424},{text:"EUROPE",x:507,y:139},{text:"NORTH AFRICA",x:548,y:246},{text:"SOUTH AFRICA",x:560,y:390},{text:"MIDDLE EAST",x:632,y:210},{text:"INDIA",x:710,y:232},{text:"CHINA",x:779,y:173},{text:"JAPAN",x:890,y:161},{text:"SOUTHEAST ASIA",x:770,y:295},{text:"AUSTRALIA",x:860,y:390}];function ge({airports:s,routes:i,source:n,destination:l,currentStep:o,plan:u,flightProgress:c,onSelectSource:x,onSelectDestination:m}){const h=b.useMemo(()=>new Map(s.map(a=>[a.code,a])),[s]),j=new Set(o?.visited??[]),y=new Set((o?.frontier??[]).map(a=>a.code)),S=o?.route?.length?o.route:u.path,g=new Set(S.slice(0,-1).map((a,d)=>[a,S[d+1]].sort().join("-"))),p=o?.relaxedRoute?[o.relaxedRoute.from,o.relaxedRoute.to].sort().join("-"):null,k=b.useMemo(()=>{if(!c)return null;const a=h.get(c.from),d=h.get(c.to);if(!a||!d)return null;const f=Math.sin(c.progress*Math.PI)*-44;return{x:a.x+(d.x-a.x)*c.progress,y:a.y+(d.y-a.y)*c.progress+f,angle:Math.atan2(d.y-a.y,d.x-a.x)*(180/Math.PI)}},[h,c]);return t.jsxs("div",{className:"relative min-h-[620px] flex-1 overflow-hidden rounded-[1.75rem] border border-slate-700/50 bg-slate-950/90 shadow-2xl shadow-black/40",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_18%_22%,rgba(14,165,233,0.16),transparent_28%),radial-gradient(circle_at_78%_72%,rgba(59,130,246,0.12),transparent_30%)]"}),t.jsxs("div",{className:"absolute left-5 top-5 z-20 rounded-2xl border border-slate-700/60 bg-slate-950/85 p-4 shadow-xl shadow-black/30 backdrop-blur-sm",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-sky-400",children:"Global Air Traffic Network"}),t.jsxs("div",{className:"mt-2 flex gap-4 text-xs text-slate-300",children:[t.jsxs("span",{children:[t.jsx("strong",{className:"font-mono text-white",children:s.length})," airports"]}),t.jsxs("span",{children:[t.jsx("strong",{className:"font-mono text-white",children:i.length})," routes"]}),t.jsxs("span",{children:[t.jsx("strong",{className:"font-mono text-white",children:u.path.length||0})," hops"]})]})]}),o&&t.jsxs("div",{className:"absolute bottom-5 left-5 z-20 max-w-md rounded-2xl border border-slate-700/60 bg-slate-950/90 p-4 shadow-xl shadow-black/35 backdrop-blur-sm",children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-indigo-300",children:"Algorithm Radar"}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-slate-300",children:o.description}),o.frontier.length>0&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:o.frontier.slice(0,7).map(a=>t.jsxs("span",{className:"rounded-full bg-sky-500/10 px-2 py-1 text-[10px] font-mono font-semibold text-sky-300 ring-1 ring-sky-500/25",children:[a.code,": ",Number.isFinite(a.priority)?a.priority:"∞"]},`${a.code}-${a.priority}`))})]}),t.jsxs("svg",{viewBox:"0 0 1000 520",className:"relative z-10 h-full w-full",preserveAspectRatio:"xMidYMid meet",children:[t.jsxs("defs",{children:[t.jsxs("filter",{id:"world-glow",x:"-40%",y:"-40%",width:"180%",height:"180%",children:[t.jsx("feGaussianBlur",{stdDeviation:"4",result:"blur"}),t.jsxs("feMerge",{children:[t.jsx("feMergeNode",{in:"blur"}),t.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),t.jsx("filter",{id:"world-shadow",x:"-60%",y:"-60%",width:"220%",height:"220%",children:t.jsx("feDropShadow",{dx:"0",dy:"8",stdDeviation:"6",floodColor:"#020617",floodOpacity:"0.7"})}),t.jsxs("linearGradient",{id:"ocean",x1:"0",x2:"1",y1:"0",y2:"1",children:[t.jsx("stop",{offset:"0%",stopColor:"#07111f"}),t.jsx("stop",{offset:"55%",stopColor:"#082f49"}),t.jsx("stop",{offset:"100%",stopColor:"#020617"})]})]}),t.jsx("rect",{width:"1000",height:"520",rx:"28",fill:"url(#ocean)"}),[130,260,390].map(a=>t.jsx("path",{d:`M0 ${a}H1000`,stroke:"#38bdf8",strokeOpacity:"0.1",strokeDasharray:"7 10"},`lat-${a}`)),[125,250,375,500,625,750,875].map(a=>t.jsx("path",{d:`M${a} 0V520`,stroke:"#38bdf8",strokeOpacity:"0.08",strokeDasharray:"7 10"},`lon-${a}`)),t.jsx("path",{d:"M0 260H1000",stroke:"#67e8f9",strokeOpacity:"0.2",strokeDasharray:"8 9"}),t.jsx("path",{d:"M500 0V520",stroke:"#67e8f9",strokeOpacity:"0.14",strokeDasharray:"8 9"}),t.jsx("g",{filter:"url(#world-shadow)",children:pe.map(a=>t.jsx("path",{d:a.path,fill:a.fill,fillOpacity:"0.78",stroke:"#a7f3d0",strokeOpacity:"0.42",strokeWidth:"1.8"},a.name))}),t.jsx("g",{children:xe.map(a=>t.jsx("path",{d:a,fill:"none",stroke:"#d1fae5",strokeOpacity:"0.22",strokeWidth:"1",strokeDasharray:"4 5"},a))}),t.jsx("g",{children:me.map(a=>t.jsx("text",{x:a.x,y:a.y,textAnchor:"middle",fontSize:"11",fontWeight:"800",letterSpacing:"1.4",fill:"#e2e8f0",fillOpacity:"0.28",children:a.text},a.text))}),i.map(a=>{const d=h.get(a.source),f=h.get(a.destination);if(!d||!f)return null;const M=[a.source,a.destination].sort().join("-"),N=g.has(M),L=M===p,D=L?"#facc15":N?"#22c55e":"#334155",R=Math.min(120,Math.abs(d.x-f.x)*.12+28),I=(d.x+f.x)/2,K=(d.y+f.y)/2-R;return t.jsx("g",{children:t.jsx("path",{d:`M${d.x},${d.y} Q${I},${K} ${f.x},${f.y}`,fill:"none",stroke:D,strokeWidth:N||L?3:1.2,strokeOpacity:N||L?.92:.24,strokeDasharray:N?void 0:"5 8",filter:N||L?"url(#world-glow)":void 0})},a.id)}),s.map(a=>{const d=a.code===n,f=a.code===l,M=j.has(a.code),N=y.has(a.code),L=o?.airportCode===a.code,D=d||f||L||N||M||a.hubScore>=92,R=d?"#fde047":f?"#fb923c":L?"#38bdf8":M?"#22c55e":N?"#a78bfa":"#94a3b8";return t.jsxs("g",{className:"cursor-pointer",children:[t.jsxs("title",{children:[a.code," - ",a.city,", ",a.country]}),t.jsx("circle",{cx:a.x,cy:a.y,r:d||f?12:8,fill:"#020617",stroke:"#0f172a",strokeWidth:7,filter:"url(#world-shadow)"}),t.jsx("circle",{cx:a.x,cy:a.y,r:d||f?9:6,fill:R,fillOpacity:d||f||M||N||L?.96:.58,stroke:R,strokeWidth:L?4:2,onClick:I=>{I.shiftKey?m(a.code):x(a.code)}}),D&&t.jsx("text",{x:a.x,y:a.y-14,textAnchor:"middle",fontSize:"10",fontWeight:"800",fontFamily:"ui-monospace, monospace",fill:R,children:a.code})]},a.code)}),k&&t.jsxs("g",{transform:`translate(${k.x} ${k.y}) rotate(${k.angle})`,filter:"url(#world-glow)",children:[t.jsx("path",{d:"M-14 -5L18 0L-14 5L-8 0Z",fill:"#f8fafc",stroke:"#38bdf8",strokeWidth:"1.2"}),t.jsx("path",{d:"M-5 -3L-12 -13L2 -4Z",fill:"#bae6fd",opacity:"0.9"}),t.jsx("path",{d:"M-5 3L-12 13L2 4Z",fill:"#bae6fd",opacity:"0.9"})]})]}),t.jsxs("div",{className:"absolute bottom-5 right-5 z-20 hidden rounded-2xl border border-slate-700/60 bg-slate-950/85 p-4 text-[10px] text-slate-400 shadow-xl shadow-black/30 backdrop-blur-sm sm:block",children:[t.jsx("div",{className:"mb-2 font-semibold uppercase tracking-[0.24em] text-slate-500",children:"Tip"}),"Click an airport to set origin. Shift-click to set destination."]})]})}const O={dijkstra:{label:"Dijkstra",description:"Finds the lowest total travel time by relaxing routes through a priority queue.",metric:"Shortest time"},astar:{label:"A* Search",description:"Uses distance-to-destination as a heuristic to guide the priority queue.",metric:"Guided shortest path"},bfs:{label:"BFS",description:"Ignores weights and searches by fewest airport connections.",metric:"Fewest stops"},greedy:{label:"Greedy",description:"Always flies toward the airport geographically closest to the destination.",metric:"Nearest-looking route"}},fe=["dijkstra","astar","bfs","greedy"];function be({airports:s,scenarios:i,source:n,destination:l,algorithm:o,plan:u,currentStep:c,stepIndex:x,totalSteps:m,phase:h,isPlaying:j,soundEnabled:y,onSourceChange:S,onDestinationChange:g,onAlgorithmChange:p,onLoadScenario:k,onPlanRoute:a,onStepBack:d,onStepForward:f,onPlay:M,onFly:N,onToggleSound:L}){return t.jsxs("aside",{className:"flex w-full shrink-0 flex-col gap-4 overflow-y-auto xl:w-88",children:[t.jsxs("section",{className:"rounded-2xl border border-sky-500/20 bg-slate-950/75 p-4 shadow-2xl shadow-black/30 backdrop-blur-sm",children:[t.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-sky-500/15 text-sky-300 ring-1 ring-sky-500/30",children:t.jsx(se,{size:18})}),t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-bold text-white",children:"World Flight Planner"}),t.jsx("p",{className:"text-[10px] text-slate-500",children:"Airport-code simulator inspired by public airport datasets."})]})]}),t.jsx("p",{className:"text-xs leading-relaxed text-slate-400",children:"Pick countries through their major airport codes, then compare how different algorithms choose routes across global hubs."})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Travel Request"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(X,{label:"Origin",value:n,airports:s,onChange:S}),t.jsx(X,{label:"Destination",value:l,airports:s,onChange:g})]}),t.jsxs("button",{onClick:a,className:"mt-3 flex w-full items-center justify-center gap-2 rounded-xl bg-sky-500/15 px-3 py-2 text-xs font-semibold text-sky-300 ring-1 ring-sky-500/30 transition hover:bg-sky-500/25",children:[t.jsx(he,{size:13})," Recalculate route"]})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Algorithms"}),t.jsx("div",{className:"grid gap-2",children:fe.map(D=>t.jsxs("button",{onClick:()=>p(D),className:`rounded-xl p-3 text-left transition ${o===D?"bg-indigo-500/15 text-indigo-200 ring-1 ring-indigo-500/35":"bg-slate-900/70 text-slate-400 ring-1 ring-slate-800/80 hover:bg-slate-800/80"}`,children:[t.jsxs("span",{className:"flex items-center justify-between text-xs font-bold",children:[O[D].label,t.jsx("span",{className:"text-[9px] uppercase tracking-wider opacity-60",children:O[D].metric})]}),t.jsx("span",{className:"mt-1 block text-[10px] leading-snug opacity-75",children:O[D].description})]},D))})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Preset Missions"}),t.jsx("div",{className:"grid gap-2",children:i.map(D=>t.jsxs("button",{onClick:()=>k(D.id),className:"rounded-xl bg-slate-900/70 p-3 text-left ring-1 ring-slate-800/80 transition hover:bg-slate-800/80",children:[t.jsxs("span",{className:"flex items-center gap-2 text-xs font-bold text-slate-200",children:[t.jsx(ae,{size:12})," ",D.title]}),t.jsx("span",{className:"mt-1 block text-[10px] leading-snug text-slate-500",children:D.description})]},D.id))})]}),t.jsxs("section",{className:"rounded-2xl border border-emerald-500/20 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Flight Plan"}),t.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[9px] font-bold uppercase tracking-wider text-emerald-300 ring-1 ring-emerald-500/25",children:h})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(H,{label:"Distance",value:`${u.totalDistanceKm.toLocaleString()} km`}),t.jsx(H,{label:"Duration",value:`${u.totalDurationHours}h`}),t.jsx(H,{label:"Stops",value:u.stops.toString()}),t.jsx(H,{label:"Est. Cost",value:`$${u.totalCostUsd.toLocaleString()}`})]}),t.jsxs("div",{className:"mt-3 rounded-xl bg-slate-900/70 p-3 ring-1 ring-slate-800/80",children:[t.jsx("p",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:"Route"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:u.path.map((D,R)=>t.jsx("span",{className:"rounded-md bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-mono font-semibold text-emerald-300 ring-1 ring-emerald-500/20",children:D},`${D}-${R}`))})]})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Simulation"}),t.jsxs("div",{className:"mb-3 flex items-center justify-between text-[10px] text-slate-500",children:[t.jsx("span",{children:"Step"}),t.jsxs("span",{className:"font-mono text-indigo-300",children:[Math.min(x+1,m)," / ",m]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsxs("button",{onClick:d,disabled:x<=0,className:"flex items-center justify-center gap-1 rounded-xl bg-slate-900/70 px-2 py-2 text-xs text-slate-400 ring-1 ring-slate-800/80 disabled:opacity-30",children:[t.jsx(oe,{size:13})," Back"]}),t.jsxs("button",{onClick:M,className:"flex items-center justify-center gap-1 rounded-xl bg-indigo-500/15 px-2 py-2 text-xs font-semibold text-indigo-300 ring-1 ring-indigo-500/30",children:[t.jsx(re,{size:13})," ",j?"Pause":"Play"]}),t.jsxs("button",{onClick:f,disabled:x>=m-1,className:"flex items-center justify-center gap-1 rounded-xl bg-slate-900/70 px-2 py-2 text-xs text-slate-400 ring-1 ring-slate-800/80 disabled:opacity-30",children:["Next ",t.jsx(ne,{size:13})]})]}),t.jsxs("button",{onClick:N,className:"mt-2 flex w-full items-center justify-center gap-2 rounded-xl bg-emerald-500/15 px-3 py-2 text-xs font-semibold text-emerald-300 ring-1 ring-emerald-500/30 transition hover:bg-emerald-500/25",children:[t.jsx(ie,{size:13})," Animate airplane"]}),c&&t.jsx("p",{className:"mt-3 text-xs leading-relaxed text-slate-400",children:c.description})]}),t.jsxs("section",{className:"rounded-2xl border border-slate-700/50 bg-slate-950/75 p-4 shadow-xl shadow-black/20 backdrop-blur-sm",children:[t.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Audio"}),t.jsxs("button",{onClick:()=>L(!y),className:`flex w-full items-center justify-center gap-2 rounded-xl px-3 py-2 text-xs font-semibold ring-1 transition ${y?"bg-sky-500/15 text-sky-300 ring-sky-500/30 hover:bg-sky-500/25":"bg-slate-900/70 text-slate-400 ring-slate-800/80 hover:bg-slate-800/80"}`,children:[y?t.jsx(le,{size:13}):t.jsx(ce,{size:13}),y?"Sound On":"Sound Off"]}),t.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-slate-500",children:"Radar pings mark search steps, with takeoff, waypoint, and arrival tones during flight."})]})]})}function X({label:s,value:i,airports:n,onChange:l}){return t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-slate-500",children:s}),t.jsx("select",{value:i,onChange:o=>l(o.target.value),className:"w-full rounded-xl border border-slate-700 bg-slate-900 px-3 py-2 text-xs font-mono text-slate-200 outline-none ring-sky-500/20 focus:ring-2",children:n.map(o=>t.jsxs("option",{value:o.code,children:[o.code," - ",o.city]},o.code))})]})}function H({label:s,value:i}){return t.jsxs("div",{className:"rounded-xl bg-slate-900/70 p-3 ring-1 ring-slate-800/80",children:[t.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wider text-slate-500",children:s}),t.jsx("div",{className:"mt-1 font-mono text-sm font-black text-white",children:i})]})}function Ae(s,i){return{x:(s+180)/360*1e3,y:(90-i)/180*520}}function r(s,i,n,l,o,u,c){return{code:s,city:i,country:n,region:l,lat:o,lon:u,hubScore:c,...Ae(u,o)}}const F=[r("ATL","Atlanta","United States","North America",33.6407,-84.4277,98),r("ORD","Chicago","United States","North America",41.9742,-87.9073,96),r("DFW","Dallas-Fort Worth","United States","North America",32.8998,-97.0403,94),r("JFK","New York","United States","North America",40.6413,-73.7781,96),r("LAX","Los Angeles","United States","North America",33.9416,-118.4085,94),r("MIA","Miami","United States","North America",25.7959,-80.287,88),r("SEA","Seattle","United States","North America",47.4502,-122.3088,84),r("SFO","San Francisco","United States","North America",37.6213,-122.379,90),r("YVR","Vancouver","Canada","North America",49.1967,-123.1815,76),r("YYZ","Toronto","Canada","North America",43.6777,-79.6248,78),r("MEX","Mexico City","Mexico","North America",19.4361,-99.0719,76),r("BOG","Bogota","Colombia","South America",4.7016,-74.1469,78),r("LIM","Lima","Peru","South America",-12.0219,-77.1143,76),r("EZE","Buenos Aires","Argentina","South America",-34.8222,-58.5358,74),r("GRU","Sao Paulo","Brazil","South America",-23.4356,-46.4731,84),r("SCL","Santiago","Chile","South America",-33.3928,-70.7858,72),r("AMS","Amsterdam","Netherlands","Europe",52.3105,4.7683,93),r("ARN","Stockholm","Sweden","Europe",59.6498,17.9238,70),r("ATH","Athens","Greece","Europe",37.9364,23.9445,72),r("BCN","Barcelona","Spain","Europe",41.2974,2.0833,76),r("BRU","Brussels","Belgium","Europe",50.9014,4.4844,74),r("CPH","Copenhagen","Denmark","Europe",55.618,12.6561,74),r("LHR","London","United Kingdom","Europe",51.47,-.4543,98),r("CDG","Paris","France","Europe",49.0097,2.5479,94),r("DUB","Dublin","Ireland","Europe",53.4264,-6.2499,70),r("FCO","Rome","Italy","Europe",41.8003,12.2389,78),r("FRA","Frankfurt","Germany","Europe",50.0379,8.5622,96),r("HEL","Helsinki","Finland","Europe",60.3172,24.9633,70),r("LIS","Lisbon","Portugal","Europe",38.7742,-9.1342,70),r("MAD","Madrid","Spain","Europe",40.4983,-3.5676,82),r("MUC","Munich","Germany","Europe",48.3538,11.7861,84),r("VIE","Vienna","Austria","Europe",48.1103,16.5697,76),r("WAW","Warsaw","Poland","Europe",52.1657,20.9671,70),r("ZRH","Zurich","Switzerland","Europe",47.4581,8.5555,82),r("IST","Istanbul","Turkey","Europe/Asia",41.2753,28.7519,92),r("ADD","Addis Ababa","Ethiopia","Africa",8.9779,38.7993,82),r("CMN","Casablanca","Morocco","Africa",33.3675,-7.58997,74),r("CAI","Cairo","Egypt","Africa",30.112,31.4003,70),r("CPT","Cape Town","South Africa","Africa",-33.9715,18.6021,70),r("LOS","Lagos","Nigeria","Africa",6.5774,3.3212,72),r("JNB","Johannesburg","South Africa","Africa",-26.1337,28.242,80),r("NBO","Nairobi","Kenya","Africa",-1.3192,36.9278,68),r("AUH","Abu Dhabi","United Arab Emirates","Middle East",24.433,54.6511,82),r("DXB","Dubai","United Arab Emirates","Middle East",25.2532,55.3657,99),r("DOH","Doha","Qatar","Middle East",25.2731,51.6081,88),r("JED","Jeddah","Saudi Arabia","Middle East",21.6796,39.1565,78),r("RUH","Riyadh","Saudi Arabia","Middle East",24.9576,46.6988,76),r("TLV","Tel Aviv","Israel","Middle East",32.0114,34.8867,74),r("BKK","Bangkok","Thailand","Asia",13.69,100.7501,88),r("BLR","Bengaluru","India","Asia",13.1986,77.7066,76),r("BOM","Mumbai","India","Asia",19.0896,72.8656,84),r("CAN","Guangzhou","China","Asia",23.3924,113.2988,86),r("CGK","Jakarta","Indonesia","Asia",-6.1256,106.6559,82),r("DEL","Delhi","India","Asia",28.5562,77.1,86),r("HKG","Hong Kong","China","Asia",22.308,113.9185,92),r("SIN","Singapore","Singapore","Asia",1.3644,103.9915,96),r("ICN","Seoul","South Korea","Asia",37.4602,126.4407,94),r("KUL","Kuala Lumpur","Malaysia","Asia",2.7456,101.7072,82),r("MNL","Manila","Philippines","Asia",14.5086,121.0194,78),r("PEK","Beijing","China","Asia",40.0799,116.6031,90),r("PVG","Shanghai","China","Asia",31.1443,121.8083,92),r("TPE","Taipei","Taiwan","Asia",25.0797,121.2342,82),r("HND","Tokyo","Japan","Asia",35.5494,139.7798,95),r("BNE","Brisbane","Australia","Oceania",-27.3842,153.1175,70),r("MEL","Melbourne","Australia","Oceania",-37.669,144.841,78),r("PER","Perth","Australia","Oceania",-31.9403,115.9672,72),r("SYD","Sydney","Australia","Oceania",-33.9399,151.1753,84),r("AKL","Auckland","New Zealand","Oceania",-37.0082,174.785,66)],V=new Map(F.map(s=>[s.code,s]));function ye(s,i){const l=h=>h*Math.PI/180,o=l(i.lat-s.lat),u=l(i.lon-s.lon),c=l(s.lat),x=l(i.lat),m=Math.sin(o/2)**2+Math.cos(c)*Math.cos(x)*Math.sin(u/2)**2;return Math.round(2*6371*Math.asin(Math.sqrt(m)))}function e(s,i){const n=V.get(s),l=V.get(i);if(!n||!l)throw new Error(`Unknown airport route: ${s}-${i}`);const o=ye(n,l);return{id:`${s}-${i}`,source:s,destination:i,distanceKm:o,durationHours:Math.round((o/870+.65)*10)/10,costUsd:Math.round(o*.11+140)}}const B=[e("ATL","DFW"),e("ATL","JFK"),e("ATL","LAX"),e("ATL","MIA"),e("ATL","ORD"),e("ATL","YYZ"),e("ORD","DFW"),e("ORD","JFK"),e("ORD","LAX"),e("ORD","SEA"),e("ORD","SFO"),e("ORD","YYZ"),e("DFW","LAX"),e("DFW","MEX"),e("DFW","MIA"),e("DFW","SFO"),e("JFK","LAX"),e("JFK","YYZ"),e("JFK","LHR"),e("JFK","CDG"),e("JFK","AMS"),e("JFK","FRA"),e("JFK","MEX"),e("JFK","MIA"),e("JFK","SFO"),e("JFK","MAD"),e("JFK","DUB"),e("JFK","GRU"),e("LAX","HND"),e("LAX","ICN"),e("LAX","PVG"),e("LAX","SIN"),e("LAX","SYD"),e("LAX","MEX"),e("LAX","SFO"),e("LAX","SEA"),e("LAX","YVR"),e("YYZ","LHR"),e("YYZ","AMS"),e("YYZ","FRA"),e("YYZ","YVR"),e("MIA","BOG"),e("MIA","GRU"),e("MIA","LIM"),e("MIA","MEX"),e("SEA","YVR"),e("SEA","HND"),e("SEA","ICN"),e("SFO","HKG"),e("SFO","HND"),e("SFO","ICN"),e("SFO","SIN"),e("YVR","HND"),e("YVR","ICN"),e("MEX","BOG"),e("MEX","GRU"),e("MEX","LIM"),e("MEX","SCL"),e("BOG","GRU"),e("BOG","LIM"),e("BOG","MAD"),e("LIM","EZE"),e("LIM","SCL"),e("LIM","GRU"),e("EZE","GRU"),e("EZE","MAD"),e("EZE","SCL"),e("GRU","SCL"),e("GRU","MAD"),e("GRU","LIS"),e("GRU","CDG"),e("GRU","JNB"),e("SCL","AKL"),e("AMS","BRU"),e("AMS","CPH"),e("AMS","DUB"),e("AMS","FRA"),e("AMS","LHR"),e("AMS","ZRH"),e("ARN","CPH"),e("ARN","HEL"),e("ARN","LHR"),e("ATH","FCO"),e("ATH","IST"),e("ATH","VIE"),e("BCN","FCO"),e("BCN","LHR"),e("BCN","MAD"),e("BRU","CDG"),e("BRU","FRA"),e("CPH","FRA"),e("CPH","HEL"),e("CPH","LHR"),e("LHR","CDG"),e("LHR","MAD"),e("LHR","FRA"),e("LHR","ZRH"),e("LHR","DUB"),e("LHR","FCO"),e("LHR","DXB"),e("LHR","DOH"),e("LHR","SIN"),e("CDG","MAD"),e("CDG","FRA"),e("CDG","FCO"),e("CDG","IST"),e("CDG","DXB"),e("DUB","LIS"),e("FCO","IST"),e("FCO","MAD"),e("FRA","IST"),e("FRA","MUC"),e("FRA","VIE"),e("FRA","ZRH"),e("FRA","DXB"),e("HEL","WAW"),e("LIS","MAD"),e("MAD","CMN"),e("MAD","CAI"),e("MAD","DOH"),e("MUC","VIE"),e("MUC","ZRH"),e("VIE","WAW"),e("VIE","IST"),e("WAW","IST"),e("ZRH","VIE"),e("IST","ADD"),e("IST","CAI"),e("IST","DXB"),e("IST","DOH"),e("IST","TLV"),e("ADD","CAI"),e("ADD","JNB"),e("ADD","NBO"),e("ADD","DXB"),e("CMN","CAI"),e("CMN","LIS"),e("CMN","LOS"),e("CAI","JNB"),e("CAI","NBO"),e("CAI","JED"),e("CAI","RUH"),e("CAI","TLV"),e("CPT","JNB"),e("CPT","ADD"),e("CPT","DXB"),e("LOS","ADD"),e("LOS","JNB"),e("JNB","NBO"),e("JNB","SYD"),e("JNB","DXB"),e("NBO","DXB"),e("NBO","DOH"),e("AUH","BOM"),e("AUH","DEL"),e("AUH","JED"),e("AUH","LHR"),e("AUH","SIN"),e("DXB","DOH"),e("DXB","AUH"),e("DXB","DEL"),e("DXB","BOM"),e("DXB","BKK"),e("DXB","SIN"),e("DXB","HKG"),e("DXB","SYD"),e("DOH","BOM"),e("DOH","DEL"),e("DOH","JED"),e("DOH","SIN"),e("DOH","SYD"),e("JED","RUH"),e("JED","DEL"),e("RUH","DXB"),e("TLV","ATH"),e("TLV","DXB"),e("BKK","DEL"),e("BKK","HKG"),e("BKK","KUL"),e("BKK","SIN"),e("BKK","TPE"),e("BLR","BOM"),e("BLR","DEL"),e("BLR","SIN"),e("BOM","DEL"),e("BOM","SIN"),e("BOM","LHR"),e("CAN","HKG"),e("CAN","PEK"),e("CAN","PVG"),e("CAN","SIN"),e("CGK","KUL"),e("CGK","SIN"),e("CGK","SYD"),e("DEL","SIN"),e("DEL","HND"),e("DEL","HKG"),e("DEL","ICN"),e("HKG","ICN"),e("HKG","MNL"),e("HKG","PVG"),e("HKG","SIN"),e("HKG","TPE"),e("ICN","HND"),e("ICN","PEK"),e("ICN","PVG"),e("SIN","HND"),e("SIN","KUL"),e("SIN","MNL"),e("SIN","SYD"),e("KUL","MNL"),e("KUL","PER"),e("MNL","HND"),e("PEK","HND"),e("PEK","PVG"),e("PEK","SFO"),e("PVG","HND"),e("PVG","TPE"),e("TPE","HND"),e("HND","SYD"),e("HND","BNE"),e("BNE","SYD"),e("BNE","MEL"),e("MEL","SYD"),e("MEL","AKL"),e("PER","MEL"),e("PER","SYD"),e("PER","SIN"),e("SYD","AKL")],Y=[{id:"trans-atlantic",title:"New York to Tokyo",description:"Compare westbound Pacific hops against eastbound European and Gulf hub routes.",source:"JFK",destination:"HND",algorithm:"dijkstra"},{id:"southern-cross",title:"London to Sydney",description:"Route across Europe, the Gulf, Asia, and Oceania using weighted flight times.",source:"LHR",destination:"SYD",algorithm:"astar"},{id:"africa-to-americas",title:"Johannesburg to Los Angeles",description:"Study how different algorithms connect Africa to the Americas through major hubs.",source:"JNB",destination:"LAX",algorithm:"greedy"},{id:"fewest-stops",title:"Toronto to Singapore",description:"Use BFS to minimize the number of airport connections, ignoring flight duration.",source:"YYZ",destination:"SIN",algorithm:"bfs"}];function W(s){return new Map(s.map(i=>[i.code,i]))}function G(s,i){return s.flatMap(n=>n.source===i?[{code:n.destination,route:n}]:n.destination===i?[{code:n.source,route:n}]:[])}function _(s,i,n){return s.find(l=>l.source===i&&l.destination===n||l.source===n&&l.destination===i)??null}function J(s,i,n,l,o){return o==="bfs"?Ne(s,i,n,l):o==="greedy"?Ce(s,i,n,l):Se(s,i,n,l,o)}function Se(s,i,n,l,o){const u=W(s),c={},x={},m=new Set,h=[{code:n,priority:0}],j=[];for(const g of s)c[g.code]=g.code===n?0:1/0,x[g.code]=null;for(j.push(E("init",n,`Start at ${n}. Set its travel time to 0 and every other airport to infinity.`,m,h,c,x));h.length>0;){h.sort((p,k)=>p.priority-k.priority);const g=h.shift();if(!m.has(g.code)){if(m.add(g.code),j.push(E("select",g.code,`Select ${g.code}, the airport with the best current priority.`,m,h,c,x)),g.code===l)break;for(const p of G(i,g.code)){if(m.has(p.code))continue;const k=c[g.code]+p.route.durationHours;if(k ${p.code} improves the route to ${c[p.code]}h.`,m,h,c,x,{from:g.code,to:p.code}))}else j.push(E("dead-end",p.code,`${g.code} -> ${p.code} is slower than the best known route.`,m,h,c,x,{from:g.code,to:p.code}))}}}const y=U(x,n,l),S=$(i,y);return j.push(E("done",l,`Route complete: ${y.join(" -> ")}`,m,h,c,x,void 0,y)),{steps:j,plan:S}}function Ne(s,i,n,l){const o=new Set([n]),u={},c={},x=[{code:n,priority:0}],m=[];for(const y of s)u[y.code]=null,c[y.code]=y.code===n?0:1/0;for(m.push(E("init",n,`Start BFS at ${n}. Each edge counts as one airport hop.`,o,x,c,u));x.length>0;){const y=x.shift();if(m.push(E("select",y.code,`Visit ${y.code} and enqueue all unseen connected airports.`,o,x,c,u)),y.code===l)break;for(const S of G(i,y.code))o.has(S.code)||(o.add(S.code),u[S.code]=y.code,c[S.code]=c[y.code]+1,x.push({code:S.code,priority:c[S.code]}),m.push(E("enqueue",S.code,`Add ${S.code} to the BFS queue at hop ${c[S.code]}.`,o,x,c,u,{from:y.code,to:S.code})))}const h=U(u,n,l),j=$(i,h);return m.push(E("done",l,`Fewest-stop route complete: ${h.join(" -> ")}`,o,x,c,u,void 0,h)),{steps:m,plan:j}}function Ce(s,i,n,l){const o=W(s),u=new Set,c={},x={},m=[];let h=n;for(const S of s)c[S.code]=null,x[S.code]=S.code===n?0:1/0;for(m.push(E("init",n,`Start greedy routing at ${n}. Always choose the neighbor closest to ${l}.`,u,[{code:n,priority:0}],x,c));h!==l;){u.add(h);const S=G(i,h).filter(p=>!u.has(p.code)).sort((p,k)=>T(o.get(p.code),o.get(l))-T(o.get(k.code),o.get(l)));if(m.push(E("select",h,`From ${h}, compare nearby hubs by straight-line distance to ${l}.`,u,S.map(p=>({code:p.code,priority:Math.round(T(o.get(p.code),o.get(l))*10)/10})),x,c)),S.length===0)break;const g=S[0];x[g.code]=Math.round((x[h]+g.route.durationHours)*10)/10,c[g.code]=h,m.push(E("relax",g.code,`Greedy picks ${g.code} as the closest-looking next airport.`,u,[],x,c,{from:h,to:g.code})),h=g.code}const j=U(c,n,l),y=$(i,j);return m.push(E("done",l,`Greedy route complete: ${j.join(" -> ")}`,u,[],x,c,void 0,j)),{steps:m,plan:y}}function E(s,i,n,l,o,u,c,x,m){return{type:s,airportCode:i,description:n,visited:Array.from(l),frontier:o.map(h=>({code:h.code,priority:h.priority})),distances:{...u},previous:{...c},relaxedRoute:x,route:m}}function U(s,i,n){const l=[];let o=n;for(;o&&(l.unshift(o),o!==i);)o=s[o];return l[0]===i?l:[]}function $(s,i){let n=0,l=0,o=0;for(let u=0;ude(),[]),o=b.useCallback((p,k,a="sine",d=.045)=>{if(!s.current)return;const f=l();if(!f)return;const M=f.createOscillator(),N=f.createGain();M.type=a,M.frequency.setValueAtTime(p,f.currentTime),N.gain.setValueAtTime(d,f.currentTime),N.gain.exponentialRampToValueAtTime(.001,f.currentTime+k),M.connect(N),N.connect(f.destination),M.start(f.currentTime),M.stop(f.currentTime+k)},[l]),u=b.useCallback((p,k,a,d=.04)=>{if(!s.current)return;const f=l();f&&p.forEach((M,N)=>{const L=f.createOscillator(),D=f.createGain(),R=f.currentTime+N*a*.75;L.type=k,L.frequency.setValueAtTime(M,R),D.gain.setValueAtTime(d,R),D.gain.exponentialRampToValueAtTime(.001,R+a),L.connect(D),D.connect(f.destination),L.start(R),L.stop(R+a)})},[l]),c=b.useCallback(()=>{o(523.25,.08,"triangle",.035)},[o]),x=b.useCallback(()=>{u([392,523.25,659.25],"sine",.1,.045)},[u]),m=b.useCallback(p=>{o(Z[p%Z.length],.055,"sine",.025)},[o]),h=b.useCallback(()=>{u([196,246.94,329.63,392],"triangle",.09,.04)},[u]),j=b.useCallback(p=>{o(p%2===0?587.33:659.25,.09,"triangle",.035)},[o]),y=b.useCallback(()=>{u([523.25,659.25,783.99,1046.5],"sine",.11,.05)},[u]),S=b.useCallback(()=>{o(220,.08,"sawtooth",.025)},[o]),g=b.useCallback(p=>{s.current=p,n(p)},[]);return{soundEnabled:i,toggleSound:g,playAirportSelect:c,playRoutePlanned:x,playScanStep:m,playFlightStart:h,playWaypoint:j,playArrive:y,playPause:S}}function De(){const[s,i]=b.useState("JFK"),[n,l]=b.useState("HND"),[o,u]=b.useState("dijkstra"),[c,x]=b.useState(()=>J(F,B,"JFK","HND","dijkstra")),[m,h]=b.useState(0),[j,y]=b.useState("idle"),[S,g]=b.useState(!1),[p,k]=b.useState(null),a=b.useRef(null),d=Me(),f=c.steps[m]??null,M=b.useCallback(()=>{a.current&&(window.clearInterval(a.current),a.current=null)},[]);b.useEffect(()=>M,[M]);const N=b.useCallback((A=s,C=n,w=o)=>{M();const ee=J(F,B,A,C,w);x(ee),h(0),y("planning"),g(!1),k(null),d.playRoutePlanned()},[o,M,n,d,s]),L=b.useCallback(A=>{A!==n&&(d.playAirportSelect(),i(A),N(A,n,o))},[o,n,N,d]),D=b.useCallback(A=>{A!==s&&(d.playAirportSelect(),l(A),N(s,A,o))},[o,N,d,s]),R=b.useCallback(A=>{d.playAirportSelect(),u(A),N(s,n,A)},[n,N,d,s]),I=b.useCallback(A=>{const C=Y.find(w=>w.id===A);C&&(d.playAirportSelect(),i(C.source),l(C.destination),u(C.algorithm),N(C.source,C.destination,C.algorithm))},[N,d]),K=b.useCallback(()=>{y("planning"),h(A=>{const C=Math.min(A+1,c.steps.length-1);return C!==A&&d.playScanStep(C),C})},[c.steps.length,d]),z=b.useCallback(()=>{y("planning"),h(A=>{const C=Math.max(A-1,0);return C!==A&&d.playScanStep(C),C})},[d]),P=b.useCallback(()=>{M();const A=c.plan.path;if(A.length<2)return;y("flying"),g(!0),d.playFlightStart();let C=0,w=0;k({from:A[0],to:A[1],progress:0}),a.current=window.setInterval(()=>{if(w+=.045,w>=1){if(C+=1,w=0,C>=A.length-1){M(),k(null),g(!1),y("complete"),d.playArrive();return}d.playWaypoint(C)}k({from:A[C],to:A[C+1],progress:w})},80)},[M,c.plan.path,d]),q=b.useCallback(()=>{if(S){M(),g(!1),d.playPause();return}y("planning"),g(!0),d.playScanStep(m),a.current=window.setInterval(()=>{h(A=>{if(A>=c.steps.length-1)return M(),g(!1),P(),A;const C=A+1;return d.playScanStep(C),C})},420)},[P,M,S,c.steps.length,d,m]),Q=b.useMemo(()=>{const A=f?.route??c.plan.path;return A.slice(0,-1).map((C,w)=>_(B,C,A[w+1])).filter(Boolean)},[f?.route,c.plan.path]);return{airports:F,routes:B,scenarios:Y,source:s,destination:n,algorithm:o,result:c,currentStep:f,stepIndex:m,phase:j,isPlaying:S,flightProgress:p,activeRoute:Q,soundEnabled:d.soundEnabled,toggleSound:d.toggleSound,changeSource:L,changeDestination:D,changeAlgorithm:R,loadScenario:I,planRoute:N,stepForward:K,stepBack:z,playPlanning:q,animateFlight:P}}function He(){const s=De();return t.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-[radial-gradient(circle_at_top_left,rgba(14,165,233,0.16),transparent_30%),radial-gradient(circle_at_bottom_right,rgba(59,130,246,0.14),transparent_28%)]",children:[t.jsx("div",{className:"border-b border-slate-800/70 bg-slate-950/75 px-4 py-3 shadow-lg shadow-black/20 backdrop-blur-sm md:px-6",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.24em] text-sky-400",children:"Airport Network Algorithms"}),t.jsx("h2",{className:"text-lg font-bold text-white",children:"World Map Flight Simulator"})]}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[t.jsx(v,{label:"Algorithm",value:O[s.algorithm].label,tone:"indigo"}),t.jsx(v,{label:"Origin",value:s.source,tone:"sky"}),t.jsx(v,{label:"Destination",value:s.destination,tone:"emerald"}),t.jsx(v,{label:"Stops",value:s.result.plan.stops.toString(),tone:"amber"})]})]})}),t.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-auto p-4 md:p-6 xl:flex-row",children:[t.jsx(ge,{airports:s.airports,routes:s.routes,source:s.source,destination:s.destination,currentStep:s.currentStep,plan:s.result.plan,flightProgress:s.flightProgress,onSelectSource:s.changeSource,onSelectDestination:s.changeDestination}),t.jsx(be,{airports:s.airports,scenarios:s.scenarios,source:s.source,destination:s.destination,algorithm:s.algorithm,plan:s.result.plan,currentStep:s.currentStep,stepIndex:s.stepIndex,totalSteps:s.result.steps.length,phase:s.phase,isPlaying:s.isPlaying,soundEnabled:s.soundEnabled,onSourceChange:s.changeSource,onDestinationChange:s.changeDestination,onAlgorithmChange:s.changeAlgorithm,onLoadScenario:s.loadScenario,onPlanRoute:()=>s.planRoute(),onStepBack:s.stepBack,onStepForward:s.stepForward,onPlay:s.playPlanning,onFly:s.animateFlight,onToggleSound:s.toggleSound})]})]})}function v({label:s,value:i,tone:n}){const l={indigo:"bg-indigo-500/10 text-indigo-200 ring-indigo-500/25",sky:"bg-sky-500/10 text-sky-200 ring-sky-500/25",emerald:"bg-emerald-500/10 text-emerald-200 ring-emerald-500/25",amber:"bg-amber-500/10 text-amber-200 ring-amber-500/25"};return t.jsxs("div",{className:`rounded-full px-3 py-1.5 text-[10px] ring-1 ${l[n]}`,children:[t.jsx("span",{className:"mr-1 uppercase tracking-wider opacity-60",children:s}),t.jsx("span",{className:"font-mono font-bold",children:i})]})}export{He as default}; diff --git a/docs/assets/arrow-left-DiyrXoev.js b/docs/assets/arrow-left-CTMPG6pL.js similarity index 61% rename from docs/assets/arrow-left-DiyrXoev.js rename to docs/assets/arrow-left-CTMPG6pL.js index bd27f39..f032b9e 100644 --- a/docs/assets/arrow-left-DiyrXoev.js +++ b/docs/assets/arrow-left-CTMPG6pL.js @@ -1 +1 @@ -import{c as o}from"./index-eCXyAnHs.js";const e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=o("arrow-left",e);export{r as A}; +import{c as o}from"./index-DBkLeWDs.js";const e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=o("arrow-left",e);export{r as A}; diff --git a/docs/assets/chevron-right-BZqZw4c2.js b/docs/assets/chevron-right-CFBAUJsk.js similarity index 69% rename from docs/assets/chevron-right-BZqZw4c2.js rename to docs/assets/chevron-right-CFBAUJsk.js index aaf0b56..1b5e9eb 100644 --- a/docs/assets/chevron-right-BZqZw4c2.js +++ b/docs/assets/chevron-right-CFBAUJsk.js @@ -1 +1 @@ -import{c as o}from"./index-eCXyAnHs.js";const e=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],n=o("chevron-left",e);const t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],h=o("chevron-right",t);export{n as C,h as a}; +import{c as o}from"./index-DBkLeWDs.js";const e=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],n=o("chevron-left",e);const t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],h=o("chevron-right",t);export{n as C,h as a}; diff --git a/docs/assets/eye-off-EsCpy5pU.js b/docs/assets/eye-off-BfEKGZbc.js similarity index 85% rename from docs/assets/eye-off-EsCpy5pU.js rename to docs/assets/eye-off-BfEKGZbc.js index 5f86084..5794747 100644 --- a/docs/assets/eye-off-EsCpy5pU.js +++ b/docs/assets/eye-off-BfEKGZbc.js @@ -1 +1 @@ -import{c as e}from"./index-eCXyAnHs.js";const a=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],t=e("eye-off",a);export{t as E}; +import{c as e}from"./index-DBkLeWDs.js";const a=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],t=e("eye-off",a);export{t as E}; diff --git a/docs/assets/index-BWwyfYSG.css b/docs/assets/index-BWwyfYSG.css new file mode 100644 index 0000000..864a47e --- /dev/null +++ b/docs/assets/index-BWwyfYSG.css @@ -0,0 +1 @@ +@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1}}}@layer theme{:root,:host{--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-950:oklch(25.8% .092 26.042);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-950:oklch(27.9% .077 45.635);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-500:oklch(79.5% .184 86.047);--color-lime-500:oklch(76.8% .233 130.85);--color-green-500:oklch(72.3% .219 149.579);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-700:oklch(50.8% .118 165.612);--color-emerald-900:oklch(37.8% .077 168.94);--color-emerald-950:oklch(26.2% .051 172.552);--color-teal-300:oklch(85.5% .138 181.071);--color-teal-500:oklch(70.4% .14 182.503);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-sky-200:oklch(90.1% .058 230.902);--color-sky-300:oklch(82.8% .111 230.318);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-500:oklch(68.5% .169 237.323);--color-sky-950:oklch(29.3% .066 243.157);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-950:oklch(28.2% .091 267.935);--color-indigo-100:oklch(93% .034 272.788);--color-indigo-200:oklch(87% .065 274.039);--color-indigo-300:oklch(78.5% .115 274.713);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-indigo-900:oklch(35.9% .144 278.697);--color-violet-300:oklch(81.1% .111 293.571);--color-violet-400:oklch(70.2% .183 293.541);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-500:oklch(62.7% .265 303.9);--color-fuchsia-400:oklch(74% .238 322.16);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-pink-500:oklch(65.6% .241 354.308);--color-rose-200:oklch(89.2% .058 10.001);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-rose-500:oklch(64.5% .246 16.439);--color-slate-100:oklch(96.8% .007 247.896);--color-slate-200:oklch(92.9% .013 255.508);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-500:oklch(55.4% .046 257.417);--color-slate-600:oklch(44.6% .043 257.281);--color-slate-700:oklch(37.2% .044 257.287);--color-slate-800:oklch(27.9% .041 260.031);--color-slate-900:oklch(20.8% .042 265.755);--color-slate-950:oklch(12.9% .042 264.695);--color-stone-50:oklch(98.5% .001 106.423);--color-stone-200:oklch(92.3% .003 48.717);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--container-7xl:80rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5 / 2.25);--text-5xl:3rem;--text-5xl--line-height:1;--text-6xl:3.75rem;--text-6xl--line-height:1;--text-7xl:4.5rem;--text-7xl--line-height:1;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--font-weight-extrabold:800;--font-weight-black:900;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-snug:1.375;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--drop-shadow-sm:0 1px 2px #00000026;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--blur-sm:8px;--blur-xl:24px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--font-display:"Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.inset-1{inset:calc(var(--spacing) * 1)}.inset-x-0{inset-inline:calc(var(--spacing) * 0)}.inset-x-1{inset-inline:calc(var(--spacing) * 1)}.inset-x-6{inset-inline:calc(var(--spacing) * 6)}.inset-y-1{inset-block:calc(var(--spacing) * 1)}.-top-0\.5{top:calc(var(--spacing) * -.5)}.-top-1\.5{top:calc(var(--spacing) * -1.5)}.top-0{top:calc(var(--spacing) * 0)}.top-1{top:calc(var(--spacing) * 1)}.top-1\.5{top:calc(var(--spacing) * 1.5)}.top-1\/2{top:50%}.top-4{top:calc(var(--spacing) * 4)}.top-5{top:calc(var(--spacing) * 5)}.top-6{top:calc(var(--spacing) * 6)}.top-16{top:calc(var(--spacing) * 16)}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing) * -.5)}.-right-1\.5{right:calc(var(--spacing) * -1.5)}.-right-14{right:calc(var(--spacing) * -14)}.right-0\.5{right:calc(var(--spacing) * .5)}.right-1{right:calc(var(--spacing) * 1)}.right-1\.5{right:calc(var(--spacing) * 1.5)}.right-3{right:calc(var(--spacing) * 3)}.right-5{right:calc(var(--spacing) * 5)}.right-6{right:calc(var(--spacing) * 6)}.-bottom-1{bottom:calc(var(--spacing) * -1)}.-bottom-5{bottom:calc(var(--spacing) * -5)}.bottom-0{bottom:calc(var(--spacing) * 0)}.bottom-1{bottom:calc(var(--spacing) * 1)}.bottom-2{bottom:calc(var(--spacing) * 2)}.bottom-3{bottom:calc(var(--spacing) * 3)}.bottom-4{bottom:calc(var(--spacing) * 4)}.bottom-5{bottom:calc(var(--spacing) * 5)}.left-0{left:calc(var(--spacing) * 0)}.left-1{left:calc(var(--spacing) * 1)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing) * 2)}.left-4{left:calc(var(--spacing) * 4)}.left-5{left:calc(var(--spacing) * 5)}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-50{z-index:50}.order-last{order:9999}.col-1{grid-column:1}.mx-0\.5{margin-inline:calc(var(--spacing) * .5)}.mx-1{margin-inline:calc(var(--spacing) * 1)}.mx-auto{margin-inline:auto}.-mt-1{margin-top:calc(var(--spacing) * -1)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-2\.5{margin-top:calc(var(--spacing) * 2.5)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-5{margin-top:calc(var(--spacing) * 5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-7{margin-top:calc(var(--spacing) * 7)}.mt-8{margin-top:calc(var(--spacing) * 8)}.mt-10{margin-top:calc(var(--spacing) * 10)}.mt-16{margin-top:calc(var(--spacing) * 16)}.mt-20{margin-top:calc(var(--spacing) * 20)}.mt-px{margin-top:1px}.mr-1{margin-right:calc(var(--spacing) * 1)}.mr-4{margin-right:calc(var(--spacing) * 4)}.-mb-px{margin-bottom:-1px}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-5{margin-bottom:calc(var(--spacing) * 5)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.mb-7{margin-bottom:calc(var(--spacing) * 7)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.table{display:table}.aspect-square{aspect-ratio:1}.h-0{height:calc(var(--spacing) * 0)}.h-1{height:calc(var(--spacing) * 1)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-11{height:calc(var(--spacing) * 11)}.h-12{height:calc(var(--spacing) * 12)}.h-14{height:calc(var(--spacing) * 14)}.h-16{height:calc(var(--spacing) * 16)}.h-20{height:calc(var(--spacing) * 20)}.h-24{height:calc(var(--spacing) * 24)}.h-28{height:calc(var(--spacing) * 28)}.h-32{height:calc(var(--spacing) * 32)}.h-36{height:calc(var(--spacing) * 36)}.h-48{height:calc(var(--spacing) * 48)}.h-56{height:calc(var(--spacing) * 56)}.h-72{height:calc(var(--spacing) * 72)}.h-\[22px\]{height:22px}.h-\[500px\]{height:500px}.h-dvh{height:100dvh}.h-full{height:100%}.h-px{height:1px}.max-h-28{max-height:calc(var(--spacing) * 28)}.max-h-32{max-height:calc(var(--spacing) * 32)}.max-h-36{max-height:calc(var(--spacing) * 36)}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-72{max-height:calc(var(--spacing) * 72)}.max-h-80{max-height:calc(var(--spacing) * 80)}.max-h-\[50vh\]{max-height:50vh}.max-h-\[55vh\]{max-height:55vh}.max-h-\[315px\]{max-height:315px}.max-h-\[420px\]{max-height:420px}.max-h-full{max-height:100%}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-10{min-height:calc(var(--spacing) * 10)}.min-h-12{min-height:calc(var(--spacing) * 12)}.min-h-16{min-height:calc(var(--spacing) * 16)}.min-h-52{min-height:calc(var(--spacing) * 52)}.min-h-64{min-height:calc(var(--spacing) * 64)}.min-h-72{min-height:calc(var(--spacing) * 72)}.min-h-\[5\.5rem\]{min-height:5.5rem}.min-h-\[5rem\]{min-height:5rem}.min-h-\[40vh\]{min-height:40vh}.min-h-\[56px\]{min-height:56px}.min-h-\[200px\]{min-height:200px}.min-h-\[240px\]{min-height:240px}.min-h-\[250px\]{min-height:250px}.min-h-\[260px\]{min-height:260px}.min-h-\[290px\]{min-height:290px}.min-h-\[300px\]{min-height:300px}.min-h-\[420px\]{min-height:420px}.min-h-\[520px\]{min-height:520px}.min-h-\[620px\]{min-height:620px}.w-0{width:calc(var(--spacing) * 0)}.w-1{width:calc(var(--spacing) * 1)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-11{width:calc(var(--spacing) * 11)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-16{width:calc(var(--spacing) * 16)}.w-24{width:calc(var(--spacing) * 24)}.w-32{width:calc(var(--spacing) * 32)}.w-36{width:calc(var(--spacing) * 36)}.w-40{width:calc(var(--spacing) * 40)}.w-48{width:calc(var(--spacing) * 48)}.w-56{width:calc(var(--spacing) * 56)}.w-64{width:calc(var(--spacing) * 64)}.w-\[22px\]{width:22px}.w-full{width:100%}.w-px{width:1px}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-7xl{max-width:var(--container-7xl)}.max-w-\[200px\]{max-width:200px}.max-w-\[1440px\]{max-width:1440px}.max-w-\[1500px\]{max-width:1500px}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.min-w-0{min-width:calc(var(--spacing) * 0)}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-12{min-width:calc(var(--spacing) * 12)}.min-w-14{min-width:calc(var(--spacing) * 14)}.min-w-\[56px\]{min-width:56px}.min-w-\[560px\]{min-width:560px}.flex-1{flex:1}.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-2{--tw-translate-y:calc(var(--spacing) * -2);translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-180{rotate:180deg}.rotate-\[-1deg\]{rotate:-1deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-\[shake_0\.3s_ease-in-out_2\]{animation:.3s ease-in-out 2 shake}.animate-path{animation:.4s ease-out forwards path}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.animate-visited{animation:.4s ease-out forwards visited}.animate-wall{animation:.2s ease-out forwards wall}.cursor-crosshair{cursor:crosshair}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-5{gap:calc(var(--spacing) * 5)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-8{gap:calc(var(--spacing) * 8)}.gap-10{gap:calc(var(--spacing) * 10)}.gap-\[1px\],.gap-px{gap:1px}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-x-6{column-gap:calc(var(--spacing) * 6)}.gap-y-1\.5{row-gap:calc(var(--spacing) * 1.5)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.gap-y-5{row-gap:calc(var(--spacing) * 5)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-\[1\.5rem\]{border-radius:1.5rem}.rounded-\[1\.15rem\]{border-radius:1.15rem}.rounded-\[1\.75rem\]{border-radius:1.75rem}.rounded-\[1px\]{border-radius:1px}.rounded-\[50\%\]{border-radius:50%}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-2xl{border-top-left-radius:var(--radius-2xl);border-top-right-radius:var(--radius-2xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-t-md{border-top-left-radius:var(--radius-md);border-top-right-radius:var(--radius-md)}.rounded-t-sm{border-top-left-radius:var(--radius-sm);border-top-right-radius:var(--radius-sm)}.rounded-r-lg{border-top-right-radius:var(--radius-lg);border-bottom-right-radius:var(--radius-lg)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r-2{border-right-style:var(--tw-border-style);border-right-width:2px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-0{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-b-4{border-bottom-style:var(--tw-border-style);border-bottom-width:4px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-amber-300{border-color:var(--color-amber-300)}.border-amber-300\/20{border-color:#ffd23633}@supports (color:color-mix(in lab,red,red)){.border-amber-300\/20{border-color:color-mix(in oklab,var(--color-amber-300) 20%,transparent)}}.border-amber-400{border-color:var(--color-amber-400)}.border-amber-400\/25{border-color:#fcbb0040}@supports (color:color-mix(in lab,red,red)){.border-amber-400\/25{border-color:color-mix(in oklab,var(--color-amber-400) 25%,transparent)}}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500) 20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500) 30%,transparent)}}.border-amber-950\/10{border-color:#4619011a}@supports (color:color-mix(in lab,red,red)){.border-amber-950\/10{border-color:color-mix(in oklab,var(--color-amber-950) 10%,transparent)}}.border-amber-950\/25{border-color:#46190140}@supports (color:color-mix(in lab,red,red)){.border-amber-950\/25{border-color:color-mix(in oklab,var(--color-amber-950) 25%,transparent)}}.border-black\/15{border-color:#00000026}@supports (color:color-mix(in lab,red,red)){.border-black\/15{border-color:color-mix(in oklab,var(--color-black) 15%,transparent)}}.border-blue-400{border-color:var(--color-blue-400)}.border-blue-950\/30{border-color:#1624564d}@supports (color:color-mix(in lab,red,red)){.border-blue-950\/30{border-color:color-mix(in oklab,var(--color-blue-950) 30%,transparent)}}.border-cyan-400\/25{border-color:#00d2ef40}@supports (color:color-mix(in lab,red,red)){.border-cyan-400\/25{border-color:color-mix(in oklab,var(--color-cyan-400) 25%,transparent)}}.border-emerald-300\/20{border-color:#5ee9b533}@supports (color:color-mix(in lab,red,red)){.border-emerald-300\/20{border-color:color-mix(in oklab,var(--color-emerald-300) 20%,transparent)}}.border-emerald-300\/50{border-color:#5ee9b580}@supports (color:color-mix(in lab,red,red)){.border-emerald-300\/50{border-color:color-mix(in oklab,var(--color-emerald-300) 50%,transparent)}}.border-emerald-400{border-color:var(--color-emerald-400)}.border-emerald-400\/25{border-color:#00d29440}@supports (color:color-mix(in lab,red,red)){.border-emerald-400\/25{border-color:color-mix(in oklab,var(--color-emerald-400) 25%,transparent)}}.border-emerald-500\/20{border-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/20{border-color:color-mix(in oklab,var(--color-emerald-500) 20%,transparent)}}.border-emerald-500\/30{border-color:#00bb7f4d}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/30{border-color:color-mix(in oklab,var(--color-emerald-500) 30%,transparent)}}.border-emerald-700\/30{border-color:#0079564d}@supports (color:color-mix(in lab,red,red)){.border-emerald-700\/30{border-color:color-mix(in oklab,var(--color-emerald-700) 30%,transparent)}}.border-emerald-900\/20{border-color:#004e3b33}@supports (color:color-mix(in lab,red,red)){.border-emerald-900\/20{border-color:color-mix(in oklab,var(--color-emerald-900) 20%,transparent)}}.border-emerald-900\/30{border-color:#004e3b4d}@supports (color:color-mix(in lab,red,red)){.border-emerald-900\/30{border-color:color-mix(in oklab,var(--color-emerald-900) 30%,transparent)}}.border-emerald-900\/40{border-color:#004e3b66}@supports (color:color-mix(in lab,red,red)){.border-emerald-900\/40{border-color:color-mix(in oklab,var(--color-emerald-900) 40%,transparent)}}.border-emerald-950\/20{border-color:#002c2233}@supports (color:color-mix(in lab,red,red)){.border-emerald-950\/20{border-color:color-mix(in oklab,var(--color-emerald-950) 20%,transparent)}}.border-emerald-950\/40{border-color:#002c2266}@supports (color:color-mix(in lab,red,red)){.border-emerald-950\/40{border-color:color-mix(in oklab,var(--color-emerald-950) 40%,transparent)}}.border-emerald-950\/50{border-color:#002c2280}@supports (color:color-mix(in lab,red,red)){.border-emerald-950\/50{border-color:color-mix(in oklab,var(--color-emerald-950) 50%,transparent)}}.border-indigo-400\/25{border-color:#7d87ff40}@supports (color:color-mix(in lab,red,red)){.border-indigo-400\/25{border-color:color-mix(in oklab,var(--color-indigo-400) 25%,transparent)}}.border-indigo-500\/20{border-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.border-indigo-500\/20{border-color:color-mix(in oklab,var(--color-indigo-500) 20%,transparent)}}.border-indigo-500\/30{border-color:#625fff4d}@supports (color:color-mix(in lab,red,red)){.border-indigo-500\/30{border-color:color-mix(in oklab,var(--color-indigo-500) 30%,transparent)}}.border-orange-400{border-color:var(--color-orange-400)}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500) 30%,transparent)}}.border-rose-400{border-color:var(--color-rose-400)}.border-rose-400\/20{border-color:#ff667f33}@supports (color:color-mix(in lab,red,red)){.border-rose-400\/20{border-color:color-mix(in oklab,var(--color-rose-400) 20%,transparent)}}.border-rose-400\/25{border-color:#ff667f40}@supports (color:color-mix(in lab,red,red)){.border-rose-400\/25{border-color:color-mix(in oklab,var(--color-rose-400) 25%,transparent)}}.border-sky-500\/20{border-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.border-sky-500\/20{border-color:color-mix(in oklab,var(--color-sky-500) 20%,transparent)}}.border-slate-500{border-color:var(--color-slate-500)}.border-slate-500\/60{border-color:#62748e99}@supports (color:color-mix(in lab,red,red)){.border-slate-500\/60{border-color:color-mix(in oklab,var(--color-slate-500) 60%,transparent)}}.border-slate-600{border-color:var(--color-slate-600)}.border-slate-700{border-color:var(--color-slate-700)}.border-slate-700\/40{border-color:#31415866}@supports (color:color-mix(in lab,red,red)){.border-slate-700\/40{border-color:color-mix(in oklab,var(--color-slate-700) 40%,transparent)}}.border-slate-700\/50{border-color:#31415880}@supports (color:color-mix(in lab,red,red)){.border-slate-700\/50{border-color:color-mix(in oklab,var(--color-slate-700) 50%,transparent)}}.border-slate-700\/60{border-color:#31415899}@supports (color:color-mix(in lab,red,red)){.border-slate-700\/60{border-color:color-mix(in oklab,var(--color-slate-700) 60%,transparent)}}.border-slate-800\/30{border-color:#1d293d4d}@supports (color:color-mix(in lab,red,red)){.border-slate-800\/30{border-color:color-mix(in oklab,var(--color-slate-800) 30%,transparent)}}.border-slate-800\/40{border-color:#1d293d66}@supports (color:color-mix(in lab,red,red)){.border-slate-800\/40{border-color:color-mix(in oklab,var(--color-slate-800) 40%,transparent)}}.border-slate-800\/50{border-color:#1d293d80}@supports (color:color-mix(in lab,red,red)){.border-slate-800\/50{border-color:color-mix(in oklab,var(--color-slate-800) 50%,transparent)}}.border-slate-800\/60{border-color:#1d293d99}@supports (color:color-mix(in lab,red,red)){.border-slate-800\/60{border-color:color-mix(in oklab,var(--color-slate-800) 60%,transparent)}}.border-slate-800\/70{border-color:#1d293db3}@supports (color:color-mix(in lab,red,red)){.border-slate-800\/70{border-color:color-mix(in oklab,var(--color-slate-800) 70%,transparent)}}.border-slate-800\/80{border-color:#1d293dcc}@supports (color:color-mix(in lab,red,red)){.border-slate-800\/80{border-color:color-mix(in oklab,var(--color-slate-800) 80%,transparent)}}.border-slate-950\/50{border-color:#02061880}@supports (color:color-mix(in lab,red,red)){.border-slate-950\/50{border-color:color-mix(in oklab,var(--color-slate-950) 50%,transparent)}}.border-slate-950\/70{border-color:#020618b3}@supports (color:color-mix(in lab,red,red)){.border-slate-950\/70{border-color:color-mix(in oklab,var(--color-slate-950) 70%,transparent)}}.border-violet-500\/30{border-color:#8d54ff4d}@supports (color:color-mix(in lab,red,red)){.border-violet-500\/30{border-color:color-mix(in oklab,var(--color-violet-500) 30%,transparent)}}.border-white\/8{border-color:#ffffff14}@supports (color:color-mix(in lab,red,red)){.border-white\/8{border-color:color-mix(in oklab,var(--color-white) 8%,transparent)}}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white) 10%,transparent)}}.border-white\/\[0\.06\]{border-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.06\]{border-color:color-mix(in oklab,var(--color-white) 6%,transparent)}}.border-white\/\[0\.07\]{border-color:#ffffff12}@supports (color:color-mix(in lab,red,red)){.border-white\/\[0\.07\]{border-color:color-mix(in oklab,var(--color-white) 7%,transparent)}}.border-r-slate-500\/60{border-right-color:#62748e99}@supports (color:color-mix(in lab,red,red)){.border-r-slate-500\/60{border-right-color:color-mix(in oklab,var(--color-slate-500) 60%,transparent)}}.border-b-slate-500\/60{border-bottom-color:#62748e99}@supports (color:color-mix(in lab,red,red)){.border-b-slate-500\/60{border-bottom-color:color-mix(in oklab,var(--color-slate-500) 60%,transparent)}}.bg-\[\#080d18\]{background-color:#080d18}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(16\,185\,129\,0\.18\)\,transparent_36\%\)\,rgba\(16\,185\,129\,0\.05\)\]{background-color:radial-gradient(circle at top left,#10b9812e,transparent 36%),#10b9810d}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(249\,115\,22\,0\.18\)\,transparent_38\%\)\,rgba\(15\,23\,42\,0\.8\)\]{background-color:radial-gradient(circle at top left,#f973162e,transparent 38%),#0f172acc}.bg-amber-300{background-color:var(--color-amber-300)}.bg-amber-300\/8{background-color:#ffd23614}@supports (color:color-mix(in lab,red,red)){.bg-amber-300\/8{background-color:color-mix(in oklab,var(--color-amber-300) 8%,transparent)}}.bg-amber-400{background-color:var(--color-amber-400)}.bg-amber-400\/10{background-color:#fcbb001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-400\/10{background-color:color-mix(in oklab,var(--color-amber-400) 10%,transparent)}}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500) 5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500) 10%,transparent)}}.bg-amber-500\/15{background-color:#f99c0026}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/15{background-color:color-mix(in oklab,var(--color-amber-500) 15%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500) 20%,transparent)}}.bg-black\/10{background-color:#0000001a}@supports (color:color-mix(in lab,red,red)){.bg-black\/10{background-color:color-mix(in oklab,var(--color-black) 10%,transparent)}}.bg-black\/15{background-color:#00000026}@supports (color:color-mix(in lab,red,red)){.bg-black\/15{background-color:color-mix(in oklab,var(--color-black) 15%,transparent)}}.bg-black\/20{background-color:#0003}@supports (color:color-mix(in lab,red,red)){.bg-black\/20{background-color:color-mix(in oklab,var(--color-black) 20%,transparent)}}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black) 30%,transparent)}}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500) 20%,transparent)}}.bg-cyan-300{background-color:var(--color-cyan-300)}.bg-cyan-400{background-color:var(--color-cyan-400)}.bg-cyan-400\/10{background-color:#00d2ef1a}@supports (color:color-mix(in lab,red,red)){.bg-cyan-400\/10{background-color:color-mix(in oklab,var(--color-cyan-400) 10%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/10{background-color:#00b7d71a}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/10{background-color:color-mix(in oklab,var(--color-cyan-500) 10%,transparent)}}.bg-cyan-500\/15{background-color:#00b7d726}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/15{background-color:color-mix(in oklab,var(--color-cyan-500) 15%,transparent)}}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500) 20%,transparent)}}.bg-cyan-500\/40{background-color:#00b7d766}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/40{background-color:color-mix(in oklab,var(--color-cyan-500) 40%,transparent)}}.bg-cyan-500\/60{background-color:#00b7d799}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/60{background-color:color-mix(in oklab,var(--color-cyan-500) 60%,transparent)}}.bg-emerald-300{background-color:var(--color-emerald-300)}.bg-emerald-300\/8{background-color:#5ee9b514}@supports (color:color-mix(in lab,red,red)){.bg-emerald-300\/8{background-color:color-mix(in oklab,var(--color-emerald-300) 8%,transparent)}}.bg-emerald-300\/10{background-color:#5ee9b51a}@supports (color:color-mix(in lab,red,red)){.bg-emerald-300\/10{background-color:color-mix(in oklab,var(--color-emerald-300) 10%,transparent)}}.bg-emerald-300\/12{background-color:#5ee9b51f}@supports (color:color-mix(in lab,red,red)){.bg-emerald-300\/12{background-color:color-mix(in oklab,var(--color-emerald-300) 12%,transparent)}}.bg-emerald-300\/\[0\.06\]{background-color:#5ee9b50f}@supports (color:color-mix(in lab,red,red)){.bg-emerald-300\/\[0\.06\]{background-color:color-mix(in oklab,var(--color-emerald-300) 6%,transparent)}}.bg-emerald-400{background-color:var(--color-emerald-400)}.bg-emerald-400\/10{background-color:#00d2941a}@supports (color:color-mix(in lab,red,red)){.bg-emerald-400\/10{background-color:color-mix(in oklab,var(--color-emerald-400) 10%,transparent)}}.bg-emerald-500{background-color:var(--color-emerald-500)}.bg-emerald-500\/5{background-color:#00bb7f0d}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/5{background-color:color-mix(in oklab,var(--color-emerald-500) 5%,transparent)}}.bg-emerald-500\/10{background-color:#00bb7f1a}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/10{background-color:color-mix(in oklab,var(--color-emerald-500) 10%,transparent)}}.bg-emerald-500\/15{background-color:#00bb7f26}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/15{background-color:color-mix(in oklab,var(--color-emerald-500) 15%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500) 20%,transparent)}}.bg-emerald-500\/25{background-color:#00bb7f40}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/25{background-color:color-mix(in oklab,var(--color-emerald-500) 25%,transparent)}}.bg-emerald-500\/70{background-color:#00bb7fb3}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/70{background-color:color-mix(in oklab,var(--color-emerald-500) 70%,transparent)}}.bg-emerald-900\/25{background-color:#004e3b40}@supports (color:color-mix(in lab,red,red)){.bg-emerald-900\/25{background-color:color-mix(in oklab,var(--color-emerald-900) 25%,transparent)}}.bg-emerald-950{background-color:var(--color-emerald-950)}.bg-emerald-950\/20{background-color:#002c2233}@supports (color:color-mix(in lab,red,red)){.bg-emerald-950\/20{background-color:color-mix(in oklab,var(--color-emerald-950) 20%,transparent)}}.bg-emerald-950\/25{background-color:#002c2240}@supports (color:color-mix(in lab,red,red)){.bg-emerald-950\/25{background-color:color-mix(in oklab,var(--color-emerald-950) 25%,transparent)}}.bg-green-500\/70{background-color:#00c758b3}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/70{background-color:color-mix(in oklab,var(--color-green-500) 70%,transparent)}}.bg-indigo-400{background-color:var(--color-indigo-400)}.bg-indigo-400\/10{background-color:#7d87ff1a}@supports (color:color-mix(in lab,red,red)){.bg-indigo-400\/10{background-color:color-mix(in oklab,var(--color-indigo-400) 10%,transparent)}}.bg-indigo-400\/40{background-color:#7d87ff66}@supports (color:color-mix(in lab,red,red)){.bg-indigo-400\/40{background-color:color-mix(in oklab,var(--color-indigo-400) 40%,transparent)}}.bg-indigo-400\/80{background-color:#7d87ffcc}@supports (color:color-mix(in lab,red,red)){.bg-indigo-400\/80{background-color:color-mix(in oklab,var(--color-indigo-400) 80%,transparent)}}.bg-indigo-500{background-color:var(--color-indigo-500)}.bg-indigo-500\/5{background-color:#625fff0d}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/5{background-color:color-mix(in oklab,var(--color-indigo-500) 5%,transparent)}}.bg-indigo-500\/10{background-color:#625fff1a}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/10{background-color:color-mix(in oklab,var(--color-indigo-500) 10%,transparent)}}.bg-indigo-500\/15{background-color:#625fff26}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/15{background-color:color-mix(in oklab,var(--color-indigo-500) 15%,transparent)}}.bg-indigo-500\/20{background-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/20{background-color:color-mix(in oklab,var(--color-indigo-500) 20%,transparent)}}.bg-indigo-500\/25{background-color:#625fff40}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/25{background-color:color-mix(in oklab,var(--color-indigo-500) 25%,transparent)}}.bg-indigo-500\/70{background-color:#625fffb3}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/70{background-color:color-mix(in oklab,var(--color-indigo-500) 70%,transparent)}}.bg-indigo-900{background-color:var(--color-indigo-900)}.bg-orange-400{background-color:var(--color-orange-400)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500) 10%,transparent)}}.bg-orange-500\/15{background-color:#fe6e0026}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/15{background-color:color-mix(in oklab,var(--color-orange-500) 15%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500) 20%,transparent)}}.bg-red-500\/5{background-color:#fb2c360d}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/5{background-color:color-mix(in oklab,var(--color-red-500) 5%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500) 10%,transparent)}}.bg-red-500\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500) 15%,transparent)}}.bg-red-500\/70{background-color:#fb2c36b3}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/70{background-color:color-mix(in oklab,var(--color-red-500) 70%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-950\/70{background-color:#460809b3}@supports (color:color-mix(in lab,red,red)){.bg-red-950\/70{background-color:color-mix(in oklab,var(--color-red-950) 70%,transparent)}}.bg-rose-300{background-color:var(--color-rose-300)}.bg-rose-400{background-color:var(--color-rose-400)}.bg-rose-400\/8{background-color:#ff667f14}@supports (color:color-mix(in lab,red,red)){.bg-rose-400\/8{background-color:color-mix(in oklab,var(--color-rose-400) 8%,transparent)}}.bg-rose-400\/10{background-color:#ff667f1a}@supports (color:color-mix(in lab,red,red)){.bg-rose-400\/10{background-color:color-mix(in oklab,var(--color-rose-400) 10%,transparent)}}.bg-rose-500{background-color:var(--color-rose-500)}.bg-rose-500\/10{background-color:#ff23571a}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/10{background-color:color-mix(in oklab,var(--color-rose-500) 10%,transparent)}}.bg-rose-500\/15{background-color:#ff235726}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/15{background-color:color-mix(in oklab,var(--color-rose-500) 15%,transparent)}}.bg-rose-500\/20{background-color:#ff235733}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/20{background-color:color-mix(in oklab,var(--color-rose-500) 20%,transparent)}}.bg-rose-500\/25{background-color:#ff235740}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/25{background-color:color-mix(in oklab,var(--color-rose-500) 25%,transparent)}}.bg-rose-500\/40{background-color:#ff235766}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/40{background-color:color-mix(in oklab,var(--color-rose-500) 40%,transparent)}}.bg-rose-500\/60{background-color:#ff235799}@supports (color:color-mix(in lab,red,red)){.bg-rose-500\/60{background-color:color-mix(in oklab,var(--color-rose-500) 60%,transparent)}}.bg-sky-400{background-color:var(--color-sky-400)}.bg-sky-500\/10{background-color:#00a5ef1a}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/10{background-color:color-mix(in oklab,var(--color-sky-500) 10%,transparent)}}.bg-sky-500\/15{background-color:#00a5ef26}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/15{background-color:color-mix(in oklab,var(--color-sky-500) 15%,transparent)}}.bg-sky-500\/25{background-color:#00a5ef40}@supports (color:color-mix(in lab,red,red)){.bg-sky-500\/25{background-color:color-mix(in oklab,var(--color-sky-500) 25%,transparent)}}.bg-slate-300{background-color:var(--color-slate-300)}.bg-slate-500{background-color:var(--color-slate-500)}.bg-slate-500\/10{background-color:#62748e1a}@supports (color:color-mix(in lab,red,red)){.bg-slate-500\/10{background-color:color-mix(in oklab,var(--color-slate-500) 10%,transparent)}}.bg-slate-600{background-color:var(--color-slate-600)}.bg-slate-700{background-color:var(--color-slate-700)}.bg-slate-800{background-color:var(--color-slate-800)}.bg-slate-800\/30{background-color:#1d293d4d}@supports (color:color-mix(in lab,red,red)){.bg-slate-800\/30{background-color:color-mix(in oklab,var(--color-slate-800) 30%,transparent)}}.bg-slate-800\/40{background-color:#1d293d66}@supports (color:color-mix(in lab,red,red)){.bg-slate-800\/40{background-color:color-mix(in oklab,var(--color-slate-800) 40%,transparent)}}.bg-slate-800\/50{background-color:#1d293d80}@supports (color:color-mix(in lab,red,red)){.bg-slate-800\/50{background-color:color-mix(in oklab,var(--color-slate-800) 50%,transparent)}}.bg-slate-800\/60{background-color:#1d293d99}@supports (color:color-mix(in lab,red,red)){.bg-slate-800\/60{background-color:color-mix(in oklab,var(--color-slate-800) 60%,transparent)}}.bg-slate-800\/70{background-color:#1d293db3}@supports (color:color-mix(in lab,red,red)){.bg-slate-800\/70{background-color:color-mix(in oklab,var(--color-slate-800) 70%,transparent)}}.bg-slate-800\/80{background-color:#1d293dcc}@supports (color:color-mix(in lab,red,red)){.bg-slate-800\/80{background-color:color-mix(in oklab,var(--color-slate-800) 80%,transparent)}}.bg-slate-900{background-color:var(--color-slate-900)}.bg-slate-900\/40{background-color:#0f172b66}@supports (color:color-mix(in lab,red,red)){.bg-slate-900\/40{background-color:color-mix(in oklab,var(--color-slate-900) 40%,transparent)}}.bg-slate-900\/50{background-color:#0f172b80}@supports (color:color-mix(in lab,red,red)){.bg-slate-900\/50{background-color:color-mix(in oklab,var(--color-slate-900) 50%,transparent)}}.bg-slate-900\/55{background-color:#0f172b8c}@supports (color:color-mix(in lab,red,red)){.bg-slate-900\/55{background-color:color-mix(in oklab,var(--color-slate-900) 55%,transparent)}}.bg-slate-900\/60{background-color:#0f172b99}@supports (color:color-mix(in lab,red,red)){.bg-slate-900\/60{background-color:color-mix(in oklab,var(--color-slate-900) 60%,transparent)}}.bg-slate-900\/70{background-color:#0f172bb3}@supports (color:color-mix(in lab,red,red)){.bg-slate-900\/70{background-color:color-mix(in oklab,var(--color-slate-900) 70%,transparent)}}.bg-slate-900\/80{background-color:#0f172bcc}@supports (color:color-mix(in lab,red,red)){.bg-slate-900\/80{background-color:color-mix(in oklab,var(--color-slate-900) 80%,transparent)}}.bg-slate-950\/25{background-color:#02061840}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/25{background-color:color-mix(in oklab,var(--color-slate-950) 25%,transparent)}}.bg-slate-950\/35{background-color:#02061859}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/35{background-color:color-mix(in oklab,var(--color-slate-950) 35%,transparent)}}.bg-slate-950\/40{background-color:#02061866}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/40{background-color:color-mix(in oklab,var(--color-slate-950) 40%,transparent)}}.bg-slate-950\/45{background-color:#02061873}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/45{background-color:color-mix(in oklab,var(--color-slate-950) 45%,transparent)}}.bg-slate-950\/50{background-color:#02061880}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/50{background-color:color-mix(in oklab,var(--color-slate-950) 50%,transparent)}}.bg-slate-950\/55{background-color:#0206188c}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/55{background-color:color-mix(in oklab,var(--color-slate-950) 55%,transparent)}}.bg-slate-950\/60{background-color:#02061899}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/60{background-color:color-mix(in oklab,var(--color-slate-950) 60%,transparent)}}.bg-slate-950\/70{background-color:#020618b3}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/70{background-color:color-mix(in oklab,var(--color-slate-950) 70%,transparent)}}.bg-slate-950\/75{background-color:#020618bf}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/75{background-color:color-mix(in oklab,var(--color-slate-950) 75%,transparent)}}.bg-slate-950\/80{background-color:#020618cc}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/80{background-color:color-mix(in oklab,var(--color-slate-950) 80%,transparent)}}.bg-slate-950\/85{background-color:#020618d9}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/85{background-color:color-mix(in oklab,var(--color-slate-950) 85%,transparent)}}.bg-slate-950\/90{background-color:#020618e6}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/90{background-color:color-mix(in oklab,var(--color-slate-950) 90%,transparent)}}.bg-slate-950\/95{background-color:#020618f2}@supports (color:color-mix(in lab,red,red)){.bg-slate-950\/95{background-color:color-mix(in oklab,var(--color-slate-950) 95%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500\/5{background-color:#8d54ff0d}@supports (color:color-mix(in lab,red,red)){.bg-violet-500\/5{background-color:color-mix(in oklab,var(--color-violet-500) 5%,transparent)}}.bg-violet-500\/10{background-color:#8d54ff1a}@supports (color:color-mix(in lab,red,red)){.bg-violet-500\/10{background-color:color-mix(in oklab,var(--color-violet-500) 10%,transparent)}}.bg-violet-500\/15{background-color:#8d54ff26}@supports (color:color-mix(in lab,red,red)){.bg-violet-500\/15{background-color:color-mix(in oklab,var(--color-violet-500) 15%,transparent)}}.bg-violet-500\/20{background-color:#8d54ff33}@supports (color:color-mix(in lab,red,red)){.bg-violet-500\/20{background-color:color-mix(in oklab,var(--color-violet-500) 20%,transparent)}}.bg-white{background-color:var(--color-white)}.bg-white\/5{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\/5{background-color:color-mix(in oklab,var(--color-white) 5%,transparent)}}.bg-white\/15{background-color:#ffffff26}@supports (color:color-mix(in lab,red,red)){.bg-white\/15{background-color:color-mix(in oklab,var(--color-white) 15%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white) 20%,transparent)}}.bg-white\/80{background-color:#fffc}@supports (color:color-mix(in lab,red,red)){.bg-white\/80{background-color:color-mix(in oklab,var(--color-white) 80%,transparent)}}.bg-white\/\[0\.025\]{background-color:#ffffff06}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.025\]{background-color:color-mix(in oklab,var(--color-white) 2.5%,transparent)}}.bg-white\/\[0\.045\]{background-color:#ffffff0b}@supports (color:color-mix(in lab,red,red)){.bg-white\/\[0\.045\]{background-color:color-mix(in oklab,var(--color-white) 4.5%,transparent)}}.bg-yellow-300{background-color:var(--color-yellow-300)}.bg-yellow-500\/10{background-color:#edb2001a}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/10{background-color:color-mix(in oklab,var(--color-yellow-500) 10%,transparent)}}.bg-yellow-500\/70{background-color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/70{background-color:color-mix(in oklab,var(--color-yellow-500) 70%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-\[linear-gradient\(135deg\,rgba\(15\,23\,42\,0\.9\)\,rgba\(6\,78\,59\,0\.34\)\)\]{background-image:linear-gradient(135deg,#0f172ae6,#064e3b57)}.bg-\[linear-gradient\(rgba\(148\,163\,184\,0\.03\)_1px\,transparent_1px\)\]{background-image:linear-gradient(#94a3b808 1px,#0000 1px)}.bg-\[radial-gradient\(circle_at_1px_1px\,rgba\(148\,163\,184\,0\.12\)_1px\,transparent_0\)\]{background-image:radial-gradient(circle at 1px 1px,#94a3b81f 1px,#0000 0)}.bg-\[radial-gradient\(circle_at_18\%_22\%\,rgba\(14\,165\,233\,0\.16\)\,transparent_28\%\)\,radial-gradient\(circle_at_78\%_72\%\,rgba\(59\,130\,246\,0\.12\)\,transparent_30\%\)\]{background-image:radial-gradient(circle at 18% 22%,#0ea5e929,#0000 28%),radial-gradient(circle at 78% 72%,#3b82f61f,#0000 30%)}.bg-\[radial-gradient\(circle_at_20\%_10\%\,rgba\(56\,189\,248\,0\.14\)\,transparent_28\%\)\,radial-gradient\(circle_at_80\%_80\%\,rgba\(34\,197\,94\,0\.1\)\,transparent_30\%\)\]{background-image:radial-gradient(circle at 20% 10%,#38bdf824,#0000 28%),radial-gradient(circle at 80% 80%,#22c55e1a,#0000 30%)}.bg-\[radial-gradient\(circle_at_30\%_15\%\,rgba\(255\,255\,255\,0\.8\)\,transparent_38\%\)\,linear-gradient\(135deg\,rgba\(255\,255\,255\,0\.35\)\,transparent\)\]{background-image:radial-gradient(circle at 30% 15%,#fffc,#0000 38%),linear-gradient(135deg,#ffffff59,#0000)}.bg-\[radial-gradient\(circle_at_top\,rgba\(16\,185\,129\,0\.08\)\,transparent_34\%\)\,linear-gradient\(180deg\,rgba\(15\,23\,42\,0\)\,rgba\(6\,78\,59\,0\.16\)\)\]{background-image:radial-gradient(circle at top,#10b98114,#0000 34%),linear-gradient(#0f172a00,#064e3b29)}.bg-\[radial-gradient\(circle_at_top\,rgba\(16\,185\,129\,0\.12\)\,transparent_34\%\)\,linear-gradient\(180deg\,rgba\(15\,23\,42\,0\)\,rgba\(6\,78\,59\,0\.16\)\)\]{background-image:radial-gradient(circle at top,#10b9811f,#0000 34%),linear-gradient(#0f172a00,#064e3b29)}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(14\,165\,233\,0\.16\)\,transparent_30\%\)\,radial-gradient\(circle_at_bottom_right\,rgba\(34\,197\,94\,0\.12\)\,transparent_28\%\)\]{background-image:radial-gradient(circle at 0 0,#0ea5e929,#0000 30%),radial-gradient(circle at 100% 100%,#22c55e1f,#0000 28%)}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(14\,165\,233\,0\.16\)\,transparent_30\%\)\,radial-gradient\(circle_at_bottom_right\,rgba\(59\,130\,246\,0\.14\)\,transparent_28\%\)\]{background-image:radial-gradient(circle at 0 0,#0ea5e929,#0000 30%),radial-gradient(circle at 100% 100%,#3b82f624,#0000 28%)}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(16\,185\,129\,0\.12\)\,transparent_34\%\)\,linear-gradient\(135deg\,rgba\(15\,23\,42\,0\.96\)\,rgba\(6\,78\,59\,0\.28\)\)\]{background-image:radial-gradient(circle at 0 0,#10b9811f,#0000 34%),linear-gradient(135deg,#0f172af5,#064e3b47)}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(16\,185\,129\,0\.14\)\,transparent_34\%\)\,linear-gradient\(135deg\,rgba\(15\,23\,42\,0\.96\)\,rgba\(6\,78\,59\,0\.32\)\)\]{background-image:radial-gradient(circle at 0 0,#10b98124,#0000 34%),linear-gradient(135deg,#0f172af5,#064e3b52)}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(16\,185\,129\,0\.14\)\,transparent_34\%\)\,linear-gradient\(135deg\,rgba\(15\,23\,42\,0\.96\)\,rgba\(6\,78\,59\,0\.36\)\)\]{background-image:radial-gradient(circle at 0 0,#10b98124,#0000 34%),linear-gradient(135deg,#0f172af5,#064e3b5c)}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(16\,185\,129\,0\.18\)\,transparent_34\%\)\,linear-gradient\(135deg\,rgba\(15\,23\,42\,0\.96\)\,rgba\(6\,78\,59\,0\.42\)\)\]{background-image:radial-gradient(circle at 0 0,#10b9812e,#0000 34%),linear-gradient(135deg,#0f172af5,#064e3b6b)}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(34\,197\,94\,0\.18\)\,transparent_34\%\)\,linear-gradient\(135deg\,rgba\(15\,23\,42\,0\.96\)\,rgba\(6\,78\,59\,0\.36\)\)\]{background-image:radial-gradient(circle at 0 0,#22c55e2e,#0000 34%),linear-gradient(135deg,#0f172af5,#064e3b5c)}.bg-\[radial-gradient\(circle_at_top_left\,rgba\(249\,115\,22\,0\.12\)\,transparent_28\%\)\,radial-gradient\(circle_at_bottom_right\,rgba\(99\,102\,241\,0\.12\)\,transparent_30\%\)\]{background-image:radial-gradient(circle at 0 0,#f973161f,#0000 28%),radial-gradient(circle at 100% 100%,#6366f11f,#0000 30%)}.from-amber-200{--tw-gradient-from:var(--color-amber-200);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-amber-300{--tw-gradient-from:var(--color-amber-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-amber-500{--tw-gradient-from:var(--color-amber-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-black\/25{--tw-gradient-from:#00000040}@supports (color:color-mix(in lab,red,red)){.from-black\/25{--tw-gradient-from:color-mix(in oklab, var(--color-black) 25%, transparent)}}.from-black\/25{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-blue-500{--tw-gradient-from:var(--color-blue-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-cyan-300{--tw-gradient-from:var(--color-cyan-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-cyan-400{--tw-gradient-from:var(--color-cyan-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-cyan-500{--tw-gradient-from:var(--color-cyan-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-emerald-300{--tw-gradient-from:var(--color-emerald-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-emerald-400{--tw-gradient-from:var(--color-emerald-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-emerald-500{--tw-gradient-from:var(--color-emerald-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-emerald-500\/70{--tw-gradient-from:#00bb7fb3}@supports (color:color-mix(in lab,red,red)){.from-emerald-500\/70{--tw-gradient-from:color-mix(in oklab, var(--color-emerald-500) 70%, transparent)}}.from-emerald-500\/70{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-emerald-500\/80{--tw-gradient-from:#00bb7fcc}@supports (color:color-mix(in lab,red,red)){.from-emerald-500\/80{--tw-gradient-from:color-mix(in oklab, var(--color-emerald-500) 80%, transparent)}}.from-emerald-500\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-emerald-950\/50{--tw-gradient-from:#002c2280}@supports (color:color-mix(in lab,red,red)){.from-emerald-950\/50{--tw-gradient-from:color-mix(in oklab, var(--color-emerald-950) 50%, transparent)}}.from-emerald-950\/50{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-fuchsia-500{--tw-gradient-from:var(--color-fuchsia-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-indigo-300{--tw-gradient-from:var(--color-indigo-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-indigo-400{--tw-gradient-from:var(--color-indigo-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-indigo-500{--tw-gradient-from:var(--color-indigo-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-indigo-500\/20{--tw-gradient-from:#625fff33}@supports (color:color-mix(in lab,red,red)){.from-indigo-500\/20{--tw-gradient-from:color-mix(in oklab, var(--color-indigo-500) 20%, transparent)}}.from-indigo-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-lime-500{--tw-gradient-from:var(--color-lime-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-purple-500{--tw-gradient-from:var(--color-purple-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-red-500\/20{--tw-gradient-from:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.from-red-500\/20{--tw-gradient-from:color-mix(in oklab, var(--color-red-500) 20%, transparent)}}.from-red-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-rose-400{--tw-gradient-from:var(--color-rose-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-rose-500{--tw-gradient-from:var(--color-rose-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-rose-500\/20{--tw-gradient-from:#ff235733}@supports (color:color-mix(in lab,red,red)){.from-rose-500\/20{--tw-gradient-from:color-mix(in oklab, var(--color-rose-500) 20%, transparent)}}.from-rose-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-rose-500\/80{--tw-gradient-from:#ff2357cc}@supports (color:color-mix(in lab,red,red)){.from-rose-500\/80{--tw-gradient-from:color-mix(in oklab, var(--color-rose-500) 80%, transparent)}}.from-rose-500\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-sky-500{--tw-gradient-from:var(--color-sky-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-stone-50{--tw-gradient-from:var(--color-stone-50);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.from-teal-500{--tw-gradient-from:var(--color-teal-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.via-amber-50{--tw-gradient-via:var(--color-amber-50);--tw-gradient-via-stops:var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-via) var(--tw-gradient-via-position), var(--tw-gradient-to) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.via-orange-200{--tw-gradient-via:var(--color-orange-200);--tw-gradient-via-stops:var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-via) var(--tw-gradient-via-position), var(--tw-gradient-to) var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-amber-400{--tw-gradient-to:var(--color-amber-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-blue-400{--tw-gradient-to:var(--color-blue-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-blue-500{--tw-gradient-to:var(--color-blue-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-cyan-300{--tw-gradient-to:var(--color-cyan-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-cyan-400{--tw-gradient-to:var(--color-cyan-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-cyan-500{--tw-gradient-to:var(--color-cyan-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-cyan-500\/20{--tw-gradient-to:#00b7d733}@supports (color:color-mix(in lab,red,red)){.to-cyan-500\/20{--tw-gradient-to:color-mix(in oklab, var(--color-cyan-500) 20%, transparent)}}.to-cyan-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-emerald-300{--tw-gradient-to:var(--color-emerald-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-emerald-700{--tw-gradient-to:var(--color-emerald-700);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-fuchsia-400{--tw-gradient-to:var(--color-fuchsia-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-fuchsia-500{--tw-gradient-to:var(--color-fuchsia-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-green-500{--tw-gradient-to:var(--color-green-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-green-500\/80{--tw-gradient-to:#00c758cc}@supports (color:color-mix(in lab,red,red)){.to-green-500\/80{--tw-gradient-to:color-mix(in oklab, var(--color-green-500) 80%, transparent)}}.to-green-500\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-indigo-500{--tw-gradient-to:var(--color-indigo-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-orange-300{--tw-gradient-to:var(--color-orange-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-orange-400{--tw-gradient-to:var(--color-orange-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-orange-500{--tw-gradient-to:var(--color-orange-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-pink-500{--tw-gradient-to:var(--color-pink-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-pink-500\/80{--tw-gradient-to:#f6339acc}@supports (color:color-mix(in lab,red,red)){.to-pink-500\/80{--tw-gradient-to:color-mix(in oklab, var(--color-pink-500) 80%, transparent)}}.to-pink-500\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-rose-300{--tw-gradient-to:var(--color-rose-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-rose-500\/20{--tw-gradient-to:#ff235733}@supports (color:color-mix(in lab,red,red)){.to-rose-500\/20{--tw-gradient-to:color-mix(in oklab, var(--color-rose-500) 20%, transparent)}}.to-rose-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-stone-200{--tw-gradient-to:var(--color-stone-200);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-teal-300{--tw-gradient-to:var(--color-teal-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-teal-500{--tw-gradient-to:var(--color-teal-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-violet-300{--tw-gradient-to:var(--color-violet-300);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-violet-400{--tw-gradient-to:var(--color-violet-400);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-violet-500{--tw-gradient-to:var(--color-violet-500);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-violet-500\/20{--tw-gradient-to:#8d54ff33}@supports (color:color-mix(in lab,red,red)){.to-violet-500\/20{--tw-gradient-to:color-mix(in oklab, var(--color-violet-500) 20%, transparent)}}.to-violet-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.bg-\[length\:24px_24px\]{background-size:24px 24px}.bg-\[length\:100\%_22px\]{background-size:100% 22px}.bg-clip-text{-webkit-background-clip:text;background-clip:text}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:calc(var(--spacing) * 1)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.px-8{padding-inline:calc(var(--spacing) * 8)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-16{padding-block:calc(var(--spacing) * 16)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-8{padding-top:calc(var(--spacing) * 8)}.pt-10{padding-top:calc(var(--spacing) * 10)}.pt-12{padding-top:calc(var(--spacing) * 12)}.pr-1{padding-right:calc(var(--spacing) * 1)}.pb-0{padding-bottom:calc(var(--spacing) * 0)}.pb-1{padding-bottom:calc(var(--spacing) * 1)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.pb-6{padding-bottom:calc(var(--spacing) * 6)}.pb-8{padding-bottom:calc(var(--spacing) * 8)}.pb-10{padding-bottom:calc(var(--spacing) * 10)}.pb-12{padding-bottom:calc(var(--spacing) * 12)}.pb-16{padding-bottom:calc(var(--spacing) * 16)}.pl-4{padding-left:calc(var(--spacing) * 4)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-display{font-family:var(--font-display)}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}.text-7xl{font-size:var(--text-7xl);line-height:var(--tw-leading,var(--text-7xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[7px\]{font-size:7px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-6{--tw-leading:calc(var(--spacing) * 6);line-height:calc(var(--spacing) * 6)}.leading-7{--tw-leading:calc(var(--spacing) * 7);line-height:calc(var(--spacing) * 7)}.leading-8{--tw-leading:calc(var(--spacing) * 8);line-height:calc(var(--spacing) * 8)}.leading-\[1\.02\]{--tw-leading:1.02;line-height:1.02}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.font-black{--tw-font-weight:var(--font-weight-black);font-weight:var(--font-weight-black)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-extrabold{--tw-font-weight:var(--font-weight-extrabold);font-weight:var(--font-weight-extrabold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-0\.04em\]{--tw-tracking:-.04em;letter-spacing:-.04em}.tracking-\[0\.2em\]{--tw-tracking:.2em;letter-spacing:.2em}.tracking-\[0\.16em\]{--tw-tracking:.16em;letter-spacing:.16em}.tracking-\[0\.18em\]{--tw-tracking:.18em;letter-spacing:.18em}.tracking-\[0\.24em\]{--tw-tracking:.24em;letter-spacing:.24em}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre{white-space:pre}.whitespace-pre-wrap{white-space:pre-wrap}.text-amber-200{color:var(--color-amber-200)}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/60{color:#ffd23699}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/60{color:color-mix(in oklab,var(--color-amber-300) 60%,transparent)}}.text-amber-300\/70{color:#ffd236b3}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/70{color:color-mix(in oklab,var(--color-amber-300) 70%,transparent)}}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab,red,red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300) 80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/80{color:#fcbb00cc}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/80{color:color-mix(in oklab,var(--color-amber-400) 80%,transparent)}}.text-amber-400\/90{color:#fcbb00e6}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/90{color:color-mix(in oklab,var(--color-amber-400) 90%,transparent)}}.text-blue-300{color:var(--color-blue-300)}.text-blue-400{color:var(--color-blue-400)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-50\/80{color:#ecfdf5cc}@supports (color:color-mix(in lab,red,red)){.text-emerald-50\/80{color:color-mix(in oklab,var(--color-emerald-50) 80%,transparent)}}.text-emerald-100{color:var(--color-emerald-100)}.text-emerald-100\/45{color:#d0fae573}@supports (color:color-mix(in lab,red,red)){.text-emerald-100\/45{color:color-mix(in oklab,var(--color-emerald-100) 45%,transparent)}}.text-emerald-100\/50{color:#d0fae580}@supports (color:color-mix(in lab,red,red)){.text-emerald-100\/50{color:color-mix(in oklab,var(--color-emerald-100) 50%,transparent)}}.text-emerald-100\/65{color:#d0fae5a6}@supports (color:color-mix(in lab,red,red)){.text-emerald-100\/65{color:color-mix(in oklab,var(--color-emerald-100) 65%,transparent)}}.text-emerald-100\/70{color:#d0fae5b3}@supports (color:color-mix(in lab,red,red)){.text-emerald-100\/70{color:color-mix(in oklab,var(--color-emerald-100) 70%,transparent)}}.text-emerald-200{color:var(--color-emerald-200)}.text-emerald-300{color:var(--color-emerald-300)}.text-emerald-400{color:var(--color-emerald-400)}.text-emerald-400\/60{color:#00d29499}@supports (color:color-mix(in lab,red,red)){.text-emerald-400\/60{color:color-mix(in oklab,var(--color-emerald-400) 60%,transparent)}}.text-emerald-500{color:var(--color-emerald-500)}.text-indigo-100{color:var(--color-indigo-100)}.text-indigo-200{color:var(--color-indigo-200)}.text-indigo-300{color:var(--color-indigo-300)}.text-indigo-400{color:var(--color-indigo-400)}.text-orange-300{color:var(--color-orange-300)}.text-orange-400{color:var(--color-orange-400)}.text-red-300{color:var(--color-red-300)}.text-red-400{color:var(--color-red-400)}.text-rose-200{color:var(--color-rose-200)}.text-rose-300{color:var(--color-rose-300)}.text-rose-400{color:var(--color-rose-400)}.text-sky-200{color:var(--color-sky-200)}.text-sky-300{color:var(--color-sky-300)}.text-sky-400{color:var(--color-sky-400)}.text-slate-100{color:var(--color-slate-100)}.text-slate-200{color:var(--color-slate-200)}.text-slate-300{color:var(--color-slate-300)}.text-slate-400{color:var(--color-slate-400)}.text-slate-500{color:var(--color-slate-500)}.text-slate-600{color:var(--color-slate-600)}.text-slate-700{color:var(--color-slate-700)}.text-slate-900\/35{color:#0f172b59}@supports (color:color-mix(in lab,red,red)){.text-slate-900\/35{color:color-mix(in oklab,var(--color-slate-900) 35%,transparent)}}.text-slate-950{color:var(--color-slate-950)}.text-slate-950\/50{color:#02061880}@supports (color:color-mix(in lab,red,red)){.text-slate-950\/50{color:color-mix(in oklab,var(--color-slate-950) 50%,transparent)}}.text-transparent{color:#0000}.text-violet-300{color:var(--color-violet-300)}.text-violet-400{color:var(--color-violet-400)}.text-white{color:var(--color-white)}.text-yellow-300{color:var(--color-yellow-300)}.capitalize{text-transform:capitalize}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.placeholder-slate-500::placeholder{color:var(--color-slate-500)}.placeholder-slate-600::placeholder{color:var(--color-slate-600)}.caret-emerald-400{caret-color:var(--color-emerald-400)}.accent-emerald-300{accent-color:var(--color-emerald-300)}.accent-indigo-400{accent-color:var(--color-indigo-400)}.accent-indigo-500{accent-color:var(--color-indigo-500)}.accent-rose-400{accent-color:var(--color-rose-400)}.accent-rose-500{accent-color:var(--color-rose-500)}.accent-sky-500{accent-color:var(--color-sky-500)}.opacity-0{opacity:0}.opacity-10{opacity:.1}.opacity-30{opacity:.3}.opacity-35{opacity:.35}.opacity-40{opacity:.4}.opacity-45{opacity:.45}.opacity-60{opacity:.6}.opacity-65{opacity:.65}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_18px_rgb\(52_211_153_\/_0\.12\)\]{--tw-shadow:0 0 18px var(--tw-shadow-color,#34d3991f);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_26px_rgba\(52\,211\,153\,0\.45\)\]{--tw-shadow:0 0 26px var(--tw-shadow-color,#34d39973);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_10px_18px_rgba\(0\,0\,0\,0\.35\)\,inset_0_-3px_0_rgba\(0\,0\,0\,0\.18\)\]{--tw-shadow:0 10px 18px var(--tw-shadow-color,#00000059), inset 0 -3px 0 var(--tw-shadow-color,#0000002e);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-inner{--tw-shadow:inset 0 2px 4px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-amber-300\/10{--tw-shadow-color:#ffd2361a}@supports (color:color-mix(in lab,red,red)){.shadow-amber-300\/10{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-amber-300) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-amber-400\/20{--tw-shadow-color:#fcbb0033}@supports (color:color-mix(in lab,red,red)){.shadow-amber-400\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-amber-400) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-amber-400\/30{--tw-shadow-color:#fcbb004d}@supports (color:color-mix(in lab,red,red)){.shadow-amber-400\/30{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-amber-400) 30%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-amber-500\/20{--tw-shadow-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.shadow-amber-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-amber-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/20{--tw-shadow-color:#0003}@supports (color:color-mix(in lab,red,red)){.shadow-black\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/30{--tw-shadow-color:#0000004d}@supports (color:color-mix(in lab,red,red)){.shadow-black\/30{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 30%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/35{--tw-shadow-color:#00000059}@supports (color:color-mix(in lab,red,red)){.shadow-black\/35{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 35%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-black\/40{--tw-shadow-color:#0006}@supports (color:color-mix(in lab,red,red)){.shadow-black\/40{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-black) 40%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-blue-500\/20{--tw-shadow-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.shadow-blue-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-blue-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-emerald-500\/15{--tw-shadow-color:#00bb7f26}@supports (color:color-mix(in lab,red,red)){.shadow-emerald-500\/15{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-emerald-500) 15%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-emerald-500\/20{--tw-shadow-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.shadow-emerald-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-emerald-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-emerald-500\/30{--tw-shadow-color:#00bb7f4d}@supports (color:color-mix(in lab,red,red)){.shadow-emerald-500\/30{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-emerald-500) 30%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-emerald-950\/20{--tw-shadow-color:#002c2233}@supports (color:color-mix(in lab,red,red)){.shadow-emerald-950\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-emerald-950) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-fuchsia-500\/20{--tw-shadow-color:#e12afb33}@supports (color:color-mix(in lab,red,red)){.shadow-fuchsia-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-fuchsia-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-indigo-500\/10{--tw-shadow-color:#625fff1a}@supports (color:color-mix(in lab,red,red)){.shadow-indigo-500\/10{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-indigo-500) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-indigo-500\/20{--tw-shadow-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.shadow-indigo-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-indigo-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-indigo-500\/25{--tw-shadow-color:#625fff40}@supports (color:color-mix(in lab,red,red)){.shadow-indigo-500\/25{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-indigo-500) 25%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-lime-500\/20{--tw-shadow-color:#80cd0033}@supports (color:color-mix(in lab,red,red)){.shadow-lime-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-lime-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-purple-500\/20{--tw-shadow-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.shadow-purple-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-purple-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-red-950\/20{--tw-shadow-color:#46080933}@supports (color:color-mix(in lab,red,red)){.shadow-red-950\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-red-950) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-rose-500\/15{--tw-shadow-color:#ff235726}@supports (color:color-mix(in lab,red,red)){.shadow-rose-500\/15{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-rose-500) 15%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-rose-500\/20{--tw-shadow-color:#ff235733}@supports (color:color-mix(in lab,red,red)){.shadow-rose-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-rose-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-rose-500\/25{--tw-shadow-color:#ff235740}@supports (color:color-mix(in lab,red,red)){.shadow-rose-500\/25{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-rose-500) 25%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-rose-500\/30{--tw-shadow-color:#ff23574d}@supports (color:color-mix(in lab,red,red)){.shadow-rose-500\/30{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-rose-500) 30%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-sky-500\/20{--tw-shadow-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.shadow-sky-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-sky-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-sky-950\/40{--tw-shadow-color:#052f4a66}@supports (color:color-mix(in lab,red,red)){.shadow-sky-950\/40{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-sky-950) 40%, transparent) var(--tw-shadow-alpha), transparent)}}.shadow-teal-500\/20{--tw-shadow-color:#00baa733}@supports (color:color-mix(in lab,red,red)){.shadow-teal-500\/20{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-teal-500) 20%, transparent) var(--tw-shadow-alpha), transparent)}}.ring-amber-300\/50{--tw-ring-color:#ffd23680}@supports (color:color-mix(in lab,red,red)){.ring-amber-300\/50{--tw-ring-color:color-mix(in oklab, var(--color-amber-300) 50%, transparent)}}.ring-amber-500\/20{--tw-ring-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.ring-amber-500\/20{--tw-ring-color:color-mix(in oklab, var(--color-amber-500) 20%, transparent)}}.ring-amber-500\/25{--tw-ring-color:#f99c0040}@supports (color:color-mix(in lab,red,red)){.ring-amber-500\/25{--tw-ring-color:color-mix(in oklab, var(--color-amber-500) 25%, transparent)}}.ring-amber-500\/30{--tw-ring-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.ring-amber-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-amber-500) 30%, transparent)}}.ring-amber-500\/40{--tw-ring-color:#f99c0066}@supports (color:color-mix(in lab,red,red)){.ring-amber-500\/40{--tw-ring-color:color-mix(in oklab, var(--color-amber-500) 40%, transparent)}}.ring-blue-500\/30{--tw-ring-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.ring-blue-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-blue-500) 30%, transparent)}}.ring-cyan-300\/40{--tw-ring-color:#53eafd66}@supports (color:color-mix(in lab,red,red)){.ring-cyan-300\/40{--tw-ring-color:color-mix(in oklab, var(--color-cyan-300) 40%, transparent)}}.ring-cyan-500\/20{--tw-ring-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.ring-cyan-500\/20{--tw-ring-color:color-mix(in oklab, var(--color-cyan-500) 20%, transparent)}}.ring-cyan-500\/30{--tw-ring-color:#00b7d74d}@supports (color:color-mix(in lab,red,red)){.ring-cyan-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-cyan-500) 30%, transparent)}}.ring-cyan-500\/40{--tw-ring-color:#00b7d766}@supports (color:color-mix(in lab,red,red)){.ring-cyan-500\/40{--tw-ring-color:color-mix(in oklab, var(--color-cyan-500) 40%, transparent)}}.ring-emerald-200{--tw-ring-color:var(--color-emerald-200)}.ring-emerald-300\/20{--tw-ring-color:#5ee9b533}@supports (color:color-mix(in lab,red,red)){.ring-emerald-300\/20{--tw-ring-color:color-mix(in oklab, var(--color-emerald-300) 20%, transparent)}}.ring-emerald-400\/50{--tw-ring-color:#00d29480}@supports (color:color-mix(in lab,red,red)){.ring-emerald-400\/50{--tw-ring-color:color-mix(in oklab, var(--color-emerald-400) 50%, transparent)}}.ring-emerald-500{--tw-ring-color:var(--color-emerald-500)}.ring-emerald-500\/20{--tw-ring-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.ring-emerald-500\/20{--tw-ring-color:color-mix(in oklab, var(--color-emerald-500) 20%, transparent)}}.ring-emerald-500\/25{--tw-ring-color:#00bb7f40}@supports (color:color-mix(in lab,red,red)){.ring-emerald-500\/25{--tw-ring-color:color-mix(in oklab, var(--color-emerald-500) 25%, transparent)}}.ring-emerald-500\/30{--tw-ring-color:#00bb7f4d}@supports (color:color-mix(in lab,red,red)){.ring-emerald-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-emerald-500) 30%, transparent)}}.ring-emerald-500\/40{--tw-ring-color:#00bb7f66}@supports (color:color-mix(in lab,red,red)){.ring-emerald-500\/40{--tw-ring-color:color-mix(in oklab, var(--color-emerald-500) 40%, transparent)}}.ring-emerald-500\/50{--tw-ring-color:#00bb7f80}@supports (color:color-mix(in lab,red,red)){.ring-emerald-500\/50{--tw-ring-color:color-mix(in oklab, var(--color-emerald-500) 50%, transparent)}}.ring-indigo-300{--tw-ring-color:var(--color-indigo-300)}.ring-indigo-400{--tw-ring-color:var(--color-indigo-400)}.ring-indigo-400\/40{--tw-ring-color:#7d87ff66}@supports (color:color-mix(in lab,red,red)){.ring-indigo-400\/40{--tw-ring-color:color-mix(in oklab, var(--color-indigo-400) 40%, transparent)}}.ring-indigo-400\/60{--tw-ring-color:#7d87ff99}@supports (color:color-mix(in lab,red,red)){.ring-indigo-400\/60{--tw-ring-color:color-mix(in oklab, var(--color-indigo-400) 60%, transparent)}}.ring-indigo-500{--tw-ring-color:var(--color-indigo-500)}.ring-indigo-500\/15{--tw-ring-color:#625fff26}@supports (color:color-mix(in lab,red,red)){.ring-indigo-500\/15{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 15%, transparent)}}.ring-indigo-500\/20{--tw-ring-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.ring-indigo-500\/20{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 20%, transparent)}}.ring-indigo-500\/25{--tw-ring-color:#625fff40}@supports (color:color-mix(in lab,red,red)){.ring-indigo-500\/25{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 25%, transparent)}}.ring-indigo-500\/30{--tw-ring-color:#625fff4d}@supports (color:color-mix(in lab,red,red)){.ring-indigo-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 30%, transparent)}}.ring-indigo-500\/35{--tw-ring-color:#625fff59}@supports (color:color-mix(in lab,red,red)){.ring-indigo-500\/35{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 35%, transparent)}}.ring-indigo-500\/40{--tw-ring-color:#625fff66}@supports (color:color-mix(in lab,red,red)){.ring-indigo-500\/40{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 40%, transparent)}}.ring-indigo-500\/50{--tw-ring-color:#625fff80}@supports (color:color-mix(in lab,red,red)){.ring-indigo-500\/50{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 50%, transparent)}}.ring-orange-200{--tw-ring-color:var(--color-orange-200)}.ring-orange-500\/25{--tw-ring-color:#fe6e0040}@supports (color:color-mix(in lab,red,red)){.ring-orange-500\/25{--tw-ring-color:color-mix(in oklab, var(--color-orange-500) 25%, transparent)}}.ring-orange-500\/30{--tw-ring-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.ring-orange-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-orange-500) 30%, transparent)}}.ring-red-500\/30{--tw-ring-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.ring-red-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-red-500) 30%, transparent)}}.ring-red-500\/60{--tw-ring-color:#fb2c3699}@supports (color:color-mix(in lab,red,red)){.ring-red-500\/60{--tw-ring-color:color-mix(in oklab, var(--color-red-500) 60%, transparent)}}.ring-rose-400\/40{--tw-ring-color:#ff667f66}@supports (color:color-mix(in lab,red,red)){.ring-rose-400\/40{--tw-ring-color:color-mix(in oklab, var(--color-rose-400) 40%, transparent)}}.ring-rose-500\/20{--tw-ring-color:#ff235733}@supports (color:color-mix(in lab,red,red)){.ring-rose-500\/20{--tw-ring-color:color-mix(in oklab, var(--color-rose-500) 20%, transparent)}}.ring-rose-500\/25{--tw-ring-color:#ff235740}@supports (color:color-mix(in lab,red,red)){.ring-rose-500\/25{--tw-ring-color:color-mix(in oklab, var(--color-rose-500) 25%, transparent)}}.ring-rose-500\/30{--tw-ring-color:#ff23574d}@supports (color:color-mix(in lab,red,red)){.ring-rose-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-rose-500) 30%, transparent)}}.ring-rose-500\/40{--tw-ring-color:#ff235766}@supports (color:color-mix(in lab,red,red)){.ring-rose-500\/40{--tw-ring-color:color-mix(in oklab, var(--color-rose-500) 40%, transparent)}}.ring-rose-500\/50{--tw-ring-color:#ff235780}@supports (color:color-mix(in lab,red,red)){.ring-rose-500\/50{--tw-ring-color:color-mix(in oklab, var(--color-rose-500) 50%, transparent)}}.ring-sky-200{--tw-ring-color:var(--color-sky-200)}.ring-sky-500\/20{--tw-ring-color:#00a5ef33}@supports (color:color-mix(in lab,red,red)){.ring-sky-500\/20{--tw-ring-color:color-mix(in oklab, var(--color-sky-500) 20%, transparent)}}.ring-sky-500\/25{--tw-ring-color:#00a5ef40}@supports (color:color-mix(in lab,red,red)){.ring-sky-500\/25{--tw-ring-color:color-mix(in oklab, var(--color-sky-500) 25%, transparent)}}.ring-sky-500\/30{--tw-ring-color:#00a5ef4d}@supports (color:color-mix(in lab,red,red)){.ring-sky-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-sky-500) 30%, transparent)}}.ring-sky-500\/40{--tw-ring-color:#00a5ef66}@supports (color:color-mix(in lab,red,red)){.ring-sky-500\/40{--tw-ring-color:color-mix(in oklab, var(--color-sky-500) 40%, transparent)}}.ring-slate-500{--tw-ring-color:var(--color-slate-500)}.ring-slate-600{--tw-ring-color:var(--color-slate-600)}.ring-slate-700{--tw-ring-color:var(--color-slate-700)}.ring-slate-700\/30{--tw-ring-color:#3141584d}@supports (color:color-mix(in lab,red,red)){.ring-slate-700\/30{--tw-ring-color:color-mix(in oklab, var(--color-slate-700) 30%, transparent)}}.ring-slate-700\/40{--tw-ring-color:#31415866}@supports (color:color-mix(in lab,red,red)){.ring-slate-700\/40{--tw-ring-color:color-mix(in oklab, var(--color-slate-700) 40%, transparent)}}.ring-slate-700\/50{--tw-ring-color:#31415880}@supports (color:color-mix(in lab,red,red)){.ring-slate-700\/50{--tw-ring-color:color-mix(in oklab, var(--color-slate-700) 50%, transparent)}}.ring-slate-800{--tw-ring-color:var(--color-slate-800)}.ring-slate-800\/50{--tw-ring-color:#1d293d80}@supports (color:color-mix(in lab,red,red)){.ring-slate-800\/50{--tw-ring-color:color-mix(in oklab, var(--color-slate-800) 50%, transparent)}}.ring-slate-800\/60{--tw-ring-color:#1d293d99}@supports (color:color-mix(in lab,red,red)){.ring-slate-800\/60{--tw-ring-color:color-mix(in oklab, var(--color-slate-800) 60%, transparent)}}.ring-slate-800\/70{--tw-ring-color:#1d293db3}@supports (color:color-mix(in lab,red,red)){.ring-slate-800\/70{--tw-ring-color:color-mix(in oklab, var(--color-slate-800) 70%, transparent)}}.ring-slate-800\/80{--tw-ring-color:#1d293dcc}@supports (color:color-mix(in lab,red,red)){.ring-slate-800\/80{--tw-ring-color:color-mix(in oklab, var(--color-slate-800) 80%, transparent)}}.ring-violet-400\/40{--tw-ring-color:#a685ff66}@supports (color:color-mix(in lab,red,red)){.ring-violet-400\/40{--tw-ring-color:color-mix(in oklab, var(--color-violet-400) 40%, transparent)}}.ring-violet-500\/20{--tw-ring-color:#8d54ff33}@supports (color:color-mix(in lab,red,red)){.ring-violet-500\/20{--tw-ring-color:color-mix(in oklab, var(--color-violet-500) 20%, transparent)}}.ring-violet-500\/30{--tw-ring-color:#8d54ff4d}@supports (color:color-mix(in lab,red,red)){.ring-violet-500\/30{--tw-ring-color:color-mix(in oklab, var(--color-violet-500) 30%, transparent)}}.ring-violet-500\/40{--tw-ring-color:#8d54ff66}@supports (color:color-mix(in lab,red,red)){.ring-violet-500\/40{--tw-ring-color:color-mix(in oklab, var(--color-violet-500) 40%, transparent)}}.ring-white\/10{--tw-ring-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.ring-white\/10{--tw-ring-color:color-mix(in oklab, var(--color-white) 10%, transparent)}}.ring-white\/30{--tw-ring-color:#ffffff4d}@supports (color:color-mix(in lab,red,red)){.ring-white\/30{--tw-ring-color:color-mix(in oklab, var(--color-white) 30%, transparent)}}.ring-white\/\[0\.06\]{--tw-ring-color:#ffffff0f}@supports (color:color-mix(in lab,red,red)){.ring-white\/\[0\.06\]{--tw-ring-color:color-mix(in oklab, var(--color-white) 6%, transparent)}}.ring-white\/\[0\.07\]{--tw-ring-color:#ffffff12}@supports (color:color-mix(in lab,red,red)){.ring-white\/\[0\.07\]{--tw-ring-color:color-mix(in oklab, var(--color-white) 7%, transparent)}}.ring-yellow-500\/25{--tw-ring-color:#edb20040}@supports (color:color-mix(in lab,red,red)){.ring-yellow-500\/25{--tw-ring-color:color-mix(in oklab, var(--color-yellow-500) 25%, transparent)}}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.blur-xl{--tw-blur:blur(var(--blur-xl));filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.drop-shadow-sm{--tw-drop-shadow-size:drop-shadow(0 1px 2px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-sm));filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.grayscale{--tw-grayscale:grayscale(100%);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.backdrop-blur-xl{--tw-backdrop-blur:blur(var(--blur-xl));-webkit-backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[height\]{transition-property:height;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-75{--tw-duration:75ms;transition-duration:75ms}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.\[animation-delay\:120ms\]{animation-delay:.12s}.\[animation-delay\:240ms\]{animation-delay:.24s}.ring-inset{--tw-ring-inset:inset}@media(hover:hover){.group-hover\:translate-x-1:is(:where(.group):hover *){--tw-translate-x:calc(var(--spacing) * 1);translate:var(--tw-translate-x) var(--tw-translate-y)}.group-hover\:-rotate-3:is(:where(.group):hover *){rotate:-3deg}.group-hover\:text-white:is(:where(.group):hover *){color:var(--color-white)}.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\:text-slate-700::placeholder{color:var(--color-slate-700)}@media(hover:hover){.hover\:-translate-y-1:hover{--tw-translate-y:calc(var(--spacing) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.hover\:-translate-y-2:hover{--tw-translate-y:calc(var(--spacing) * -2);translate:var(--tw-translate-x) var(--tw-translate-y)}.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\:scale-\[1\.01\]:hover{scale:1.01}.hover\:rotate-1:hover{rotate:1deg}.hover\:border-emerald-300\/30:hover{border-color:#5ee9b54d}@supports (color:color-mix(in lab,red,red)){.hover\:border-emerald-300\/30:hover{border-color:color-mix(in oklab,var(--color-emerald-300) 30%,transparent)}}.hover\:border-slate-600\/60:hover{border-color:#45556c99}@supports (color:color-mix(in lab,red,red)){.hover\:border-slate-600\/60:hover{border-color:color-mix(in oklab,var(--color-slate-600) 60%,transparent)}}.hover\:bg-amber-200:hover{background-color:var(--color-amber-200)}.hover\:bg-amber-500\/25:hover{background-color:#f99c0040}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/25:hover{background-color:color-mix(in oklab,var(--color-amber-500) 25%,transparent)}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500) 30%,transparent)}}.hover\:bg-blue-500\/30:hover{background-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/30:hover{background-color:color-mix(in oklab,var(--color-blue-500) 30%,transparent)}}.hover\:bg-cyan-500\/30:hover{background-color:#00b7d74d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-cyan-500\/30:hover{background-color:color-mix(in oklab,var(--color-cyan-500) 30%,transparent)}}.hover\:bg-emerald-200:hover{background-color:var(--color-emerald-200)}.hover\:bg-emerald-300\/8:hover{background-color:#5ee9b514}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-300\/8:hover{background-color:color-mix(in oklab,var(--color-emerald-300) 8%,transparent)}}.hover\:bg-emerald-500\/25:hover{background-color:#00bb7f40}@supports (color:color-mix(in lab,red,red)){.hover\:bg-emerald-500\/25:hover{background-color:color-mix(in oklab,var(--color-emerald-500) 25%,transparent)}}.hover\:bg-indigo-500\/10:hover{background-color:#625fff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-indigo-500\/10:hover{background-color:color-mix(in oklab,var(--color-indigo-500) 10%,transparent)}}.hover\:bg-indigo-500\/15:hover{background-color:#625fff26}@supports (color:color-mix(in lab,red,red)){.hover\:bg-indigo-500\/15:hover{background-color:color-mix(in oklab,var(--color-indigo-500) 15%,transparent)}}.hover\:bg-indigo-500\/25:hover{background-color:#625fff40}@supports (color:color-mix(in lab,red,red)){.hover\:bg-indigo-500\/25:hover{background-color:color-mix(in oklab,var(--color-indigo-500) 25%,transparent)}}.hover\:bg-indigo-500\/30:hover{background-color:#625fff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-indigo-500\/30:hover{background-color:color-mix(in oklab,var(--color-indigo-500) 30%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500) 20%,transparent)}}.hover\:bg-red-500\/25:hover{background-color:#fb2c3640}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/25:hover{background-color:color-mix(in oklab,var(--color-red-500) 25%,transparent)}}.hover\:bg-rose-500\/25:hover{background-color:#ff235740}@supports (color:color-mix(in lab,red,red)){.hover\:bg-rose-500\/25:hover{background-color:color-mix(in oklab,var(--color-rose-500) 25%,transparent)}}.hover\:bg-rose-500\/30:hover{background-color:#ff23574d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-rose-500\/30:hover{background-color:color-mix(in oklab,var(--color-rose-500) 30%,transparent)}}.hover\:bg-sky-500\/25:hover{background-color:#00a5ef40}@supports (color:color-mix(in lab,red,red)){.hover\:bg-sky-500\/25:hover{background-color:color-mix(in oklab,var(--color-sky-500) 25%,transparent)}}.hover\:bg-slate-700\/50:hover{background-color:#31415880}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-700\/50:hover{background-color:color-mix(in oklab,var(--color-slate-700) 50%,transparent)}}.hover\:bg-slate-700\/60:hover{background-color:#31415899}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-700\/60:hover{background-color:color-mix(in oklab,var(--color-slate-700) 60%,transparent)}}.hover\:bg-slate-700\/70:hover{background-color:#314158b3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-700\/70:hover{background-color:color-mix(in oklab,var(--color-slate-700) 70%,transparent)}}.hover\:bg-slate-700\/80:hover{background-color:#314158cc}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-700\/80:hover{background-color:color-mix(in oklab,var(--color-slate-700) 80%,transparent)}}.hover\:bg-slate-800\/30:hover{background-color:#1d293d4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-800\/30:hover{background-color:color-mix(in oklab,var(--color-slate-800) 30%,transparent)}}.hover\:bg-slate-800\/40:hover{background-color:#1d293d66}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-800\/40:hover{background-color:color-mix(in oklab,var(--color-slate-800) 40%,transparent)}}.hover\:bg-slate-800\/50:hover{background-color:#1d293d80}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-800\/50:hover{background-color:color-mix(in oklab,var(--color-slate-800) 50%,transparent)}}.hover\:bg-slate-800\/60:hover{background-color:#1d293d99}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-800\/60:hover{background-color:color-mix(in oklab,var(--color-slate-800) 60%,transparent)}}.hover\:bg-slate-800\/70:hover{background-color:#1d293db3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-800\/70:hover{background-color:color-mix(in oklab,var(--color-slate-800) 70%,transparent)}}.hover\:bg-slate-800\/80:hover{background-color:#1d293dcc}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-800\/80:hover{background-color:color-mix(in oklab,var(--color-slate-800) 80%,transparent)}}.hover\:bg-slate-900\/70:hover{background-color:#0f172bb3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-900\/70:hover{background-color:color-mix(in oklab,var(--color-slate-900) 70%,transparent)}}.hover\:bg-slate-900\/80:hover{background-color:#0f172bcc}@supports (color:color-mix(in lab,red,red)){.hover\:bg-slate-900\/80:hover{background-color:color-mix(in oklab,var(--color-slate-900) 80%,transparent)}}.hover\:bg-violet-500\/30:hover{background-color:#8d54ff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-violet-500\/30:hover{background-color:color-mix(in oklab,var(--color-violet-500) 30%,transparent)}}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white) 5%,transparent)}}.hover\:bg-white\/\[0\.045\]:hover{background-color:#ffffff0b}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/\[0\.045\]:hover{background-color:color-mix(in oklab,var(--color-white) 4.5%,transparent)}}.hover\:from-indigo-500\/30:hover{--tw-gradient-from:#625fff4d}@supports (color:color-mix(in lab,red,red)){.hover\:from-indigo-500\/30:hover{--tw-gradient-from:color-mix(in oklab, var(--color-indigo-500) 30%, transparent)}}.hover\:from-indigo-500\/30:hover{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.hover\:from-rose-500\/30:hover{--tw-gradient-from:#ff23574d}@supports (color:color-mix(in lab,red,red)){.hover\:from-rose-500\/30:hover{--tw-gradient-from:color-mix(in oklab, var(--color-rose-500) 30%, transparent)}}.hover\:from-rose-500\/30:hover{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.hover\:to-cyan-500\/30:hover{--tw-gradient-to:#00b7d74d}@supports (color:color-mix(in lab,red,red)){.hover\:to-cyan-500\/30:hover{--tw-gradient-to:color-mix(in oklab, var(--color-cyan-500) 30%, transparent)}}.hover\:to-cyan-500\/30:hover{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.hover\:to-violet-500\/30:hover{--tw-gradient-to:#8d54ff4d}@supports (color:color-mix(in lab,red,red)){.hover\:to-violet-500\/30:hover{--tw-gradient-to:color-mix(in oklab, var(--color-violet-500) 30%, transparent)}}.hover\:to-violet-500\/30:hover{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.hover\:text-emerald-200:hover{color:var(--color-emerald-200)}.hover\:text-indigo-300:hover{color:var(--color-indigo-300)}.hover\:text-rose-400:hover{color:var(--color-rose-400)}.hover\:text-slate-200:hover{color:var(--color-slate-200)}.hover\:text-slate-300:hover{color:var(--color-slate-300)}.hover\:text-slate-400:hover{color:var(--color-slate-400)}.hover\:text-white:hover{color:var(--color-white)}.hover\:shadow-\[0_18px_28px_rgba\(0\,0\,0\,0\.45\)\]:hover{--tw-shadow:0 18px 28px var(--tw-shadow-color,#00000073);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-xl:hover{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:ring-1:hover{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-indigo-500\/10:hover{--tw-shadow-color:#625fff1a}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-indigo-500\/10:hover{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-indigo-500) 10%, transparent) var(--tw-shadow-alpha), transparent)}}.hover\:shadow-indigo-500\/30:hover{--tw-shadow-color:#625fff4d}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-indigo-500\/30:hover{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-indigo-500) 30%, transparent) var(--tw-shadow-alpha), transparent)}}.hover\:shadow-indigo-500\/40:hover{--tw-shadow-color:#625fff66}@supports (color:color-mix(in lab,red,red)){.hover\:shadow-indigo-500\/40:hover{--tw-shadow-color:color-mix(in oklab, color-mix(in oklab, var(--color-indigo-500) 40%, transparent) var(--tw-shadow-alpha), transparent)}}.hover\:ring-indigo-400\/50:hover{--tw-ring-color:#7d87ff80}@supports (color:color-mix(in lab,red,red)){.hover\:ring-indigo-400\/50:hover{--tw-ring-color:color-mix(in oklab, var(--color-indigo-400) 50%, transparent)}}.hover\:ring-indigo-500\/20:hover{--tw-ring-color:#625fff33}@supports (color:color-mix(in lab,red,red)){.hover\:ring-indigo-500\/20:hover{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 20%, transparent)}}.hover\:ring-indigo-500\/30:hover{--tw-ring-color:#625fff4d}@supports (color:color-mix(in lab,red,red)){.hover\:ring-indigo-500\/30:hover{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 30%, transparent)}}.hover\:ring-white\/20:hover{--tw-ring-color:#fff3}@supports (color:color-mix(in lab,red,red)){.hover\:ring-white\/20:hover{--tw-ring-color:color-mix(in oklab, var(--color-white) 20%, transparent)}}.hover\:brightness-110:hover{--tw-brightness:brightness(110%);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-cyan-500\/50:focus{--tw-ring-color:#00b7d780}@supports (color:color-mix(in lab,red,red)){.focus\:ring-cyan-500\/50:focus{--tw-ring-color:color-mix(in oklab, var(--color-cyan-500) 50%, transparent)}}.focus\:ring-indigo-500\/50:focus{--tw-ring-color:#625fff80}@supports (color:color-mix(in lab,red,red)){.focus\:ring-indigo-500\/50:focus{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 50%, transparent)}}.focus\:ring-rose-500\/50:focus{--tw-ring-color:#ff235780}@supports (color:color-mix(in lab,red,red)){.focus\:ring-rose-500\/50:focus{--tw-ring-color:color-mix(in oklab, var(--color-rose-500) 50%, transparent)}}.active\:translate-y-0:active{--tw-translate-y:calc(var(--spacing) * 0);translate:var(--tw-translate-x) var(--tw-translate-y)}.active\:scale-95:active{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.active\:scale-\[0\.98\]:active{scale:.98}.active\:scale-\[0\.99\]:active{scale:.99}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(min-width:40rem){.sm\:block{display:block}.sm\:h-14{height:calc(var(--spacing) * 14)}.sm\:h-16{height:calc(var(--spacing) * 16)}.sm\:h-28{height:calc(var(--spacing) * 28)}.sm\:h-44{height:calc(var(--spacing) * 44)}.sm\:h-\[4\.6rem\]{height:4.6rem}.sm\:w-10{width:calc(var(--spacing) * 10)}.sm\:w-12{width:calc(var(--spacing) * 12)}.sm\:w-14{width:calc(var(--spacing) * 14)}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-9{grid-template-columns:repeat(9,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:gap-2{gap:calc(var(--spacing) * 2)}.sm\:p-4{padding:calc(var(--spacing) * 4)}.sm\:p-5{padding:calc(var(--spacing) * 5)}.sm\:p-6{padding:calc(var(--spacing) * 6)}.sm\:p-8{padding:calc(var(--spacing) * 8)}.sm\:px-6{padding-inline:calc(var(--spacing) * 6)}.sm\:py-10{padding-block:calc(var(--spacing) * 10)}.sm\:pt-16{padding-top:calc(var(--spacing) * 16)}.sm\:text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.sm\:text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}.sm\:text-6xl{font-size:var(--text-6xl);line-height:var(--tw-leading,var(--text-6xl--line-height))}.sm\:text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.sm\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}}@media(min-width:48rem){.md\:order-first{order:-9999}.md\:mb-4{margin-bottom:calc(var(--spacing) * 4)}.md\:h-14{height:calc(var(--spacing) * 14)}.md\:h-20{height:calc(var(--spacing) * 20)}.md\:h-52{height:calc(var(--spacing) * 52)}.md\:h-\[4\.35rem\]{height:4.35rem}.md\:max-h-full{max-height:100%}.md\:max-h-none{max-height:none}.md\:min-h-0{min-height:calc(var(--spacing) * 0)}.md\:min-h-\[400px\]{min-height:400px}.md\:w-14{width:calc(var(--spacing) * 14)}.md\:w-16{width:calc(var(--spacing) * 16)}.md\:w-72{width:calc(var(--spacing) * 72)}.md\:w-80{width:calc(var(--spacing) * 80)}.md\:max-w-sm{max-width:var(--container-sm)}.md\:flex-1{flex:1}.md\:shrink-0{flex-shrink:0}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:flex-row{flex-direction:row}.md\:items-start{align-items:flex-start}.md\:justify-between{justify-content:space-between}.md\:gap-1\.5{gap:calc(var(--spacing) * 1.5)}.md\:gap-2{gap:calc(var(--spacing) * 2)}.md\:gap-2\.5{gap:calc(var(--spacing) * 2.5)}.md\:gap-3{gap:calc(var(--spacing) * 3)}.md\:gap-6{gap:calc(var(--spacing) * 6)}:where(.md\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.md\:space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.md\:space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)))}.md\:overflow-auto{overflow:auto}.md\:overflow-y-auto{overflow-y:auto}.md\:p-5{padding:calc(var(--spacing) * 5)}.md\:p-6{padding:calc(var(--spacing) * 6)}.md\:px-6{padding-inline:calc(var(--spacing) * 6)}.md\:text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.md\:text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.md\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.md\:text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.md\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media(min-width:64rem){.lg\:col-span-2{grid-column:span 2/span 2}.lg\:block{display:block}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:w-64{width:calc(var(--spacing) * 64)}.lg\:shrink-0{flex-shrink:0}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.lg\:grid-cols-\[220px_minmax\(0\,1fr\)\]{grid-template-columns:220px minmax(0,1fr)}.lg\:grid-cols-\[minmax\(0\,1fr\)_280px\]{grid-template-columns:minmax(0,1fr) 280px}.lg\:grid-cols-\[minmax\(0\,1fr\)_360px\]{grid-template-columns:minmax(0,1fr) 360px}.lg\:grid-cols-\[minmax\(0\,1fr\)_460px\]{grid-template-columns:minmax(0,1fr) 460px}.lg\:items-end{align-items:flex-end}.lg\:gap-16{gap:calc(var(--spacing) * 16)}.lg\:p-10{padding:calc(var(--spacing) * 10)}.lg\:px-8{padding-inline:calc(var(--spacing) * 8)}.lg\:py-10{padding-block:calc(var(--spacing) * 10)}.lg\:py-12{padding-block:calc(var(--spacing) * 12)}.lg\:pt-20{padding-top:calc(var(--spacing) * 20)}.lg\:text-7xl{font-size:var(--text-7xl);line-height:var(--tw-leading,var(--text-7xl--line-height))}}@media(min-width:80rem){.xl\:order-first{order:-9999}.xl\:min-h-0{min-height:calc(var(--spacing) * 0)}.xl\:w-80{width:calc(var(--spacing) * 80)}.xl\:w-88{width:calc(var(--spacing) * 88)}.xl\:w-\[410px\]{width:410px}.xl\:shrink-0{flex-shrink:0}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-\[minmax\(360px\,0\.82fr\)_minmax\(0\,1\.18fr\)\]{grid-template-columns:minmax(360px,.82fr) minmax(0,1.18fr)}.xl\:flex-row{flex-direction:row}.xl\:gap-4{gap:calc(var(--spacing) * 4)}}@media(min-width:96rem){.\32xl\:w-\[460px\]{width:460px}}}:root{--ink-950:#070a12;--ink-900:#0c1220;--ink-850:#111827;--paper-100:#f8fafc;--paper-300:#cbd5e1;--accent-amber:#fcd34d;--space-page:clamp(1rem, 3vw, 2rem);--radius-panel:1.25rem;--shadow-panel:0 24px 80px #00000038;--color-canvas:var(--ink-950);--color-surface:var(--ink-900);--color-surface-raised:var(--ink-850);--color-text:var(--paper-100);--color-text-muted:var(--paper-300);--color-accent:var(--accent-amber);--panel-background:#0c1220b8;--panel-border:#ffffff14;--panel-radius:var(--radius-panel);--panel-shadow:var(--shadow-panel)}*{box-sizing:border-box}html{color-scheme:dark}body{background:radial-gradient(circle at 12% -8%,#fbbf2417,transparent 28rem),radial-gradient(circle at 88% 10%,#6366f114,transparent 32rem),var(--color-canvas);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;min-width:320px;min-height:100vh;margin:0;overflow-x:hidden}button,input,textarea,select{font:inherit}button,a{-webkit-tap-highlight-color:transparent}:focus-visible{outline:2px solid var(--color-accent);outline-offset:3px}::selection{color:#fff;background:#fcd34d3d}.font-display{font-family:var(--font-display)}.book-page{background-image:linear-gradient(#ffffff05 1px,#0000 1px),linear-gradient(90deg,#ffffff05 1px,#0000 1px);background-size:32px 32px}.book-panel{border:1px solid var(--panel-border);border-radius:var(--panel-radius);background:var(--panel-background);box-shadow:var(--panel-shadow);-webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px)}.book-topic-card{border:1px solid var(--panel-border);background:#0f172a85;border-radius:1rem;transition:transform .18s,border-color .18s,background-color .18s;box-shadow:0 12px 40px #0000001f}.book-topic-card:hover{background:#0f172ac7;border-color:#ffffff29;transform:translateY(-2px)}.trace-control{color:#94a3b8;background:#ffffff0b;border-radius:.5rem;justify-content:center;align-items:center;width:2rem;height:2rem;transition:color .15s,background-color .15s;display:inline-flex;box-shadow:inset 0 0 0 1px #ffffff12}.trace-control:hover:not(:disabled){color:#fff;background:#ffffff14}.trace-control:disabled{cursor:not-allowed;opacity:.3}.trace-control-primary{color:#022c22;box-shadow:none;background:#6ee7b7}.trace-control-primary:hover:not(:disabled){color:#022c22;background:#a7f3d0}@media(prefers-reduced-motion:reduce){*,:before,:after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}@keyframes visited{0%{opacity:0;border-radius:50%;transform:scale(.3)}50%{opacity:.8;border-radius:30%;transform:scale(1.1)}to{opacity:1;border-radius:0;transform:scale(1)}}@keyframes path{0%{opacity:0;transform:scale(.5)}50%{opacity:1;transform:scale(1.3)}to{opacity:1;transform:scale(1)}}@keyframes wall{0%{transform:scale(.6)}50%{transform:scale(1.1)}to{transform:scale(1)}}@keyframes shake{0%,to{transform:translate(0)}25%{transform:translate(-6px)}50%{transform:translate(6px)}75%{transform:translate(-4px)}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}} diff --git a/docs/assets/index-DBkLeWDs.js b/docs/assets/index-DBkLeWDs.js new file mode 100644 index 0000000..c827793 --- /dev/null +++ b/docs/assets/index-DBkLeWDs.js @@ -0,0 +1,16 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AlgorithmPlaygroundPage-DJ5poldo.js","assets/AlgorithmCodePanel-CE3r0DXd.js","assets/audioContext-NbgqvQGz.js","assets/shuffle-Dlr-c52A.js","assets/chevron-right-CFBAUJsk.js","assets/play-mcIZClKO.js","assets/rotate-ccw-7GTUOPy4.js","assets/volume-x-BSx9gxSg.js","assets/LinkedListAlgorithmsPage-CUxv2ABR.js","assets/linkedListAlgo-0_WYfSZm.js","assets/arrow-left-CTMPG6pL.js","assets/LinkedListAlgoPage-qNeBmS2f.js","assets/pause-CG1snUW9.js","assets/GraphTraversalPage-B_xobZ-f.js","assets/index-DrhCNtmA.js","assets/sparkles-3Zw4K66N.js","assets/square-Bc_q5e3l.js","assets/SortingPage-R3xRGgbf.js","assets/index-iw_6MvvU.js","assets/SudokuPage-C5NKtd3W.js","assets/zap-CUITaKA-.js","assets/TreeTraversalPage-B0ns8Kv6.js","assets/TriePage-CjYcQVOU.js","assets/plus-DVazsZHX.js","assets/BalancedTreePage-2nu-ZXqQ.js","assets/StackPage-0M1nrFIi.js","assets/useDSSound-KKipmh13.js","assets/trash-2-C6_cMdiI.js","assets/QueuePage-0cpMqKev.js","assets/ArrayPage-CbscCeVa.js","assets/LinkedListPage-CPh-u55R.js","assets/AdvancedStructurePage-BNdv4Rsg.js","assets/FibonacciGamePage-Bd8sKYsw.js","assets/trophy-C1QWh03u.js","assets/lightbulb-xA5HFx8I.js","assets/timer-e0gb0oZa.js","assets/DijkstraGamePage-DovdEQ8Y.js","assets/map-9j6oGOs_.js","assets/route-C4zDL9m7.js","assets/eye-off-BfEKGZbc.js","assets/BattlePage-aVfnCuym.js","assets/MahjongGamePage-CBqcyOb2.js","assets/skip-forward-C79KMIOU.js","assets/EvolutionSimulatorPage-C1Me-6kF.js","assets/RubiksCubeGamePage-B1qlWFPn.js","assets/WorldMapGamePage-Dd7brX_d.js","assets/GitPage-B_7vY4jd.js","assets/CodeVisualizerPage-CGESrDz0.js"])))=>i.map(i=>d[i]); +(function(){const f=document.createElement("link").relList;if(f&&f.supports&&f.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const y of o)if(y.type==="childList")for(const x of y.addedNodes)x.tagName==="LINK"&&x.rel==="modulepreload"&&s(x)}).observe(document,{childList:!0,subtree:!0});function d(o){const y={};return o.integrity&&(y.integrity=o.integrity),o.referrerPolicy&&(y.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?y.credentials="include":o.crossOrigin==="anonymous"?y.credentials="omit":y.credentials="same-origin",y}function s(o){if(o.ep)return;o.ep=!0;const y=d(o);fetch(o.href,y)}})();var Us={exports:{}},Bn={};var ch;function R1(){if(ch)return Bn;ch=1;var c=Symbol.for("react.transitional.element"),f=Symbol.for("react.fragment");function d(s,o,y){var x=null;if(y!==void 0&&(x=""+y),o.key!==void 0&&(x=""+o.key),"key"in o){y={};for(var j in o)j!=="key"&&(y[j]=o[j])}else y=o;return o=y.ref,{$$typeof:c,type:s,key:x,ref:o!==void 0?o:null,props:y}}return Bn.Fragment=f,Bn.jsx=d,Bn.jsxs=d,Bn}var sh;function M1(){return sh||(sh=1,Us.exports=R1()),Us.exports}var h=M1(),Hs={exports:{}},P={};var fh;function N1(){if(fh)return P;fh=1;var c=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),x=Symbol.for("react.context"),j=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),B=Symbol.iterator;function V(g){return g===null||typeof g!="object"?null:(g=B&&g[B]||g["@@iterator"],typeof g=="function"?g:null)}var Q={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Y=Object.assign,H={};function J(g,U,L){this.props=g,this.context=U,this.refs=H,this.updater=L||Q}J.prototype.isReactComponent={},J.prototype.setState=function(g,U){if(typeof g!="object"&&typeof g!="function"&&g!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,g,U,"setState")},J.prototype.forceUpdate=function(g){this.updater.enqueueForceUpdate(this,g,"forceUpdate")};function et(){}et.prototype=J.prototype;function $(g,U,L){this.props=g,this.context=U,this.refs=H,this.updater=L||Q}var xt=$.prototype=new et;xt.constructor=$,Y(xt,J.prototype),xt.isPureReactComponent=!0;var St=Array.isArray;function jt(){}var F={H:null,A:null,T:null,S:null},Dt=Object.prototype.hasOwnProperty;function $t(g,U,L){var G=L.ref;return{$$typeof:c,type:g,key:U,ref:G!==void 0?G:null,props:L}}function Be(g,U){return $t(g.type,U,g.props)}function ge(g){return typeof g=="object"&&g!==null&&g.$$typeof===c}function Wt(g){var U={"=":"=0",":":"=2"};return"$"+g.replace(/[=:]/g,function(L){return U[L]})}var qe=/\/+/g;function be(g,U){return typeof g=="object"&&g!==null&&g.key!=null?Wt(""+g.key):U.toString(36)}function Bt(g){switch(g.status){case"fulfilled":return g.value;case"rejected":throw g.reason;default:switch(typeof g.status=="string"?g.then(jt,jt):(g.status="pending",g.then(function(U){g.status==="pending"&&(g.status="fulfilled",g.value=U)},function(U){g.status==="pending"&&(g.status="rejected",g.reason=U)})),g.status){case"fulfilled":return g.value;case"rejected":throw g.reason}}throw g}function O(g,U,L,G,I){var at=typeof g;(at==="undefined"||at==="boolean")&&(g=null);var ht=!1;if(g===null)ht=!0;else switch(at){case"bigint":case"string":case"number":ht=!0;break;case"object":switch(g.$$typeof){case c:case f:ht=!0;break;case M:return ht=g._init,O(ht(g._payload),U,L,G,I)}}if(ht)return I=I(g),ht=G===""?"."+be(g,0):G,St(I)?(L="",ht!=null&&(L=ht.replace(qe,"$&/")+"/"),O(I,U,L,"",function(ka){return ka})):I!=null&&(ge(I)&&(I=Be(I,L+(I.key==null||g&&g.key===I.key?"":(""+I.key).replace(qe,"$&/")+"/")+ht)),U.push(I)),1;ht=0;var Pt=G===""?".":G+":";if(St(g))for(var Ct=0;Ct>>1,Et=O[pt];if(0>>1;pto(L,W))Go(I,L)?(O[pt]=I,O[G]=W,pt=G):(O[pt]=L,O[U]=W,pt=U);else if(Go(I,W))O[pt]=I,O[G]=W,pt=G;else break t}}return q}function o(O,q){var W=O.sortIndex-q.sortIndex;return W!==0?W:O.id-q.id}if(c.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var y=performance;c.unstable_now=function(){return y.now()}}else{var x=Date,j=x.now();c.unstable_now=function(){return x.now()-j}}var S=[],p=[],M=1,A=null,B=3,V=!1,Q=!1,Y=!1,H=!1,J=typeof setTimeout=="function"?setTimeout:null,et=typeof clearTimeout=="function"?clearTimeout:null,$=typeof setImmediate<"u"?setImmediate:null;function xt(O){for(var q=d(p);q!==null;){if(q.callback===null)s(p);else if(q.startTime<=O)s(p),q.sortIndex=q.expirationTime,f(S,q);else break;q=d(p)}}function St(O){if(Y=!1,xt(O),!Q)if(d(S)!==null)Q=!0,jt||(jt=!0,Wt());else{var q=d(p);q!==null&&Bt(St,q.startTime-O)}}var jt=!1,F=-1,Dt=5,$t=-1;function Be(){return H?!0:!(c.unstable_now()-$tO&&Be());){var pt=A.callback;if(typeof pt=="function"){A.callback=null,B=A.priorityLevel;var Et=pt(A.expirationTime<=O);if(O=c.unstable_now(),typeof Et=="function"){A.callback=Et,xt(O),q=!0;break e}A===d(S)&&s(S),xt(O)}else s(S);A=d(S)}if(A!==null)q=!0;else{var g=d(p);g!==null&&Bt(St,g.startTime-O),q=!1}}break t}finally{A=null,B=W,V=!1}q=void 0}}finally{q?Wt():jt=!1}}}var Wt;if(typeof $=="function")Wt=function(){$(ge)};else if(typeof MessageChannel<"u"){var qe=new MessageChannel,be=qe.port2;qe.port1.onmessage=ge,Wt=function(){be.postMessage(null)}}else Wt=function(){J(ge,0)};function Bt(O,q){F=J(function(){O(c.unstable_now())},q)}c.unstable_IdlePriority=5,c.unstable_ImmediatePriority=1,c.unstable_LowPriority=4,c.unstable_NormalPriority=3,c.unstable_Profiling=null,c.unstable_UserBlockingPriority=2,c.unstable_cancelCallback=function(O){O.callback=null},c.unstable_forceFrameRate=function(O){0>O||125pt?(O.sortIndex=W,f(p,O),d(S)===null&&O===d(p)&&(Y?(et(F),F=-1):Y=!0,Bt(St,W-pt))):(O.sortIndex=Et,f(S,O),Q||V||(Q=!0,jt||(jt=!0,Wt()))),O},c.unstable_shouldYield=Be,c.unstable_wrapCallback=function(O){var q=B;return function(){var W=B;B=q;try{return O.apply(this,arguments)}finally{B=W}}}})(Ls)),Ls}var dh;function D1(){return dh||(dh=1,qs.exports=O1()),qs.exports}var ws={exports:{}},Ft={};var hh;function C1(){if(hh)return Ft;hh=1;var c=Js();function f(S){var p="https://react.dev/errors/"+S;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(c)}catch(f){console.error(f)}}return c(),ws.exports=C1(),ws.exports}var yh;function H1(){if(yh)return qn;yh=1;var c=D1(),f=Js(),d=U1();function s(t){var e="https://react.dev/errors/"+t;if(1Et||(t.current=pt[Et],pt[Et]=null,Et--)}function L(t,e){Et++,pt[Et]=t.current,t.current=e}var G=g(null),I=g(null),at=g(null),ht=g(null);function Pt(t,e){switch(L(at,e),L(I,t),L(G,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Nd(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Nd(e),t=Od(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}U(G),L(G,t)}function Ct(){U(G),U(I),U(at)}function ka(t){t.memoizedState!==null&&L(ht,t);var e=G.current,l=Od(e,t.type);e!==l&&(L(I,t),L(G,l))}function Xn(t){I.current===t&&(U(G),U(I)),ht.current===t&&(U(ht),Dn._currentValue=W)}var pi,nf;function ql(t){if(pi===void 0)try{throw Error()}catch(l){var e=l.stack.trim().match(/\n( *(at )?)/);pi=e&&e[1]||"",nf=-1)":-1n||m[a]!==_[n]){var N=` +`+m[a].replace(" at new "," at ");return t.displayName&&N.includes("")&&(N=N.replace("",t.displayName)),N}while(1<=a&&0<=n);break}}}finally{vi=!1,Error.prepareStackTrace=l}return(l=t?t.displayName||t.name:"")?ql(l):""}function um(t,e){switch(t.tag){case 26:case 27:case 5:return ql(t.type);case 16:return ql("Lazy");case 13:return t.child!==e&&e!==null?ql("Suspense Fallback"):ql("Suspense");case 19:return ql("SuspenseList");case 0:case 15:return gi(t.type,!1);case 11:return gi(t.type.render,!1);case 1:return gi(t.type,!0);case 31:return ql("Activity");default:return""}}function uf(t){try{var e="",l=null;do e+=um(t,l),l=t,t=t.return;while(t);return e}catch(a){return` +Error generating stack: `+a.message+` +`+a.stack}}var bi=Object.prototype.hasOwnProperty,xi=c.unstable_scheduleCallback,Si=c.unstable_cancelCallback,im=c.unstable_shouldYield,cm=c.unstable_requestPaint,se=c.unstable_now,sm=c.unstable_getCurrentPriorityLevel,cf=c.unstable_ImmediatePriority,sf=c.unstable_UserBlockingPriority,Vn=c.unstable_NormalPriority,fm=c.unstable_LowPriority,ff=c.unstable_IdlePriority,rm=c.log,om=c.unstable_setDisableYieldValue,Qa=null,fe=null;function dl(t){if(typeof rm=="function"&&om(t),fe&&typeof fe.setStrictMode=="function")try{fe.setStrictMode(Qa,t)}catch{}}var re=Math.clz32?Math.clz32:mm,dm=Math.log,hm=Math.LN2;function mm(t){return t>>>=0,t===0?32:31-(dm(t)/hm|0)|0}var Zn=256,Kn=262144,Jn=4194304;function Ll(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function $n(t,e,l){var a=t.pendingLanes;if(a===0)return 0;var n=0,u=t.suspendedLanes,i=t.pingedLanes;t=t.warmLanes;var r=a&134217727;return r!==0?(a=r&~u,a!==0?n=Ll(a):(i&=r,i!==0?n=Ll(i):l||(l=r&~t,l!==0&&(n=Ll(l))))):(r=a&~u,r!==0?n=Ll(r):i!==0?n=Ll(i):l||(l=a&~t,l!==0&&(n=Ll(l)))),n===0?0:e!==0&&e!==n&&(e&u)===0&&(u=n&-n,l=e&-e,u>=l||u===32&&(l&4194048)!==0)?e:n}function Xa(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function ym(t,e){switch(t){case 1:case 2:case 4:case 8:case 64:return e+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function rf(){var t=Jn;return Jn<<=1,(Jn&62914560)===0&&(Jn=4194304),t}function Ei(t){for(var e=[],l=0;31>l;l++)e.push(t);return e}function Va(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function pm(t,e,l,a,n,u){var i=t.pendingLanes;t.pendingLanes=l,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=l,t.entangledLanes&=l,t.errorRecoveryDisabledLanes&=l,t.shellSuspendCounter=0;var r=t.entanglements,m=t.expirationTimes,_=t.hiddenUpdates;for(l=i&~l;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Em=/[\n"\\]/g;function Se(t){return t.replace(Em,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function Ri(t,e,l,a,n,u,i,r){t.name="",i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"?t.type=i:t.removeAttribute("type"),e!=null?i==="number"?(e===0&&t.value===""||t.value!=e)&&(t.value=""+xe(e)):t.value!==""+xe(e)&&(t.value=""+xe(e)):i!=="submit"&&i!=="reset"||t.removeAttribute("value"),e!=null?Mi(t,i,xe(e)):l!=null?Mi(t,i,xe(l)):a!=null&&t.removeAttribute("value"),n==null&&u!=null&&(t.defaultChecked=!!u),n!=null&&(t.checked=n&&typeof n!="function"&&typeof n!="symbol"),r!=null&&typeof r!="function"&&typeof r!="symbol"&&typeof r!="boolean"?t.name=""+xe(r):t.removeAttribute("name")}function _f(t,e,l,a,n,u,i,r){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(t.type=u),e!=null||l!=null){if(!(u!=="submit"&&u!=="reset"||e!=null)){ji(t);return}l=l!=null?""+xe(l):"",e=e!=null?""+xe(e):l,r||e===t.value||(t.value=e),t.defaultValue=e}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,t.checked=r?t.checked:!!a,t.defaultChecked=!!a,i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"&&(t.name=i),ji(t)}function Mi(t,e,l){e==="number"&&Pn(t.ownerDocument)===t||t.defaultValue===""+l||(t.defaultValue=""+l)}function ca(t,e,l,a){if(t=t.options,e){e={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ui=!1;if(Ve)try{var $a={};Object.defineProperty($a,"passive",{get:function(){Ui=!0}}),window.addEventListener("test",$a,$a),window.removeEventListener("test",$a,$a)}catch{Ui=!1}var ml=null,Hi=null,tu=null;function Nf(){if(tu)return tu;var t,e=Hi,l=e.length,a,n="value"in ml?ml.value:ml.textContent,u=n.length;for(t=0;t=Pa),Bf=" ",qf=!1;function Lf(t,e){switch(t){case"keyup":return Wm.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wf(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var oa=!1;function Pm(t,e){switch(t){case"compositionend":return wf(e);case"keypress":return e.which!==32?null:(qf=!0,Bf);case"textInput":return t=e.data,t===Bf&&qf?null:t;default:return null}}function Im(t,e){if(oa)return t==="compositionend"||!Yi&&Lf(t,e)?(t=Nf(),tu=Hi=ml=null,oa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:l,offset:e-t};t=a}t:{for(;l;){if(l.nextSibling){l=l.nextSibling;break t}l=l.parentNode}l=void 0}l=Kf(l)}}function $f(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?$f(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Wf(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=Pn(t.document);e instanceof t.HTMLIFrameElement;){try{var l=typeof e.contentWindow.location.href=="string"}catch{l=!1}if(l)t=e.contentWindow;else break;e=Pn(t.document)}return e}function Qi(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var c0=Ve&&"documentMode"in document&&11>=document.documentMode,da=null,Xi=null,ln=null,Vi=!1;function Ff(t,e,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Vi||da==null||da!==Pn(a)||(a=da,"selectionStart"in a&&Qi(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),ln&&en(ln,a)||(ln=a,a=Ku(Xi,"onSelect"),0>=i,n-=i,Le=1<<32-re(e)+n|l<lt?(ct=k,k=null):ct=k.sibling;var ot=T(b,k,E[lt],D);if(ot===null){k===null&&(k=ct);break}t&&k&&ot.alternate===null&&e(b,k),v=u(ot,v,lt),rt===null?X=ot:rt.sibling=ot,rt=ot,k=ct}if(lt===E.length)return l(b,k),ft&&Ke(b,lt),X;if(k===null){for(;ltlt?(ct=k,k=null):ct=k.sibling;var Bl=T(b,k,ot.value,D);if(Bl===null){k===null&&(k=ct);break}t&&k&&Bl.alternate===null&&e(b,k),v=u(Bl,v,lt),rt===null?X=Bl:rt.sibling=Bl,rt=Bl,k=ct}if(ot.done)return l(b,k),ft&&Ke(b,lt),X;if(k===null){for(;!ot.done;lt++,ot=E.next())ot=C(b,ot.value,D),ot!==null&&(v=u(ot,v,lt),rt===null?X=ot:rt.sibling=ot,rt=ot);return ft&&Ke(b,lt),X}for(k=a(k);!ot.done;lt++,ot=E.next())ot=R(k,b,lt,ot.value,D),ot!==null&&(t&&ot.alternate!==null&&k.delete(ot.key===null?lt:ot.key),v=u(ot,v,lt),rt===null?X=ot:rt.sibling=ot,rt=ot);return t&&k.forEach(function(j1){return e(b,j1)}),ft&&Ke(b,lt),X}function bt(b,v,E,D){if(typeof E=="object"&&E!==null&&E.type===Y&&E.key===null&&(E=E.props.children),typeof E=="object"&&E!==null){switch(E.$$typeof){case V:t:{for(var X=E.key;v!==null;){if(v.key===X){if(X=E.type,X===Y){if(v.tag===7){l(b,v.sibling),D=n(v,E.props.children),D.return=b,b=D;break t}}else if(v.elementType===X||typeof X=="object"&&X!==null&&X.$$typeof===Dt&&$l(X)===v.type){l(b,v.sibling),D=n(v,E.props),fn(D,E),D.return=b,b=D;break t}l(b,v);break}else e(b,v);v=v.sibling}E.type===Y?(D=Xl(E.props.children,b.mode,D,E.key),D.return=b,b=D):(D=ru(E.type,E.key,E.props,null,b.mode,D),fn(D,E),D.return=b,b=D)}return i(b);case Q:t:{for(X=E.key;v!==null;){if(v.key===X)if(v.tag===4&&v.stateNode.containerInfo===E.containerInfo&&v.stateNode.implementation===E.implementation){l(b,v.sibling),D=n(v,E.children||[]),D.return=b,b=D;break t}else{l(b,v);break}else e(b,v);v=v.sibling}D=Pi(E,b.mode,D),D.return=b,b=D}return i(b);case Dt:return E=$l(E),bt(b,v,E,D)}if(Bt(E))return w(b,v,E,D);if(Wt(E)){if(X=Wt(E),typeof X!="function")throw Error(s(150));return E=X.call(E),Z(b,v,E,D)}if(typeof E.then=="function")return bt(b,v,vu(E),D);if(E.$$typeof===$)return bt(b,v,hu(b,E),D);gu(b,E)}return typeof E=="string"&&E!==""||typeof E=="number"||typeof E=="bigint"?(E=""+E,v!==null&&v.tag===6?(l(b,v.sibling),D=n(v,E),D.return=b,b=D):(l(b,v),D=Fi(E,b.mode,D),D.return=b,b=D),i(b)):l(b,v)}return function(b,v,E,D){try{sn=0;var X=bt(b,v,E,D);return _a=null,X}catch(k){if(k===Ea||k===yu)throw k;var rt=de(29,k,null,b.mode);return rt.lanes=D,rt.return=b,rt}}}var Fl=xr(!0),Sr=xr(!1),bl=!1;function rc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function oc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function xl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Sl(t,e,l){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,(dt&2)!==0){var n=a.pending;return n===null?e.next=e:(e.next=n.next,n.next=e),a.pending=e,e=fu(t),nr(t,null,l),e}return su(t,a,e,l),fu(t)}function rn(t,e,l){if(e=e.updateQueue,e!==null&&(e=e.shared,(l&4194048)!==0)){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,df(t,l)}}function dc(t,e){var l=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,u=null;if(l=l.firstBaseUpdate,l!==null){do{var i={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};u===null?n=u=i:u=u.next=i,l=l.next}while(l!==null);u===null?n=u=e:u=u.next=e}else n=u=e;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=e:t.next=e,l.lastBaseUpdate=e}var hc=!1;function on(){if(hc){var t=Sa;if(t!==null)throw t}}function dn(t,e,l,a){hc=!1;var n=t.updateQueue;bl=!1;var u=n.firstBaseUpdate,i=n.lastBaseUpdate,r=n.shared.pending;if(r!==null){n.shared.pending=null;var m=r,_=m.next;m.next=null,i===null?u=_:i.next=_,i=m;var N=t.alternate;N!==null&&(N=N.updateQueue,r=N.lastBaseUpdate,r!==i&&(r===null?N.firstBaseUpdate=_:r.next=_,N.lastBaseUpdate=m))}if(u!==null){var C=n.baseState;i=0,N=_=m=null,r=u;do{var T=r.lane&-536870913,R=T!==r.lane;if(R?(it&T)===T:(a&T)===T){T!==0&&T===xa&&(hc=!0),N!==null&&(N=N.next={lane:0,tag:r.tag,payload:r.payload,callback:null,next:null});t:{var w=t,Z=r;T=e;var bt=l;switch(Z.tag){case 1:if(w=Z.payload,typeof w=="function"){C=w.call(bt,C,T);break t}C=w;break t;case 3:w.flags=w.flags&-65537|128;case 0:if(w=Z.payload,T=typeof w=="function"?w.call(bt,C,T):w,T==null)break t;C=A({},C,T);break t;case 2:bl=!0}}T=r.callback,T!==null&&(t.flags|=64,R&&(t.flags|=8192),R=n.callbacks,R===null?n.callbacks=[T]:R.push(T))}else R={lane:T,tag:r.tag,payload:r.payload,callback:r.callback,next:null},N===null?(_=N=R,m=C):N=N.next=R,i|=T;if(r=r.next,r===null){if(r=n.shared.pending,r===null)break;R=r,r=R.next,R.next=null,n.lastBaseUpdate=R,n.shared.pending=null}}while(!0);N===null&&(m=C),n.baseState=m,n.firstBaseUpdate=_,n.lastBaseUpdate=N,u===null&&(n.shared.lanes=0),Al|=i,t.lanes=i,t.memoizedState=C}}function Er(t,e){if(typeof t!="function")throw Error(s(191,t));t.call(e)}function _r(t,e){var l=t.callbacks;if(l!==null)for(t.callbacks=null,t=0;tu?u:8;var i=O.T,r={};O.T=r,Dc(t,!1,e,l);try{var m=n(),_=O.S;if(_!==null&&_(r,m),m!==null&&typeof m=="object"&&typeof m.then=="function"){var N=p0(m,a);yn(t,e,N,ve(t))}else yn(t,e,a,ve(t))}catch(C){yn(t,e,{then:function(){},status:"rejected",reason:C},ve())}finally{q.p=u,i!==null&&r.types!==null&&(i.types=r.types),O.T=i}}function E0(){}function Nc(t,e,l,a){if(t.tag!==5)throw Error(s(476));var n=eo(t).queue;to(t,n,e,W,l===null?E0:function(){return lo(t),l(a)})}function eo(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fe,lastRenderedState:W},next:null};var l={};return e.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fe,lastRenderedState:l},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function lo(t){var e=eo(t);e.next===null&&(e=t.alternate.memoizedState),yn(t,e.next.queue,{},ve())}function Oc(){return Zt(Dn)}function ao(){return Ht().memoizedState}function no(){return Ht().memoizedState}function _0(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var l=ve();t=xl(l);var a=Sl(e,t,l);a!==null&&(ie(a,e,l),rn(a,e,l)),e={cache:ic()},t.payload=e;return}e=e.return}}function z0(t,e,l){var a=ve();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ru(t)?io(e,l):(l=$i(t,e,l,a),l!==null&&(ie(l,t,a),co(l,e,a)))}function uo(t,e,l){var a=ve();yn(t,e,l,a)}function yn(t,e,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Ru(t))io(e,n);else{var u=t.alternate;if(t.lanes===0&&(u===null||u.lanes===0)&&(u=e.lastRenderedReducer,u!==null))try{var i=e.lastRenderedState,r=u(i,l);if(n.hasEagerState=!0,n.eagerState=r,oe(r,i))return su(t,e,n,0),_t===null&&cu(),!1}catch{}if(l=$i(t,e,n,a),l!==null)return ie(l,t,a),co(l,e,a),!0}return!1}function Dc(t,e,l,a){if(a={lane:2,revertLane:rs(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Ru(t)){if(e)throw Error(s(479))}else e=$i(t,l,a,2),e!==null&&ie(e,t,2)}function Ru(t){var e=t.alternate;return t===tt||e!==null&&e===tt}function io(t,e){Ta=Su=!0;var l=t.pending;l===null?e.next=e:(e.next=l.next,l.next=e),t.pending=e}function co(t,e,l){if((l&4194048)!==0){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,df(t,l)}}var pn={readContext:Zt,use:zu,useCallback:Nt,useContext:Nt,useEffect:Nt,useImperativeHandle:Nt,useLayoutEffect:Nt,useInsertionEffect:Nt,useMemo:Nt,useReducer:Nt,useRef:Nt,useState:Nt,useDebugValue:Nt,useDeferredValue:Nt,useTransition:Nt,useSyncExternalStore:Nt,useId:Nt,useHostTransitionStatus:Nt,useFormState:Nt,useActionState:Nt,useOptimistic:Nt,useMemoCache:Nt,useCacheRefresh:Nt};pn.useEffectEvent=Nt;var so={readContext:Zt,use:zu,useCallback:function(t,e){return It().memoizedState=[t,e===void 0?null:e],t},useContext:Zt,useEffect:Vr,useImperativeHandle:function(t,e,l){l=l!=null?l.concat([t]):null,Au(4194308,4,$r.bind(null,e,t),l)},useLayoutEffect:function(t,e){return Au(4194308,4,t,e)},useInsertionEffect:function(t,e){Au(4,2,t,e)},useMemo:function(t,e){var l=It();e=e===void 0?null:e;var a=t();if(Pl){dl(!0);try{t()}finally{dl(!1)}}return l.memoizedState=[a,e],a},useReducer:function(t,e,l){var a=It();if(l!==void 0){var n=l(e);if(Pl){dl(!0);try{l(e)}finally{dl(!1)}}}else n=e;return a.memoizedState=a.baseState=n,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},a.queue=t,t=t.dispatch=z0.bind(null,tt,t),[a.memoizedState,t]},useRef:function(t){var e=It();return t={current:t},e.memoizedState=t},useState:function(t){t=Tc(t);var e=t.queue,l=uo.bind(null,tt,e);return e.dispatch=l,[t.memoizedState,l]},useDebugValue:Rc,useDeferredValue:function(t,e){var l=It();return Mc(l,t,e)},useTransition:function(){var t=Tc(!1);return t=to.bind(null,tt,t.queue,!0,!1),It().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,l){var a=tt,n=It();if(ft){if(l===void 0)throw Error(s(407));l=l()}else{if(l=e(),_t===null)throw Error(s(349));(it&127)!==0||Mr(a,e,l)}n.memoizedState=l;var u={value:l,getSnapshot:e};return n.queue=u,Vr(Or.bind(null,a,u,t),[t]),a.flags|=2048,ja(9,{destroy:void 0},Nr.bind(null,a,u,l,e),null),l},useId:function(){var t=It(),e=_t.identifierPrefix;if(ft){var l=we,a=Le;l=(a&~(1<<32-re(a)-1)).toString(32)+l,e="_"+e+"R_"+l,l=Eu++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?i.createElement("select",{is:a.is}):i.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?i.createElement(n,{is:a.is}):i.createElement(n)}}u[Xt]=e,u[te]=a;t:for(i=e.child;i!==null;){if(i.tag===5||i.tag===6)u.appendChild(i.stateNode);else if(i.tag!==4&&i.tag!==27&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===e)break t;for(;i.sibling===null;){if(i.return===null||i.return===e)break t;i=i.return}i.sibling.return=i.return,i=i.sibling}e.stateNode=u;t:switch(Jt(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break t;case"img":a=!0;break t;default:a=!1}a&&Ie(e)}}return Tt(e),Zc(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,l),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==a&&Ie(e);else{if(typeof a!="string"&&e.stateNode===null)throw Error(s(166));if(t=at.current,ga(e)){if(t=e.stateNode,l=e.memoizedProps,a=null,n=Vt,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}t[Xt]=e,t=!!(t.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||Rd(t.nodeValue,l)),t||vl(e,!0)}else t=Ju(t).createTextNode(a),t[Xt]=e,e.stateNode=t}return Tt(e),null;case 31:if(l=e.memoizedState,t===null||t.memoizedState!==null){if(a=ga(e),l!==null){if(t===null){if(!a)throw Error(s(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[Xt]=e}else Vl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Tt(e),t=!1}else l=lc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=l),t=!0;if(!t)return e.flags&256?(me(e),e):(me(e),null);if((e.flags&128)!==0)throw Error(s(558))}return Tt(e),null;case 13:if(a=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(n=ga(e),a!==null&&a.dehydrated!==null){if(t===null){if(!n)throw Error(s(318));if(n=e.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));n[Xt]=e}else Vl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Tt(e),n=!1}else n=lc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),n=!0;if(!n)return e.flags&256?(me(e),e):(me(e),null)}return me(e),(e.flags&128)!==0?(e.lanes=l,e):(l=a!==null,t=t!==null&&t.memoizedState!==null,l&&(a=e.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),l!==t&&l&&(e.child.flags|=8192),Cu(e,e.updateQueue),Tt(e),null);case 4:return Ct(),t===null&&ms(e.stateNode.containerInfo),Tt(e),null;case 10:return $e(e.type),Tt(e),null;case 19:if(U(Ut),a=e.memoizedState,a===null)return Tt(e),null;if(n=(e.flags&128)!==0,u=a.rendering,u===null)if(n)gn(a,!1);else{if(Ot!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(u=xu(t),u!==null){for(e.flags|=128,gn(a,!1),t=u.updateQueue,e.updateQueue=t,Cu(e,t),e.subtreeFlags=0,t=l,l=e.child;l!==null;)ur(l,t),l=l.sibling;return L(Ut,Ut.current&1|2),ft&&Ke(e,a.treeForkCount),e.child}t=t.sibling}a.tail!==null&&se()>Lu&&(e.flags|=128,n=!0,gn(a,!1),e.lanes=4194304)}else{if(!n)if(t=xu(u),t!==null){if(e.flags|=128,n=!0,t=t.updateQueue,e.updateQueue=t,Cu(e,t),gn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!ft)return Tt(e),null}else 2*se()-a.renderingStartTime>Lu&&l!==536870912&&(e.flags|=128,n=!0,gn(a,!1),e.lanes=4194304);a.isBackwards?(u.sibling=e.child,e.child=u):(t=a.last,t!==null?t.sibling=u:e.child=u,a.last=u)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=se(),t.sibling=null,l=Ut.current,L(Ut,n?l&1|2:l&1),ft&&Ke(e,a.treeForkCount),t):(Tt(e),null);case 22:case 23:return me(e),yc(),a=e.memoizedState!==null,t!==null?t.memoizedState!==null!==a&&(e.flags|=8192):a&&(e.flags|=8192),a?(l&536870912)!==0&&(e.flags&128)===0&&(Tt(e),e.subtreeFlags&6&&(e.flags|=8192)):Tt(e),l=e.updateQueue,l!==null&&Cu(e,l.retryQueue),l=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),a=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),a!==l&&(e.flags|=2048),t!==null&&U(Jl),null;case 24:return l=null,t!==null&&(l=t.memoizedState.cache),e.memoizedState.cache!==l&&(e.flags|=2048),$e(qt),Tt(e),null;case 25:return null;case 30:return null}throw Error(s(156,e.tag))}function M0(t,e){switch(tc(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return $e(qt),Ct(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return Xn(e),null;case 31:if(e.memoizedState!==null){if(me(e),e.alternate===null)throw Error(s(340));Vl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(me(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(s(340));Vl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return U(Ut),null;case 4:return Ct(),null;case 10:return $e(e.type),null;case 22:case 23:return me(e),yc(),t!==null&&U(Jl),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return $e(qt),null;case 25:return null;default:return null}}function Co(t,e){switch(tc(e),e.tag){case 3:$e(qt),Ct();break;case 26:case 27:case 5:Xn(e);break;case 4:Ct();break;case 31:e.memoizedState!==null&&me(e);break;case 13:me(e);break;case 19:U(Ut);break;case 10:$e(e.type);break;case 22:case 23:me(e),yc(),t!==null&&U(Jl);break;case 24:$e(qt)}}function bn(t,e){try{var l=e.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&t)===t){a=void 0;var u=l.create,i=l.inst;a=u(),i.destroy=a}l=l.next}while(l!==n)}}catch(r){yt(e,e.return,r)}}function zl(t,e,l){try{var a=e.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&t)===t){var i=a.inst,r=i.destroy;if(r!==void 0){i.destroy=void 0,n=e;var m=l,_=r;try{_()}catch(N){yt(n,m,N)}}}a=a.next}while(a!==u)}}catch(N){yt(e,e.return,N)}}function Uo(t){var e=t.updateQueue;if(e!==null){var l=t.stateNode;try{_r(e,l)}catch(a){yt(t,t.return,a)}}}function Ho(t,e,l){l.props=Il(t.type,t.memoizedProps),l.state=t.memoizedState;try{l.componentWillUnmount()}catch(a){yt(t,e,a)}}function xn(t,e){try{var l=t.ref;if(l!==null){switch(t.tag){case 26:case 27:case 5:var a=t.stateNode;break;case 30:a=t.stateNode;break;default:a=t.stateNode}typeof l=="function"?t.refCleanup=l(a):l.current=a}}catch(n){yt(t,e,n)}}function Ye(t,e){var l=t.ref,a=t.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){yt(t,e,n)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){yt(t,e,n)}else l.current=null}function Bo(t){var e=t.type,l=t.memoizedProps,a=t.stateNode;try{t:switch(e){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break t;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){yt(t,t.return,n)}}function Kc(t,e,l){try{var a=t.stateNode;F0(a,t.type,l,e),a[te]=e}catch(n){yt(t,t.return,n)}}function qo(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Ol(t.type)||t.tag===4}function Jc(t){t:for(;;){for(;t.sibling===null;){if(t.return===null||qo(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Ol(t.type)||t.flags&2||t.child===null||t.tag===4)continue t;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function $c(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(t,e):(e=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,e.appendChild(t),l=l._reactRootContainer,l!=null||e.onclick!==null||(e.onclick=Xe));else if(a!==4&&(a===27&&Ol(t.type)&&(l=t.stateNode,e=null),t=t.child,t!==null))for($c(t,e,l),t=t.sibling;t!==null;)$c(t,e,l),t=t.sibling}function Uu(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?l.insertBefore(t,e):l.appendChild(t);else if(a!==4&&(a===27&&Ol(t.type)&&(l=t.stateNode),t=t.child,t!==null))for(Uu(t,e,l),t=t.sibling;t!==null;)Uu(t,e,l),t=t.sibling}function Lo(t){var e=t.stateNode,l=t.memoizedProps;try{for(var a=t.type,n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Jt(e,a,l),e[Xt]=t,e[te]=l}catch(u){yt(t,t.return,u)}}var tl=!1,Yt=!1,Wc=!1,wo=typeof WeakSet=="function"?WeakSet:Set,Qt=null;function N0(t,e){if(t=t.containerInfo,vs=ei,t=Wf(t),Qi(t)){if("selectionStart"in t)var l={start:t.selectionStart,end:t.selectionEnd};else t:{l=(l=t.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{l.nodeType,u.nodeType}catch{l=null;break t}var i=0,r=-1,m=-1,_=0,N=0,C=t,T=null;e:for(;;){for(var R;C!==l||n!==0&&C.nodeType!==3||(r=i+n),C!==u||a!==0&&C.nodeType!==3||(m=i+a),C.nodeType===3&&(i+=C.nodeValue.length),(R=C.firstChild)!==null;)T=C,C=R;for(;;){if(C===t)break e;if(T===l&&++_===n&&(r=i),T===u&&++N===a&&(m=i),(R=C.nextSibling)!==null)break;C=T,T=C.parentNode}C=R}l=r===-1||m===-1?null:{start:r,end:m}}else l=null}l=l||{start:0,end:0}}else l=null;for(gs={focusedElem:t,selectionRange:l},ei=!1,Qt=e;Qt!==null;)if(e=Qt,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Qt=t;else for(;Qt!==null;){switch(e=Qt,u=e.alternate,t=e.flags,e.tag){case 0:if((t&4)!==0&&(t=e.updateQueue,t=t!==null?t.events:null,t!==null))for(l=0;l title"))),Jt(u,a,l),u[Xt]=t,kt(u),a=u;break t;case"link":var i=Vd("link","href",n).get(a+(l.href||""));if(i){for(var r=0;rbt&&(i=bt,bt=Z,Z=i);var b=Jf(r,Z),v=Jf(r,bt);if(b&&v&&(R.rangeCount!==1||R.anchorNode!==b.node||R.anchorOffset!==b.offset||R.focusNode!==v.node||R.focusOffset!==v.offset)){var E=C.createRange();E.setStart(b.node,b.offset),R.removeAllRanges(),Z>bt?(R.addRange(E),R.extend(v.node,v.offset)):(E.setEnd(v.node,v.offset),R.addRange(E))}}}}for(C=[],R=r;R=R.parentNode;)R.nodeType===1&&C.push({element:R,left:R.scrollLeft,top:R.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;rl?32:l,O.T=null,l=as,as=null;var u=Rl,i=ul;if(Gt=0,Da=Rl=null,ul=0,(dt&6)!==0)throw Error(s(331));var r=dt;if(dt|=4,Wo(u.current),Ko(u,u.current,i,l),dt=r,An(0,!1),fe&&typeof fe.onPostCommitFiberRoot=="function")try{fe.onPostCommitFiberRoot(Qa,u)}catch{}return!0}finally{q.p=n,O.T=a,md(t,e)}}function pd(t,e,l){e=_e(l,e),e=Bc(t.stateNode,e,2),t=Sl(t,e,2),t!==null&&(Va(t,2),Ge(t))}function yt(t,e,l){if(t.tag===3)pd(t,t,l);else for(;e!==null;){if(e.tag===3){pd(e,t,l);break}else if(e.tag===1){var a=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(jl===null||!jl.has(a))){t=_e(l,t),l=vo(2),a=Sl(e,l,2),a!==null&&(go(l,a,e,t),Va(a,2),Ge(a));break}}e=e.return}}function cs(t,e,l){var a=t.pingCache;if(a===null){a=t.pingCache=new C0;var n=new Set;a.set(e,n)}else n=a.get(e),n===void 0&&(n=new Set,a.set(e,n));n.has(l)||(Ic=!0,n.add(l),t=L0.bind(null,t,e,l),e.then(t,t))}function L0(t,e,l){var a=t.pingCache;a!==null&&a.delete(e),t.pingedLanes|=t.suspendedLanes&l,t.warmLanes&=~l,_t===t&&(it&l)===l&&(Ot===4||Ot===3&&(it&62914560)===it&&300>se()-qu?(dt&2)===0&&Ca(t,0):ts|=l,Oa===it&&(Oa=0)),Ge(t)}function vd(t,e){e===0&&(e=rf()),t=Ql(t,e),t!==null&&(Va(t,e),Ge(t))}function w0(t){var e=t.memoizedState,l=0;e!==null&&(l=e.retryLane),vd(t,l)}function Y0(t,e){var l=0;switch(t.tag){case 31:case 13:var a=t.stateNode,n=t.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=t.stateNode;break;case 22:a=t.stateNode._retryCache;break;default:throw Error(s(314))}a!==null&&a.delete(e),vd(t,l)}function G0(t,e){return xi(t,e)}var Xu=null,Ha=null,ss=!1,Vu=!1,fs=!1,Nl=0;function Ge(t){t!==Ha&&t.next===null&&(Ha===null?Xu=Ha=t:Ha=Ha.next=t),Vu=!0,ss||(ss=!0,Q0())}function An(t,e){if(!fs&&Vu){fs=!0;do for(var l=!1,a=Xu;a!==null;){if(t!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var i=a.suspendedLanes,r=a.pingedLanes;u=(1<<31-re(42|t)+1)-1,u&=n&~(i&~r),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(l=!0,Sd(a,u))}else u=it,u=$n(a,a===_t?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||Xa(a,u)||(l=!0,Sd(a,u));a=a.next}while(l);fs=!1}}function k0(){gd()}function gd(){Vu=ss=!1;var t=0;Nl!==0&&I0()&&(t=Nl);for(var e=se(),l=null,a=Xu;a!==null;){var n=a.next,u=bd(a,e);u===0?(a.next=null,l===null?Xu=n:l.next=n,n===null&&(Ha=l)):(l=a,(t!==0||(u&3)!==0)&&(Vu=!0)),a=n}Gt!==0&&Gt!==5||An(t),Nl!==0&&(Nl=0)}function bd(t,e){for(var l=t.suspendedLanes,a=t.pingedLanes,n=t.expirationTimes,u=t.pendingLanes&-62914561;0r)break;var N=m.transferSize,C=m.initiatorType;N&&Md(C)&&(m=m.responseEnd,i+=N*(m"u"?null:document;function Gd(t,e,l){var a=Ba;if(a&&typeof e=="string"&&e){var n=Se(e);n='link[rel="'+t+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),Yd.has(n)||(Yd.add(n),t={rel:t,crossOrigin:l,href:e},a.querySelector(n)===null&&(e=a.createElement("link"),Jt(e,"link",t),kt(e),a.head.appendChild(e)))}}function s1(t){il.D(t),Gd("dns-prefetch",t,null)}function f1(t,e){il.C(t,e),Gd("preconnect",t,e)}function r1(t,e,l){il.L(t,e,l);var a=Ba;if(a&&t&&e){var n='link[rel="preload"][as="'+Se(e)+'"]';e==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+Se(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+Se(l.imageSizes)+'"]')):n+='[href="'+Se(t)+'"]';var u=n;switch(e){case"style":u=qa(t);break;case"script":u=La(t)}Me.has(u)||(t=A({rel:"preload",href:e==="image"&&l&&l.imageSrcSet?void 0:t,as:e},l),Me.set(u,t),a.querySelector(n)!==null||e==="style"&&a.querySelector(Nn(u))||e==="script"&&a.querySelector(On(u))||(e=a.createElement("link"),Jt(e,"link",t),kt(e),a.head.appendChild(e)))}}function o1(t,e){il.m(t,e);var l=Ba;if(l&&t){var a=e&&typeof e.as=="string"?e.as:"script",n='link[rel="modulepreload"][as="'+Se(a)+'"][href="'+Se(t)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=La(t)}if(!Me.has(u)&&(t=A({rel:"modulepreload",href:t},e),Me.set(u,t),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(On(u)))return}a=l.createElement("link"),Jt(a,"link",t),kt(a),l.head.appendChild(a)}}}function d1(t,e,l){il.S(t,e,l);var a=Ba;if(a&&t){var n=ua(a).hoistableStyles,u=qa(t);e=e||"default";var i=n.get(u);if(!i){var r={loading:0,preload:null};if(i=a.querySelector(Nn(u)))r.loading=5;else{t=A({rel:"stylesheet",href:t,"data-precedence":e},l),(l=Me.get(u))&&Ts(t,l);var m=i=a.createElement("link");kt(m),Jt(m,"link",t),m._p=new Promise(function(_,N){m.onload=_,m.onerror=N}),m.addEventListener("load",function(){r.loading|=1}),m.addEventListener("error",function(){r.loading|=2}),r.loading|=4,Wu(i,e,a)}i={type:"stylesheet",instance:i,count:1,state:r},n.set(u,i)}}}function h1(t,e){il.X(t,e);var l=Ba;if(l&&t){var a=ua(l).hoistableScripts,n=La(t),u=a.get(n);u||(u=l.querySelector(On(n)),u||(t=A({src:t,async:!0},e),(e=Me.get(n))&&As(t,e),u=l.createElement("script"),kt(u),Jt(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function m1(t,e){il.M(t,e);var l=Ba;if(l&&t){var a=ua(l).hoistableScripts,n=La(t),u=a.get(n);u||(u=l.querySelector(On(n)),u||(t=A({src:t,async:!0,type:"module"},e),(e=Me.get(n))&&As(t,e),u=l.createElement("script"),kt(u),Jt(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function kd(t,e,l,a){var n=(n=at.current)?$u(n):null;if(!n)throw Error(s(446));switch(t){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(e=qa(l.href),l=ua(n).hoistableStyles,a=l.get(e),a||(a={type:"style",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){t=qa(l.href);var u=ua(n).hoistableStyles,i=u.get(t);if(i||(n=n.ownerDocument||n,i={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(t,i),(u=n.querySelector(Nn(t)))&&!u._p&&(i.instance=u,i.state.loading=5),Me.has(t)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Me.set(t,l),u||y1(n,t,l,i.state))),e&&a===null)throw Error(s(528,""));return i}if(e&&a!==null)throw Error(s(529,""));return null;case"script":return e=l.async,l=l.src,typeof l=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=La(l),l=ua(n).hoistableScripts,a=l.get(e),a||(a={type:"script",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,t))}}function qa(t){return'href="'+Se(t)+'"'}function Nn(t){return'link[rel="stylesheet"]['+t+"]"}function Qd(t){return A({},t,{"data-precedence":t.precedence,precedence:null})}function y1(t,e,l,a){t.querySelector('link[rel="preload"][as="style"]['+e+"]")?a.loading=1:(e=t.createElement("link"),a.preload=e,e.addEventListener("load",function(){return a.loading|=1}),e.addEventListener("error",function(){return a.loading|=2}),Jt(e,"link",l),kt(e),t.head.appendChild(e))}function La(t){return'[src="'+Se(t)+'"]'}function On(t){return"script[async]"+t}function Xd(t,e,l){if(e.count++,e.instance===null)switch(e.type){case"style":var a=t.querySelector('style[data-href~="'+Se(l.href)+'"]');if(a)return e.instance=a,kt(a),a;var n=A({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(t.ownerDocument||t).createElement("style"),kt(a),Jt(a,"style",n),Wu(a,l.precedence,t),e.instance=a;case"stylesheet":n=qa(l.href);var u=t.querySelector(Nn(n));if(u)return e.state.loading|=4,e.instance=u,kt(u),u;a=Qd(l),(n=Me.get(n))&&Ts(a,n),u=(t.ownerDocument||t).createElement("link"),kt(u);var i=u;return i._p=new Promise(function(r,m){i.onload=r,i.onerror=m}),Jt(u,"link",a),e.state.loading|=4,Wu(u,l.precedence,t),e.instance=u;case"script":return u=La(l.src),(n=t.querySelector(On(u)))?(e.instance=n,kt(n),n):(a=l,(n=Me.get(u))&&(a=A({},l),As(a,n)),t=t.ownerDocument||t,n=t.createElement("script"),kt(n),Jt(n,"link",a),t.head.appendChild(n),e.instance=n);case"void":return null;default:throw Error(s(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(a=e.instance,e.state.loading|=4,Wu(a,l.precedence,t));return e.instance}function Wu(t,e,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,i=0;i title"):null)}function p1(t,e,l){if(l===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;return e.rel==="stylesheet"?(t=e.disabled,typeof e.precedence=="string"&&t==null):!0;case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function Kd(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function v1(t,e,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=qa(a.href),u=e.querySelector(Nn(n));if(u){e=u._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=Pu.bind(t),e.then(t,t)),l.state.loading|=4,l.instance=u,kt(u);return}u=e.ownerDocument||e,a=Qd(a),(n=Me.get(n))&&Ts(a,n),u=u.createElement("link"),kt(u);var i=u;i._p=new Promise(function(r,m){i.onload=r,i.onerror=m}),Jt(u,"link",a),l.instance=u}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(l,e),(e=l.state.preload)&&(l.state.loading&3)===0&&(t.count++,l=Pu.bind(t),e.addEventListener("load",l),e.addEventListener("error",l))}}var js=0;function g1(t,e){return t.stylesheets&&t.count===0&&ti(t,t.stylesheets),0js?50:800)+e);return t.unsuspend=l,function(){t.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function Pu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ti(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Iu=null;function ti(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Iu=new Map,e.forEach(b1,t),Iu=null,Pu.call(t))}function b1(t,e){if(!(e.state.loading&4)){var l=Iu.get(t);if(l)var a=l.get(null);else{l=new Map,Iu.set(t,l);for(var n=t.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(c)}catch(f){console.error(f)}}return c(),Bs.exports=H1(),Bs.exports}var q1=B1();const L1="modulepreload",w1=function(c){return"/algorithm-visualizer/"+c},vh={},Mt=function(f,d,s){let o=Promise.resolve();if(d&&d.length>0){let S=function(p){return Promise.all(p.map(M=>Promise.resolve(M).then(A=>({status:"fulfilled",value:A}),A=>({status:"rejected",reason:A}))))};document.getElementsByTagName("link");const x=document.querySelector("meta[property=csp-nonce]"),j=x?.nonce||x?.getAttribute("nonce");o=S(d.map(p=>{if(p=w1(p),p in vh)return;vh[p]=!0;const M=p.endsWith(".css"),A=M?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${A}`))return;const B=document.createElement("link");if(B.rel=M?"stylesheet":L1,M||(B.as="script"),B.crossOrigin="",B.href=p,j&&B.setAttribute("nonce",j),document.head.appendChild(B),M)return new Promise((V,Q)=>{B.addEventListener("load",V),B.addEventListener("error",()=>Q(new Error(`Unable to preload CSS for ${p}`)))})}))}function y(x){const j=new Event("vite:preloadError",{cancelable:!0});if(j.payload=x,window.dispatchEvent(j),!j.defaultPrevented)throw x}return o.then(x=>{for(const j of x||[])j.status==="rejected"&&y(j.reason);return f().catch(y)})};var gh="popstate";function bh(c){return typeof c=="object"&&c!=null&&"pathname"in c&&"search"in c&&"hash"in c&&"state"in c&&"key"in c}function Y1(c={}){function f(s,o){let y=o.state?.masked,{pathname:x,search:j,hash:S}=y||s.location;return Vs("",{pathname:x,search:j,hash:S},o.state&&o.state.usr||null,o.state&&o.state.key||"default",y?{pathname:s.location.pathname,search:s.location.search,hash:s.location.hash}:void 0)}function d(s,o){return typeof o=="string"?o:wn(o)}return k1(f,d,null,c)}function Rt(c,f){if(c===!1||c===null||typeof c>"u")throw new Error(f)}function ke(c,f){if(!c){typeof console<"u"&&console.warn(f);try{throw new Error(f)}catch{}}}function G1(){return Math.random().toString(36).substring(2,10)}function xh(c,f){return{usr:c.state,key:c.key,idx:f,masked:c.mask?{pathname:c.pathname,search:c.search,hash:c.hash}:void 0}}function Vs(c,f,d=null,s,o){return{pathname:typeof c=="string"?c:c.pathname,search:"",hash:"",...typeof f=="string"?Ya(f):f,state:d,key:f&&f.key||s||G1(),mask:o}}function wn({pathname:c="/",search:f="",hash:d=""}){return f&&f!=="?"&&(c+=f.charAt(0)==="?"?f:"?"+f),d&&d!=="#"&&(c+=d.charAt(0)==="#"?d:"#"+d),c}function Ya(c){let f={};if(c){let d=c.indexOf("#");d>=0&&(f.hash=c.substring(d),c=c.substring(0,d));let s=c.indexOf("?");s>=0&&(f.search=c.substring(s),c=c.substring(0,s)),c&&(f.pathname=c)}return f}function k1(c,f,d,s={}){let{window:o=document.defaultView,v5Compat:y=!1}=s,x=o.history,j="POP",S=null,p=M();p==null&&(p=0,x.replaceState({...x.state,idx:p},""));function M(){return(x.state||{idx:null}).idx}function A(){j="POP";let H=M(),J=H==null?null:H-p;p=H,S&&S({action:j,location:Y.location,delta:J})}function B(H,J){j="PUSH";let et=bh(H)?H:Vs(Y.location,H,J);p=M()+1;let $=xh(et,p),xt=Y.createHref(et.mask||et);try{x.pushState($,"",xt)}catch(St){if(St instanceof DOMException&&St.name==="DataCloneError")throw St;o.location.assign(xt)}y&&S&&S({action:j,location:Y.location,delta:1})}function V(H,J){j="REPLACE";let et=bh(H)?H:Vs(Y.location,H,J);p=M();let $=xh(et,p),xt=Y.createHref(et.mask||et);x.replaceState($,"",xt),y&&S&&S({action:j,location:Y.location,delta:0})}function Q(H){return Q1(o,H)}let Y={get action(){return j},get location(){return c(o,x)},listen(H){if(S)throw new Error("A history only accepts one active listener");return o.addEventListener(gh,A),S=H,()=>{o.removeEventListener(gh,A),S=null}},createHref(H){return f(o,H)},createURL:Q,encodeLocation(H){let J=Q(H);return{pathname:J.pathname,search:J.search,hash:J.hash}},push:B,replace:V,go(H){return x.go(H)}};return Y}function Q1(c,f,d=!1){let s="http://localhost";c&&(s=c.location.origin!=="null"?c.location.origin:c.location.href),Rt(s,"No window.location.(origin|href) available to create URL");let o=typeof f=="string"?f:wn(f);return o=o.replace(/ $/,"%20"),!d&&o.startsWith("//")&&(o=s+o),new URL(o,s)}function Uh(c,f,d="/"){return X1(c,f,d,!1)}function X1(c,f,d,s,o){let y=typeof f=="string"?Ya(f):f,x=rl(y.pathname||"/",d);if(x==null)return null;let j=V1(c),S=null,p=ay(x);for(let M=0;S==null&&M{let M={relativePath:p===void 0?x.path||"":p,caseSensitive:x.caseSensitive===!0,childrenIndex:j,route:x};if(M.relativePath.startsWith("/")){if(!M.relativePath.startsWith(s)&&S)return;Rt(M.relativePath.startsWith(s),`Absolute route path "${M.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),M.relativePath=M.relativePath.slice(s.length)}let A=Ue([s,M.relativePath]),B=d.concat(M);x.children&&x.children.length>0&&(Rt(x.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${A}".`),Hh(x.children,f,B,A,S)),!(x.path==null&&!x.index)&&f.push({path:A,score:I1(A,x.index),routesMeta:B})};return c.forEach((x,j)=>{if(x.path===""||!x.path?.includes("?"))y(x,j);else for(let S of Bh(x.path))y(x,j,!0,S)}),f}function Bh(c){let f=c.split("/");if(f.length===0)return[];let[d,...s]=f,o=d.endsWith("?"),y=d.replace(/\?$/,"");if(s.length===0)return o?[y,""]:[y];let x=Bh(s.join("/")),j=[];return j.push(...x.map(S=>S===""?y:[y,S].join("/"))),o&&j.push(...x),j.map(S=>c.startsWith("/")&&S===""?"/":S)}function Z1(c){c.sort((f,d)=>f.score!==d.score?d.score-f.score:ty(f.routesMeta.map(s=>s.childrenIndex),d.routesMeta.map(s=>s.childrenIndex)))}var K1=/^:[\w-]+$/,J1=3,$1=2,W1=1,F1=10,P1=-2,Sh=c=>c==="*";function I1(c,f){let d=c.split("/"),s=d.length;return d.some(Sh)&&(s+=P1),f&&(s+=$1),d.filter(o=>!Sh(o)).reduce((o,y)=>o+(K1.test(y)?J1:y===""?W1:F1),s)}function ty(c,f){return c.length===f.length&&c.slice(0,-1).every((s,o)=>s===f[o])?c[c.length-1]-f[f.length-1]:0}function ey(c,f,d=!1){let{routesMeta:s}=c,o={},y="/",x=[];for(let j=0;j{if(M==="*"){let Q=j[B]||"";x=y.slice(0,y.length-Q.length).replace(/(.)\/+$/,"$1")}const V=j[B];return A&&!V?p[M]=void 0:p[M]=(V||"").replace(/%2F/g,"/"),p},{}),pathname:y,pathnameBase:x,pattern:c}}function ly(c,f=!1,d=!0){ke(c==="*"||!c.endsWith("*")||c.endsWith("/*"),`Route path "${c}" will be treated as if it were "${c.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${c.replace(/\*$/,"/*")}".`);let s=[],o="^"+c.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(x,j,S,p,M)=>{if(s.push({paramName:j,isOptional:S!=null}),S){let A=M.charAt(p+x.length);return A&&A!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return c.endsWith("*")?(s.push({paramName:"*"}),o+=c==="*"||c==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):d?o+="\\/*$":c!==""&&c!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,f?void 0:"i"),s]}function ay(c){try{return c.split("/").map(f=>decodeURIComponent(f).replace(/\//g,"%2F")).join("/")}catch(f){return ke(!1,`The URL path "${c}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${f}).`),c}}function rl(c,f){if(f==="/")return c;if(!c.toLowerCase().startsWith(f.toLowerCase()))return null;let d=f.endsWith("/")?f.length-1:f.length,s=c.charAt(d);return s&&s!=="/"?null:c.slice(d)||"/"}var ny=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function uy(c,f="/"){let{pathname:d,search:s="",hash:o=""}=typeof c=="string"?Ya(c):c,y;return d?(d=Lh(d),d.startsWith("/")?y=Eh(d.substring(1),"/"):y=Eh(d,f)):y=f,{pathname:y,search:sy(s),hash:fy(o)}}function Eh(c,f){let d=hi(f).split("/");return c.split("/").forEach(o=>{o===".."?d.length>1&&d.pop():o!=="."&&d.push(o)}),d.length>1?d.join("/"):"/"}function Ys(c,f,d,s){return`Cannot include a '${c}' character in a manually specified \`to.${f}\` field [${JSON.stringify(s)}]. Please separate it out to the \`to.${d}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function iy(c){return c.filter((f,d)=>d===0||f.route.path&&f.route.path.length>0)}function qh(c){let f=iy(c);return f.map((d,s)=>s===f.length-1?d.pathname:d.pathnameBase)}function $s(c,f,d,s=!1){let o;typeof c=="string"?o=Ya(c):(o={...c},Rt(!o.pathname||!o.pathname.includes("?"),Ys("?","pathname","search",o)),Rt(!o.pathname||!o.pathname.includes("#"),Ys("#","pathname","hash",o)),Rt(!o.search||!o.search.includes("#"),Ys("#","search","hash",o)));let y=c===""||o.pathname==="",x=y?"/":o.pathname,j;if(x==null)j=d;else{let A=f.length-1;if(!s&&x.startsWith("..")){let B=x.split("/");for(;B[0]==="..";)B.shift(),A-=1;o.pathname=B.join("/")}j=A>=0?f[A]:"/"}let S=uy(o,j),p=x&&x!=="/"&&x.endsWith("/"),M=(y||x===".")&&d.endsWith("/");return!S.pathname.endsWith("/")&&(p||M)&&(S.pathname+="/"),S}var Lh=c=>c.replace(/\/\/+/g,"/"),Ue=c=>Lh(c.join("/")),hi=c=>c.replace(/\/+$/,""),cy=c=>hi(c).replace(/^\/*/,"/"),sy=c=>!c||c==="?"?"":c.startsWith("?")?c:"?"+c,fy=c=>!c||c==="#"?"":c.startsWith("#")?c:"#"+c,ry=class{constructor(c,f,d,s=!1){this.status=c,this.statusText=f||"",this.internal=s,d instanceof Error?(this.data=d.toString(),this.error=d):this.data=d}};function oy(c){return c!=null&&typeof c.status=="number"&&typeof c.statusText=="string"&&typeof c.internal=="boolean"&&"data"in c}function dy(c){let f=c.map(d=>d.route.path).filter(Boolean);return Ue(f)||"/"}var wh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Yh(c,f){let d=c;if(typeof d!="string"||!ny.test(d))return{absoluteURL:void 0,isExternal:!1,to:d};let s=d,o=!1;if(wh)try{let y=new URL(window.location.href),x=d.startsWith("//")?new URL(y.protocol+d):new URL(d),j=rl(x.pathname,f);x.origin===y.origin&&j!=null?d=j+x.search+x.hash:o=!0}catch{ke(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:o,to:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Gh=["POST","PUT","PATCH","DELETE"];new Set(Gh);var hy=["GET",...Gh];new Set(hy);var Ga=z.createContext(null);Ga.displayName="DataRouter";var mi=z.createContext(null);mi.displayName="DataRouterState";var kh=z.createContext(!1);function my(){return z.useContext(kh)}var Qh=z.createContext({isTransitioning:!1});Qh.displayName="ViewTransition";var yy=z.createContext(new Map);yy.displayName="Fetchers";var py=z.createContext(null);py.displayName="Await";var Ne=z.createContext(null);Ne.displayName="Navigation";var Gn=z.createContext(null);Gn.displayName="Location";var ol=z.createContext({outlet:null,matches:[],isDataRoute:!1});ol.displayName="Route";var Ws=z.createContext(null);Ws.displayName="RouteError";var Xh="REACT_ROUTER_ERROR",vy="REDIRECT",gy="ROUTE_ERROR_RESPONSE";function by(c){if(c.startsWith(`${Xh}:${vy}:{`))try{let f=JSON.parse(c.slice(28));if(typeof f=="object"&&f&&typeof f.status=="number"&&typeof f.statusText=="string"&&typeof f.location=="string"&&typeof f.reloadDocument=="boolean"&&typeof f.replace=="boolean")return f}catch{}}function xy(c){if(c.startsWith(`${Xh}:${gy}:{`))try{let f=JSON.parse(c.slice(40));if(typeof f=="object"&&f&&typeof f.status=="number"&&typeof f.statusText=="string")return new ry(f.status,f.statusText,f.data)}catch{}}function Sy(c,{relative:f}={}){Rt(kn(),"useHref() may be used only in the context of a component.");let{basename:d,navigator:s}=z.useContext(Ne),{hash:o,pathname:y,search:x}=Qn(c,{relative:f}),j=y;return d!=="/"&&(j=y==="/"?d:Ue([d,y])),s.createHref({pathname:j,search:x,hash:o})}function kn(){return z.useContext(Gn)!=null}function He(){return Rt(kn(),"useLocation() may be used only in the context of a component."),z.useContext(Gn).location}var Vh="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Zh(c){z.useContext(Ne).static||z.useLayoutEffect(c)}function Ey(){let{isDataRoute:c}=z.useContext(ol);return c?Hy():_y()}function _y(){Rt(kn(),"useNavigate() may be used only in the context of a component.");let c=z.useContext(Ga),{basename:f,navigator:d}=z.useContext(Ne),{matches:s}=z.useContext(ol),{pathname:o}=He(),y=JSON.stringify(qh(s)),x=z.useRef(!1);return Zh(()=>{x.current=!0}),z.useCallback((S,p={})=>{if(ke(x.current,Vh),!x.current)return;if(typeof S=="number"){d.go(S);return}let M=$s(S,JSON.parse(y),o,p.relative==="path");c==null&&f!=="/"&&(M.pathname=M.pathname==="/"?f:Ue([f,M.pathname])),(p.replace?d.replace:d.push)(M,p.state,p)},[f,d,y,o,c])}z.createContext(null);function Qn(c,{relative:f}={}){let{matches:d}=z.useContext(ol),{pathname:s}=He(),o=JSON.stringify(qh(d));return z.useMemo(()=>$s(c,JSON.parse(o),s,f==="path"),[c,o,s,f])}function zy(c,f){return Kh(c,f)}function Kh(c,f,d){Rt(kn(),"useRoutes() may be used only in the context of a component.");let{navigator:s}=z.useContext(Ne),{matches:o}=z.useContext(ol),y=o[o.length-1],x=y?y.params:{},j=y?y.pathname:"/",S=y?y.pathnameBase:"/",p=y&&y.route;{let H=p&&p.path||"";$h(j,!p||H.endsWith("*")||H.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${j}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + +Please change the parent to .`)}let M=He(),A;if(f){let H=typeof f=="string"?Ya(f):f;Rt(S==="/"||H.pathname?.startsWith(S),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${S}" but pathname "${H.pathname}" was given in the \`location\` prop.`),A=H}else A=M;let B=A.pathname||"/",V=B;if(S!=="/"){let H=S.replace(/^\//,"").split("/");V="/"+B.replace(/^\//,"").split("/").slice(H.length).join("/")}let Q=d&&d.state.matches.length?d.state.matches.map(H=>Object.assign(H,{route:d.manifest[H.route.id]||H.route})):Uh(c,{pathname:V});ke(p||Q!=null,`No routes matched location "${A.pathname}${A.search}${A.hash}" `),ke(Q==null||Q[Q.length-1].route.element!==void 0||Q[Q.length-1].route.Component!==void 0||Q[Q.length-1].route.lazy!==void 0,`Matched leaf route at location "${A.pathname}${A.search}${A.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let Y=My(Q&&Q.map(H=>Object.assign({},H,{params:Object.assign({},x,H.params),pathname:Ue([S,s.encodeLocation?s.encodeLocation(H.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:H.pathname]),pathnameBase:H.pathnameBase==="/"?S:Ue([S,s.encodeLocation?s.encodeLocation(H.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:H.pathnameBase])})),o,d);return f&&Y?z.createElement(Gn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...A},navigationType:"POP"}},Y):Y}function Ty(){let c=Uy(),f=oy(c)?`${c.status} ${c.statusText}`:c instanceof Error?c.message:JSON.stringify(c),d=c instanceof Error?c.stack:null,s="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:s},y={padding:"2px 4px",backgroundColor:s},x=null;return console.error("Error handled by React Router default ErrorBoundary:",c),x=z.createElement(z.Fragment,null,z.createElement("p",null,"💿 Hey developer 👋"),z.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",z.createElement("code",{style:y},"ErrorBoundary")," or"," ",z.createElement("code",{style:y},"errorElement")," prop on your route.")),z.createElement(z.Fragment,null,z.createElement("h2",null,"Unexpected Application Error!"),z.createElement("h3",{style:{fontStyle:"italic"}},f),d?z.createElement("pre",{style:o},d):null,x)}var Ay=z.createElement(Ty,null),Jh=class extends z.Component{constructor(c){super(c),this.state={location:c.location,revalidation:c.revalidation,error:c.error}}static getDerivedStateFromError(c){return{error:c}}static getDerivedStateFromProps(c,f){return f.location!==c.location||f.revalidation!=="idle"&&c.revalidation==="idle"?{error:c.error,location:c.location,revalidation:c.revalidation}:{error:c.error!==void 0?c.error:f.error,location:f.location,revalidation:c.revalidation||f.revalidation}}componentDidCatch(c,f){this.props.onError?this.props.onError(c,f):console.error("React Router caught the following error during render",c)}render(){let c=this.state.error;if(this.context&&typeof c=="object"&&c&&"digest"in c&&typeof c.digest=="string"){const d=xy(c.digest);d&&(c=d)}let f=c!==void 0?z.createElement(ol.Provider,{value:this.props.routeContext},z.createElement(Ws.Provider,{value:c,children:this.props.component})):this.props.children;return this.context?z.createElement(jy,{error:c},f):f}};Jh.contextType=kh;var Gs=new WeakMap;function jy({children:c,error:f}){let{basename:d}=z.useContext(Ne);if(typeof f=="object"&&f&&"digest"in f&&typeof f.digest=="string"){let s=by(f.digest);if(s){let o=Gs.get(f);if(o)throw o;let y=Yh(s.location,d);if(wh&&!Gs.get(f))if(y.isExternal||s.reloadDocument)window.location.href=y.absoluteURL||y.to;else{const x=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(y.to,{replace:s.replace}));throw Gs.set(f,x),x}return z.createElement("meta",{httpEquiv:"refresh",content:`0;url=${y.absoluteURL||y.to}`})}}return c}function Ry({routeContext:c,match:f,children:d}){let s=z.useContext(Ga);return s&&s.static&&s.staticContext&&(f.route.errorElement||f.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=f.route.id),z.createElement(ol.Provider,{value:c},d)}function My(c,f=[],d){let s=d?.state;if(c==null){if(!s)return null;if(s.errors)c=s.matches;else if(f.length===0&&!s.initialized&&s.matches.length>0)c=s.matches;else return null}let o=c,y=s?.errors;if(y!=null){let M=o.findIndex(A=>A.route.id&&y?.[A.route.id]!==void 0);Rt(M>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(y).join(",")}`),o=o.slice(0,Math.min(o.length,M+1))}let x=!1,j=-1;if(d&&s){x=s.renderFallback;for(let M=0;M=0?o=o.slice(0,j+1):o=[o[0]];break}}}}let S=d?.onError,p=s&&S?(M,A)=>{S(M,{location:s.location,params:s.matches?.[0]?.params??{},pattern:dy(s.matches),errorInfo:A})}:void 0;return o.reduceRight((M,A,B)=>{let V,Q=!1,Y=null,H=null;s&&(V=y&&A.route.id?y[A.route.id]:void 0,Y=A.route.errorElement||Ay,x&&(j<0&&B===0?($h("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),Q=!0,H=null):j===B&&(Q=!0,H=A.route.hydrateFallbackElement||null)));let J=f.concat(o.slice(0,B+1)),et=()=>{let $;return V?$=Y:Q?$=H:A.route.Component?$=z.createElement(A.route.Component,null):A.route.element?$=A.route.element:$=M,z.createElement(Ry,{match:A,routeContext:{outlet:M,matches:J,isDataRoute:s!=null},children:$})};return s&&(A.route.ErrorBoundary||A.route.errorElement||B===0)?z.createElement(Jh,{location:s.location,revalidation:s.revalidation,component:Y,error:V,children:et(),routeContext:{outlet:null,matches:J,isDataRoute:!0},onError:p}):et()},null)}function Fs(c){return`${c} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ny(c){let f=z.useContext(Ga);return Rt(f,Fs(c)),f}function Oy(c){let f=z.useContext(mi);return Rt(f,Fs(c)),f}function Dy(c){let f=z.useContext(ol);return Rt(f,Fs(c)),f}function Ps(c){let f=Dy(c),d=f.matches[f.matches.length-1];return Rt(d.route.id,`${c} can only be used on routes that contain a unique "id"`),d.route.id}function Cy(){return Ps("useRouteId")}function Uy(){let c=z.useContext(Ws),f=Oy("useRouteError"),d=Ps("useRouteError");return c!==void 0?c:f.errors?.[d]}function Hy(){let{router:c}=Ny("useNavigate"),f=Ps("useNavigate"),d=z.useRef(!1);return Zh(()=>{d.current=!0}),z.useCallback(async(o,y={})=>{ke(d.current,Vh),d.current&&(typeof o=="number"?await c.navigate(o):await c.navigate(o,{fromRouteId:f,...y}))},[c,f])}var _h={};function $h(c,f,d){!f&&!_h[c]&&(_h[c]=!0,ke(!1,d))}z.memo(By);function By({routes:c,manifest:f,future:d,state:s,isStatic:o,onError:y}){return Kh(c,void 0,{manifest:f,state:s,isStatic:o,onError:y})}function K(c){Rt(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function qy({basename:c="/",children:f=null,location:d,navigationType:s="POP",navigator:o,static:y=!1,useTransitions:x}){Rt(!kn(),"You cannot render a inside another . You should never have more than one in your app.");let j=c.replace(/^\/*/,"/"),S=z.useMemo(()=>({basename:j,navigator:o,static:y,useTransitions:x,future:{}}),[j,o,y,x]);typeof d=="string"&&(d=Ya(d));let{pathname:p="/",search:M="",hash:A="",state:B=null,key:V="default",mask:Q}=d,Y=z.useMemo(()=>{let H=rl(p,j);return H==null?null:{location:{pathname:H,search:M,hash:A,state:B,key:V,mask:Q},navigationType:s}},[j,p,M,A,B,V,s,Q]);return ke(Y!=null,` is not able to match the URL "${p}${M}${A}" because it does not start with the basename, so the won't render anything.`),Y==null?null:z.createElement(Ne.Provider,{value:S},z.createElement(Gn.Provider,{children:f,value:Y}))}function Ly({children:c,location:f}){return zy(Zs(c),f)}function Zs(c,f=[]){let d=[];return z.Children.forEach(c,(s,o)=>{if(!z.isValidElement(s))return;let y=[...f,o];if(s.type===z.Fragment){d.push.apply(d,Zs(s.props.children,y));return}Rt(s.type===K,`[${typeof s.type=="string"?s.type:s.type.name}] is not a component. All component children of must be a or `),Rt(!s.props.index||!s.props.children,"An index route cannot have child routes.");let x={id:s.props.id||y.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,middleware:s.props.middleware,loader:s.props.loader,action:s.props.action,hydrateFallbackElement:s.props.hydrateFallbackElement,HydrateFallback:s.props.HydrateFallback,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.hasErrorBoundary===!0||s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(x.children=Zs(s.props.children,y)),d.push(x)}),d}var fi="get",ri="application/x-www-form-urlencoded";function yi(c){return typeof HTMLElement<"u"&&c instanceof HTMLElement}function wy(c){return yi(c)&&c.tagName.toLowerCase()==="button"}function Yy(c){return yi(c)&&c.tagName.toLowerCase()==="form"}function Gy(c){return yi(c)&&c.tagName.toLowerCase()==="input"}function ky(c){return!!(c.metaKey||c.altKey||c.ctrlKey||c.shiftKey)}function Qy(c,f){return c.button===0&&(!f||f==="_self")&&!ky(c)}var si=null;function Xy(){if(si===null)try{new FormData(document.createElement("form"),0),si=!1}catch{si=!0}return si}var Vy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ks(c){return c!=null&&!Vy.has(c)?(ke(!1,`"${c}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${ri}"`),null):c}function Zy(c,f){let d,s,o,y,x;if(Yy(c)){let j=c.getAttribute("action");s=j?rl(j,f):null,d=c.getAttribute("method")||fi,o=ks(c.getAttribute("enctype"))||ri,y=new FormData(c)}else if(wy(c)||Gy(c)&&(c.type==="submit"||c.type==="image")){let j=c.form;if(j==null)throw new Error('Cannot submit a - {/* Mobile menu dropdown */} {menuOpen && ( -