diff --git a/app/assets/interface/bundle-BT-miy7R.js b/app/assets/interface/bundle-tvCSkI-U.js similarity index 97% rename from app/assets/interface/bundle-BT-miy7R.js rename to app/assets/interface/bundle-tvCSkI-U.js index 4a20e9a0..45e88cfc 100644 --- a/app/assets/interface/bundle-BT-miy7R.js +++ b/app/assets/interface/bundle-tvCSkI-U.js @@ -1,4 +1,4 @@ -import{j as e,L as Y}from"./preload-helper-7J6LhHV_.js";import{u as l}from"./levelcode-B9y_e5v8.js";function E(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Note:d,Warning:a}=n;return t||f("Card"),i||f("CardGroup"),r||f("Kbd"),d||f("Note"),a||f("Warning"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"agent",children:"Agent"}),` +import{j as e,L as Y}from"./preload-helper-7J6LhHV_.js";import{u as l}from"./levelcode-DDEAdB7B.js";function E(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Note:d,Warning:a}=n;return t||f("Card"),i||f("CardGroup"),r||f("Kbd"),d||f("Note"),a||f("Warning"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"agent",children:"Agent"}),` `,e.jsxs(n.blockquote,{children:[` `,e.jsx(n.p,{children:"State a goal. The agent plans it, edits across files, runs commands behind approval gates, checks its own work, and reports back."}),` `]}),` @@ -112,13 +112,13 @@ import{j as e,L as Y}from"./preload-helper-7J6LhHV_.js";import{u as l}from"./lev `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:"It won't repeat what's already there."})," A suggestion that merely duplicates the text after your cursor is discarded."]}),` `,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:"Cost."})," On BYOK you pay per request, and typing generates a lot of them. On a metered plan, completions draw on the same credits as everything else. If cost is a concern, raise the debounce or turn autocomplete off and rely on ",e.jsx(n.a,{href:"/docs/edit",children:"Edit"}),"."]}),` `]}),` -`,e.jsxs(i,{children:[e.jsx(t,{title:"Edit",href:"/docs/edit",children:e.jsx(n.p,{children:"Rewrite a whole selection instead of finishing a line."})}),e.jsx(t,{title:"Providers and models",href:"/docs/providers",children:e.jsx(n.p,{children:"Which providers have a fast tier, and what it costs."})})]})]})}function $(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(I,{...s})}):I(s)}function C(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function T(s){const n={a:"a",blockquote:"blockquote",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Accordion:t,AccordionGroup:i,Card:r,CardGroup:d,Note:a}=n;return t||k("Accordion"),i||k("AccordionGroup"),r||k("Card"),d||k("CardGroup"),a||k("Note"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"levelcode-in-your-browser",children:"LevelCode in your browser"}),` +`,e.jsxs(i,{children:[e.jsx(t,{title:"Edit",href:"/docs/edit",children:e.jsx(n.p,{children:"Rewrite a whole selection instead of finishing a line."})}),e.jsx(t,{title:"Providers and models",href:"/docs/providers",children:e.jsx(n.p,{children:"Which providers have a fast tier, and what it costs."})})]})]})}function $(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(I,{...s})}):I(s)}function C(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function T(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Accordion:t,AccordionGroup:i,Card:r,CardGroup:d,Note:a}=n;return t||k("Accordion"),i||k("AccordionGroup"),r||k("Card"),d||k("CardGroup"),a||k("Note"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"levelcode-in-your-browser",children:"LevelCode in your browser"}),` `,e.jsxs(n.blockquote,{children:[` `,e.jsx(n.p,{children:"The LevelCode workbench in a browser tab. Sign in with your account, open a folder or a scratch workspace, and work with the chat panel and the agent. Nothing to install."}),` `]}),` `,` `,e.jsx(n.p,{children:"The browser edition is the real LevelCode workbench running in a tab. The explorer, editor tabs, themes, the chat panel and the agent are all there. You sign in with the same LevelCode account as the Mac app, and the gateway plan and usage are the same."}),` -`,e.jsxs(n.p,{children:["A few things stay in the Mac app. The browser edition has no terminal, and the agent does not run shell commands. The ",e.jsx(n.a,{href:"#what-stays-in-the-mac-app",children:"full list"})," is below."]}),` +`,e.jsxs(n.p,{children:["The browser edition has a terminal, LevelCode Shell, that works on your files. It does not run programs, so a few things stay in the Mac app. The ",e.jsx(n.a,{href:"#what-stays-in-the-mac-app",children:"full list"})," is below."]}),` `,e.jsx(n.h2,{id:"open-it",children:"Open it"}),` `,e.jsxs(n.p,{children:["Open ",e.jsx(n.a,{href:"/web",children:"LevelCode in your browser"})," and choose ",e.jsx(n.strong,{children:"Open LevelCode"}),". If you are signed in, ",e.jsx(n.strong,{children:"Open in browser"})," on your ",e.jsx(n.a,{href:"/account",children:"account page"})," goes to the same place."]}),` `,e.jsx(n.p,{children:"The editor opens in the same tab."}),` @@ -135,12 +135,21 @@ import{j as e,L as Y}from"./preload-helper-7J6LhHV_.js";import{u as l}from"./lev `,e.jsx(a,{children:e.jsxs(n.p,{children:["Files stay in your browser or on your computer. ",e.jsx(n.a,{href:"#privacy",children:"Privacy"})," covers what goes to the model."]})}),` `,e.jsx(n.h2,{id:"what-the-agent-can-do-here",children:"What the agent can do here"}),` `,e.jsx(n.p,{children:"The agent can read, search, create, edit and delete files in the open workspace. Its changes are applied at once and offered for Keep or Undo."}),` -`,e.jsx(n.p,{children:"It cannot run shell commands, and there is no terminal. Work that needs either one stays in the Mac app."}),` +`,e.jsxs(n.p,{children:["It can also run commands in LevelCode Shell, the same terminal you can open yourself. See ",e.jsx(n.a,{href:"#levelcode-shell",children:"LevelCode Shell"})," below for what it does and does not do. Work that needs real programs stays in the Mac app."]}),` +`,e.jsx(n.h2,{id:"levelcode-shell",children:"LevelCode Shell"}),` +`,e.jsxs(n.p,{children:["LevelCode Shell is a terminal in the tab. It is bash (pipes, loops, functions, redirections) with about eighty built-in commands, such as ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"ls"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"cat"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"grep"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"sed"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"awk"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"find"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"sort"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"uniq"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"xargs"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"jq"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"diff"})})})})," and ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"tree"})})})}),". It works on the files of the open workspace."]}),` +`,e.jsxs(n.ul,{children:[` +`,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:"Open it"})," from the Command Palette with ",e.jsx(n.em,{children:"LevelCode Shell: New Terminal"}),", or from the Terminal panel."]}),` +`,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:"It does not run programs."})," There is no Node, npm, git, Python or compiler in it, and no network. ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"npm test"})})})}),' answers "command not found". Use it to read, search and reshape files: count TODOs, rename a batch of files, run a ',e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"sed"})})})})," over several files, look at a JSON file with ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"jq"})})})}),"."]}),` +`,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:"The agent uses it too."})," When the agent runs a command, it runs here. Files it changes are offered for Keep or Undo like any other edit. A command that would touch repository metadata or tool settings (",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:".git"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:".vscode"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:".github/workflows"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"AGENTS.md"})})})})," and similar), a file that is not plain text, or a file you have unsaved changes in, is refused as a whole, and nothing from that command is applied."]}),` +`,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:"Stop it with Ctrl+C."})," A command that is stopped, runs out of time or hits a limit changes nothing."]}),` +`,e.jsxs(n.li,{children:[e.jsx(n.strong,{children:"The working folder and exported variables carry from one line to the next."})," Functions and shell options do not."]}),` +`]}),` `,e.jsx(n.h2,{id:"what-stays-in-the-mac-app",children:"What stays in the Mac app"}),` `,e.jsx(n.p,{children:"These are not in the browser edition."}),` `,e.jsxs(n.ul,{children:[` -`,e.jsx(n.li,{children:"The terminal"}),` -`,e.jsx(n.li,{children:"Running shell commands"}),` +`,e.jsx(n.li,{children:"Running programs: Node, npm, git, Python, test runners and builds"}),` +`,e.jsx(n.li,{children:"Background commands and dev servers"}),` `,e.jsx(n.li,{children:"MCP servers that start local processes"}),` `,e.jsx(n.li,{children:"Installing extensions"}),` `]}),` @@ -152,8 +161,8 @@ import{j as e,L as Y}from"./preload-helper-7J6LhHV_.js";import{u as l}from"./lev `,e.jsx(n.p,{children:"Files stay in your browser or on your computer."}),` `,e.jsxs(n.p,{children:["The text you send in chat and the files you ask LevelCode to read go to the model through the LevelCode gateway, the same as in the Mac app. ",e.jsx(n.a,{href:"/docs/cloud#privacy",children:"Cloud and billing"})," explains how requests are routed on the gateway."]}),` `,e.jsx(n.h2,{id:"troubleshooting",children:"Troubleshooting"}),` -`,e.jsxs(i,{children:[e.jsx(t,{title:"After signing in I am not back in the editor",children:e.jsxs(n.p,{children:["Signing in returns to the editor in the same tab. If you end on a page that says you are signed in, use ",e.jsx(n.strong,{children:"Open LevelCode in this tab"})," there: the editor finishes the sign-in when it opens. The sign-in is good for about two minutes."]})}),e.jsx(t,{title:"I am asked to sign in again, or my workspace is missing",children:e.jsx(n.p,{children:"The editor keeps your sign-in and your scratch workspace in your browser's site storage (local storage and IndexedDB), not in cookies. Settings that block site data, or that clear it when you close the browser, remove them. Allow site data for the editor's address, and keep it from being cleared when you quit the browser."})}),e.jsx(t,{title:"Safari private browsing",children:e.jsx(n.p,{children:"A private window in Safari discards site data when you close it. A scratch workspace and your sign-in do not carry over to the next private window. Use a regular window to keep them."})}),e.jsx(t,{title:"I cannot open a folder",children:e.jsx(n.p,{children:"Opening a folder works in Chrome and Edge. In Safari and Firefox, use a scratch workspace."})}),e.jsx(t,{title:"The terminal or an extension is missing",children:e.jsx(n.p,{children:"The terminal, running shell commands, MCP servers that start local processes and installing extensions stay in the Mac app."})})]}),` -`,e.jsxs(d,{children:[e.jsx(r,{title:"Install and setup",href:"/docs/setup",children:e.jsx(n.p,{children:"Get the Mac app, for the terminal and everything else that stays there."})}),e.jsx(r,{title:"Cloud and billing",href:"/docs/cloud",children:e.jsx(n.p,{children:"Sign in, usage, and how requests are routed."})})]})]})}function X(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(T,{...s})}):T(s)}function k(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function L(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Note:d,Tip:a}=n;return t||v("Card"),i||v("CardGroup"),r||v("Kbd"),d||v("Note"),a||v("Tip"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"chat",children:"Chat"}),` +`,e.jsxs(i,{children:[e.jsx(t,{title:"After signing in I am not back in the editor",children:e.jsxs(n.p,{children:["Signing in returns to the editor in the same tab. If you end on a page that says you are signed in, use ",e.jsx(n.strong,{children:"Open LevelCode in this tab"})," there: the editor finishes the sign-in when it opens. The sign-in is good for about two minutes."]})}),e.jsx(t,{title:"I am asked to sign in again, or my workspace is missing",children:e.jsx(n.p,{children:"The editor keeps your sign-in and your scratch workspace in your browser's site storage (local storage and IndexedDB), not in cookies. Settings that block site data, or that clear it when you close the browser, remove them. Allow site data for the editor's address, and keep it from being cleared when you quit the browser."})}),e.jsx(t,{title:"Safari private browsing",children:e.jsx(n.p,{children:"A private window in Safari discards site data when you close it. A scratch workspace and your sign-in do not carry over to the next private window. Use a regular window to keep them."})}),e.jsx(t,{title:"I cannot open a folder",children:e.jsx(n.p,{children:"Opening a folder works in Chrome and Edge. In Safari and Firefox, use a scratch workspace."})}),e.jsx(t,{title:"A program or an extension is missing",children:e.jsxs(n.p,{children:["The terminal in the browser edition is LevelCode Shell, which does not run programs. ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"node"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"npm"})})})}),", ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"git"})})})})," and ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"python"})})})}),' are not in it, so a command that needs one answers "command not found". Running programs, background commands, MCP servers that start local processes and installing extensions stay in the Mac app.']})})]}),` +`,e.jsxs(d,{children:[e.jsx(r,{title:"Install and setup",href:"/docs/setup",children:e.jsx(n.p,{children:"Get the Mac app, for real programs and everything else that stays there."})}),e.jsx(r,{title:"Cloud and billing",href:"/docs/cloud",children:e.jsx(n.p,{children:"Sign in, usage, and how requests are routed."})})]})]})}function X(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(T,{...s})}):T(s)}function k(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function L(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Note:d,Tip:a}=n;return t||v("Card"),i||v("CardGroup"),r||v("Kbd"),d||v("Note"),a||v("Tip"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"chat",children:"Chat"}),` `,e.jsxs(n.blockquote,{children:[` `,e.jsx(n.p,{children:"Ask questions about your codebase. Chat answers and explains — it never edits a file or runs a command."}),` `]}),` @@ -607,7 +616,7 @@ import{j as e,L as Y}from"./preload-helper-7J6LhHV_.js";import{u as l}from"./lev `]}),` `,e.jsx(n.h2,{id:"troubleshooting",children:"Troubleshooting"}),` `,e.jsxs(i,{children:[e.jsx(t,{title:"The server never starts and there's no error",children:e.jsxs(n.p,{children:["It's repo-defined and waiting for approval. Run ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"/mcp"})})})})," — the row will say ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"needs approval"})})})}),". Ask the agent to do something that needs the server and the consent card appears."]})}),e.jsx(t,{title:"ENOENT on a command that works in my terminal",children:e.jsxs(n.p,{children:["Two causes. Either the config uses the ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"env FOO=1 npx"})})})})," form, which needs a shell LevelCode doesn't use — put the variables in the ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"env"})})})})," block instead. Or LevelCode was launched from the Dock and has a different ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"PATH"})})})})," than your shell. Use an absolute path for ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"command"})})})}),"."]})}),e.jsx(t,{title:"It works when I launch LevelCode from a terminal, but not from the Dock",children:e.jsxs(n.p,{children:["macOS GUI apps don't inherit your shell environment, so an exported API key isn't there. Use a wrapper script that fetches the secret itself — see ",e.jsx(n.a,{href:"#keep-secrets-out-of-settingsjson",children:"Keep secrets out of settings.json"}),"."]})}),e.jsx(t,{title:"My toolPolicy entry is ignored",children:e.jsxs(n.p,{children:["The key is wrong. Names are namespaced ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"server__tool"})})})}),", and characters that are illegal in a tool name are rewritten — a dot becomes an underscore. Run ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"/mcp"})})})})," and copy the exact name it prints."]})}),e.jsx(t,{title:"The agent says the image was omitted",children:e.jsxs(n.p,{children:["The server returned inline base64. There's nothing to configure — switch to a server that returns a URL or writes a file. See the table in ",e.jsx(n.a,{href:"#image-generation",children:"Image generation"}),"."]})}),e.jsx(t,{title:"A result ends in “MCP result truncated”",children:e.jsx(n.p,{children:"It exceeded 24,000 characters. Ask for a narrower query — a specific file rather than a whole tree. The cap protects the context window."})}),e.jsx(t,{title:"The handshake times out",children:e.jsxs(n.p,{children:["Spawn, ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"initialize"})})})})," and ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"tools/list"})})})})," share a 20-second budget. Cold starts are the usual cause — a first ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"npx"})})})})," run downloading the package, or Docker pulling an image. Run the command once in a terminal to warm the cache, then retry."]})}),e.jsx(t,{title:"A tool asks every time despite being allow-listed",children:e.jsxs(n.p,{children:["The server marks it with ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"destructiveHint"})})})}),". That always asks and the policy cannot override it — which is the point."]})}),e.jsx(t,{title:"“Ignored duplicate server”",children:e.jsxs(n.p,{children:["The same name is defined in your settings and in a repo's ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:".levelcode/mcp.json"})})})}),". Yours wins, deliberately — a repo must not be able to redefine a server you already trust. Rename the repo's entry if you want both."]})}),e.jsx(t,{title:"A row says “command changed — needs approval”",children:e.jsx(n.p,{children:"You approved this repo-defined server before, and the repo has edited what it wants to run since. Read the new command line in the card before re-approving — this is exactly the case the approval gate exists to catch."})})]}),` -`,e.jsxs(d,{children:[e.jsx(r,{title:"MCP servers",href:"/docs/mcp",children:e.jsx(n.p,{children:"How the protocol is wired, and the approval model these servers run under."})}),e.jsx(r,{title:"Troubleshooting",href:"/docs/troubleshooting",children:e.jsx(n.p,{children:"Everything else — first launch, providers and keys, the agent, updates."})})]})]})}function ne(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(_,{...s})}):_(s)}function j(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function q(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Accordion:t,AccordionGroup:i,Card:r,CardGroup:d,Kbd:a,Note:o,Tab:c,Tabs:h}=n;return t||u("Accordion"),i||u("AccordionGroup"),r||u("Card"),d||u("CardGroup"),a||u("Kbd"),o||u("Note"),c||u("Tab"),h||u("Tabs"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"overview",children:"Overview"}),` +`,e.jsxs(d,{children:[e.jsx(r,{title:"MCP servers",href:"/docs/mcp",children:e.jsx(n.p,{children:"How the protocol is wired, and the approval model these servers run under."})}),e.jsx(r,{title:"Troubleshooting",href:"/docs/troubleshooting",children:e.jsx(n.p,{children:"Everything else — first launch, providers and keys, the agent, updates."})})]})]})}function ne(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(_,{...s})}):_(s)}function j(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function N(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",li:"li",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Accordion:t,AccordionGroup:i,Card:r,CardGroup:d,Kbd:a,Note:o,Tab:c,Tabs:h}=n;return t||u("Accordion"),i||u("AccordionGroup"),r||u("Card"),d||u("CardGroup"),a||u("Kbd"),o||u("Note"),c||u("Tab"),h||u("Tabs"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"overview",children:"Overview"}),` `,e.jsxs(n.blockquote,{children:[` `,e.jsx(n.p,{children:"LevelCode is an AI-native, open-source code editor for macOS. It reads your codebase, edits across files, runs commands behind approval gates, and verifies its own work — on your own API key or on a metered plan."}),` `]}),` @@ -636,7 +645,7 @@ import{j as e,L as Y}from"./preload-helper-7J6LhHV_.js";import{u as l}from"./lev `,e.jsx(n.h2,{id:"where-things-live",children:"Where things live"}),` `,e.jsxs(n.table,{children:[e.jsx(n.thead,{children:e.jsxs(n.tr,{children:[e.jsx(n.th,{children:"I want to..."}),e.jsx(n.th,{children:"Go here"})]})}),e.jsxs(n.tbody,{children:[e.jsxs(n.tr,{children:[e.jsx(n.td,{children:"Install it and run my first task"}),e.jsx(n.td,{children:e.jsx(n.a,{href:"/docs/quickstart",children:"Quickstart"})})]}),e.jsxs(n.tr,{children:[e.jsx(n.td,{children:"Use my own API key"}),e.jsx(n.td,{children:e.jsx(n.a,{href:"/docs/providers#bring-your-own-key",children:"Providers and models"})})]}),e.jsxs(n.tr,{children:[e.jsx(n.td,{children:"Run a model on my own machine"}),e.jsx(n.td,{children:e.jsx(n.a,{href:"/docs/providers#local-models-with-ollama",children:"Providers → Ollama"})})]}),e.jsxs(n.tr,{children:[e.jsx(n.td,{children:"Stop the agent asking before every command"}),e.jsx(n.td,{children:e.jsx(n.a,{href:"/docs/agent#autopilot",children:"Agent → Autopilot"})})]}),e.jsxs(n.tr,{children:[e.jsx(n.td,{children:"Undo something the agent did"}),e.jsx(n.td,{children:e.jsx(n.a,{href:"/docs/agent#keep-undo-and-checkpoints",children:"Agent → Keep, Undo, and checkpoints"})})]}),e.jsxs(n.tr,{children:[e.jsx(n.td,{children:"Give the agent project-specific rules"}),e.jsx(n.td,{children:e.jsx(n.a,{href:"/docs/agent#project-rules",children:"Agent → Project rules"})})]}),e.jsxs(n.tr,{children:[e.jsx(n.td,{children:"Bring my VS Code setup over"}),e.jsx(n.td,{children:e.jsx(n.a,{href:"/docs/import-and-updates",children:"Import and updates"})})]}),e.jsxs(n.tr,{children:[e.jsx(n.td,{children:"Install extensions"}),e.jsx(n.td,{children:e.jsx(n.a,{href:"/docs/import-and-updates#extensions-come-from-open-vsx",children:"Import and updates → Extensions"})})]}),e.jsxs(n.tr,{children:[e.jsx(n.td,{children:"Understand what a run cost"}),e.jsx(n.td,{children:e.jsx(n.a,{href:"/docs/cloud#credits",children:"Cloud and billing"})})]})]})]}),` `,e.jsx(n.h2,{id:"next-steps",children:"Next steps"}),` -`,e.jsxs(d,{children:[e.jsx(r,{title:"Quickstart",href:"/docs/quickstart",children:e.jsx(n.p,{children:"Install, connect a model, and run a real agent task end to end."})}),e.jsx(r,{title:"Providers and models",href:"/docs/providers",children:e.jsx(n.p,{children:"Every supported provider, what each model can do, and where your keys live."})}),e.jsx(r,{title:"Agent",href:"/docs/agent",children:e.jsx(n.p,{children:"The loop in full: approvals, verification, checkpoints, and limits."})}),e.jsx(r,{title:"Troubleshooting",href:"/docs/troubleshooting",children:e.jsx(n.p,{children:"First-launch blocks, key errors, agent problems, update failures."})})]})]})}function se(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(q,{...s})}):q(s)}function u(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function N(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Tip:d,Warning:a}=n;return t||B("Card"),i||B("CardGroup"),r||B("Kbd"),d||B("Tip"),a||B("Warning"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"power-editing",children:"Power editing"}),` +`,e.jsxs(d,{children:[e.jsx(r,{title:"Quickstart",href:"/docs/quickstart",children:e.jsx(n.p,{children:"Install, connect a model, and run a real agent task end to end."})}),e.jsx(r,{title:"Providers and models",href:"/docs/providers",children:e.jsx(n.p,{children:"Every supported provider, what each model can do, and where your keys live."})}),e.jsx(r,{title:"Agent",href:"/docs/agent",children:e.jsx(n.p,{children:"The loop in full: approvals, verification, checkpoints, and limits."})}),e.jsx(r,{title:"Troubleshooting",href:"/docs/troubleshooting",children:e.jsx(n.p,{children:"First-launch blocks, key errors, agent problems, update failures."})})]})]})}function se(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(N,{...s})}):N(s)}function u(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function q(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",h3:"h3",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Tip:d,Warning:a}=n;return t||B("Card"),i||B("CardGroup"),r||B("Kbd"),d||B("Tip"),a||B("Warning"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"power-editing",children:"Power editing"}),` `,e.jsxs(n.blockquote,{children:[` `,e.jsx(n.p,{children:"The Notepad++ toolkit, rebuilt on Code-OSS: macros, column mode, line operations, encoding control, and a read-optimized mode for enormous files."}),` `]}),` @@ -683,7 +692,7 @@ import{j as e,L as Y}from"./preload-helper-7J6LhHV_.js";import{u as l}from"./lev `,e.jsxs(n.p,{children:[e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"indent"})})})})," accepts ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:'"editor"'})})})})," (follow the buffer's own settings), a number of spaces, or ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:'"tab"'})})})}),"."]}),` `,e.jsx(n.h2,{id:"hot-exit",children:"Hot exit"}),` `,e.jsxs(n.p,{children:["LevelCode defaults ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"files.hotExit"})})})})," to ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"onExitAndWindowClose"})})})}),", the Sublime behavior: unsaved edits and untitled tabs survive quitting the app ",e.jsx(n.strong,{children:"and"})," closing a window. Set it back to ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"onExit"})})})})," or ",e.jsx(n.span,{"data-rehype-pretty-code-figure":"",children:e.jsx(n.code,{"data-language":"text","data-theme":"one-dark-pro",children:e.jsx(n.span,{"data-line":"",children:e.jsx(n.span,{children:"off"})})})})," if you'd rather be prompted."]}),` -`,e.jsxs(i,{children:[e.jsx(t,{title:"Customization",href:"/docs/customization",children:e.jsx(n.p,{children:"Keymap presets, the init script, and writing your own packages."})}),e.jsx(t,{title:"Import and updates",href:"/docs/import-and-updates",children:e.jsx(n.p,{children:"Bring your VS Code settings and keybindings across."})})]})]})}function te(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(N,{...s})}):N(s)}function B(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function W(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Note:d,Step:a,Steps:o,Warning:c}=n;return t||m("Card"),i||m("CardGroup"),r||m("Kbd"),d||m("Note"),a||m("Step"),o||m("Steps"),c||m("Warning"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"providers-and-models",children:"Providers and models"}),` +`,e.jsxs(i,{children:[e.jsx(t,{title:"Customization",href:"/docs/customization",children:e.jsx(n.p,{children:"Keymap presets, the init script, and writing your own packages."})}),e.jsx(t,{title:"Import and updates",href:"/docs/import-and-updates",children:e.jsx(n.p,{children:"Bring your VS Code settings and keybindings across."})})]})]})}function te(s={}){const{wrapper:n}={...l(),...s.components};return n?e.jsx(n,{...s,children:e.jsx(q,{...s})}):q(s)}function B(s,n){throw new Error("Expected component `"+s+"` to be defined: you likely forgot to import, pass, or provide it.")}function W(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Note:d,Step:a,Steps:o,Warning:c}=n;return t||m("Card"),i||m("CardGroup"),r||m("Kbd"),d||m("Note"),a||m("Step"),o||m("Steps"),c||m("Warning"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"providers-and-models",children:"Providers and models"}),` `,e.jsxs(n.blockquote,{children:[` `,e.jsx(n.p,{children:"One provider registry and one OpenAI-compatible adapter. Set a key once and it works across chat, the agent, edit, and autocomplete."}),` `]}),` diff --git a/app/assets/interface/levelcode-B9y_e5v8.js b/app/assets/interface/levelcode-B9y_e5v8.js deleted file mode 100644 index 55376867..00000000 --- a/app/assets/interface/levelcode-B9y_e5v8.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/bundle-BT-miy7R.js","assets/preload-helper-7J6LhHV_.js"])))=>i.map(i=>d[i]); -var $t=Object.defineProperty;var Dt=(t,s,a)=>s in t?$t(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var fe=(t,s,a)=>Dt(t,typeof s!="symbol"?s+"":s,a);import{r as o,j as e,L as b,u as re,R as he,b as K,_ as It,d as Pt,e as Rt,f as P,c as Ot,N as Bt,g as qt,B as Ft}from"./preload-helper-7J6LhHV_.js";const Wt=typeof window<"u"&&window.__ENV__||{},Pe=String(Wt.API_BASE??"").replace(/\/+$/,"");let ge=null;async function Ut(){const t=typeof document<"u"?document.querySelector('meta[name="csrf-token"]'):null,s=t==null?void 0:t.getAttribute("content");return s||(ge||(ge=fetch(`${Pe}/ai/csrf`,{credentials:"include"}).then(a=>a.ok?a.json():{token:""}).then(a=>a.token??"").catch(()=>"")),ge)}class te extends Error{constructor(a,r,n){super(r);fe(this,"status");fe(this,"code");this.name="ApiError",this.status=a,this.code=n}}async function $(t,s={}){const a=s.method??(s.body!==void 0?"POST":"GET"),r={Accept:"application/json",...s.headers};s.body!==void 0&&(r["Content-Type"]="application/json"),a!=="GET"&&a!=="HEAD"&&(r["X-CSRF-Token"]=await Ut());const n=await fetch(`${Pe}${t}`,{method:a,headers:r,credentials:"include",body:s.body!==void 0?JSON.stringify(s.body):void 0}),l=await n.text();let d=null;if(l)try{d=JSON.parse(l)}catch{d=null}if(!n.ok){const c=d==null?void 0:d.error;throw new te(n.status,(c==null?void 0:c.message)??`Request failed (${n.status})`,c==null?void 0:c.code)}return d}function ae(t){window.location.href=t}function U(){const[t,s]=o.useState({loading:!0,profile:null});return o.useEffect(()=>{let a=!0;return $("/api/levelcode/v1/account/profile").then(r=>{a&&s({loading:!1,profile:r})}).catch(()=>{a&&s({loading:!1,profile:null})}),()=>{a=!1}},[]),t}function xt(t,s){const a=(t||s||"").trim();if(!a)return"··";const r=a.split(/[\s@._-]+/).filter(Boolean);return r.length>=2?(r[0][0]+r[1][0]).toUpperCase():a.slice(0,2).toUpperCase()}const F="https://github.com/levelcodeai/levelcode";function Vt(){try{const t=localStorage.getItem("lc-theme");return t==="dark"||t==="light"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch{return"light"}}function D({children:t}){const[s,a]=o.useState(Vt),r=()=>a(n=>{const l=n==="light"?"dark":"light";try{localStorage.setItem("lc-theme",l)}catch{}return l});return e.jsxs("div",{className:`classic ${s==="dark"?"classic--dark":""} flex min-h-screen flex-col bg-[var(--c-bg)] text-[16px] leading-relaxed text-[var(--c-text2)]`,children:[e.jsx(Yt,{theme:s,onToggleTheme:r}),e.jsx("div",{className:"flex-1",children:t}),e.jsx("footer",{className:"bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col items-center justify-between gap-4 px-5 py-8 text-[14px] sm:flex-row",children:[e.jsxs("ul",{className:"flex flex-wrap items-center justify-center gap-x-5 gap-y-2",children:[e.jsx("li",{children:e.jsx(b,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/terms",children:"Terms of Service"})}),e.jsx("li",{children:e.jsx(b,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/privacy",children:"Privacy"})}),e.jsx("li",{children:e.jsx(b,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/docs",children:"Documentation"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:F,children:"GitHub"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:`${F}/releases`,children:"Releases"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:`${F}/discussions`,children:"Discussions"})}),e.jsx("li",{children:e.jsx(b,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/pricing",children:"Pricing"})})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--c-text3)]",children:[e.jsx(Ht,{})," with ",e.jsx(Zt,{})," by LevelCode"]})]})})]})}function Yt({theme:t,onToggleTheme:s}){const{profile:a}=U();return e.jsx("nav",{"aria-label":"Primary",className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto flex h-12 max-w-5xl items-center justify-between px-5",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs(b,{to:"/",className:"text-[15px] font-bold text-[var(--c-text)]",children:["Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsxs("ul",{className:"hidden items-center gap-5 sm:flex",children:[e.jsx("li",{children:e.jsx(b,{to:"/docs",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Documentation"})}),e.jsx("li",{children:e.jsx("a",{href:"https://open-vsx.org/",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Extensions"})}),e.jsx("li",{children:e.jsx("a",{href:`${F}/releases`,className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Releases"})}),e.jsx("li",{children:e.jsx(b,{to:"/pricing",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Pricing"})})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{type:"button",onClick:s,"aria-label":t==="light"?"Switch to dark mode":"Switch to light mode",title:t==="light"?"Dark mode (One Dark)":"Light mode",className:"flex h-8 w-8 items-center justify-center rounded-full border border-[var(--c-line)] bg-[var(--c-bg)] text-[var(--c-text2)] transition-colors hover:border-[var(--c-accent)] hover:text-[var(--c-text)]",children:t==="light"?e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M13.3 9.9A5.6 5.6 0 0 1 6.1 2.7a.4.4 0 0 0-.5-.5 6.4 6.4 0 1 0 8.2 8.2.4.4 0 0 0-.5-.5z"})}):e.jsxs("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,children:[e.jsx("circle",{cx:"8",cy:"8",r:"3.2"}),e.jsx("path",{d:"M8 1.2v1.8M8 13v1.8M1.2 8H3M13 8h1.8M3.2 3.2l1.3 1.3M11.5 11.5l1.3 1.3M12.8 3.2l-1.3 1.3M4.5 11.5l-1.3 1.3"})]})}),a?e.jsx(b,{to:"/account",title:"Account","aria-label":"Account",className:"flex h-8 w-8 items-center justify-center rounded-full border border-[var(--c-line)] bg-[var(--c-bg)] text-[12px] font-semibold text-[var(--c-text)] hover:border-[var(--c-accent)]",children:xt(a.name,a.email)}):e.jsxs(b,{to:"/login",className:"flex items-center gap-1.5 text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M10 3.75a.75.75 0 0 1 .75-.75h2.5A1.75 1.75 0 0 1 15 4.75v6.5A1.75 1.75 0 0 1 13.25 13h-2.5a.75.75 0 0 1 0-1.5h2.5a.25.25 0 0 0 .25-.25v-6.5a.25.25 0 0 0-.25-.25h-2.5a.75.75 0 0 1-.75-.75Zm-3.28.72a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H1.75a.75.75 0 0 1 0-1.5h6.69L6.72 5.53a.75.75 0 0 1 0-1.06Z"})}),"Sign in"]})]})]})})}function ut({size:t=56}){return e.jsx("svg",{viewBox:"0 0 120 120",width:t,height:t,"aria-hidden":!0,children:e.jsxs("g",{fill:"none",stroke:"var(--c-accent)",strokeWidth:"13",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M28 92 L60 69 L92 92",opacity:"0.4"}),e.jsx("path",{d:"M28 68 L60 45 L92 68",opacity:"0.7"}),e.jsx("path",{d:"M28 44 L60 21 L92 44"})]})})}function Ht(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m5.5 4.5-3.5 3.5 3.5 3.5M10.5 4.5 14 8l-3.5 3.5"})})}function Zt(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"var(--c-accent)","aria-hidden":!0,children:e.jsx("path",{d:"m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002Z"})})}const Gt=1e4,ne="en-US";function Re(t){return(t??0)/Gt}function zt(t){const s=Re(t);return(s>0?Math.round(s):0).toLocaleString(ne)}function Te(t){const s=Re(t);return s>0?s>=10?Math.round(s).toLocaleString(ne):s<.05?"<0.1":s.toFixed(1):"0"}function _e(t){return(t??0).toLocaleString(ne)}const Kt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Fe=["bg-[var(--c-line)]","bg-flame/25","bg-flame/50","bg-flame/75","bg-[var(--c-accent)]"];function Xt(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}-${String(t.getUTCDate()).padStart(2,"0")}`}function Jt(t){return t<=0?0:t<=2?1:t<=6?2:t<=14?3:4}function J(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:_e(t)}function be(t){const[s,a,r]=t.split("-").map(Number);return new Date(Date.UTC(s,a-1,r)).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function Qt({activity:t,year:s,years:a,onYear:r}){const[n,l]=o.useState(null),d=(t==null?void 0:t.days)??{},{weeks:c,monthCols:h}=o.useMemo(()=>{var v;const i=new Date(Date.UTC(s,0,1)),f=new Date(i);f.setUTCDate(i.getUTCDate()-i.getUTCDay());const p=new Date(Date.UTC(s,11,31)),N=new Date(p);N.setUTCDate(p.getUTCDate()+(6-p.getUTCDay()));const w=[],j=[],C=new Date(f);let x=-1;for(;C<=N;){const u=[];let L=null;for(let _=0;_<7;_++){const q=C.getUTCFullYear()===s;if(_===0&&(L=q?C.getUTCMonth():null),q){const V=Xt(C);u.push({key:V,count:((v=d[V])==null?void 0:v.count)??0,date:new Date(C)})}else u.push({key:null,count:0,date:null});C.setUTCDate(C.getUTCDate()+1)}L!=null&&L!==x?(j.push(Kt[L]),x=L):j.push(null),w.push(u)}return{weeks:w,monthCols:j}},[s,d]),m=n?d[n]??null:null,g=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"classic-card p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"classic-label",children:"activity"}),e.jsxs("div",{className:"mt-1 text-lg font-semibold tracking-tight text-[var(--c-text)]",children:[_e((t==null?void 0:t.total)??0)," request",((t==null?void 0:t.total)??0)===1?"":"s"," in ",s]})]}),a.length>1?e.jsx("div",{className:"flex flex-wrap gap-1",children:a.map(i=>e.jsx("button",{type:"button",onClick:()=>{l(null),r(i)},className:`rounded-md px-2.5 py-1 font-mono text-[12px] transition-colors ${i===s?"bg-[var(--c-accent)] text-white":"text-[var(--c-text2)] hover:bg-[var(--c-line)]"}`,children:i},i))}):null]}),e.jsx("div",{className:"mt-5 overflow-x-auto",children:e.jsxs("div",{className:"inline-flex flex-col gap-1",children:[e.jsx("div",{className:"flex gap-[3px] pl-8",children:h.map((i,f)=>e.jsx("div",{className:"w-[11px] font-mono text-[10px] text-[var(--c-text3)]",children:i?e.jsx("span",{className:"relative -left-[1px] whitespace-nowrap",children:i}):null},f))}),e.jsxs("div",{className:"flex gap-[3px]",children:[e.jsx("div",{className:"mr-1 flex w-7 flex-col gap-[3px]",children:["","Mon","","Wed","","Fri",""].map((i,f)=>e.jsx("div",{className:"h-[11px] font-mono text-[9px] leading-[11px] text-[var(--c-text3)]",children:i},f))}),c.map((i,f)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:i.map((p,N)=>{var v,u;if(!p.key)return e.jsx("div",{className:"h-[11px] w-[11px]"},N);const w=Jt(p.count),j=n===p.key,C=(u=(v=d[p.key])==null?void 0:v.models)==null?void 0:u[0],x=p.count>0?`${be(p.key)} · ${p.count} request${p.count===1?"":"s"}${C?` · ${ve(C.model)} ${C.count}`:""}`:`${be(p.key)} · no activity`;return e.jsx("button",{type:"button",title:x,onClick:()=>l(j?null:p.key),className:`h-[11px] w-[11px] rounded-[2px] ${Fe[w]} ${j?"ring-1 ring-ink ring-offset-1":""} transition-colors hover:ring-1 hover:ring-ink/40`},N)})},f))]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 pl-8 font-mono text-[10px] text-[var(--c-text3)]",children:[e.jsx("span",{className:"mr-1",children:"Less"}),Fe.map((i,f)=>e.jsx("span",{className:`h-[11px] w-[11px] rounded-[2px] ${i}`},f)),e.jsx("span",{className:"ml-1",children:"More"})]})]})}),n&&m?e.jsxs("div",{className:"mt-6 rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"font-mono text-[12px] text-[var(--c-text2)]",children:be(n)}),e.jsxs("div",{className:"font-mono text-[12px] text-[var(--c-text3)]",children:[m.count," req · ",J(m.input)," in · ",J(m.output)," out ·"," ",Te(m.cost_micros)," credits"]})]}),e.jsx("ul",{className:"mt-3 space-y-1.5",children:m.models.map(i=>e.jsxs("li",{className:"flex items-center justify-between gap-3 font-mono text-[12px]",children:[e.jsx("span",{className:"truncate text-[var(--c-text)]",children:ve(i.model)}),e.jsxs("span",{className:"whitespace-nowrap text-[var(--c-text3)]",children:[i.count," · ",J(i.input+i.output)," tok"]})]},i.model))})]}):e.jsx("p",{className:"mt-4 font-mono text-[11px] text-[var(--c-text3)]",children:"Click a day to see its per-model breakdown."}),g.length?e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"classic-label mb-3",children:["by model · ",s]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[520px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"py-1.5 pr-3 font-normal",children:"model"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"requests"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"input"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"output"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"credits"}),e.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"reactions"})]})}),e.jsx("tbody",{children:g.map(i=>e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("td",{className:"py-1.5 pr-3 text-[var(--c-text)]",children:ve(i.model)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:_e(i.count)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:J(i.input)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:J(i.output)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:Te(i.cost_micros)}),e.jsx("td",{className:"py-1.5 pl-3 text-right tabular-nums text-[var(--c-text3)]",children:e.jsxs("span",{className:"inline-flex items-center justify-end gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(es,{className:"text-[var(--c-text2)]"})," ",i.up]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(ts,{className:"text-[var(--c-text2)]"})," ",i.down]})]})})]},i.model))})]})})]}):null]})}function ve(t){const s=t||"unknown",a=s.indexOf("/");return a>=0?s.slice(a+1):s}function es({className:t=""}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"currentColor","aria-hidden":"true",className:t,children:e.jsx("path",{d:"M12.999 6.00002H10.672L11.207 4.21802C11.278 3.98102 11.314 3.73902 11.314 3.49602C11.314 2.12002 10.192 0.999023 8.81298 0.999023C8.42998 0.999023 8.08498 1.21202 7.91398 1.55402L5.82998 5.72202C5.74498 5.89202 5.57398 5.99802 5.38298 5.99802H3.00098C1.89798 5.99802 1.00098 6.89502 1.00098 7.99802V12.998C1.00098 14.101 1.89798 14.998 3.00098 14.998H11.163C12.727 14.998 13.283 13.796 13.565 12.893L14.908 8.59602C14.969 8.40102 15 8.19902 15 7.99602C15 6.89402 14.103 5.99802 12.999 5.99802V6.00002ZM1.99998 13V8.00002C1.99998 7.44902 2.44898 7.00002 2.99998 7.00002H3.99998V14H2.99998C2.44898 14 1.99998 13.551 1.99998 13ZM13.954 8.29802L12.611 12.596C12.247 13.761 11.769 13.999 11.163 13.999H5.00098V6.99902H5.38298C5.95498 6.99902 6.46898 6.68102 6.72498 6.17002L8.80898 2.00202C8.80898 2.00202 8.81098 2.00002 8.81298 2.00002C9.64098 2.00002 10.314 2.67102 10.314 3.49702C10.314 3.64202 10.292 3.78802 10.249 3.93202L9.52098 6.35702C9.47598 6.50802 9.50398 6.67202 9.59898 6.79902C9.69398 6.92602 9.84198 7.00102 9.99998 7.00102H12.999C13.551 7.00102 14 7.44802 14 7.99902C14 8.10002 13.984 8.20102 13.954 8.30002V8.29802Z"})})}function ts({className:t=""}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"currentColor","aria-hidden":"true",className:t,children:e.jsx("path",{d:"M13 1H4.838C3.274 1 2.717 2.202 2.435 3.105L1.092 7.404C1.031 7.6 1 7.801 1 8.002C1 9.104 1.897 10 3.001 10H5.328L4.794 11.781C4.723 12.016 4.687 12.26 4.687 12.504C4.687 13.88 5.809 15.001 7.189 15.001C7.571 15.001 7.915 14.789 8.087 14.446L10.171 10.277C10.256 10.107 10.427 10.001 10.618 10.001H13C14.103 10.001 15 9.104 15 8.001V3C15 1.897 14.103 1 13 1ZM9.276 9.829L7.193 13.996L7.188 13.999C6.36 13.999 5.686 13.328 5.686 12.502C5.686 12.356 5.707 12.21 5.75 12.067L6.478 9.642C6.524 9.491 6.495 9.327 6.401 9.2C6.306 9.073 6.158 8.998 6 8.998H3.001C2.449 8.998 2 8.551 2 8C2 7.9 2.016 7.799 2.047 7.699L3.39 3.401C3.753 2.236 4.232 1.998 4.838 1.998H11V8.998H10.618C10.046 8.998 9.531 9.316 9.276 9.827V9.829ZM14 8C14 8.551 13.552 9 13 9H12V2H13C13.552 2 14 2.449 14 3V8Z"})})}const ss="/api/levelcode/v1/web_editor",as=1e4,rs={enabled:!1,url:null,loading:!0},se={enabled:!1,url:null,loading:!1};function ns(t){if(typeof t!="string")return null;let s;try{s=new URL(t.trim())}catch{return null}if(s.username||s.password)return null;if(s.protocol==="https:")return s.href;const a=s.hostname,r=a==="localhost"||a==="127.0.0.1"||a==="[::1]"||a.endsWith(".localhost");return s.protocol==="http:"&&r?s.href:null}function ls(t){const s=new URL(t);return s.searchParams.set("signin","1"),s.href}function os(t){if(!t||typeof t!="object")return se;const{enabled:s,url:a}=t,r=ns(a);return s===!0&&r?{enabled:!0,url:ls(r),loading:!1}:se}let Ee=rs,We=!1;const $e=new Set;function oe(t){Ee.loading&&(Ee=t,$e.forEach(s=>s()))}function is(){if(We)return;We=!0;const t=setTimeout(()=>oe(se),as);$(ss).then(s=>{clearTimeout(t);try{oe(os(s))}catch{oe(se)}},()=>{clearTimeout(t),oe(se)})}function cs(t){return $e.add(t),is(),()=>{$e.delete(t)}}const ds=()=>Ee;function X(){return o.useSyncExternalStore(cs,ds)}function xs(){const t=re(),{loading:s,profile:a}=U(),r=X(),[n,l]=o.useState(null),[d,c]=o.useState(null),[h,m]=o.useState(null),[g,i]=o.useState(new Date().getFullYear()),[f,p]=o.useState(null);o.useEffect(()=>{!s&&!a&&t("/login",{replace:!0})},[s,a,t]),o.useEffect(()=>{if(!a)return;let x=!0;return $("/api/levelcode/v1/account/usage").then(v=>{x&&l(v)}).catch(()=>{x&&p("We couldn’t load your usage right now. Please try again shortly.")}),()=>{x=!1}},[a]),o.useEffect(()=>{if(!a)return;let x=!0;return $("/api/levelcode/v1/account/models").then(v=>{x&&c(v)}).catch(()=>{}),()=>{x=!1}},[a]),o.useEffect(()=>{if(!a)return;let x=!0;return $(`/api/levelcode/v1/account/activity?year=${g}`).then(v=>{x&&m(v)}).catch(()=>{}),()=>{x=!1}},[a,g]);async function N(){try{const x=await $("/ai/billing",{method:"POST"});x.url&&ae(x.url)}catch{p("Could not open billing. Please try again.")}}async function w(){try{await $("/ai/signout",{method:"POST"})}catch{}t("/login",{replace:!0})}if(s||!a)return e.jsx(D,{children:e.jsx("main",{className:"mx-auto max-w-4xl px-5 py-12"})});const j=n?Ve(n.input_used,n.input_cap):0,C=n?Ve(n.output_used,n.output_cap):0;return e.jsx(D,{children:e.jsxs("main",{className:"mx-auto max-w-4xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:a.name?`Hi, ${a.name}`:"Your account"}),a.email?e.jsx("p",{className:"mt-2 font-mono text-[13px] text-[var(--c-text3)]",children:a.email}):null]}),e.jsxs("span",{className:"flex flex-wrap items-center gap-4",children:[r.enabled&&r.url?e.jsx("a",{href:r.url,title:"Open LevelCode in your browser",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"Open in browser →"}):null,a.role==="admin"?e.jsxs(e.Fragment,{children:[e.jsx(b,{to:"/admin",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"System dashboard →"}),e.jsx(b,{to:"/admin/referrals",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"Referrals →"})]}):null,e.jsxs("span",{className:"rounded-[3px] border border-[var(--c-line)] bg-[var(--c-surface)] px-2.5 py-1 font-mono text-[12px] text-[var(--c-text2)]",children:["plan · ",(n==null?void 0:n.plan)??a.plan??"free"]})]})]}),f?e.jsx("div",{className:"classic-card mt-10 p-8 text-[15px] text-[var(--c-text2)]",children:f}):n?e.jsxs("div",{className:"mt-10 grid gap-5 sm:grid-cols-2",children:[e.jsx(Ue,{label:"Input tokens",used:n.input_used,cap:n.input_cap,pct:j}),e.jsx(Ue,{label:"Output tokens",used:n.output_used,cap:n.output_cap,pct:C}),e.jsx("div",{className:"classic-card p-6 sm:col-span-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"classic-label",children:"billing period resets"}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--c-text)]",children:hs(n.period_end)}),e.jsxs("div",{className:"mt-1 font-mono text-[12px] text-[var(--c-text3)]",children:["overage policy · ",n.overage_policy]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",onClick:N,className:"classic-button--quiet",children:"Manage billing"}),e.jsx(b,{to:"/pricing",className:"classic-button",children:"Upgrade"})]})]})})]}):null,d&&d.models.length?e.jsx(us,{models:d}):null,e.jsx("div",{className:"mt-6",children:e.jsx(Qt,{activity:h,year:g,years:(h==null?void 0:h.years)??[g],onYear:i})}),e.jsx("button",{type:"button",onClick:w,className:"mt-10 text-[13px] text-[var(--c-accent)] hover:underline",children:"Sign out"})]})})}function us({models:t}){const s=t.budget_micros||0,a=t.ceiling_micros??s,r=t.spent_micros||0,n=t.credits_remaining_micros||0,l=a0?Math.min(Math.round(r/a*100),100):0,h=zt,m=i=>Re(i)>0?Te(i):"—",g=i=>i.includes("/")?i.slice(i.indexOf("/")+1):i;return e.jsxs("div",{className:"classic-card mt-5 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsx("div",{className:"classic-label",children:l?"usage available now":"compute credits"}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-[var(--c-text2)]",children:[h(r)," / ",h(a)," · ",c,"%"]})]}),e.jsxs("div",{className:"mt-1 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:[h(n),e.jsxs("span",{className:"text-sm font-normal text-[var(--c-text3)]",children:[" ","credits ",l?"available now":"left this period"]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-[var(--c-line)]",children:e.jsx("div",{className:`h-full rounded-full ${c>=100?"bg-red-500":"bg-[var(--c-accent)]"}`,style:{width:`${c}%`}})}),l&&d?e.jsxs("div",{className:"mt-2 font-mono text-[11px] text-[var(--c-text3)]",children:["More unlocks ",d.toLocaleDateString(void 0,{month:"short",day:"numeric"})," · ",h(s)," ","credits total this cycle"]}):null,e.jsx("div",{className:"mt-6 lineno",children:"models on your plan"}),e.jsx("div",{className:"mt-3 overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[460px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"py-1.5 pr-3 font-normal",children:"model"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"credits/turn"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"≈ turns left"}),e.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"status"})]})}),e.jsx("tbody",{children:t.models.map(i=>e.jsxs("tr",{className:`border-b border-[var(--c-line)] ${i.live?"":"opacity-55"}`,children:[e.jsx("td",{className:"py-1.5 pr-3 text-[var(--c-text)]",children:g(i.id)}),e.jsxs("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",title:`${i.multiplier}× the baseline model`,children:[m(i.per_turn_micros),e.jsxs("span",{className:"sr-only",children:[" credits per turn, ",i.multiplier,"× the baseline model"]})]}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:i.live?(i.turns_left??0).toLocaleString(ne):"—"}),e.jsx("td",{className:"py-1.5 pl-3 text-right",children:i.live?e.jsx("span",{className:"text-[11px] text-[var(--c-accent)]",children:"live"}):e.jsx("span",{className:"rounded bg-[var(--c-line)] px-1.5 py-0.5 text-[10px] text-[var(--c-text3)]",children:"soon"})})]},i.id))})]})})]})}function Ue({label:t,used:s,cap:a,pct:r}){const n=r>=100;return e.jsxs("div",{className:"classic-card p-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"classic-label",children:t}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-[var(--c-text2)]",children:[r,"%"]})]}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:[Ye(s),e.jsxs("span",{className:"text-sm font-normal text-[var(--c-text3)]",children:[" / ",Ye(a)]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-[var(--c-line)]",children:e.jsx("div",{className:`h-full rounded-full ${n?"bg-red-500":"bg-[var(--c-accent)]"}`,style:{width:`${Math.min(r,100)}%`}})})]})}function Ve(t,s){return!s||s<=0?0:Math.round(t/s*100)}function Ye(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString(ne)}function hs(t){if(!t)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}function ms(){const t=re(),{loading:s,profile:a}=U(),[r,n]=o.useState(null),[l,d]=o.useState(null),[c,h]=o.useState("input"),[m,g]=o.useState("desc"),[i,f]=o.useState(""),[p,N]=o.useState(""),[w,j]=o.useState(null),C=(a==null?void 0:a.role)==="admin";o.useEffect(()=>{s||(a?C||t("/account",{replace:!0}):t("/login",{replace:!0}))},[s,a,C,t]),o.useEffect(()=>{if(!C)return;let u=!0;return $("/api/levelcode/v1/admin/summary").then(L=>u&&n(L)).catch(()=>u&&j("Couldn’t load the admin summary.")),()=>{u=!1}},[C]),o.useEffect(()=>{if(!C)return;let u=!0;const L=new URLSearchParams({sort:c,dir:m,limit:"200"});return i.trim()&&L.set("q",i.trim()),p&&L.set("plan",p),$(`/api/levelcode/v1/admin/users?${L.toString()}`).then(_=>u&&d(_)).catch(()=>u&&j("Couldn’t load users.")),()=>{u=!1}},[C,c,m,i,p]);const x=o.useMemo(()=>Object.keys((r==null?void 0:r.plans)??{}).sort(),[r]);function v(u){c===u?g(L=>L==="desc"?"asc":"desc"):(h(u),g(u==="email"||u==="plan"?"asc":"desc"))}return s||!C?e.jsx(D,{children:e.jsx("main",{className:"mx-auto max-w-6xl px-5 py-12"})}):e.jsx(D,{children:e.jsxs("main",{className:"mx-auto max-w-6xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:"System dashboard"}),e.jsx("p",{className:"mt-2 text-[14px] text-[var(--c-text3)]",children:"tokens burned · plans · geography · login health"})]}),e.jsx(b,{to:"/admin/referrals",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Referrals →"})]}),w?e.jsx("div",{className:"classic-card mt-8 p-6 text-[14px] text-red-500",children:w}):null,e.jsxs("div",{className:"mt-10 grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Q,{label:"users",value:H(r==null?void 0:r.users),sub:`${H(r==null?void 0:r.active_users)} active`}),e.jsx(Q,{label:"requests",value:H(r==null?void 0:r.requests),sub:He(r==null?void 0:r.cost_micros)}),e.jsx(Q,{label:"input tokens",value:ie(r==null?void 0:r.input)}),e.jsx(Q,{label:"output tokens",value:ie(r==null?void 0:r.output)}),e.jsx(Q,{label:"auth attempts",value:H(r==null?void 0:r.auth_attempts),sub:`${H(r==null?void 0:r.auth_failures)} failed`,alert:((r==null?void 0:r.auth_failures)??0)>0}),e.jsx(je,{label:"plans",map:r==null?void 0:r.plans}),e.jsx(je,{label:"countries",map:r==null?void 0:r.countries}),e.jsx(je,{label:"auth failures · country",map:r==null?void 0:r.auth_failures_by_country,alert:!0})]}),e.jsxs("div",{className:"mt-10 flex flex-wrap items-center gap-3",children:[e.jsx("input",{value:i,onChange:u=>f(u.target.value),placeholder:"Search email…",className:"w-full max-w-xs rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2 font-mono text-[13px] text-[var(--c-text)] outline-none focus:border-[var(--c-accent)] sm:w-auto"}),e.jsxs("select",{value:p,onChange:u=>N(u.target.value),className:"rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2 font-mono text-[13px] text-[var(--c-text2)] outline-none focus:border-[var(--c-accent)]",children:[e.jsx("option",{value:"",children:"all plans"}),x.map(u=>e.jsx("option",{value:u,children:u},u))]}),e.jsxs("span",{className:"font-mono text-[12px] text-[var(--c-text3)]",children:[H(l==null?void 0:l.total)," users"]})]}),e.jsx("div",{className:"classic-card mt-4 overflow-x-auto p-0",children:e.jsxs("table",{className:"w-full min-w-[880px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx(W,{label:"email",col:"email",sort:c,dir:m,onClick:v,align:"left"}),e.jsx(W,{label:"plan",col:"plan",sort:c,dir:m,onClick:v,align:"left"}),e.jsx(W,{label:"input",col:"input",sort:c,dir:m,onClick:v}),e.jsx(W,{label:"output",col:"output",sort:c,dir:m,onClick:v}),e.jsx(W,{label:"requests",col:"requests",sort:c,dir:m,onClick:v}),e.jsx(W,{label:"cost",col:"cost",sort:c,dir:m,onClick:v}),e.jsx("th",{className:"px-3 py-2 text-left font-normal",children:"country"}),e.jsx(W,{label:"auth",col:"auth_attempts",sort:c,dir:m,onClick:v}),e.jsx(W,{label:"last seen",col:"last_seen",sort:c,dir:m,onClick:v}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"reach"})]})}),e.jsxs("tbody",{children:[((l==null?void 0:l.users)??[]).map(u=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] hover:bg-[var(--c-surface)]",children:[e.jsxs("td",{className:"px-3 py-2 text-[var(--c-text)]",children:[u.email,u.role==="admin"?e.jsx("span",{className:"ml-2 rounded border border-[var(--c-accent)] px-1.5 py-0.5 text-[10px] text-[var(--c-accent)]",children:"admin"}):null]}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:u.plan}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:ie(u.input)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:ie(u.output)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:H(u.requests)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:He(u.cost_micros)}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:u.country??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:e.jsxs("span",{className:u.auth_failures>0?"text-red-500":"text-[var(--c-text3)]",children:[u.auth_attempts,u.auth_failures>0?` · ${u.auth_failures}✗`:""]})}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text3)]",children:ps(u.last_seen_at)}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("a",{className:"text-[var(--c-accent)] underline decoration-[var(--c-line)] underline-offset-2 hover:decoration-[var(--c-accent)]",href:`mailto:${u.email}`,children:"email"})})]},u.id)),l&&l.users.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:10,className:"px-3 py-6 text-center text-[var(--c-text3)]",children:"No users match."})}):null]})]})})]})})}function W({label:t,col:s,sort:a,dir:r,onClick:n,align:l="right"}){const d=a===s;return e.jsx("th",{className:`px-3 py-2 font-normal ${l==="right"?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>n(s),className:`inline-flex items-center gap-1 ${d?"text-[var(--c-text)]":"hover:text-[var(--c-text)]"}`,children:[t,e.jsx("span",{className:"text-[9px]",children:d?r==="desc"?"▼":"▲":"↕"})]})})}function Q({label:t,value:s,sub:a,alert:r}){return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("div",{className:"classic-label",children:t}),e.jsx("div",{className:"mt-1 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:s}),a?e.jsx("div",{className:`mt-1 font-mono text-[11px] ${r?"text-red-500":"text-[var(--c-text3)]"}`,children:a}):null]})}function je({label:t,map:s,alert:a}){const r=Object.entries(s??{}).sort((n,l)=>l[1]-n[1]);return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("div",{className:"classic-label",children:t}),r.length?e.jsx("ul",{className:"mt-2 space-y-1 font-mono text-[12px]",children:r.slice(0,5).map(([n,l])=>e.jsxs("li",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--c-text2)]",children:n}),e.jsx("span",{className:`tabular-nums ${a?"text-red-500":"text-[var(--c-text3)]"}`,children:l})]},n))}):e.jsx("div",{className:"mt-2 font-mono text-[12px] text-[var(--c-text3)]",children:"—"})]})}function H(t){return(t??0).toLocaleString()}function ie(t){const s=t??0;return s>=1e6?`${+(s/1e6).toFixed(1)}M`:s>=1e3?`${+(s/1e3).toFixed(0)}K`:s.toLocaleString()}function He(t){return`$${((t??0)/1e6).toFixed(2)}`}function ps(t){if(!t)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?"—":s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}const De={},ht=he.createContext(De);function fs(t){const s=he.useContext(ht);return he.useMemo(function(){return typeof t=="function"?t(s):{...s,...t}},[s,t])}function gs(t){let s;return t.disableParentContext?s=typeof t.components=="function"?t.components(De):t.components||De:s=fs(t.components),he.createElement(ht.Provider,{value:s},t.children)}const mt=[{group:"Get started",items:[{title:"Overview",href:"/docs",blurb:"What LevelCode is, how the AI layer is wired, and where to go next."},{title:"Quickstart",href:"/docs/quickstart",blurb:"Install the editor, connect a model provider, and run your first agent task end to end."},{title:"Install and setup",href:"/docs/setup",blurb:"Download and verify a build, run from source, and handle macOS first-launch prompts."},{title:"In your browser",href:"/docs/browser",blurb:"Open LevelCode in a browser tab, choose a folder or a scratch workspace, and see what stays in the Mac app.",requiresWebEditor:!0}]},{group:"AI",items:[{title:"Chat",href:"/docs/chat",blurb:"Ask questions about your codebase, with context pulled in automatically or pinned by hand."},{title:"Agent",href:"/docs/agent",blurb:"The autonomous loop: planning, multi-file edits, approval-gated commands, self-verification, and checkpoints."},{title:"Edit",href:"/docs/edit",blurb:"Select code, describe the change, and review it as a diff before anything lands."},{title:"Autocomplete",href:"/docs/autocomplete",blurb:"Inline ghost-text completion as you type, and how to tune it."},{title:"Providers and models",href:"/docs/providers",blurb:"Bring your own key for any supported provider, run models locally with Ollama, or use the metered gateway."}]},{group:"MCP",items:[{title:"MCP servers",href:"/docs/mcp",blurb:"Connect Model Context Protocol servers to give the agent tools LevelCode doesn't ship, and the approval model that governs them."},{title:"Server recipes",href:"/docs/mcp-recipes",blurb:"Working configurations for GitHub, the filesystem, image generation, and hosted servers — plus how to keep API tokens out of settings.json."}]},{group:"The editor",items:[{title:"Power editing",href:"/docs/power-editing",blurb:"The Notepad++ pack: macros, column mode, line operations, encoding and line-ending control, big-file mode."},{title:"Customization",href:"/docs/customization",blurb:"The init script, package authoring with hot reload, keymap presets, and themes."},{title:"Import and updates",href:"/docs/import-and-updates",blurb:"Bring your settings over from VS Code, VSCodium, or Cursor, install extensions from Open VSX, and stay on the latest build."}]},{group:"Account",items:[{title:"Cloud and billing",href:"/docs/cloud",blurb:"Sign in, understand credits and usage, and decide between your own key and the metered gateway."}]},{group:"Help",items:[{title:"Troubleshooting",href:"/docs/troubleshooting",blurb:"Fixes for first-launch blocks, provider and key errors, agent and terminal problems, and update failures."}]}],pt=mt.flatMap(t=>t.items),ft=(t,s)=>!t.requiresWebEditor||s.webEditor;function bs(t){return mt.map(s=>({...s,items:s.items.filter(a=>ft(a,t))})).filter(s=>s.items.length>0)}function vs(t,s={webEditor:!1}){const a=pt.filter(n=>ft(n,s)),r=a.findIndex(n=>n.href===t);return r===-1?{prev:null,next:null}:{prev:r>0?a[r-1]:null,next:re.jsxs("div",{className:"mb-6 last:mb-0",children:[e.jsx("p",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wide text-[var(--c-text3)]",children:r.group}),e.jsx("ul",{className:"space-y-0.5 border-l border-[var(--c-line)]",children:r.items.map(n=>{const l=s===n.href;return e.jsx("li",{children:e.jsx(b,{to:n.href,onClick:t,"aria-current":l?"page":void 0,className:`-ml-px block border-l py-1 pl-3 transition-colors ${l?"border-[var(--c-accent)] font-medium text-[var(--c-accent)]":"border-transparent text-[var(--c-text2)] hover:border-[var(--c-line)] hover:text-[var(--c-text)]"}`,children:n.title})},n.href)})})]},r.group))})}function ys(){const{pathname:t}=K(),[s,a]=o.useState(!1);return o.useEffect(()=>a(!1),[t]),e.jsxs("div",{className:"border-b border-[var(--c-line)] lg:hidden",children:[e.jsxs("button",{type:"button",onClick:()=>a(r=>!r),"aria-expanded":s,"aria-controls":"docs-mobile-nav",className:"flex w-full items-center gap-2 px-5 py-3 text-[14px] font-medium text-[var(--c-text)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:`text-[var(--c-text3)] transition-transform duration-150 ${s?"rotate-90":""}`,children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})}),"Documentation menu"]}),s?e.jsx("div",{id:"docs-mobile-nav",className:"px-5 pb-5",children:e.jsx(gt,{onNavigate:()=>a(!1)})}):null]})}function Ns(){return e.jsx("aside",{className:"hidden lg:block",children:e.jsx("div",{className:"sticky top-0 max-h-screen overflow-y-auto py-12 pr-6",children:e.jsx(gt,{})})})}function ws({revision:t=0}){const{pathname:s}=K(),[a,r]=o.useState([]),[n,l]=o.useState("");return o.useEffect(()=>{const d=document.querySelector("article");if(!d)return;const c=Array.from(d.querySelectorAll("h2[id], h3[id]")).map(h=>{const m=h.cloneNode(!0);return m.querySelectorAll("a").forEach(g=>g.remove()),{id:h.id,text:(m.textContent??"").trim(),level:Number(h.tagName[1])}});r(h=>h.length===c.length&&h.every((m,g)=>m.id===c[g].id)?h:c)},[s,t]),o.useEffect(()=>{if(a.length===0)return;const d=()=>{let h=a[0].id;for(const m of a){const g=document.getElementById(m.id);g&&g.getBoundingClientRect().top<=120&&(h=m.id)}window.innerHeight+window.scrollY>=document.body.offsetHeight-2&&(h=a[a.length-1].id),l(h)};return d(),window.addEventListener("scroll",d,{passive:!0}),()=>window.removeEventListener("scroll",d)},[a]),a.length<2?null:e.jsxs("nav",{"aria-labelledby":"toc-heading",className:"text-[13.5px]",children:[e.jsx("p",{id:"toc-heading",className:"mb-3 font-semibold text-[var(--c-text)]",children:"On this page"}),e.jsx("ul",{className:"space-y-1.5 border-l border-[var(--c-line)]",children:a.map(d=>e.jsx("li",{children:e.jsx("a",{href:`#${d.id}`,"aria-current":n===d.id?"location":void 0,className:`-ml-px block border-l py-0.5 leading-snug transition-colors ${d.level===3?"pl-6":"pl-3"} ${n===d.id?"border-[var(--c-accent)] text-[var(--c-accent)]":"border-transparent text-[var(--c-text2)] hover:text-[var(--c-text)]"}`,children:d.text})},d.id))})]})}function bt(t,s=24){const a=Math.max(0,t.getBoundingClientRect().top+window.scrollY-s);return window.scrollTo({top:a,behavior:"instant"}),Math.abs(window.scrollY-a)<=2}function ks(){window.scrollTo({top:0,behavior:"instant"})}function Cs(t){return t.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-")}function Ss({title:t,defaultOpen:s=!1,children:a}){const r=Cs(t),n=o.useRef(null),[l,d]=o.useState(s);return o.useEffect(()=>{const c=()=>{decodeURIComponent(window.location.hash.slice(1))===r&&(d(!0),requestAnimationFrame(()=>{n.current&&bt(n.current)}))};return c(),window.addEventListener("hashchange",c),()=>window.removeEventListener("hashchange",c)},[r]),e.jsxs("details",{ref:n,id:r,open:l,onToggle:c=>d(c.currentTarget.open),className:"group scroll-mt-8 border-b border-[var(--c-line)] last:border-b-0 [&_>_summary_>_svg]:open:rotate-90",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 py-3 text-[15px] font-medium text-[var(--c-text)] marker:content-none hover:text-[var(--c-accent)] [&::-webkit-details-marker]:hidden",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:"shrink-0 text-[var(--c-text3)] transition-transform duration-150",children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})}),t]}),e.jsx("div",{className:"pb-4 pl-[20px]",children:a})]})}function Ls({children:t}){return e.jsx("div",{className:"my-6 rounded-md border border-[var(--c-line)] px-4",children:t})}function Ms({title:t,href:s,children:a}){const r=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[15px] font-semibold text-[var(--c-text)]",children:[t,s?e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:"text-[var(--c-text3)] transition-transform duration-150 group-hover:translate-x-0.5 group-hover:text-[var(--c-accent)]",children:e.jsx("path",{d:"M8.22 2.97a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06l2.97-2.97H3.75a.75.75 0 0 1 0-1.5h7.44L8.22 4.03a.75.75 0 0 1 0-1.06Z"})}):null]}),a?e.jsx("span",{className:"mt-1.5 block text-[14px] leading-relaxed text-[var(--c-text2)]",children:a}):null]}),n="group block rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-4 no-underline transition-colors";return s?e.jsx(b,{to:s,className:`${n} hover:border-[var(--c-accent)]`,children:r}):e.jsx("div",{className:n,children:r})}function As({cols:t=2,children:s}){const a=t===1?"sm:grid-cols-1":t===3?"sm:grid-cols-3":"sm:grid-cols-2";return e.jsx("div",{className:`my-6 grid grid-cols-1 gap-3 ${a}`,children:s})}const Ts={note:{wrap:"border-[var(--c-line)] bg-[var(--c-surface)]",icon:"text-[var(--c-text3)]",label:"Note",path:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"},tip:{wrap:"border-[#149963]/30 bg-[#149963]/[0.08]",icon:"text-[#149963]",label:"Tip",path:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"},info:{wrap:"border-[var(--c-accent)]/30 bg-[var(--c-accent)]/[0.07]",icon:"text-[var(--c-accent)]",label:"Info",path:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"},warning:{wrap:"border-[#d19a66]/40 bg-[#d19a66]/[0.1]",icon:"text-[#b3701a]",label:"Warning",path:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}};function pe({variant:t,children:s}){const a=Ts[t];return e.jsxs("div",{className:`my-5 flex gap-3 rounded-md border px-4 py-3 ${a.wrap}`,children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor","aria-hidden":!0,className:`mt-[3px] shrink-0 ${a.icon}`,children:e.jsx("path",{d:a.path})}),e.jsxs("div",{className:"min-w-0 text-[15px] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:[e.jsxs("span",{className:"sr-only",children:[a.label,": "]}),s]})]})}const _s=({children:t})=>e.jsx(pe,{variant:"note",children:t}),Es=({children:t})=>e.jsx(pe,{variant:"tip",children:t}),$s=({children:t})=>e.jsx(pe,{variant:"info",children:t}),Ds=({children:t})=>e.jsx(pe,{variant:"warning",children:t});function Is({children:t,...s}){const a=o.useRef(null),[r,n]=o.useState(!1),[l,d]=o.useState(null);o.useEffect(()=>{var h,m;d(((m=(h=a.current)==null?void 0:h.querySelector("pre"))==null?void 0:m.getAttribute("data-language"))??null)},[]);async function c(){var m,g;const h=((g=(m=a.current)==null?void 0:m.querySelector("pre"))==null?void 0:g.textContent)??"";try{await navigator.clipboard.writeText(h),n(!0),window.setTimeout(()=>n(!1),1600)}catch{}}return e.jsxs("figure",{ref:a,...s,className:"group relative my-5 overflow-hidden rounded-md border border-black/20 bg-[#0d1321] text-[#abb2bf] [&_code]:grid [&_code]:rounded-none [&_code]:border-0 [&_code]:bg-transparent [&_code]:p-0 [&_code]:font-mono [&_code]:text-[13.5px] [&_code]:leading-[1.65] [&_code]:text-inherit [&_pre]:overflow-x-auto [&_pre]:bg-transparent [&_pre]:py-4 [&_[data-line]]:px-4",children:[e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex items-center gap-2",children:[l?e.jsx("span",{className:"select-none font-mono text-[11px] uppercase tracking-wide text-[#7d8695] opacity-0 transition-opacity group-hover:opacity-100",children:l}):null,e.jsx("button",{type:"button",onClick:c,"aria-label":r?"Copied to clipboard":"Copy code",className:"rounded-[4px] border border-white/10 bg-white/5 px-2 py-1 font-mono text-[11px] text-[#b9c0cb] opacity-0 transition-all hover:border-white/25 hover:bg-white/10 focus-visible:opacity-100 group-hover:opacity-100",children:r?"Copied":"Copy"})]}),t]})}const Ze={cmd:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",opt:"⌥",shift:"⇧",enter:"↩",return:"↩",tab:"⇥",escape:"⎋",esc:"⎋",space:"Space",backspace:"⌫",delete:"⌦",up:"↑",down:"↓",left:"←",right:"→"};function Ps(t){const s=t.trim().toLowerCase();return Ze[s]?Ze[s]:t.trim().length===1?t.trim().toUpperCase():t.trim()}function Rs({keys:t}){const s=t.trim().split(/\s+/);return e.jsx("span",{className:"inline-flex items-baseline gap-1 whitespace-nowrap align-baseline",children:s.map((a,r)=>e.jsx("kbd",{className:"inline-flex items-center rounded-[4px] border border-[var(--c-line)] bg-[var(--c-surface)] px-[6px] py-[2px] font-mono text-[12.5px] font-medium text-[var(--c-text)]",children:a.split("+").map(Ps).join("")},`${a}-${r}`))})}function Os({children:t}){return e.jsx(e.Fragment,{children:t})}function Bs(t){var s;return o.isValidElement(t)&&typeof((s=t.props)==null?void 0:s.title)=="string"}function qs({children:t}){const s=o.Children.toArray(t).filter(Bs);return s.length===0?null:e.jsx("ol",{className:"my-6 list-none space-y-0 pl-0",children:s.map((a,r)=>e.jsxs("li",{className:"relative pb-6 pl-10 last:pb-0",children:[r*:first-child]:mt-0 [&>*:last-child]:mb-0",children:a.props.children})]},`${a.props.title}-${r}`))})}function Fs({children:t}){return e.jsx(e.Fragment,{children:t})}function Ws(t){var s;return o.isValidElement(t)&&typeof((s=t.props)==null?void 0:s.title)=="string"}function Us({children:t}){const s=o.Children.toArray(t).filter(Ws),[a,r]=o.useState(0),n=o.useId();if(s.length===0)return null;const l=s[Math.min(a,s.length-1)];return e.jsxs("div",{className:"my-6",children:[e.jsx("div",{role:"tablist","aria-orientation":"horizontal",className:"flex flex-wrap gap-1 border-b border-[var(--c-line)]",children:s.map((d,c)=>{const h=c===a;return e.jsx("button",{type:"button",role:"tab",id:`${n}-tab-${c}`,"aria-selected":h,"aria-controls":`${n}-panel-${c}`,onClick:()=>r(c),className:`-mb-px border-b-2 px-3 py-2 text-[14px] font-medium transition-colors ${h?"border-[var(--c-accent)] text-[var(--c-text)]":"border-transparent text-[var(--c-text2)] hover:border-[var(--c-line)] hover:text-[var(--c-text)]"}`,children:d.props.title},`${d.props.title}-${c}`)})}),e.jsx("div",{role:"tabpanel",id:`${n}-panel-${a}`,"aria-labelledby":`${n}-tab-${a}`,className:"pt-4",children:l.props.children})]})}function ye(t){const s=`h${t}`,a=t===2?"mt-12 text-[24px] font-semibold":t===3?"mt-9 text-[18.5px] font-semibold":"mt-7 text-[16px] font-semibold";return function({id:n,children:l,...d}){return e.jsxs(s,{id:n,className:`group mb-3 scroll-mt-8 text-[var(--c-text)] ${a}`,...d,children:[l,n?e.jsx("a",{href:`#${n}`,"aria-label":"Link to this section",className:"ml-2 text-[var(--c-text3)] opacity-0 transition-opacity hover:text-[var(--c-accent)] focus-visible:opacity-100 group-hover:opacity-100",children:"#"}):null]})}}const Ge="font-medium text-[var(--c-accent)] underline decoration-[var(--c-accent)]/30 underline-offset-2 transition-colors hover:decoration-[var(--c-accent)]",Vs={h1:({children:t,...s})=>e.jsx("h1",{className:"mb-4 text-[34px] font-bold leading-tight tracking-tight text-[var(--c-text)]",...s,children:t}),h2:ye(2),h3:ye(3),h4:ye(4),p:t=>e.jsx("p",{className:"my-4 text-[16px] leading-[1.7] pretty",...t}),a:({href:t="",children:s,...a})=>{if(t.startsWith("/"))return e.jsx(b,{to:t,className:Ge,...a,children:s});const r=!t.startsWith("#");return e.jsx("a",{href:t,className:Ge,...r?{target:"_blank",rel:"noopener noreferrer"}:{},...a,children:s})},ul:t=>e.jsx("ul",{className:"my-4 list-disc space-y-2 pl-5 marker:text-[var(--c-text3)]",...t}),ol:t=>e.jsx("ol",{className:"my-4 list-decimal space-y-2 pl-5 marker:text-[var(--c-text3)]",...t}),li:t=>e.jsx("li",{className:"leading-[1.7] [&>ol]:my-2 [&>ul]:my-2",...t}),strong:t=>e.jsx("strong",{className:"font-semibold text-[var(--c-text)]",...t}),code:t=>e.jsx("code",{className:"rounded-[3px] border border-[var(--c-line)] bg-[var(--c-surface)] px-[5px] py-[1.5px] font-mono text-[0.875em] text-[var(--c-text)]",...t}),figure:({children:t,...s})=>"data-rehype-pretty-code-figure"in s?e.jsx(Is,{...s,children:t}):e.jsx("figure",{className:"my-6",...s,children:t}),blockquote:t=>e.jsx("blockquote",{className:"my-5 border-l-2 border-[var(--c-line)] pl-4 text-[var(--c-text2)] [&>p]:my-2",...t}),hr:()=>e.jsx("hr",{className:"my-10 border-[var(--c-line)]"}),table:t=>e.jsx("div",{className:"my-6 overflow-x-auto rounded-md border border-[var(--c-line)]",children:e.jsx("table",{className:"w-full border-collapse text-left text-[14.5px]",...t})}),thead:t=>e.jsx("thead",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",...t}),th:t=>e.jsx("th",{className:"px-4 py-2.5 font-semibold text-[var(--c-text)] [&_code]:text-[0.9em]",...t}),td:t=>e.jsx("td",{className:"border-t border-[var(--c-line)] px-4 py-2.5 align-top leading-[1.6] [&_code]:text-[0.9em]",...t}),Tabs:Us,Tab:Fs,Accordion:Ss,AccordionGroup:Ls,Card:Ms,CardGroup:As,Steps:qs,Step:Os,Note:_s,Tip:Es,Info:$s,Warning:Ds,Kbd:Rs};function Ys(){const[t,s]=o.useState(0);return o.useEffect(()=>{const a=document.querySelector("article");if(!a)return;const r=new MutationObserver(()=>s(n=>n+1));return r.observe(a,{childList:!0,subtree:!0}),()=>r.disconnect()},[]),t}function Hs(t){o.useEffect(()=>{const s=pt.find(d=>d.href===t),a=document.title;document.title=s?`${s.title} — LevelCode Docs`:"LevelCode Docs";const r=document.querySelector('meta[name="description"]'),n=(r==null?void 0:r.hasAttribute("content"))??!1,l=(r==null?void 0:r.getAttribute("content"))??null;return r&&s&&r.setAttribute("content",s.blurb),()=>{document.title=a,r&&(n&&l!==null?r.setAttribute("content",l):r.removeAttribute("content"))}},[t])}function Zs(t,s,a){const r=o.useRef("");o.useEffect(()=>{const n=t+s;if(!s){r.current!==n&&(r.current=n,ks());return}if(r.current===n)return;const l=document.getElementById(decodeURIComponent(s.slice(1)));if(!l)return;const d=()=>{bt(l)&&(r.current=n)};d(),requestAnimationFrame(d)},[t,s,a])}function Gs({children:t}){const{pathname:s,hash:a}=K(),r=Ys();return Hs(s),Zs(s,a,r),e.jsxs(D,{children:[e.jsx(ys,{}),e.jsx("div",{className:"mx-auto max-w-[88rem] px-5",children:e.jsxs("div",{className:"lg:grid lg:grid-cols-[14rem_minmax(0,1fr)] lg:gap-10 xl:grid-cols-[14rem_minmax(0,1fr)_13rem]",children:[e.jsx(Ns,{}),e.jsxs("main",{className:"min-w-0 py-10 lg:py-12",children:[e.jsx("article",{className:"max-w-[46rem]",children:e.jsx(gs,{components:Vs,children:t})}),e.jsx("div",{className:"max-w-[46rem]",children:e.jsx(js,{})})]}),e.jsx("div",{className:"hidden xl:block",children:e.jsx("div",{className:"sticky top-0 max-h-screen overflow-y-auto py-12",children:e.jsx(ws,{revision:r})})})]})})]})}const zs=o.lazy(()=>It(()=>import("./bundle-BT-miy7R.js"),__vite__mapDeps([0,1])));function vt({slug:t=""}){return e.jsx(Gs,{children:e.jsx(o.Suspense,{fallback:e.jsx(Ks,{}),children:e.jsx(zs,{slug:t})})})}function Ks(){return e.jsxs("div",{"aria-hidden":!0,className:"animate-pulse",children:[e.jsx("div",{className:"h-9 w-2/3 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-6 h-4 w-full rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-11/12 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-4/5 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-10 h-6 w-1/3 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-5 h-4 w-full rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-10/12 rounded bg-[var(--c-surface)]"}),e.jsx("span",{className:"sr-only",children:"Loading documentation…"})]})}const Xs="https://github.com/levelcodeai/levelcode",Js="levelcode://levelcode.levelcode-ai/launch";function Qs(){const{profile:t}=U(),s=X();return e.jsx("header",{className:"fixed inset-x-0 top-0 z-50 border-b border-rule bg-paper/85 backdrop-blur-md",children:e.jsxs("nav",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-5",children:[e.jsxs(b,{to:"/",className:"font-display text-[15px] font-bold tracking-tightest",children:["LevelCode ",e.jsx("span",{className:"font-medium text-faint",children:"Cloud"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(b,{to:"/pricing",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Pricing"}),e.jsx("a",{href:Xs,target:"_blank",rel:"noreferrer",className:"hidden items-center gap-2 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:"GitHub"}),e.jsx(b,{to:"/download",className:"rounded-full bg-ink px-4 py-1.5 text-sm font-semibold text-paper transition-colors hover:bg-flame",children:"Download"}),t?e.jsxs(e.Fragment,{children:[t.role==="admin"?e.jsx(b,{to:"/admin",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Admin"}):null,e.jsxs("a",{href:Js,title:"Open the LevelCode editor (signs it into this account)",className:"inline-flex items-center gap-1 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink",children:["IDE ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}),s.enabled&&s.url?e.jsxs("a",{href:s.url,title:"Open LevelCode in your browser","aria-label":"Open LevelCode in your browser",className:"hidden items-center gap-1 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:["Browser ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}):null,e.jsx(b,{to:"/account",title:"Account","aria-label":"Account",className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-rule bg-card text-[12px] font-semibold text-ink transition-colors hover:border-ink",children:xt(t.name,t.email)})]}):e.jsx(b,{to:"/login",className:"hidden items-center gap-2 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:"Sign in"})]})]})})}function jt(){if(typeof navigator>"u")return!1;const t=navigator.userAgent||"",s=/Mac/i.test(navigator.platform||"")||/Macintosh/.test(t),a=s&&(navigator.maxTouchPoints??0)>1;return s&&!a}async function ea(){var s,a;if(!jt())return"not-mac";const t=navigator;try{const r=await((a=(s=t.userAgentData)==null?void 0:s.getHighEntropyValues)==null?void 0:a.call(s,["architecture"]));if((r==null?void 0:r.architecture)==="arm")return"arm64";if((r==null?void 0:r.architecture)==="x86")return"x64"}catch{}try{const r=document.createElement("canvas"),n=r.getContext("webgl")||r.getContext("experimental-webgl"),l=n==null?void 0:n.getExtension("WEBGL_debug_renderer_info"),d=l&&n?String(n.getParameter(l.UNMASKED_RENDERER_WEBGL)):"";if(/apple/i.test(d))return"arm64";if(/intel|amd|radeon/i.test(d))return"x64"}catch{}return"unknown-mac"}const ze="https://github.com/levelcodeai/levelcode/releases/latest",Ne={arm64:`${ze}/download/LevelCode-arm64.dmg`,x64:`${ze}/download/LevelCode-x64.dmg`};function ta(){const[t,s]=o.useState("unknown-mac"),a=X();o.useEffect(()=>{let d=!0;return ea().then(c=>{d&&s(c)}),()=>{d=!1}},[]);const r=t==="x64"?"x64":"arm64",n=r==="arm64"?"Apple Silicon":"Intel",l=t==="not-mac";return e.jsxs(e.Fragment,{children:[e.jsx(Qs,{}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-24",children:[e.jsx("div",{className:"lineno mb-4",children:"06 · download"}),e.jsxs("h1",{className:"font-display text-[clamp(2rem,5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-balance",children:["Download ",e.jsx("span",{className:"pp",children:"LevelCode"})," for macOS"]}),e.jsx("p",{className:"mt-5 max-w-xl text-[17px] leading-relaxed text-sub pretty",children:"The AI-native editor — your plan, keys, and usage in one place. Universal on any modern Mac; pick Intel if you’re on an older one."}),l?e.jsx("div",{className:"surface mt-8 p-5 text-[14px] text-sub",children:"LevelCode is a macOS app for now. Grab it on your Mac — or download a build below to move over."}):null,e.jsxs("div",{className:"mt-9 flex flex-col items-start gap-3",children:[e.jsxs("a",{href:Ne[r],className:"btn-primary text-[15px]",download:!0,children:["Download for ",n," Mac"]}),e.jsx("p",{className:"font-mono text-[12px] text-faint",children:"Universal .dmg · latest release · macOS 12 Monterey or later"}),a.enabled?e.jsxs("p",{className:"text-[15px] text-sub",children:["Or"," ",e.jsx(b,{to:"/web",className:"text-ink underline decoration-ink/30 underline-offset-4 transition-colors hover:text-flame hover:decoration-flame",children:"open it in your browser"}),"."]}):null]}),e.jsx("div",{className:"mt-10 lineno",children:"all builds"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[e.jsx("a",{href:Ne.arm64,className:"btn-ghost text-[14px]",download:!0,children:"Apple Silicon (M1–M4)"}),e.jsx("a",{href:Ne.x64,className:"btn-ghost text-[14px]",download:!0,children:"Intel Mac (x64)"})]}),e.jsx("p",{className:"mt-4 font-mono text-[12px] text-faint",children:"Not sure which Mac you have? Apple menu → About This Mac. “Apple M…” chip → Apple Silicon; “Intel” → Intel."})]})]})}const O=t=>({t,c:"text-[#c58aff]"}),Ke=t=>({t,c:"text-[#7fd88f]"}),Z=t=>({t,c:"text-[#9fb4ff]"}),we=t=>({t,c:"text-[#5b6172]"}),ke=t=>({t,c:"text-[#e6a86b]"}),y=t=>({t}),B=[{id:"generate",label:"Generate",file:"payments/refund_service.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Generate."})," Describe the change in plain language — LevelCode writes idiomatic code in your project’s style, right in the buffer."]}),chat:[{who:"you",text:"Add idempotency to RefundService — same request twice must not double-refund."},{who:"ai",text:"Adding an idempotency key check backed by Redis, with a 24h TTL. Writing it now…"}],code:[{no:"12",toks:[O("class"),y(" "),Z("RefundService")]},{no:"13",toks:[y(" "),O("def"),y(" "),Z("call"),y("(charge, key:)")]},{no:"14",toks:[y(" "),O("return"),y(" cached(key) "),O("if"),y(" seen?(key)")]},{no:"15",toks:[y(" result = gateway.refund(charge)")]},{no:"16",toks:[y(" remember(key, result, ttl: "),ke("24"),y(".hours)")]},{no:"17",toks:[y(" result")]},{no:"18",toks:[y(" "),O("end")]},{no:"19",toks:[O("end")]}]},{id:"refactor",label:"Refactor",file:"api/orders_controller.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Refactor."})," Select any block and ask. LevelCode restructures across files, keeping behavior identical and diffs reviewable."]}),chat:[{who:"you",text:"This controller does too much. Extract the pricing logic."},{who:"ai",text:"Extracting to app/services/pricing_calculator.rb and updating 3 call sites. Behavior unchanged — diff ready."}],code:[{no:"40",toks:[we("# before: 62 lines in controller")]},{no:"41",toks:[O("def"),y(" "),Z("create")]},{no:"42",toks:[y(" total = "),Z("PricingCalculator")]},{no:"43",toks:[y(" .new(cart, coupon: params[:coupon])")]},{no:"44",toks:[y(" .total")]},{no:"45",toks:[y(" order = "),Z("Order"),y(".create!(total:)")]},{no:"46",toks:[y(" render json: order")]},{no:"47",toks:[O("end")]}]},{id:"explain",label:"Explain",file:"legacy/billing_engine.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Explain."})," Point at unfamiliar code — get a walkthrough of what it does, why it exists, and where it’s called from."]}),chat:[{who:"you",text:"What is this proration branch actually doing?"},{who:"ai",text:"It splits the billing period at the plan-change date, credits unused time on the old plan, and charges the remainder at the new rate. Called from 2 places — both webhooks."}],code:[{no:"88",toks:[O("if"),y(" plan_changed_mid_cycle?")]},{no:"89",toks:[y(" credit = unused_ratio * old_rate")]},{no:"90",toks:[y(" charge = remaining_ratio * new_rate")]},{no:"91",toks:[y(" invoice.adjust(credit:, charge:)")]},{no:"92",toks:[O("end")]},{no:"93",toks:[we("# ← LevelCode: proration on plan change")]}]},{id:"test",label:"Test",file:"spec/refund_service_spec.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Test."})," LevelCode drafts the spec, runs it, reads the failure, and fixes the code — a full red-green loop without leaving the editor."]}),chat:[{who:"you",text:"Write specs for the double-refund case."},{who:"ai",text:"Spec written. Running… 1 failure: cache key ignored currency. Patched — all green ✓"}],code:[{no:"05",toks:[Z("it"),y(" "),Ke('"refunds only once per key"'),y(" "),O("do")]},{no:"06",toks:[y(" "),ke("2"),y(".times { service.call(charge, key:) }")]},{no:"07",toks:[y(" expect(gateway.refunds.count).to eq("),ke("1"),y(")")]},{no:"08",toks:[O("end")]},{no:"09",toks:[y("")]},{no:"10",toks:[Ke("✓ 14 examples, 0 failures — 0.42s")]}]},{id:"review",label:"Review",file:"PR #241 · fix race in webhook retry — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Review."})," Before you push, LevelCode flags edge cases, security issues, and style drift — like a senior reviewer on every commit."]}),chat:[{who:"you",text:"Review this PR before I push."},{who:"ai",text:"One real issue: retry loop can fire twice if the worker restarts between enqueue and ack. Suggesting a fix inline."}],code:[{no:"21",toks:[we("# ⚠ LevelCode: not restart-safe")]},{no:"22",toks:[{t:"- retry_later(webhook)",c:"text-[#e06c75]"}]},{no:"23",toks:[{t:"+ ",c:"text-[#7fd88f]"},Z("WebhookRetryJob")]},{no:"24",toks:[{t:"+ ",c:"text-[#7fd88f]"},y(" .set(wait: backoff(attempt))")]},{no:"25",toks:[{t:"+ ",c:"text-[#7fd88f]"},y(" .perform_later(webhook.id,")]},{no:"26",toks:[{t:"+ ",c:"text-[#7fd88f]"},y(" lock: webhook.lock_token)")]}]}];function sa(){const[t,s]=o.useState(!1),[a,r]=o.useState(0),[n,l]=o.useState(!0),[d,c]=o.useState(!0),[h,m]=o.useState(0),[g,i]=o.useState(0),[f,p]=o.useState(0),[N,w]=o.useState(!1),[j,C]=o.useState(0),x=o.useRef(null),v=o.useRef(null),u=o.useRef([]),L=o.useRef([]),_=o.useRef([]),q=B[a],V=q.duration??9;o.useEffect(()=>{window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(s(!0),l(!1),i(B[a].code.length))},[]),o.useLayoutEffect(()=>{var M;const S=()=>{const k=u.current[a],T=v.current;if(!k||!T||!k.parentElement)return;const I=k.getBoundingClientRect(),Y=k.parentElement.getBoundingClientRect();T.style.width=`${I.width}px`,T.style.transform=`translateX(${I.left-Y.left}px)`};return S(),window.addEventListener("resize",S),(M=document.fonts)==null||M.ready.then(S).catch(()=>{}),()=>window.removeEventListener("resize",S)},[a,t]),o.useEffect(()=>{const S=x.current;if(!S)return;const M=new IntersectionObserver(([k])=>c(k.isIntersecting),{threshold:.25});return M.observe(S),()=>M.disconnect()},[]),o.useEffect(()=>{if(a===f)return;w(!0);const S=setTimeout(()=>{p(a),w(!1)},200);return()=>clearTimeout(S)},[a,f]),o.useEffect(()=>{if(t||(_.current.forEach(clearTimeout),_.current=[],!n||!d))return;const S=L.current[a],M=S?Array.from(S.querySelectorAll("[data-text]")):[];M.forEach(T=>T.textContent=""),i(0),C(T=>T+1);let k=300;return M.forEach(T=>{const I=T.dataset.text??"";for(let Y=1;Y<=I.length;Y++)k+=14,_.current.push(setTimeout(()=>T.textContent=I.slice(0,Y),k));k+=350}),B[a].code.forEach((T,I)=>{k+=320,_.current.push(setTimeout(()=>i(I+1),k))}),_.current.push(setTimeout(()=>r(T=>(T+1)%B.length),(B[a].duration??9)*1e3)),()=>{_.current.forEach(clearTimeout),_.current=[]}},[a,n,d,h,t]);const le=()=>{l(S=>{const M=!S;return M&&m(k=>k+1),M})},qe=S=>t?B[S].code.length:S===a?g:0;return e.jsxs("div",{ref:x,className:"relative",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-1/2 top-1/2 h-[70%] w-[85%] -translate-x-1/2 -translate-y-1/2 rounded-full bg-flame/10 blur-3xl"}),e.jsxs("div",{role:"tablist","aria-label":"LevelCode capabilities",className:"relative mx-auto mb-6 flex w-max max-w-full gap-1 overflow-x-auto rounded-full border border-rule bg-card p-1.5 [scrollbar-width:none]",children:[e.jsx("span",{ref:v,"aria-hidden":!0,className:"absolute left-0 top-1.5 h-[calc(100%-12px)] rounded-full bg-flame shadow-[0_0_18px_rgb(var(--accent-rgb)/0.45)] transition-[transform,width] duration-300 ease-out"}),B.map((S,M)=>e.jsx("button",{ref:k=>{u.current[M]=k},role:"tab",id:`sc-tab-${S.id}`,"aria-selected":M===a,"aria-controls":`sc-pane-${S.id}`,onClick:()=>{M===a?m(k=>k+1):r(M)},onKeyDown:k=>{var T,I;k.key==="ArrowRight"&&((T=u.current[(M+1)%B.length])==null||T.focus()),k.key==="ArrowLeft"&&((I=u.current[(M-1+B.length)%B.length])==null||I.focus())},className:`relative z-10 whitespace-nowrap rounded-full px-5 py-2 text-sm font-semibold transition-colors ${M===a?"text-paper":"text-sub hover:text-ink"}`,children:S.label},S.id))]}),e.jsx("p",{"aria-live":"polite",className:`mx-auto mb-8 min-h-[48px] max-w-xl text-center text-[15px] leading-relaxed text-sub transition-opacity duration-200 ${N?"opacity-0":"opacity-100"}`,children:B[f].caption}),e.jsxs("div",{className:"shot-shadow relative overflow-hidden rounded-2xl border border-[#20232f] bg-[#0a0c16]",children:[e.jsxs("div",{className:"flex h-10 items-center gap-2 border-b border-[#1b1e2b] bg-[#0d1020] px-4",children:[e.jsxs("span",{className:"flex gap-1.5","aria-hidden":!0,children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#ff5f57]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#febc2e]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#28c840]"})]}),e.jsx("span",{className:"ml-2 truncate font-mono text-[12px] text-[#6b7280]",children:q.file}),e.jsx("span",{className:"ml-auto shrink-0 rounded-full border border-[#7d6bff]/40 bg-[#7d6bff]/15 px-2.5 py-0.5 font-mono text-[10.5px] text-[#c6bfff]",children:"AI session · live"})]}),e.jsxs("div",{className:"relative aspect-video bg-black/20",children:[B.map((S,M)=>e.jsx("div",{ref:k=>{L.current[M]=k},role:"tabpanel",id:`sc-pane-${S.id}`,"aria-labelledby":`sc-tab-${S.id}`,className:`absolute inset-0 transition-opacity duration-300 ${M===a?"opacity-100":"pointer-events-none opacity-0"}`,children:e.jsxs("div",{className:"grid h-full grid-cols-1 md:grid-cols-[minmax(200px,300px)_1fr]",children:[e.jsx("div",{className:"hidden flex-col gap-4 border-r border-[#1b1e2b] bg-black/15 p-5 font-mono text-[12.5px] leading-relaxed md:flex",children:S.chat.map((k,T)=>e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[10px] uppercase tracking-[0.14em] text-[#a99bff]",children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-[#7d6bff] shadow-[0_0_8px_rgba(125,107,255,0.9)]"}),k.who==="you"?"You":"LevelCode"]}),e.jsx("div",{"data-text":k.text,className:k.who==="you"?"text-[#c7cbe0]":"text-[#8b93ad]",children:t?k.text:""})]},T))}),e.jsx("div",{className:"overflow-hidden whitespace-pre p-5 font-mono text-[12px] leading-[1.9] text-[#c7cbe0] md:text-[13px]",children:S.code.slice(0,qe(M)).map((k,T)=>e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-[2.6em] select-none text-[#3b4157]",children:k.no}),k.toks.map((I,Y)=>e.jsx("span",{className:I.c??"text-[#c7cbe0]",children:I.t},Y)),T===qe(M)-1&&!t&&e.jsx("span",{className:"ml-px inline-block h-[1.05em] w-[2px] -translate-y-[1px] animate-caret bg-[#7d6bff] align-middle"})]},T))})]})},S.id)),!t&&e.jsx("button",{type:"button",onClick:le,"aria-label":n?"Pause showcase":"Play showcase",className:"absolute bottom-4 right-4 z-10 grid h-10 w-10 place-items-center rounded-full border border-white/20 bg-black/50 text-white backdrop-blur transition-colors hover:bg-[#7d6bff]/30",children:n?e.jsxs("svg",{viewBox:"0 0 16 16",className:"h-4 w-4 fill-current","aria-hidden":!0,children:[e.jsx("rect",{x:"3",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"9",y:"2",width:"4",height:"12",rx:"1"})]}):e.jsx("svg",{viewBox:"0 0 16 16",className:"h-4 w-4 fill-current","aria-hidden":!0,children:e.jsx("path",{d:"M4 2.5v11a1 1 0 0 0 1.53.85l9-5.5a1 1 0 0 0 0-1.7l-9-5.5A1 1 0 0 0 4 2.5z"})})}),e.jsx("div",{"aria-hidden":!0,className:"absolute inset-x-0 bottom-0 h-[3px]",children:e.jsx("i",{className:"block h-full w-0 bg-[#7d6bff] shadow-[0_0_10px_rgba(125,107,255,0.8)]",style:n&&d&&!t?{animation:`scfill ${V}s linear forwards`}:void 0},j)})]})]})]})}const aa={amber:"#e2a43c",blue:"#57a2e8",green:"#7cb85c"},ra={name:"Design a Key-Value Store",goal:"Build and test a distributed, highly-available key-value store — implement it in C.",reference:"https://bytebytego.com/courses/system-design-interview/design-a-key-value-store",w:1740,h:700,nodes:[{id:"req",label:"requirements",tier:"powerful",color:"amber",x:20,y:300},{id:"arch",label:"architecture",tier:"powerful",color:"amber",x:320,y:300},{id:"storage",label:"storage-engine",tier:"balanced",color:"amber",x:620,y:130},{id:"hash",label:"consistent-hash",tier:"balanced",color:"blue",x:620,y:245},{id:"repl",label:"replication+quorum",tier:"balanced",color:"amber",x:620,y:360},{id:"vclock",label:"vector-clocks",tier:"balanced",color:"amber",x:620,y:475},{id:"gossip",label:"gossip+failover",tier:"balanced",color:"blue",x:620,y:590},{id:"integrate",label:"integrate+server",tier:"balanced",color:"blue",x:920,y:300},{id:"tests",label:"tests",tier:"balanced",color:"green",x:1220,y:240},{id:"build",label:"build+validate",tier:"balanced",color:"green",x:1220,y:360},{id:"review",label:"review+run-guide",tier:"balanced",color:"amber",x:1520,y:300}],edges:[{from:"req",to:"arch"},{from:"arch",to:"storage"},{from:"arch",to:"hash"},{from:"arch",to:"repl"},{from:"arch",to:"vclock"},{from:"arch",to:"gossip"},{from:"storage",to:"integrate"},{from:"hash",to:"integrate"},{from:"repl",to:"integrate"},{from:"vclock",to:"integrate"},{from:"gossip",to:"integrate"},{from:"integrate",to:"tests"},{from:"integrate",to:"build"},{from:"tests",to:"review"},{from:"build",to:"review"}]},na={name:"Real-time Gaming Leaderboard",goal:"Design and test a real-time gaming leaderboard — top 10 by score, a user's rank, and ±4 neighbours around them.",reference:"https://bytebytego.com/courses/system-design-interview/real-time-gaming-leaderboard",w:1740,h:640,nodes:[{id:"arch",label:"architecture",tier:"powerful",color:"amber",x:20,y:300},{id:"api",label:"public-api",tier:"balanced",color:"blue",x:320,y:130},{id:"gateway",label:"api-gateway",tier:"balanced",color:"blue",x:320,y:300},{id:"game",label:"game-service",tier:"balanced",color:"blue",x:320,y:470},{id:"relational",label:"relational-baseline",tier:"balanced",color:"amber",x:620,y:130},{id:"redis",label:"redis-sorted-set",tier:"balanced",color:"amber",x:620,y:300},{id:"nosql",label:"nosql-dynamodb",tier:"balanced",color:"amber",x:620,y:470},{id:"persist",label:"persistence-mysql",tier:"balanced",color:"amber",x:920,y:130},{id:"shard",label:"sharding",tier:"balanced",color:"blue",x:920,y:300},{id:"cache",label:"rank-cache",tier:"balanced",color:"amber",x:920,y:470},{id:"service",label:"leaderboard-service",tier:"balanced",color:"blue",x:1220,y:300},{id:"tests",label:"tests",tier:"balanced",color:"green",x:1520,y:300}],edges:[{from:"arch",to:"api"},{from:"arch",to:"gateway"},{from:"arch",to:"game"},{from:"api",to:"relational"},{from:"api",to:"redis"},{from:"gateway",to:"redis"},{from:"game",to:"redis"},{from:"relational",to:"redis"},{from:"redis",to:"persist"},{from:"redis",to:"nosql"},{from:"redis",to:"shard"},{from:"shard",to:"cache"},{from:"persist",to:"service"},{from:"cache",to:"service"},{from:"nosql",to:"service"},{from:"service",to:"tests"}]},ce=[ra,na],la={"Design a Key-Value Store":"KV","Real-time Gaming Leaderboard":"LB"},oa=200,ee=44;function ia({preload:t=!1}){const[s,a]=o.useState(()=>t?ce[0]:null),[r,n]=o.useState(()=>t?ce[0].goal:""),[l,d]=o.useState(!1),[c,h]=o.useState(!1),[m,g]=o.useState(new Set),i=o.useRef(null),f=o.useRef(null),p=o.useRef([]),N=o.useCallback(x=>{a(x),n(x.goal),g(new Set)},[]),w=o.useCallback(()=>{s&&(p.current.forEach(clearTimeout),p.current=[],g(new Set),s.nodes.forEach((x,v)=>{const u=setTimeout(()=>{g(_=>new Set(_).add(x.id))},v*900),L=setTimeout(()=>{g(_=>{const q=new Set(_);return q.delete(x.id),q})},v*900+1600);p.current.push(u,L)}))},[s]);o.useEffect(()=>()=>p.current.forEach(clearTimeout),[]),o.useEffect(()=>{const x=f.current;!x||!s||(x.scrollLeft=0,x.scrollTop=Math.max(0,s.nodes[0].y+ee-x.clientHeight/2))},[s]);const j=x=>{x.preventDefault(),h(!1),d(!1);const v=x.dataTransfer.getData("text/levelcode-sketch"),u=ce.find(L=>L.name===v);u&&N(u)},C=x=>s==null?void 0:s.nodes.find(v=>v.id===x);return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[260px_1fr]",children:[e.jsxs("div",{className:"surface p-4",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.24em] text-flame",children:"template palette"}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-sub",children:"Drag a card onto the canvas to lay down a fully-configured agent topology."}),e.jsx("div",{className:"mt-4 space-y-3",children:ce.map(x=>e.jsxs("button",{type:"button",draggable:!0,onDragStart:v=>{v.dataTransfer.setData("text/levelcode-sketch",x.name),v.dataTransfer.effectAllowed="copy",d(!0)},onDragEnd:()=>d(!1),onClick:()=>N(x),className:"group w-full cursor-grab rounded-md border border-rule bg-paper p-3 text-left transition-colors hover:border-flame/60 active:cursor-grabbing",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"grid h-7 w-7 place-items-center rounded border border-flame/30 bg-flame/10 font-mono text-[13px] text-flame",children:la[x.name]??"◆"}),e.jsx("span",{className:"font-display text-[13.5px] font-semibold leading-tight text-ink",children:x.name})]}),e.jsxs("p",{className:"mt-2 font-mono text-[10px] uppercase tracking-[0.14em] text-faint",children:[x.nodes.length," agents · ",x.edges.length," links · bytebytego"]}),e.jsx("span",{className:"mt-2 inline-block font-mono text-[10px] text-flame/70 group-hover:text-flame",children:"⠿ drag onto canvas →"})]},x.name))})]}),e.jsxs("div",{ref:i,onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy",h(!0)},onDragLeave:()=>h(!1),onDrop:j,className:`relative min-h-[440px] overflow-hidden rounded-xl border bg-[#f2f0ea] transition-colors ${c?"border-flame/70":"border-rule"}`,children:[e.jsx("div",{"aria-hidden":!0,className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle, rgba(27,26,23,0.13) 1px, transparent 1.4px)",backgroundSize:"22px 22px"}}),s&&e.jsxs("div",{className:"relative z-10 flex items-center gap-2 border-b border-rule bg-card/80 px-3 py-2 backdrop-blur-sm",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-flame",children:"goal"}),e.jsx("input",{value:r,onChange:x=>n(x.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[12.5px] text-ink outline-none placeholder:text-faint",placeholder:"Describe what to build…"}),e.jsx("button",{type:"button",onClick:w,className:"shrink-0 rounded bg-flame px-3 py-1 font-mono text-[11px] font-semibold text-paper transition-colors hover:bg-flamedeep",children:"▶ Run"})]}),!s&&e.jsx("div",{className:"relative z-10 grid h-full min-h-[440px] place-items-center px-6 text-center",children:e.jsxs("div",{children:[e.jsx("div",{className:`mx-auto mb-4 grid h-14 w-14 place-items-center rounded-lg border-2 border-dashed transition-colors ${l||c?"border-flame text-flame":"border-faint/50 text-faint"}`,children:"⠿"}),e.jsx("p",{className:"font-display text-[15px] font-semibold text-ink",children:"Drop a template here"}),e.jsx("p",{className:"mx-auto mt-1.5 max-w-xs text-[12.5px] leading-relaxed text-sub",children:"Drag a template card in — or just click it — to materialise the full topology."})]})}),s&&e.jsx("div",{ref:f,className:"relative z-10 max-h-[420px] w-full overflow-auto p-3 md:max-h-none",children:e.jsxs("div",{className:"relative",style:{width:s.w,height:s.h},children:[e.jsx("svg",{className:"pointer-events-none absolute inset-0 h-full w-full",viewBox:`0 0 ${s.w} ${s.h}`,children:s.edges.map((x,v)=>{const u=C(x.from),L=C(x.to);if(!u||!L)return null;const _=u.x+oa,q=u.y+ee,V=L.x,le=L.y+ee;return e.jsx("path",{d:`M${_},${q} C ${_+70},${q} ${V-70},${le} ${V},${le}`,fill:"none",stroke:"#b9b4a8",strokeWidth:1.5},v)})}),s.nodes.map(x=>{const v=aa[x.color],u=m.has(x.id);return e.jsxs("div",{className:`sb-node absolute w-[200px] rounded-lg border bg-white p-3 shadow-[0_2px_10px_rgba(27,26,23,0.08)] ${u?"sb-node--running":""}`,style:{left:x.x,top:x.y,borderColor:u?"transparent":"#e2ddd2"},children:[u&&e.jsx("svg",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full overflow-visible",children:e.jsx("rect",{className:"sb-ants",x:"0.75",y:"0.75",rx:"8",fill:"none",stroke:"#65a34a",strokeWidth:"1.5",strokeDasharray:"6 6",style:{width:"calc(100% - 1.5px)",height:"calc(100% - 1.5px)"}})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 shrink-0 rounded-[3px] ${u?"sb-pulse":""}`,style:{background:u?"#65a34a":v}}),e.jsx("span",{className:"truncate text-[13px] font-semibold text-[#2a2822]",children:x.label}),u?e.jsx("span",{className:"ml-auto shrink-0 font-mono text-[9px] uppercase tracking-[0.14em] text-[#65a34a]",children:"running"}):e.jsx("span",{"aria-hidden":!0,className:"ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-[#3f3c34]/50"})]}),e.jsxs("p",{className:"mt-1 text-[11px] text-[#8a8578]",children:["tier: ",x.tier]}),e.jsx("span",{"aria-hidden":!0,className:"absolute -left-[5px] h-2.5 w-2.5 rounded-full border-2 border-[#8a8578] bg-white",style:{top:ee-5}}),e.jsx("span",{"aria-hidden":!0,className:"absolute -right-[5px] h-2.5 w-2.5 rounded-full border-2 border-[#8a8578] bg-white",style:{top:ee-5}})]},x.id)})]})}),s&&e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute bottom-3 right-3 z-10 flex items-center gap-1.5 font-mono text-[11px] text-sub",children:["−","99%","+","⤢","⇄ Tidy"].map(x=>e.jsx("span",{className:"rounded-md border border-[#e2ddd2] bg-white px-2 py-1 shadow-sm",children:x},x))})]})]})}const yt=`${F}/releases/latest`,Nt=`${yt}/download/LevelCode-arm64.dmg`,Xe=`${yt}/download/LevelCode-x64.dmg`,Je="1.2.0";function ca(){const[t,s]=o.useState(()=>{try{return sessionStorage.getItem("lc-latest-version")||Je}catch{return Je}});return o.useEffect(()=>{try{if(sessionStorage.getItem("lc-latest-version"))return}catch{}let a=!0;return fetch("https://api.github.com/repos/levelcodeai/levelcode/releases/latest",{headers:{Accept:"application/vnd.github+json"}}).then(r=>r.ok?r.json():null).then(r=>{const n=String((r==null?void 0:r.tag_name)??"").replace(/^v/,"");if(a&&n){s(n);try{sessionStorage.setItem("lc-latest-version",n)}catch{}}}).catch(()=>{}),()=>{a=!1}},[]),t}function da(){const[t,s]=o.useState(null);return o.useEffect(()=>{let a=!0;return $("/api/levelcode/v1/pricing").then(r=>{const n=(r.tiers??[]).filter(c=>c.price_cents>0);if(!a||n.length===0)return;const l=n.reduce((c,h)=>h.price_cents{}),()=>{a=!1}},[]),t}function Qe(){const t=ca(),s=da(),{profile:a}=U(),[r]=o.useState(jt),n=`${F}/releases/tag/v${t}`;return e.jsxs(D,{children:[e.jsx("section",{className:"lp-hero",children:e.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col items-center px-5 pb-14 pt-16 text-center sm:pb-16 sm:pt-24",children:[e.jsx(et,{id:"lp-icon-hero",size:88}),e.jsx("h1",{className:"lp-h1 mt-8 text-balance",children:"The AI code editor that keeps you in control"}),e.jsx("p",{className:"lp-lead mt-5 max-w-2xl text-balance",children:"LevelCode plans, edits, and verifies work across your codebase. You review every change, and commands wait for your approval."}),e.jsx("div",{className:"mt-9",children:e.jsx(Ce,{isMac:r,profile:a})}),r?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-5 text-[15px] text-[var(--c-text2)]",children:"Free and open source. No account required."}),e.jsxs("p",{className:"mt-1.5 text-[13px] text-[var(--c-text3)]",children:["Version ",t," ·"," ",e.jsx("a",{href:n,className:"lp-link",children:"Release notes"})," ","· Intel Mac?"," ",e.jsx("a",{href:Xe,className:"lp-link",download:!0,children:"Download the x64 build"})]})]}):e.jsxs("p",{className:"mt-5 max-w-md text-[15px] text-[var(--c-text2)] pretty",children:["LevelCode is a desktop app for macOS. Open this page on your Mac to download it, or see"," ",e.jsx("a",{href:`${F}/releases`,className:"lp-link",children:"all builds"}),"."]})]})}),e.jsx("section",{"aria-label":"Why LevelCode is safe to adopt",children:e.jsx("ul",{className:"mx-auto grid max-w-5xl grid-cols-2 gap-x-6 gap-y-8 px-5 pb-16 md:grid-cols-4",children:ma.map(l=>e.jsxs("li",{className:"flex flex-col items-center text-center",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:l.icon}),e.jsx("span",{className:"mt-2.5 text-[15px] font-semibold text-[var(--c-text)]",children:l.title}),e.jsx("span",{className:"mt-0.5 text-[13px] text-[var(--c-text3)]",children:l.detail})]},l.title))})}),e.jsx("section",{id:"agent",className:"scroll-mt-14",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 pb-24",children:[e.jsx("h2",{className:"sr-only",children:"LevelCode at work"}),e.jsx(sa,{})]})}),e.jsx("section",{id:"get-started",className:"scroll-mt-14 border-y border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Get started"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"LevelCode is free to use with your own API key. Add a plan when you want managed models."})]}),e.jsxs("div",{className:"mx-auto mt-12 grid max-w-4xl gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"lp-card flex flex-col p-7",children:[e.jsx("h3",{className:"text-[22px] font-semibold text-[var(--c-text)]",children:"Free"}),e.jsx("p",{className:"mt-1.5 text-[16px] pretty",children:"The complete editor, with your own API key or a local model."}),e.jsx("p",{className:"mt-7 flex h-12 items-end gap-2",children:e.jsx("span",{className:"text-[40px] font-semibold leading-none tracking-tight text-[var(--c-text)]",children:"$0"})}),e.jsx("div",{className:"mt-6 flex flex-1 items-end",children:r?e.jsx(Ce,{isMac:!0,profile:a,fullWidth:!0}):e.jsx(b,{to:"/docs/quickstart",className:"lp-cta lp-cta--quiet w-full",children:"Read the quickstart"})})]}),e.jsxs("div",{className:"lp-card flex flex-col p-7",children:[e.jsx("h3",{className:"text-[22px] font-semibold text-[var(--c-text)]",children:"LevelCode Cloud"}),e.jsx("p",{className:"mt-1.5 text-[16px] pretty",children:"Managed models with no key to set up, and the cost of every run shown in the editor."}),s?e.jsxs("p",{className:"mt-7 flex h-12 items-end gap-2",children:[e.jsx("span",{className:"pb-1 text-[15px] text-[var(--c-text3)]",children:"From"}),e.jsx("span",{className:"text-[40px] font-semibold leading-none tracking-tight text-[var(--c-text)]",children:s.amount}),e.jsxs("span",{className:"pb-1 text-[15px] text-[var(--c-text3)]",children:["/ ",s.interval]})]}):null,e.jsx("div",{className:"mt-6 flex flex-1 items-end",children:e.jsx(b,{to:"/pricing",className:"lp-cta lp-cta--quiet w-full",children:"View plans"})})]})]}),e.jsx("p",{className:"mt-8 text-center text-[14px] text-[var(--c-text3)]",children:"Every plan includes the full editor. Plans meter managed AI usage only."})]})}),e.jsxs("section",{id:"features",className:"scroll-mt-14",children:[e.jsxs("div",{className:"mx-auto max-w-6xl px-5 pb-10 pt-24 sm:pt-28",children:[e.jsx("h2",{className:"lp-h2 text-center text-balance",children:"An agent that shows its work"}),e.jsxs("div",{className:"mt-16 space-y-24 sm:mt-20 sm:space-y-28",children:[e.jsx(Se,{title:"From goal to verified change",body:"Describe the outcome you want. LevelCode plans the steps, edits across files, and runs the commands it needs. Before it reports back, it checks its changes against your type checker and linter, and runs the verify command you set.",visual:e.jsx(xa,{})}),e.jsx(Se,{flip:!0,title:"You decide what lands",body:"Every edit is tracked file by file, with Keep and Undo. Commands wait for your approval before they run, and each message is a checkpoint you can restore.",visual:e.jsx(ua,{})})]})]}),e.jsxs("div",{id:"sketches",className:"mx-auto max-w-6xl scroll-mt-14 px-5 py-14 sm:py-16",children:[e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"lp-h3",children:"Coordinate a team of agents"}),e.jsx("p",{className:"lp-body mt-4 pretty",children:"Sketch a workflow on a canvas: place specialized agents, connect them, and run. Independent steps run in parallel, and each one reports its token usage and estimated cost."})]}),e.jsx("div",{className:"classic-demo-sketch mt-10",children:e.jsx(ia,{preload:!0})})]}),e.jsx("div",{className:"mx-auto max-w-6xl px-5 pb-24 pt-10 sm:pb-28",children:e.jsx(Se,{title:"Use the models you choose",body:"Bring your own API key for Anthropic, OpenAI, OpenRouter, and other providers, or run local models with Ollama for chat, edits, and autocomplete. Prefer a single bill? LevelCode Cloud adds managed models on a monthly plan.",visual:e.jsx(ha,{})})})]}),e.jsx("section",{className:"border-y border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Works with the tools you already use"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"Keep your extensions, your settings, and your workflow."})]}),e.jsx("div",{className:"mt-12 grid gap-6 md:grid-cols-3",children:pa.map(l=>e.jsxs("div",{className:"lp-card p-6",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:l.icon}),e.jsx("h3",{className:"mt-4 text-[18px] font-semibold text-[var(--c-text)]",children:l.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:l.body})]},l.title))}),e.jsx("p",{className:"mt-10 text-center",children:e.jsx(b,{to:"/docs",className:"lp-link text-[16px] font-medium",children:"Read the documentation →"})})]})}),e.jsx("section",{children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"A complete editor underneath"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"LevelCode is built on Code-OSS, the open-source project behind VS Code. The editing experience, keybindings, and extension model are the ones you already know."})]}),e.jsx("div",{className:"mt-14 grid gap-x-10 gap-y-10 sm:grid-cols-2 lg:grid-cols-3",children:fa.map(l=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:l.icon}),e.jsx("h3",{className:"mt-3 text-[17px] font-semibold text-[var(--c-text)]",children:l.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:l.body})]},l.title))})]})}),e.jsx("section",{id:"security",className:"scroll-mt-14 border-y border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Security you can verify"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"LevelCode is designed so you can see what it does and decide what it is allowed to do."})]}),e.jsx("div",{className:"mt-12 grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:ga.map(l=>e.jsxs("div",{className:"lp-card p-6",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:l.icon}),e.jsx("h3",{className:"mt-4 text-[18px] font-semibold text-[var(--c-text)]",children:l.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:l.body})]},l.title))}),e.jsxs("div",{className:"mt-10 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("a",{href:F,className:"lp-cta lp-cta--quiet",children:[e.jsx(ba,{}),"View the source on GitHub"]}),e.jsx(b,{to:"/privacy",className:"lp-cta lp-cta--quiet",children:"Read the privacy policy"})]})]})}),e.jsx("section",{id:"download",className:"lp-hero lp-hero--closing scroll-mt-14",children:e.jsxs("div",{className:"mx-auto flex max-w-3xl flex-col items-center px-5 py-24 text-center sm:py-28",children:[e.jsx(et,{id:"lp-icon-closing",size:64,decorative:!0}),e.jsx("h2",{className:"lp-h2 mt-6 text-balance",children:"Start building with LevelCode"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"Free and open source. No account required."}),r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("a",{href:Nt,className:"lp-cta",download:!0,children:[e.jsx(Ie,{}),"Download for Apple Silicon"]}),e.jsxs("a",{href:Xe,className:"lp-cta lp-cta--quiet",download:!0,children:[e.jsx(Ie,{}),"Download for Intel"]})]}),e.jsxs("p",{className:"mt-5 text-[13px] text-[var(--c-text3)]",children:["Version ",t," ·"," ",e.jsx("a",{href:n,className:"lp-link",children:"Release notes"})," ","·"," ",e.jsx("a",{href:`${F}/releases`,className:"lp-link",children:"All releases"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-9",children:e.jsx(Ce,{isMac:r,profile:a})}),e.jsxs("p",{className:"mt-5 max-w-md text-[14px] text-[var(--c-text3)] pretty",children:["LevelCode runs on Apple Silicon and Intel Macs. Open this page on your Mac to download it, or see"," ",e.jsx("a",{href:`${F}/releases`,className:"lp-link",children:"all releases"}),"."]})]}),e.jsx("p",{className:"mt-12 max-w-xl text-[12px] text-[var(--c-text2)] pretty",children:"LevelCode is an independent project. It is not produced by, endorsed by, or affiliated with Microsoft."})]})})]})}function Ce({isMac:t,profile:s,fullWidth:a=!1}){const r=`lp-cta${a?" w-full":""}`;return t?e.jsxs("a",{href:Nt,className:r,download:!0,children:[e.jsx(Ie,{}),"Download for macOS"]}):e.jsx(b,{to:s?"/account":"/login",className:r,children:s?"Your account":"Sign in"})}function Se({title:t,body:s,visual:a,flip:r=!1}){return e.jsxs("div",{className:"grid items-center gap-10 md:grid-cols-12 md:gap-12 lg:gap-16",children:[e.jsxs("div",{className:`md:col-span-5 lg:col-span-4 ${r?"md:order-2":""}`,children:[e.jsx("h3",{className:"lp-h3 text-balance",children:t}),e.jsx("p",{className:"lp-body mt-4 pretty",children:s})]}),e.jsx("div",{className:`md:col-span-7 lg:col-span-8 ${r?"md:order-1":""}`,children:a})]})}function xa(){return e.jsx("div",{className:"lp-stage",role:"img","aria-label":"LevelCode working through a task: it reads the relevant files, edits three of them, runs the tests, and verifies the result before reporting back.",children:e.jsxs("div",{className:"lp-pane w-full max-w-[460px] p-5","aria-hidden":!0,children:[e.jsx("p",{className:"lp-bubble",children:"Add rate limiting to the public API routes, then run the tests."}),e.jsxs("ul",{className:"mt-5 space-y-2.5 text-[14px] text-[var(--c-text)]",children:[e.jsx(de,{children:"Read 6 files, searched the workspace"}),e.jsxs(de,{children:["Edited 3 files ",e.jsx(Oe,{add:84,del:21})]}),e.jsxs(de,{children:["Ran ",e.jsx("code",{className:"lp-code",children:"npm test"})]}),e.jsx(de,{children:"Verified the edits"})]}),e.jsx("p",{className:"mt-5 border-t border-[var(--c-line)] pt-4 text-[13.5px] leading-relaxed text-[var(--c-text2)]",children:"Rate limiting is in place on every public route. The tests pass, and the change introduced no new type or lint problems."})]})})}function ua(){return e.jsx("div",{className:"lp-stage",role:"img","aria-label":"A command waiting for approval with Run and Skip buttons, above a list of three changed files with Keep and Undo for each.",children:e.jsxs("div",{className:"flex w-full max-w-[480px] flex-col gap-4","aria-hidden":!0,children:[e.jsxs("div",{className:"lp-pane p-5",children:[e.jsx("p",{className:"text-[15px] font-semibold text-[var(--c-text)]",children:"Run this command?"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-[var(--c-text3)]",children:"LevelCode wants to run this in your terminal."}),e.jsx("p",{className:"lp-well mt-3",children:"npm test"}),e.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[e.jsxs("span",{className:"lp-btn",children:["Skip ",e.jsx("kbd",{children:"esc"})]}),e.jsxs("span",{className:"lp-btn lp-btn--primary",children:["Run ",e.jsx("kbd",{children:"⏎"})]})]})]}),e.jsxs("div",{className:"lp-pane p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx("span",{className:"text-[15px] font-semibold text-[var(--c-text)]",children:"3 files changed"}),e.jsx(Oe,{add:84,del:21}),e.jsxs("span",{className:"ml-auto flex gap-2",children:[e.jsx("span",{className:"lp-btn",children:"Undo all"}),e.jsx("span",{className:"lp-btn lp-btn--primary",children:"Keep all"})]})]}),e.jsxs("ul",{className:"mt-3 divide-y divide-[var(--c-line)] border-t border-[var(--c-line)]",children:[e.jsx(Le,{name:"routes/api.ts",add:41,del:9}),e.jsx(Le,{name:"middleware/rateLimit.ts",add:38,del:0}),e.jsx(Le,{name:"routes/api.test.ts",add:5,del:12})]})]})]})})}function ha(){return e.jsx("div",{className:"lp-stage",role:"img","aria-label":"The model picker, grouped three ways: your own API key with a provider such as Anthropic, OpenAI, OpenRouter or Mistral; a local model with Ollama; or managed models on LevelCode Cloud.",children:e.jsxs("div",{className:"lp-pane w-full max-w-[440px] p-5","aria-hidden":!0,children:[e.jsx("p",{className:"text-[15px] font-semibold text-[var(--c-text)]",children:"Select model"}),e.jsx("p",{className:"lp-group mt-4",children:"Your API key"}),e.jsxs("ul",{className:"mt-1.5 space-y-1",children:[e.jsx(z,{name:"Anthropic",note:"Direct",selected:!0}),e.jsx(z,{name:"OpenAI",note:"Direct"}),e.jsx(z,{name:"OpenRouter",note:"Direct"}),e.jsx(z,{name:"Mistral",note:"Direct"})]}),e.jsx("p",{className:"lp-group mt-4",children:"On this Mac"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:e.jsx(z,{name:"Ollama",note:"Local"})}),e.jsx("p",{className:"lp-group mt-4",children:"LevelCode Cloud"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:e.jsx(z,{name:"Managed models",note:"Included in a plan"})})]})})}function de({children:t}){return e.jsxs("li",{className:"flex items-center gap-2.5",children:[e.jsxs("svg",{viewBox:"0 0 16 16",width:"16",height:"16",className:"shrink-0 text-[var(--lp-add)]","aria-hidden":!0,children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.35",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("path",{d:"M5.05 8.25 7 10.2l4.15-4.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("span",{className:"flex flex-wrap items-center gap-x-2",children:t})]})}function Oe({add:t,del:s}){return e.jsxs("span",{className:"font-mono text-[12.5px] tabular-nums",children:[e.jsxs("span",{className:"text-[var(--lp-add)]",children:["+",t]})," ",e.jsxs("span",{className:"text-[var(--lp-del)]",children:["−",s]})]})}function Le({name:t,add:s,del:a}){return e.jsxs("li",{className:"flex items-center gap-3 py-2.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12.5px] text-[var(--c-text)]",children:t}),e.jsx(Oe,{add:s,del:a}),e.jsxs("span",{className:"hidden gap-1.5 sm:flex",children:[e.jsx("span",{className:"lp-btn lp-btn--sm",children:"Undo"}),e.jsx("span",{className:"lp-btn lp-btn--sm lp-btn--primary",children:"Keep"})]})]})}function z({name:t,note:s,selected:a=!1}){return e.jsxs("li",{className:`lp-row ${a?"lp-row--on":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:`lp-radio ${a?"lp-radio--on":""}`}),e.jsx("span",{className:"text-[14px] text-[var(--c-text)]",children:t}),e.jsx("span",{className:"ml-auto text-[12.5px] text-[var(--c-text3)]",children:s})]})}const ma=[{title:"Open source",detail:"MIT licensed",icon:e.jsx(E,{d:"M9 5 3 12l6 7m6-14 6 7-6 7"})},{title:"Built on Code-OSS",detail:"The open-source core of VS Code",icon:e.jsx(E,{d:"m12 3 9 5-9 5-9-5 9-5Zm-9 9 9 5 9-5M3 16l9 5 9-5"})},{title:"Notarized by Apple",detail:"Signed with a Developer ID",icon:e.jsx(E,{d:"M12 3 4.5 6v5.5c0 4.6 3.1 8.2 7.5 9.5 4.4-1.3 7.5-4.9 7.5-9.5V6L12 3Zm-3.2 9 2.3 2.3 4.1-4.6"})},{title:"Private by default",detail:"No telemetry",icon:e.jsx(E,{d:"M7 11V8a5 5 0 0 1 10 0v3M6 11h12v9H6v-9Zm6 3.5v2"})}],pa=[{title:"Extensions",body:"Install language support, themes, and tools from Open VSX, the open extension registry, without leaving the editor.",icon:e.jsx(E,{d:"M12 3 4 7v10l8 4 8-4V7l-8-4Zm0 0v8m8-4-8 4M4 7l8 4"})},{title:"MCP servers",body:"Give the agent new tools through the Model Context Protocol. Every tool call asks before it runs, unless you choose to allow it.",icon:e.jsx(E,{d:"M9 3v5m6-5v5M6 8h12v3a6 6 0 0 1-12 0V8Zm6 9v4"})},{title:"Import from VS Code",body:"Bring your settings, keybindings, and snippets from VS Code, VSCodium, or Cursor in one step. Your existing files are backed up first.",icon:e.jsx(E,{d:"M12 3v12m0 0-4-4m4 4 4-4M4 20h16"})}],fa=[{title:"Chat",body:"Ask questions about your codebase and get answers grounded in your files. Chat never edits them.",icon:e.jsx(E,{d:"M4 5h16v11H9l-5 4V5Z"})},{title:"Inline edits",body:"Select code, describe the change, and review it as a diff before anything lands.",icon:e.jsx(E,{d:"M4 20h4L19 9l-4-4L4 16v4Zm9.5-13.5 4 4"})},{title:"Autocomplete",body:"Suggestions appear as you type. Press Tab to accept one, or keep typing to dismiss it.",icon:e.jsx(E,{d:"M12 3a6 6 0 0 1 3.5 10.9c-.6.45-1 1.1-1 1.85V17h-5v-1.25c0-.75-.4-1.4-1-1.85A6 6 0 0 1 12 3ZM10 20h4"})},{title:"Power editing",body:"Keystroke macros, column editing, line operations, encoding control, and a mode for very large files.",icon:e.jsx(E,{d:"M4 5h16M4 9h10M4 13h16M4 17h7"})},{title:"Familiar keys and themes",body:"Keymap presets for Atom and Notepad++, with One Dark and One Light built in.",icon:e.jsx(E,{d:"M3 7h18v10H3V7Zm4 3.5h.01M11 10.5h.01M15 10.5h.01M7.5 14h9"})},{title:"Yours to extend",body:"Add your own commands with a startup script, or build a package and see changes as you save.",icon:e.jsx(E,{d:"M4 5h16v14H4V5Zm3.5 4.5 3 2.5-3 2.5M13 15h3.5"})}],ga=[{title:"Open source",body:"LevelCode is MIT licensed and built on Code-OSS, the open-source project behind VS Code. The full source is on GitHub for you or your security team to review.",icon:e.jsx(E,{d:"M9 5 3 12l6 7m6-14 6 7-6 7"})},{title:"Signed and notarized",body:"Releases are signed with an Apple Developer ID and notarized by Apple, so macOS verifies the app before it opens.",icon:e.jsx(E,{d:"M12 3 4.5 6v5.5c0 4.6 3.1 8.2 7.5 9.5 4.4-1.3 7.5-4.9 7.5-9.5V6L12 3Zm-3.2 9 2.3 2.3 4.1-4.6"})},{title:"Your keys stay on your Mac",body:"API keys are stored in the macOS Keychain, never in a settings file. With your own key, requests go directly from your Mac to your provider.",icon:e.jsx(E,{d:"M8 19a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm2.8-6.8L20 3m-3.5 3.5 2.5 2.5M14 9l2 2"})},{title:"Approval before action",body:"Commands and third-party tools wait for your approval by default. A tool server defined by a repository cannot start until you approve its exact command.",icon:e.jsx(E,{d:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm-4-9 3 3 5-6"})},{title:"No telemetry",body:"Telemetry is off, and there is no setting that turns it on.",icon:e.jsx(E,{d:"M3 3l18 18M10.6 6.1A9.6 9.6 0 0 1 12 6c5 0 8.5 4.5 9 6-.3.9-1.2 2.3-2.7 3.6M6.3 7.8C4.4 9.1 3.3 10.9 3 12c.5 1.5 4 6 9 6 1.3 0 2.6-.3 3.7-.8M9.9 9.9a3 3 0 0 0 4.2 4.2"})},{title:"No account required",body:"Download and use the editor without signing up. An account is only needed for a LevelCode Cloud plan.",icon:e.jsx(E,{d:"M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm-7 9a7 7 0 0 1 14 0"})}];function E({d:t}){return e.jsx("svg",{viewBox:"0 0 24 24",width:"28",height:"28",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"inline-block",children:e.jsx("path",{d:t})})}function et({id:t,size:s,decorative:a=!1}){const r=a?{"aria-hidden":!0}:{role:"img","aria-label":"LevelCode"};return e.jsxs("svg",{viewBox:"0 0 120 120",width:s,height:s,className:"lp-appicon",...r,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:t,x1:"0",y1:"104",x2:"0",y2:"14",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#5b3fd6"}),e.jsx("stop",{offset:".45",stopColor:"#7d6bff"}),e.jsx("stop",{offset:".75",stopColor:"#5fb4ff"}),e.jsx("stop",{offset:"1",stopColor:"#a8ecff"})]})}),e.jsx("rect",{width:"120",height:"120",rx:"27",fill:"#0a0c16"}),e.jsxs("g",{fill:"none",stroke:`url(#${t})`,strokeWidth:"13",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M28 92 L60 69 L92 92",opacity:".55"}),e.jsx("path",{d:"M28 68 L60 45 L92 68",opacity:".8"}),e.jsx("path",{d:"M28 44 L60 21 L92 44"})]})]})}function Ie(){return e.jsx("svg",{viewBox:"0 0 814 1000",width:"15",height:"15",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M788 341c-6 4-107 61-107 187 0 146 128 198 132 199-1 3-20 70-67 138-42 60-86 120-153 120s-84-39-161-39c-75 0-102 40-163 40s-104-56-153-124C60 782 13 660 13 544c0-186 121-285 240-285 63 0 116 42 156 42 38 0 97-44 169-44 27 0 125 2 210 84zM554 172c31-37 53-88 53-139 0-7-1-14-2-20-50 2-110 34-146 76-29 32-55 83-55 135 0 8 1 16 2 18 3 1 8 2 13 2 45 0 102-30 135-72z"})})}function ba(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})})}const wt="lc_attribution",kt=["linkedin","youtube","ref","utm_source","utm_medium","utm_campaign","utm_content"],Ct=120,va=40,me=300,ja=40;function ya(t){if(!t||typeof t!="object")return null;const s=t,a={},r=s.params;if(r&&typeof r=="object")for(const d of kt){const c=r[d];typeof c=="string"&&c&&(a[d]=c.slice(0,Ct))}const n=typeof s.source=="string"?s.source.slice(0,va):"";if(Object.keys(a).length===0&&!n)return null;const l=(d,c)=>typeof d=="string"?d.slice(0,c):"";return{source:n||"other",params:a,landing:l(s.landing,me),referrer:l(s.referrer,me),ts:l(s.ts,ja)}}function St(){try{const t=localStorage.getItem(wt);return t?ya(JSON.parse(t)):null}catch{return null}}function Na(){if(!(typeof window>"u"))try{if(St())return;const t=new URLSearchParams(window.location.search),s={};for(const n of kt){const l=t.get(n);l&&(s[n]=l.slice(0,Ct))}if(Object.keys(s).length===0)return;const r={source:s.linkedin?"linkedin":s.youtube?"youtube":s.utm_source||s.ref||"other",params:s,landing:window.location.pathname.slice(0,me),referrer:(document.referrer||"").slice(0,me),ts:new Date().toISOString()};localStorage.setItem(wt,JSON.stringify(r))}catch{}}function Lt(){return typeof window>"u"?null:St()}function wa({redirectUri:t,codeChallenge:s}){const[a,r]=o.useState("email"),[n,l]=o.useState(""),[d,c]=o.useState(""),[h,m]=o.useState(!1),[g,i]=o.useState(null);async function f(N){N.preventDefault(),m(!0),i(null);try{await $("/ai/auth/email",{body:{email:n}}),r("code")}catch(w){i(w instanceof te?w.message:"Couldn't send a code. Try again.")}finally{m(!1)}}async function p(N){N.preventDefault(),m(!0),i(null);try{const w=await $("/ai/auth/verify",{body:{email:n,code:d,redirect_uri:t,code_challenge:s,attribution:Lt()}});if(!w.redirect)throw new te(422,"That code is invalid or has expired.");if(!w.redirect.startsWith("/")&&!/^https?:\/\//i.test(w.redirect)){const j=window.setTimeout(()=>{m(!1),i("Open LevelCode to finish signing in. If nothing happened, the editor may not be installed on this device.")},1500);window.addEventListener("pagehide",()=>window.clearTimeout(j),{once:!0}),ae(w.redirect);return}ae(w.redirect)}catch(w){i(w instanceof te?w.message:"That code is invalid or has expired."),m(!1)}}return a==="email"?e.jsxs("form",{onSubmit:f,className:"flex flex-col gap-3",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest text-[var(--c-text3)]",children:"Email"}),e.jsx("input",{type:"email",required:!0,autoFocus:!0,autoComplete:"email",value:n,onChange:N=>l(N.target.value),placeholder:"you@studio.dev",className:"rounded-[4px] border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2.5 text-[15px] text-[var(--c-text)] outline-none transition-colors focus:border-[var(--c-accent)]"})]}),g?e.jsx("p",{className:"text-[13px] text-red-500",children:g}):null,e.jsx("button",{type:"submit",disabled:h,className:"classic-button w-full",children:h?"Sending…":"Email me a sign-in code"})]}):e.jsxs("form",{onSubmit:p,className:"flex flex-col gap-3",children:[e.jsxs("p",{className:"text-[13px]",children:["We sent a 6-digit code to ",e.jsx("span",{className:"font-medium text-[var(--c-text)]",children:n}),". Enter it below."]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest text-[var(--c-text3)]",children:"Verification code"}),e.jsx("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]*",maxLength:6,required:!0,autoFocus:!0,value:d,onChange:N=>c(N.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",className:"rounded-[4px] border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2.5 text-center font-mono text-[22px] font-semibold tracking-[0.4em] text-[var(--c-text)] outline-none transition-colors focus:border-[var(--c-accent)]"})]}),g?e.jsx("p",{className:"text-[13px] text-red-500",children:g}):null,e.jsx("button",{type:"submit",disabled:h||d.length<6,className:"classic-button w-full",children:h?"Verifying…":"Verify & continue"}),e.jsxs("div",{className:"flex items-center justify-between text-[13px]",children:[e.jsx("button",{type:"button",onClick:f,disabled:h,className:"text-[var(--c-accent)] hover:underline",children:"Resend code"}),e.jsx("button",{type:"button",onClick:()=>{r("email"),c(""),i(null)},className:"text-[var(--c-accent)] hover:underline",children:"Use a different email"})]})]})}function ka({redirectUri:t,codeChallenge:s}){return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(tt,{provider:"google",label:"Continue with Google",redirectUri:t,codeChallenge:s,children:e.jsx(Sa,{})}),e.jsx(tt,{provider:"github",label:"Continue with GitHub",redirectUri:t,codeChallenge:s,children:e.jsx(La,{})})]})}function tt({provider:t,label:s,redirectUri:a,codeChallenge:r,children:n}){return e.jsxs("a",{href:Ca(t,a,r),className:"classic-button--quiet w-full gap-2.5",children:[n,s]})}function Ca(t,s,a){const r=new URLSearchParams;s&&a&&(r.set("redirect_uri",s),r.set("code_challenge",a));const n=Lt();n&&r.set("attribution",JSON.stringify({source:n.source,params:n.params,landing:n.landing,ts:n.ts}));const l=r.toString();return`${Pe}/ai/auth/oauth/${t}${l?`?${l}`:""}`}function Sa(){return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",className:"shrink-0",children:[e.jsx("path",{fill:"#4285F4",d:"M17.64 9.2045c0-.6381-.0573-1.2518-.1636-1.8409H9v3.4814h4.8436c-.2086 1.125-.8427 2.0782-1.7959 2.7164v2.2581h2.9086c1.7018-1.5668 2.6837-3.874 2.6837-6.615z"}),e.jsx("path",{fill:"#34A853",d:"M9 18c2.43 0 4.4673-.806 5.9564-2.1805l-2.9086-2.2581c-.8059.54-1.8368.859-3.0478.859-2.344 0-4.3282-1.5832-5.036-3.7105H.9573v2.3318C2.4382 15.9832 5.4818 18 9 18z"}),e.jsx("path",{fill:"#FBBC05",d:"M3.964 10.71c-.18-.54-.2822-1.1168-.2822-1.71s.1023-1.17.2823-1.71V4.9582H.9573C.3477 6.1732 0 7.5477 0 9s.3477 2.8268.9573 4.0418L3.964 10.71z"}),e.jsx("path",{fill:"#EA4335",d:"M9 3.5795c1.3214 0 2.5077.4541 3.4405 1.346l2.5813-2.5814C13.4636.8918 11.426 0 9 0 5.4818 0 2.4382 2.0168.9573 4.9582L3.964 7.29C4.6718 5.1627 6.656 3.5795 9 3.5795z"})]})}function La(){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:"shrink-0",children:e.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}const Ma={session_expired:"Your sign-in session expired. Please try again.",link_expired:"That sign-in link expired. Please try again from the editor."};function Aa(){const t=re(),[s]=Pt(),a=s.get("redirect_uri"),r=s.get("code_challenge"),n=s.get("error"),l=a&&r?{redirectUri:a,codeChallenge:r}:null,d=!!l,c=!!l&&/^https?:\/\//i.test(l.redirectUri),{loading:h,profile:m}=U(),[g,i]=o.useState("idle");return o.useEffect(()=>{if(!h){if(!m){i("form");return}if(a&&r){i("completing");let f=!0;return $("/ai/authorize_editor",{method:"POST",body:{redirect_uri:a,code_challenge:r}}).then(p=>{f&&(p.redirect?ae(p.redirect):i("form"))}).catch(()=>{f&&i("form")}),()=>{f=!1}}t("/account",{replace:!0})}},[h,m,a,r,t]),g==="completing"?e.jsx(D,{children:e.jsx("main",{className:"mx-auto flex max-w-5xl flex-col items-center px-5 py-24",children:e.jsxs("div",{className:"w-full max-w-md rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-8 text-center",children:[e.jsx("h1",{className:"text-xl font-semibold text-[var(--c-text)]",children:"Opening LevelCode…"}),e.jsx("p",{className:"mt-3 text-[14px] pretty",children:c?"Signing the editor into your account. You are being sent back to LevelCode.":"Signing the editor into your account. You can return to LevelCode — this tab can be closed."})]})})}):g!=="form"?e.jsx(D,{children:e.jsx("main",{className:"mx-auto flex min-h-[60vh] max-w-5xl flex-col px-5 py-24"})}):e.jsx(D,{children:e.jsx("main",{className:"mx-auto flex max-w-5xl flex-col items-center px-5 py-16",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-block",children:e.jsx(ut,{})}),e.jsxs("h1",{className:"mt-3 text-[28px] font-bold tracking-tight text-[var(--c-text)]",children:["Sign in to Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsx("p",{className:"mt-2 text-[15px] pretty",children:d?"Connect the editor to your account — you'll be sent back to LevelCode when you're done.":"Manage your plan, keys, and usage."})]}),e.jsxs("div",{className:"mt-8 rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-7",children:[n?e.jsx("div",{role:"alert",className:"mb-5 rounded-[4px] border border-red-500/50 bg-red-500/10 px-4 py-3 text-[13px] text-red-500",children:Ma[n]??"Sign-in failed. Please try again."}):null,e.jsx(ka,{redirectUri:l==null?void 0:l.redirectUri,codeChallenge:l==null?void 0:l.codeChallenge}),e.jsxs("div",{className:"my-5 flex items-center gap-3 text-[var(--c-text3)]","aria-hidden":"true",children:[e.jsx("span",{className:"flex-1 border-t border-[var(--c-line)]"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",children:"or"}),e.jsx("span",{className:"flex-1 border-t border-[var(--c-line)]"})]}),e.jsx(wa,{redirectUri:l==null?void 0:l.redirectUri,codeChallenge:l==null?void 0:l.codeChallenge})]}),e.jsxs("p",{className:"mt-5 text-center text-[13px] text-[var(--c-text3)]",children:["By continuing you agree to the"," ",e.jsx(b,{to:"/terms",className:"text-[var(--c-accent)] hover:underline",children:"Terms of Service"})," ","and"," ",e.jsx(b,{to:"/privacy",className:"text-[var(--c-accent)] hover:underline",children:"Privacy Policy"}),". Bring your own key — we never resell provider access."]})]})})})}function Ta({tiers:t,authed:s,currentPlan:a}){const r=re(),[n,l]=o.useState(null),[d,c]=o.useState(null),h=i=>(i??"").trim().toLowerCase(),m=i=>s&&!!a&&h(a)===h(i.name);async function g(i){if(c(null),!s){r("/login");return}l(i.key);try{const f=await $("/ai/checkout",{body:{lookup_key:i.key}});if(f.url){ae(f.url);return}if(f.status==="plan_changed"){r("/account?checkout=changed");return}c("Could not start checkout."),l(null)}catch(f){c(f instanceof te?f.message:"Could not start checkout."),l(null)}}return e.jsxs(e.Fragment,{children:[d?e.jsx("p",{className:"mb-4 text-center text-[13px] text-red-500",role:"alert",children:d}):null,e.jsx("div",{className:"grid gap-5 sm:grid-cols-2 lg:grid-cols-4",children:t.map((i,f)=>{const p=f===1,N=m(i);return e.jsxs("div",{className:`flex flex-col rounded-md border bg-[var(--c-bg)] p-6 ${N||p?"border-[var(--c-accent)]":"border-[var(--c-line)]"} ${N?"shadow-[0_0_0_1px_var(--c-accent)]":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--c-text)]",children:i.name}),N?e.jsx("span",{className:"rounded-[3px] bg-[var(--c-accent)] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-white",children:"current"}):p?e.jsx("span",{className:"rounded-[3px] border border-[var(--c-accent)] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-[var(--c-accent)]",children:"popular"}):null]}),e.jsxs("div",{className:"mt-4 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-3xl font-bold tracking-tight text-[var(--c-text)]",children:_a(i.price_cents)}),e.jsxs("span",{className:"text-sm text-[var(--c-text3)]",children:["/",i.interval||"mo"]})]}),e.jsxs("dl",{className:"mt-5 space-y-1.5 font-mono text-[12px] text-[var(--c-text2)]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"input"}),e.jsx("dd",{className:"tabular-nums",children:st(i.input_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"output"}),e.jsx("dd",{className:"tabular-nums",children:st(i.output_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"turns"}),e.jsx("dd",{className:"tabular-nums",children:(i.turns??0).toLocaleString()})]})]}),e.jsx("ul",{className:"mt-5 flex-1 space-y-2 text-[13px] text-[var(--c-text2)]",children:(i.features??[]).map(w=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"mt-1.5 h-1 w-1 flex-none rounded-full bg-[var(--c-accent)]"}),e.jsx("span",{className:"pretty",children:w})]},w))}),N?e.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"classic-button--quiet mt-6 w-full cursor-default opacity-70",children:"✓ Current plan"}):e.jsx("button",{onClick:()=>g(i),disabled:n===i.key,className:`mt-6 w-full ${p?"classic-button":"classic-button--quiet"}`,children:n===i.key?"Starting…":s?"Choose plan":"Sign in to start"})]},i.key)})})]})}function _a(t){const s=t/100;return`$${s%1===0?s.toFixed(0):s.toFixed(2)}`}function st(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString()}function Ea(){const{profile:t}=U(),[s,a]=o.useState([]),[r,n]=o.useState(null);return o.useEffect(()=>{let l=!0;return $("/api/levelcode/v1/pricing").then(d=>{l&&a(d.tiers??[])}).catch(()=>{l&&n("Pricing is temporarily unavailable. Please try again shortly.")}),()=>{l=!1}},[]),e.jsxs(D,{children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-12 text-center",children:[e.jsx("h1",{className:"text-[30px] font-bold tracking-tight text-[var(--c-text)] sm:text-[36px]",children:"Plans that scale as you ship"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl pretty",children:"Every plan is bring-your-own-key by default — free, forever. Switch on the gateway and your monthly credit is all you pay; we never mark up the provider."})]})}),e.jsx("section",{children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-12",children:[r?e.jsx("div",{className:"rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-8 text-center text-[15px]",children:r}):e.jsx(Ta,{tiers:s,authed:!!t,currentPlan:(t==null?void 0:t.plan)??null}),e.jsx("p",{className:"mt-10 text-center text-[13px] text-[var(--c-text3)]",children:"All plans include the full editor — it’s free and open source. Plans meter the managed AI gateway only."})]})})]})}function Mt({title:t,updated:s,intro:a,children:r}){return e.jsxs(D,{children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-3xl px-5 py-10 text-center",children:[e.jsx("h1",{className:"text-[30px] font-bold tracking-tight text-[var(--c-text)] sm:text-[36px]",children:t}),e.jsxs("p",{className:"mt-2 text-[13px] text-[var(--c-text3)]",children:["Last updated: ",s]})]})}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-12",children:[e.jsx("p",{className:"text-[16px] leading-relaxed pretty",children:a}),e.jsx("div",{className:"mt-10 space-y-9",children:r})]})]})}function A({id:t,heading:s,children:a}){return e.jsxs("section",{id:t,className:"scroll-mt-24",children:[e.jsx("h2",{className:"text-xl font-semibold tracking-tight text-[var(--c-text)]",children:s}),e.jsx("div",{className:"mt-3 space-y-3 text-[15px] leading-relaxed pretty",children:a})]})}function $a(){return e.jsxs(Mt,{title:"Privacy Policy",updated:"July 9, 2026",intro:e.jsx(e.Fragment,{children:"This policy explains what LevelCode collects, how we use it, and who we share it with when you use the LevelCode editor and LevelCode Cloud (levelcode.ai). The most important thing to know: to generate AI responses, we send your prompts and selected code to third-party model providers."}),children:[e.jsxs(A,{id:"collect",heading:"1. What we collect",children:[e.jsxs("ul",{className:"list-disc space-y-1.5 pl-5",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Account"})," — your email and basic profile, and the authentication tokens the editor uses to talk to the service."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Prompts & code"})," — the prompts and code you submit to the AI gateway, so we can generate responses and meter usage."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Usage & billing"})," — model used, token counts, timestamps, plan, and spend, used to meter your allowance and support billing. Payments are handled by Stripe; we do not receive or store your full card number."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Technical"})," — IP address, device/browser info, and server logs, used for security and to operate the Service."]})]}),e.jsx("p",{children:"Product telemetry in the editor is off by default. If you use bring-your-own-key (BYOK), those requests go directly to your provider and your prompts and code do not pass through our gateway."})]}),e.jsx(A,{id:"use",heading:"2. How we use it",children:e.jsx("p",{children:"To provide, secure, and improve the Service — including generating AI responses, metering your usage against your plan, processing subscriptions, providing support, preventing abuse, and meeting legal obligations. We do not sell your personal information, and we do not use the content of your prompts or code to advertise to you."})}),e.jsxs(A,{id:"share",heading:"3. Who we share it with",children:[e.jsx("p",{children:"We share information only with service providers that help us run LevelCode:"}),e.jsxs("ul",{className:"list-disc space-y-1.5 pl-5",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"AI model providers & routing"})," — your prompts and selected code are sent to the AI provider(s) that generate your response, via our routing partner. They process this content to return a result and under their own terms and privacy policies."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Payments"})," — Stripe, to process subscriptions and payments."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Hosting & infrastructure"})," — our cloud hosting provider, which stores and serves the Service on our behalf."]})]}),e.jsx("p",{children:"We may also disclose information if required by law, to enforce our terms, or to protect the rights, safety, and security of LevelCode and its users. If we’re involved in a merger or acquisition, your information may transfer as part of that transaction."})]}),e.jsx(A,{id:"retention",heading:"4. Retention",children:e.jsxs("p",{children:["We keep account and billing records for as long as your account is active and as needed to meet legal, tax, and security obligations. Prompts, code, and usage records are retained only as long as needed to operate the Service and support your account, after which they are deleted or anonymized."," "]})}),e.jsx(A,{id:"cookies",heading:"5. Cookies",children:e.jsx("p",{children:"We use strictly necessary cookies to keep you signed in and to operate the site. We do not use third-party advertising cookies. Your browser settings let you control cookies, though the Service may not work properly without the essential ones."})}),e.jsx(A,{id:"security",heading:"6. Security",children:e.jsx("p",{children:"We use technical and organizational measures — including encryption in transit and access controls — to protect your information. No method of transmission or storage is perfectly secure, so we cannot guarantee absolute security."})}),e.jsx(A,{id:"rights",heading:"7. Your rights",children:e.jsx("p",{children:"Depending on where you live (for example, under GDPR or the CCPA), you may have the right to access, correct, delete, or export your personal information, and to object to or restrict certain processing. To make a request, email us at the address below; we will respond as required by applicable law."})}),e.jsx(A,{id:"children",heading:"8. Children",children:e.jsx("p",{children:"The Service is not directed to children under 13, and we do not knowingly collect their personal information. If you believe a child has provided us information, contact us and we will delete it."})}),e.jsx(A,{id:"international",heading:"9. International transfers",children:e.jsx("p",{children:"We and our providers may process your information in countries other than yours. Where required, we rely on appropriate safeguards for such transfers."})}),e.jsx(A,{id:"changes",heading:"10. Changes",children:e.jsx("p",{children:"We may update this policy from time to time. Material changes will be reflected in the date above and, where appropriate, communicated to you."})}),e.jsx(A,{id:"contact",heading:"11. Contact",children:e.jsxs("p",{children:["Privacy questions or requests? Email"," ",e.jsx("a",{href:"mailto:privacy@levelcode.ai",className:"text-[var(--c-accent)] hover:underline",children:"privacy@levelcode.ai"}),"."]})})]})}function At(t){const s=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${s}-${a}`}function at(t){const s=new Date;return s.setDate(s.getDate()-t),At(s)}const ue=()=>At(new Date),rt=/^\d{4}-\d{2}-\d{2}$/;function Da(t,s){return!rt.test(t)||!rt.test(s)?"Pick both a start and an end date.":t>s?"The start date is after the end date.":s>ue()?"The end date is in the future.":null}function Ia(){const t=re(),{loading:s,profile:a}=U(),[r,n]=o.useState(()=>at(29)),[l,d]=o.useState(ue),[c,h]=o.useState(null),[m,g]=o.useState(null),[i,f]=o.useState(!0),p=(a==null?void 0:a.role)==="admin";o.useEffect(()=>{s||(a?p||t("/account",{replace:!0}):t("/login",{replace:!0}))},[s,a,p,t]);const N=Da(r,l);if(o.useEffect(()=>{if(!p)return;if(N){f(!1);return}let j=!0;f(!0),g(null);const C=new URLSearchParams({from:r,to:l});return $(`/api/levelcode/v1/admin/referrals?${C.toString()}`).then(x=>{j&&(h(x),f(!1))}).catch(()=>{j&&(h(null),g("Couldn’t load the referral funnel."),f(!1))}),()=>{j=!1}},[p,r,l,N]),s||!p)return e.jsx(D,{children:e.jsx("main",{className:"mx-auto max-w-5xl px-5 py-12"})});const w=(c==null?void 0:c.rows)??[];return e.jsx(D,{children:e.jsxs("main",{className:"mx-auto max-w-5xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:"Referrals"}),e.jsx("p",{className:"mt-2 text-[14px] text-[var(--c-text3)]",children:"clicks · signups · paid, per marketing channel"})]}),e.jsx(b,{to:"/admin",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"← System dashboard"})]}),m?e.jsx("div",{className:"classic-card mt-8 p-6 text-[14px] text-red-500",children:m}):null,N?e.jsxs("div",{role:"alert",className:"mt-8 rounded-md border border-[#d19a66]/40 bg-[#d19a66]/[0.1] px-4 py-3 text-[14px] text-[var(--c-text)]",children:[N,c?" Showing the last loaded range below.":null]}):null,e.jsxs("div",{className:"mt-8 flex flex-wrap items-center gap-3",children:[e.jsx(nt,{label:"from",value:r,max:l,onChange:n}),e.jsx(nt,{label:"to",value:l,min:r,max:ue(),onChange:d}),e.jsx("div",{className:"flex gap-2",children:[{label:"7d",days:6},{label:"30d",days:29},{label:"90d",days:89}].map(j=>e.jsx("button",{type:"button",onClick:()=>{n(at(j.days)),d(ue())},className:"rounded-md border border-[var(--c-line)] px-2.5 py-1.5 font-mono text-[12px] text-[var(--c-text2)] transition-colors hover:border-[var(--c-accent)] hover:text-[var(--c-text)]",children:j.label},j.label))})]}),e.jsxs("div",{className:"mt-6 grid gap-4 sm:grid-cols-3",children:[e.jsx(Me,{label:"clicks",value:c==null?void 0:c.totals.clicks}),e.jsx(Me,{label:"signups",value:c==null?void 0:c.totals.signups}),e.jsx(Me,{label:"paid",value:c==null?void 0:c.totals.paid})]}),c?e.jsxs("p",{className:"mt-3 font-mono text-[12px] text-[var(--c-text3)]",children:["covering ",c.from," → ",c.to]}):null,e.jsx("div",{className:"classic-card mt-6 overflow-x-auto p-0",children:e.jsxs("table",{className:"w-full min-w-[620px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"px-3 py-2 font-normal",children:"channel"}),e.jsx("th",{className:"px-3 py-2 font-normal",children:"handle"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"clicks"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"signups"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"paid"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"click → signup"})]})}),e.jsxs("tbody",{children:[w.map(j=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] last:border-b-0 hover:bg-[var(--c-surface)]",children:[e.jsx("td",{className:"px-3 py-2 text-[var(--c-text)]",children:j.channel}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:j.handle??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:j.clicks}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text)]",children:j.signups}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:j.paid}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text3)]",children:j.clicks>0?`${(j.signups/j.clicks*100).toFixed(1)}%`:"—"})]},`${j.channel}-${j.handle??""}`)),c&&w.length===0&&!i?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-8 text-center text-[var(--c-text3)]",children:"No referral activity in this range."})}):null]})]})}),e.jsxs("div",{className:"mt-4 space-y-1.5 text-[12px] leading-relaxed text-[var(--c-text3)]",children:[c?e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:c.unattributed_signups})," ","signup",c.unattributed_signups===1?"":"s"," in this range carried no channel — organic, or the visitor’s browser dropped the stored attribution. They are not in the table."]}):null,e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:"paid"})," counts people who signed up in this range and are on a paid plan ",e.jsx("em",{children:"right now"})," — there is no “became paid” timestamp to measure conversions inside the range."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:"clicks"})," are matched to a channel through the short link’s current destination and exclude bots. Editing a link’s destination re-attributes its past clicks."]}),e.jsx("p",{children:"Clicks and signups are counted independently and joined only by channel name, so click → signup is a ratio between two populations, not a tracked journey."})]})]})})}function nt({label:t,value:s,min:a,max:r,onChange:n}){return e.jsxs("label",{className:"flex items-center gap-2 font-mono text-[12px] text-[var(--c-text3)]",children:[t,e.jsx("input",{type:"date",value:s,min:a,max:r,onChange:l=>n(l.target.value),className:"rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-2.5 py-1.5 font-mono text-[12px] text-[var(--c-text)] outline-none focus:border-[var(--c-accent)]"})]})}function Me({label:t,value:s}){return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("p",{className:"classic-label",children:t}),e.jsx("p",{className:"mt-1 text-[26px] font-bold tabular-nums text-[var(--c-text)]",children:s===void 0?"—":s.toLocaleString("en-US")})]})}function Pa(){return e.jsxs(Mt,{title:"Terms of Service",updated:"July 9, 2026",intro:e.jsxs(e.Fragment,{children:["These Terms govern your use of LevelCode — the LevelCode editor and the LevelCode Cloud service at levelcode.ai (together, the “Service”). By creating an account or using the Service, you agree to these Terms and to our"," ",e.jsx("a",{href:"/privacy",className:"text-[var(--c-accent)] hover:underline",children:"Privacy Policy"}),"."]}),children:[e.jsx(A,{heading:"1. The Service",children:e.jsx("p",{children:"LevelCode is an AI-native code editor and a metered AI gateway. On a paid plan or the free tier, the editor sends your prompts and selected code to our gateway, which routes them to third-party AI model providers to generate responses. You may also use your own provider API key (“bring-your-own-key” / BYOK); in that mode requests go directly to your provider and do not run through our gateway or metering."})}),e.jsx(A,{heading:"2. Eligibility & accounts",children:e.jsx("p",{children:"You must be at least 13 years old (and, if under the age of majority where you live, have your parent or guardian’s consent) to use the Service. You are responsible for your account and for keeping your credentials and API keys secure. Notify us promptly of any unauthorized use."})}),e.jsxs(A,{heading:"3. Plans, billing & usage limits",children:[e.jsx("p",{children:"Paid plans are subscriptions billed in advance through our payment processor (Stripe) and renew automatically each period until canceled. You can cancel anytime; cancellation takes effect at the end of the current billing period, and, except where required by law, payments are non-refundable."}),e.jsx("p",{children:"Each plan includes a monthly usage allowance, expressed as approximate model “turns.” To keep the Service reliable, that allowance is metered and may be made available progressively over the billing cycle rather than all at once (rolling usage windows) — heavy use may be paced or, on some plans, temporarily served by a lighter model until more of your allowance becomes available or the period renews. We show your current usage and when more becomes available in your account. We may change plans, prices, allowances, or limits prospectively, with notice for existing subscribers."})]}),e.jsxs(A,{heading:"4. Your content and code",children:[e.jsx("p",{children:"You retain all rights to the code, prompts, and other content you submit (“Your Content”). You grant us a limited license to process, transmit, and store Your Content solely to operate and improve the Service — including sending it to the AI model providers needed to generate responses. We do not claim ownership of Your Content or of the outputs generated for you."}),e.jsx("p",{children:"You are responsible for having the rights to submit Your Content and for ensuring your use complies with any licenses that apply to code you work on."})]}),e.jsx(A,{heading:"5. AI output — no warranty",children:e.jsx("p",{children:"AI-generated code and text may be inaccurate, insecure, or unsuitable for your purpose, and similar outputs may be generated for other users. You are responsible for reviewing, testing, and deciding whether to use any output. The Service is not a substitute for professional judgment, and outputs are not legal, financial, security, or other professional advice."})}),e.jsxs(A,{heading:"6. Acceptable use",children:[e.jsx("p",{children:"You agree not to use the Service to:"}),e.jsxs("ul",{className:"list-disc space-y-1 pl-5",children:[e.jsx("li",{children:"break the law or infringe others’ rights;"}),e.jsx("li",{children:"generate malware, or content intended to harm, harass, defraud, or deceive;"}),e.jsx("li",{children:"abuse, overload, reverse-engineer, or circumvent the gateway, metering, or usage limits;"}),e.jsx("li",{children:"resell or provide the Service to third parties except as expressly permitted; or"}),e.jsx("li",{children:"violate the terms of the underlying AI providers or other third-party services."})]})]}),e.jsx(A,{heading:"7. Third-party services",children:e.jsx("p",{children:"The Service relies on third parties — including the AI model providers and routing partner behind our gateway, our payment processor, and our hosting provider. Your use of the Service through these providers is also subject to their terms, and we are not responsible for their acts or omissions."})}),e.jsx(A,{heading:"8. Intellectual property & open source",children:e.jsx("p",{children:"The LevelCode name, site, and service are owned by us or our licensors. The editor is built on open-source software, which remains governed by its own licenses; nothing here restricts your rights under those licenses. Except for those open-source components and Your Content, you may not copy, modify, or create derivative works of the Service without permission."})}),e.jsx(A,{heading:"9. Disclaimers & limitation of liability",children:e.jsx("p",{children:"The Service is provided “as is” and “as available,” without warranties of any kind to the fullest extent permitted by law. To the extent permitted by law, we are not liable for indirect, incidental, or consequential damages, and our total liability for any claim relating to the Service will not exceed the amount you paid us for the Service in the twelve months before the claim."})}),e.jsx(A,{heading:"10. Termination",children:e.jsx("p",{children:"You may stop using the Service at any time. We may suspend or terminate access if you violate these Terms or to protect the Service or other users. Sections that by their nature should survive termination (for example, ownership, disclaimers, and limitations of liability) will survive."})}),e.jsx(A,{heading:"11. Changes to these Terms",children:e.jsx("p",{children:"We may update these Terms from time to time. If we make material changes we will update the date above and, where appropriate, notify you. Your continued use of the Service after changes take effect means you accept the updated Terms."})}),e.jsx(A,{heading:"12. Governing law",children:e.jsx("p",{children:"These Terms are governed by the laws of [governing-law jurisdiction], without regard to conflict-of-laws rules, and any disputes will be resolved in the courts located there. "})}),e.jsx(A,{heading:"13. Contact",children:e.jsxs("p",{children:["Questions about these Terms? Email"," ",e.jsx("a",{href:"mailto:legal@levelcode.ai",className:"text-[var(--c-accent)] hover:underline",children:"legal@levelcode.ai"}),"."]})})]})}const R={lede:"The real LevelCode workbench, running in a browser tab. Explorer, editor tabs, themes, the chat panel and the agent are all there. Nothing to install.",signIn:"Sign in with your LevelCode account. The gateway plan and usage are the same as in the Mac app. The editor takes this tab to your account and back, and if you are already signed in there you come straight back.",works:[{title:"The workbench",body:"Explorer, editor tabs, themes and the chat panel."},{title:"The agent",body:"It can read, search, create, edit and delete files in the open workspace. Its changes are applied at once and offered for Keep or Undo."},{title:"Your account",body:"The gateway plan and usage are the same as in the Mac app."},{title:"Your own key",body:"Use a provider key of your own instead of the gateway. It is kept encrypted in this browser, and requests go from the browser to the provider, so the provider has to accept requests from a web page."},{title:"Your files",body:"Open a folder from your computer, or work in a scratch workspace saved in your browser."}],staysInMacApp:["Terminal","Running shell commands","MCP servers that start local processes","Installing extensions"],folder:{title:"Open a folder from your computer",body:"LevelCode uses the File System Access API, so edits go straight to the folder you picked. Available in Chrome and Edge."},scratch:{title:"Use a scratch workspace",body:"A workspace that is saved in your browser. It works in every modern browser, including Safari and Firefox. Clearing the site's data in your browser removes it."},browsers:[{name:"Chrome",folder:!0},{name:"Edge",folder:!0},{name:"Safari",folder:!1},{name:"Firefox",folder:!1}],privacy:{title:"What goes to the model",files:"Files stay in your browser or on your computer.",model:"The text you send in chat and the files you ask LevelCode to read go to the model through the LevelCode gateway, the same as in the Mac app."}};function Ra(){const{enabled:t,url:s,loading:a}=X();if(Ba(t),a)return e.jsx(D,{children:e.jsx("main",{"aria-busy":"true",className:"mx-auto min-h-[60vh] max-w-5xl px-5 py-24"})});if(!t||!s)return e.jsx(Oa,{});const r=new URL(s).host;return e.jsx(D,{children:e.jsxs("main",{children:[e.jsxs("section",{className:"lp-hero",children:[e.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col items-center px-5 pb-12 pt-16 text-center sm:pb-14 sm:pt-24",children:[e.jsx("h1",{className:"lp-h1 text-balance",children:"LevelCode in your browser"}),e.jsx("p",{className:"lp-lead mt-5 max-w-2xl text-balance",children:R.lede}),e.jsx("div",{className:"mt-9",children:e.jsx(lt,{url:s})}),e.jsx("p",{className:"mt-5 max-w-md text-[15px] text-[var(--c-text2)] pretty",children:R.signIn})]}),e.jsx("div",{className:"mx-auto max-w-5xl px-5 pb-20 sm:pb-24",children:e.jsx(qa,{host:r})})]}),e.jsx("section",{className:"border-y border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"What works here, and what stays in the Mac app"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"The browser edition covers the workbench and the agent’s work on your files. A few things stay in the Mac app."})]}),e.jsxs("div",{className:"lp-card mx-auto mt-12 grid max-w-4xl divide-y divide-[var(--c-line)] md:grid-cols-2 md:divide-x md:divide-y-0",children:[e.jsxs("div",{className:"p-7",children:[e.jsx("h3",{className:"text-[22px] font-semibold leading-snug text-[var(--c-text)]",children:"Works in your browser"}),e.jsx("ul",{className:"mt-6 space-y-5",children:R.works.map(n=>e.jsxs("li",{className:"flex gap-3",children:[e.jsx("span",{className:"mt-[3px] shrink-0 text-[var(--lp-add)]",children:e.jsx(Tt,{})}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[16px] font-semibold text-[var(--c-text)]",children:n.title}),e.jsx("span",{className:"mt-0.5 block text-[15px] text-[var(--c-text2)] pretty",children:n.body})]})]},n.title))})]}),e.jsxs("div",{className:"p-7",children:[e.jsx("h3",{className:"text-[22px] font-semibold leading-snug text-[var(--c-text)]",children:"Stays in the Mac app"}),e.jsx("ul",{className:"mt-6 space-y-4",children:R.staysInMacApp.map(n=>e.jsxs("li",{className:"flex gap-3 text-[16px] text-[var(--c-text)]",children:[e.jsx("span",{className:"mt-[3px] shrink-0 text-[var(--c-text3)]",children:e.jsx(_t,{})}),n]},n))}),e.jsx("p",{className:"mt-8",children:e.jsx(b,{to:"/download",className:"lp-link text-[15px] font-medium",children:"Download LevelCode for Mac →"})})]})]})]})}),e.jsx("section",{children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Where your files live"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"There are two ways to work with files in the browser."})]}),e.jsxs("div",{className:"mx-auto mt-12 grid max-w-4xl gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"lp-card p-7",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:e.jsx(Fa,{})}),e.jsx("h3",{className:"mt-4 text-[20px] font-semibold leading-snug text-[var(--c-text)]",children:R.folder.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:R.folder.body})]}),e.jsxs("div",{className:"lp-card p-7",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:e.jsx(Wa,{})}),e.jsx("h3",{className:"mt-4 text-[20px] font-semibold leading-snug text-[var(--c-text)]",children:R.scratch.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:R.scratch.body})]})]}),e.jsx("div",{className:"mx-auto mt-6 max-w-4xl",children:e.jsx("div",{className:"lp-card overflow-x-auto px-5 py-3 sm:px-7",children:e.jsxs("table",{className:"w-full border-collapse text-left text-[15px]",children:[e.jsx("caption",{className:"sr-only",children:"Which browsers can open a folder, and which can use a scratch workspace"}),e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--c-line)] text-[13px] text-[var(--c-text3)]",children:[e.jsx("th",{scope:"col",className:"py-2.5 pr-4 font-medium",children:"Browser"}),e.jsx("th",{scope:"col",className:"px-4 py-2.5 font-medium",children:"Open a folder"}),e.jsx("th",{scope:"col",className:"py-2.5 pl-4 font-medium",children:"Scratch workspace"})]})}),e.jsx("tbody",{children:R.browsers.map(n=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] last:border-b-0",children:[e.jsx("th",{scope:"row",className:"py-3 pr-4 font-medium text-[var(--c-text)]",children:n.name}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(ot,{yes:n.folder})}),e.jsx("td",{className:"py-3 pl-4",children:e.jsx(ot,{yes:!0})})]},n.name))})]})})}),e.jsx("div",{className:"mx-auto mt-6 max-w-4xl",children:e.jsxs("div",{className:"lp-card flex flex-col gap-4 p-7 sm:flex-row sm:items-start sm:gap-5",children:[e.jsx("span",{className:"shrink-0 text-[var(--c-accent)]",children:e.jsx(Et,{})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[20px] font-semibold leading-snug text-[var(--c-text)]",children:R.privacy.title}),e.jsxs("p",{className:"mt-1.5 text-[15px] pretty",children:[R.privacy.files," ",R.privacy.model]}),e.jsx("p",{className:"mt-3",children:e.jsx(b,{to:"/privacy",className:"lp-link text-[15px] font-medium",children:"Read the privacy policy"})})]})]})})]})}),e.jsx("section",{className:"lp-hero lp-hero--closing border-t border-[var(--c-line)]",children:e.jsxs("div",{className:"mx-auto flex max-w-3xl flex-col items-center px-5 py-24 text-center sm:py-28",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Start in your browser"}),e.jsx("p",{className:"lp-lead mt-4 max-w-xl text-balance",children:"Sign in with your LevelCode account, then open a folder or a scratch workspace."}),e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsx(lt,{url:s}),e.jsx(b,{to:"/download",className:"lp-cta lp-cta--quiet",children:"Download for Mac"})]}),e.jsx("p",{className:"mt-6 text-[14px] text-[var(--c-text3)]",children:e.jsx(b,{to:"/docs/browser",className:"lp-link",children:"Read the browser edition guide"})})]})})]})})}function Oa(){return e.jsx(D,{children:e.jsx("main",{children:e.jsx("section",{className:"lp-hero",children:e.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col items-center px-5 pb-28 pt-20 text-center sm:pt-28",children:[e.jsx("h1",{className:"lp-h1 text-balance",children:"LevelCode in your browser"}),e.jsx("p",{className:"lp-lead mt-5 text-balance",children:"The browser edition is not available right now."}),e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsx(b,{to:"/download",className:"lp-cta",children:"Download LevelCode for Mac"}),e.jsx(b,{to:"/docs",className:"lp-cta lp-cta--quiet",children:"Read the documentation"})]})]})})})})}function lt({url:t}){return e.jsxs("a",{href:t,className:"lp-cta",children:["Open LevelCode",e.jsx("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M3 8h10m-4-4 4 4-4 4"})})]})}function ot({yes:t}){return t?e.jsxs("span",{className:"inline-flex items-center gap-2 text-[var(--c-text)]",children:[e.jsx("span",{className:"text-[var(--lp-add)]",children:e.jsx(Tt,{})}),"Yes"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-[var(--c-text3)]",children:[e.jsx(_t,{}),"No"]})}function Ba(t){o.useEffect(()=>{if(!t)return;const s=document.title;document.title="LevelCode in your browser";const a=document.querySelector('meta[name="description"]'),r=(a==null?void 0:a.hasAttribute("content"))??!1,n=(a==null?void 0:a.getAttribute("content"))??null;return a==null||a.setAttribute("content",R.lede),()=>{document.title=s,a&&(r&&n!==null?a.setAttribute("content",n):a.removeAttribute("content"))}},[t])}const xe="text-[#c58aff]",it="text-[#9fb4ff]",ct="text-[#7fd88f]";function qa({host:t}){return e.jsx("div",{className:"lp-stage",role:"img","aria-label":"LevelCode open in a browser tab: the file explorer, a file in the editor, and the chat panel with the agent's steps.",children:e.jsxs("div",{className:"shot-shadow w-full max-w-[940px] overflow-hidden rounded-xl border border-[var(--c-line)] bg-[var(--c-bg)] text-left","aria-hidden":!0,children:[e.jsxs("div",{className:"flex items-end gap-3 border-b border-[var(--c-line)] bg-[var(--c-surface)] px-3 pt-2.5",children:[e.jsxs("span",{className:"flex gap-1.5 self-center pb-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[var(--c-line)]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[var(--c-line)]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[var(--c-line)]"})]}),e.jsxs("span",{className:"relative -mb-px flex items-center gap-2 rounded-t-lg border border-b-0 border-[var(--c-line)] bg-[var(--c-bg)] px-3.5 py-2 text-[12.5px] font-medium text-[var(--c-text)]",children:[e.jsx(ut,{size:14}),"LevelCode"]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 border-b border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2",children:[e.jsxs("span",{className:"flex gap-2 text-[var(--c-text3)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M10 3 5 8l5 5"})}),e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-50",children:e.jsx("path",{d:"m6 3 5 5-5 5"})})]}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 rounded-full bg-[var(--lp-well)] px-3.5 py-1.5 font-mono text-[12px] text-[var(--c-text2)]",children:[e.jsx("span",{className:"shrink-0 text-[var(--c-text3)]",children:e.jsx(Et,{size:12})}),e.jsx("span",{className:"truncate",children:t})]})]}),e.jsxs("div",{className:"grid bg-[#0a0c16] md:grid-cols-[minmax(0,1fr)_262px] lg:grid-cols-[172px_minmax(0,1fr)_262px]",children:[e.jsxs("div",{className:"hidden border-r border-[#1b1e2b] bg-[#0d1020] px-3 py-3.5 font-mono text-[12px] lg:block",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.14em] text-[#6b7280]",children:"Explorer"}),e.jsxs("ul",{className:"mt-3 space-y-1 text-[#8b93ad]",children:[e.jsxs("li",{className:"flex items-center gap-1.5 text-[#c7cbe0]",children:[e.jsx(dt,{open:!0}),"my-blog"]}),e.jsxs("li",{className:"flex items-center gap-1.5 pl-3",children:[e.jsx(dt,{open:!0}),"src"]}),e.jsx("li",{className:"-mx-3 bg-[#7d6bff]/15 py-0.5 pl-11 text-[#e2defe]",children:"slug.ts"}),e.jsx("li",{className:"pl-8",children:"post.ts"}),e.jsx("li",{className:"pl-8",children:"index.ts"}),e.jsx("li",{className:"pl-3",children:"package.json"}),e.jsx("li",{className:"pl-3",children:"README.md"})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex border-b border-[#1b1e2b] bg-[#0d1020] font-mono text-[12px]",children:[e.jsx("span",{className:"border-r border-[#1b1e2b] border-t-2 border-t-[#7d6bff] bg-[#0a0c16] px-4 py-2 text-[#e2defe]",children:"slug.ts"}),e.jsx("span",{className:"border-r border-[#1b1e2b] px-4 py-2 text-[#6b7280]",children:"post.ts"})]}),e.jsxs("div",{className:"overflow-hidden whitespace-pre px-3 py-4 font-mono text-[11px] leading-[1.95] text-[#c7cbe0] sm:px-4 sm:text-[12px] md:text-[12.5px]",children:[e.jsxs(G,{no:"1",children:[e.jsx("span",{className:xe,children:"import"})," ","{ words }"," ",e.jsx("span",{className:xe,children:"from"})," ",e.jsx("span",{className:ct,children:'"./text"'}),";"]}),e.jsx(G,{no:"2"}),e.jsxs(G,{no:"3",children:[e.jsx("span",{className:xe,children:"export function"})," ",e.jsx("span",{className:it,children:"slugify"}),"(title) ","{"]}),e.jsxs(G,{no:"4",children:[" ",e.jsx("span",{className:xe,children:"return"})," ",e.jsx("span",{className:it,children:"words"}),"(title)"]}),e.jsxs(G,{no:"5",children:[" ",".map((w) => w.toLowerCase())"]}),e.jsxs(G,{no:"6",children:[" ",".join(",e.jsx("span",{className:ct,children:'"-"'}),");"]}),e.jsxs(G,{no:"7",children:["}",e.jsx("span",{className:"ml-px inline-block h-[1.05em] w-[2px] -translate-y-[1px] animate-caret bg-[#7d6bff] align-middle"})]})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-4 border-t border-[#1b1e2b] bg-[#0d1020]/60 p-4 text-[13px] leading-relaxed md:border-l md:border-t-0",children:[e.jsxs("div",{className:"flex items-center justify-between font-mono text-[10px] uppercase tracking-[0.14em] text-[#a99bff]",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#7d6bff] shadow-[0_0_8px_rgba(125,107,255,0.9)]"}),"LevelCode"]}),e.jsx("span",{className:"rounded-full border border-[#7d6bff]/40 bg-[#7d6bff]/15 px-2 py-0.5 normal-case tracking-normal text-[#c6bfff]",children:"Agent"})]}),e.jsx("p",{className:"rounded-lg bg-[#171a2b] px-3 py-2.5 text-[#c7cbe0]",children:"Rename makeSlug to slugify everywhere it is used."}),e.jsxs("ul",{className:"space-y-2 text-[#8b93ad]",children:[e.jsx(Ae,{children:"Searched the workspace"}),e.jsx(Ae,{children:"Read 4 files"}),e.jsxs(Ae,{children:["Edited 3 files ",e.jsx("span",{className:"ml-1 font-mono text-[12px] text-[#7fd88f]",children:"+6"})," ",e.jsx("span",{className:"font-mono text-[12px] text-[#f47067]",children:"−6"})]})]}),e.jsx("p",{className:"border-t border-[#1b1e2b] pt-3 text-[#8b93ad]",children:"Renamed makeSlug in 3 files."})]})]})]})})}function G({no:t,children:s}){return e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-[2.4em] select-none text-[#3b4157]",children:t}),s]})}function Ae({children:t}){return e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",className:"mt-[3px] shrink-0 text-[#7fd88f]",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.35",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("path",{d:"M5.05 8.25 7 10.2l4.15-4.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("span",{children:t})]})}function dt({open:t}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"10",height:"10",fill:"currentColor",className:t?"rotate-90":"",children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})})}function Tt(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m3.5 8.5 3 3 6-7"})})}function _t(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":!0,children:e.jsx("path",{d:"M4 8h8"})})}function Be({d:t,size:s=28}){return e.jsx("svg",{viewBox:"0 0 24 24",width:s,height:s,fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"inline-block",children:e.jsx("path",{d:t})})}const Fa=()=>e.jsx(Be,{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),Wa=()=>e.jsx(Be,{d:"M3 6a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6Zm0 4h18M8 4v6"}),Et=({size:t=28})=>e.jsx(Be,{size:t,d:"M7 11V8a5 5 0 0 1 10 0v3M6 11h12v9H6v-9Zm6 3.5v2"});function Ua(){return e.jsxs(Rt,{children:[e.jsx(P,{path:"/",element:e.jsx(Qe,{})}),e.jsx(P,{path:"/login",element:e.jsx(Aa,{})}),e.jsx(P,{path:"/pricing",element:e.jsx(Ea,{})}),e.jsx(P,{path:"/account",element:e.jsx(xs,{})}),e.jsx(P,{path:"/admin",element:e.jsx(ms,{})}),e.jsx(P,{path:"/admin/referrals",element:e.jsx(Ia,{})}),e.jsx(P,{path:"/terms",element:e.jsx(Pa,{})}),e.jsx(P,{path:"/privacy",element:e.jsx($a,{})}),e.jsx(P,{path:"/download",element:e.jsx(ta,{})}),e.jsx(P,{path:"/web",element:e.jsx(Ra,{})}),e.jsx(P,{path:"/docs",element:e.jsx(vt,{})}),e.jsx(P,{path:"/docs/:slug",element:e.jsx(Ya,{})}),e.jsx(P,{path:"*",element:e.jsx(Qe,{})})]})}const Va={hackability:"customization"};function Ya(){const{slug:t}=Ot(),{hash:s}=K(),a=t?Va[t]:void 0;return a?e.jsx(Bt,{to:`/docs/${a}${s}`,replace:!0}):e.jsx(vt,{slug:t})}Na();qt(document.getElementById("root")).render(e.jsx(o.StrictMode,{children:e.jsx(Ft,{basename:"/ai",children:e.jsx(Ua,{})})}));export{fs as u}; diff --git a/app/assets/interface/levelcode-DDEAdB7B.js b/app/assets/interface/levelcode-DDEAdB7B.js new file mode 100644 index 00000000..20a13363 --- /dev/null +++ b/app/assets/interface/levelcode-DDEAdB7B.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/bundle-tvCSkI-U.js","assets/preload-helper-7J6LhHV_.js"])))=>i.map(i=>d[i]); +var qt=Object.defineProperty;var Ft=(t,s,a)=>s in t?qt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a;var je=(t,s,a)=>Ft(t,typeof s!="symbol"?s+"":s,a);import{r as o,j as e,L as j,u as re,R as me,b as X,_ as Ut,d as Wt,e as Vt,f as P,c as Yt,N as Ht,g as Zt,B as Gt}from"./preload-helper-7J6LhHV_.js";const zt=typeof window<"u"&&window.__ENV__||{},qe=String(zt.API_BASE??"").replace(/\/+$/,"");let ye=null;async function Kt(){const t=typeof document<"u"?document.querySelector('meta[name="csrf-token"]'):null,s=t==null?void 0:t.getAttribute("content");return s||(ye||(ye=fetch(`${qe}/ai/csrf`,{credentials:"include"}).then(a=>a.ok?a.json():{token:""}).then(a=>a.token??"").catch(()=>"")),ye)}class te extends Error{constructor(a,r,n){super(r);je(this,"status");je(this,"code");this.name="ApiError",this.status=a,this.code=n}}async function D(t,s={}){const a=s.method??(s.body!==void 0?"POST":"GET"),r={Accept:"application/json",...s.headers};s.body!==void 0&&(r["Content-Type"]="application/json"),a!=="GET"&&a!=="HEAD"&&(r["X-CSRF-Token"]=await Kt());const n=await fetch(`${qe}${t}`,{method:a,headers:r,credentials:"include",body:s.body!==void 0?JSON.stringify(s.body):void 0}),l=await n.text();let c=null;if(l)try{c=JSON.parse(l)}catch{c=null}if(!n.ok){const i=c==null?void 0:c.error;throw new te(n.status,(i==null?void 0:i.message)??`Request failed (${n.status})`,i==null?void 0:i.code)}return c}function ae(t){window.location.href=t}function W(){const[t,s]=o.useState({loading:!0,profile:null});return o.useEffect(()=>{let a=!0;return D("/api/levelcode/v1/account/profile").then(r=>{a&&s({loading:!1,profile:r})}).catch(()=>{a&&s({loading:!1,profile:null})}),()=>{a=!1}},[]),t}function gt(t,s){const a=(t||s||"").trim();if(!a)return"··";const r=a.split(/[\s@._-]+/).filter(Boolean);return r.length>=2?(r[0][0]+r[1][0]).toUpperCase():a.slice(0,2).toUpperCase()}const F="https://github.com/levelcodeai/levelcode";function Xt(){try{const t=localStorage.getItem("lc-theme");return t==="dark"||t==="light"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch{return"light"}}function $({children:t}){const[s,a]=o.useState(Xt),r=()=>a(n=>{const l=n==="light"?"dark":"light";try{localStorage.setItem("lc-theme",l)}catch{}return l});return e.jsxs("div",{className:`classic ${s==="dark"?"classic--dark":""} flex min-h-screen flex-col bg-[var(--c-bg)] text-[16px] leading-relaxed text-[var(--c-text2)]`,children:[e.jsx(Jt,{theme:s,onToggleTheme:r}),e.jsx("div",{className:"flex-1",children:t}),e.jsx("footer",{className:"bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col items-center justify-between gap-4 px-5 py-8 text-[14px] sm:flex-row",children:[e.jsxs("ul",{className:"flex flex-wrap items-center justify-center gap-x-5 gap-y-2",children:[e.jsx("li",{children:e.jsx(j,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/terms",children:"Terms of Service"})}),e.jsx("li",{children:e.jsx(j,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/privacy",children:"Privacy"})}),e.jsx("li",{children:e.jsx(j,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/docs",children:"Documentation"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:F,children:"GitHub"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:`${F}/releases`,children:"Releases"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:`${F}/discussions`,children:"Discussions"})}),e.jsx("li",{children:e.jsx(j,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/pricing",children:"Pricing"})})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--c-text3)]",children:[e.jsx(Qt,{})," with ",e.jsx(es,{})," by LevelCode"]})]})})]})}function Jt({theme:t,onToggleTheme:s}){const{profile:a}=W();return e.jsx("nav",{"aria-label":"Primary",className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto flex h-12 max-w-5xl items-center justify-between px-5",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs(j,{to:"/",className:"text-[15px] font-bold text-[var(--c-text)]",children:["Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsxs("ul",{className:"hidden items-center gap-5 sm:flex",children:[e.jsx("li",{children:e.jsx(j,{to:"/docs",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Documentation"})}),e.jsx("li",{children:e.jsx("a",{href:"https://open-vsx.org/",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Extensions"})}),e.jsx("li",{children:e.jsx("a",{href:`${F}/releases`,className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Releases"})}),e.jsx("li",{children:e.jsx(j,{to:"/pricing",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Pricing"})})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{type:"button",onClick:s,"aria-label":t==="light"?"Switch to dark mode":"Switch to light mode",title:t==="light"?"Dark mode (One Dark)":"Light mode",className:"flex h-8 w-8 items-center justify-center rounded-full border border-[var(--c-line)] bg-[var(--c-bg)] text-[var(--c-text2)] transition-colors hover:border-[var(--c-accent)] hover:text-[var(--c-text)]",children:t==="light"?e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M13.3 9.9A5.6 5.6 0 0 1 6.1 2.7a.4.4 0 0 0-.5-.5 6.4 6.4 0 1 0 8.2 8.2.4.4 0 0 0-.5-.5z"})}):e.jsxs("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,children:[e.jsx("circle",{cx:"8",cy:"8",r:"3.2"}),e.jsx("path",{d:"M8 1.2v1.8M8 13v1.8M1.2 8H3M13 8h1.8M3.2 3.2l1.3 1.3M11.5 11.5l1.3 1.3M12.8 3.2l-1.3 1.3M4.5 11.5l-1.3 1.3"})]})}),a?e.jsx(j,{to:"/account",title:"Account","aria-label":"Account",className:"flex h-8 w-8 items-center justify-center rounded-full border border-[var(--c-line)] bg-[var(--c-bg)] text-[12px] font-semibold text-[var(--c-text)] hover:border-[var(--c-accent)]",children:gt(a.name,a.email)}):e.jsxs(j,{to:"/login",className:"flex items-center gap-1.5 text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M10 3.75a.75.75 0 0 1 .75-.75h2.5A1.75 1.75 0 0 1 15 4.75v6.5A1.75 1.75 0 0 1 13.25 13h-2.5a.75.75 0 0 1 0-1.5h2.5a.25.25 0 0 0 .25-.25v-6.5a.25.25 0 0 0-.25-.25h-2.5a.75.75 0 0 1-.75-.75Zm-3.28.72a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H1.75a.75.75 0 0 1 0-1.5h6.69L6.72 5.53a.75.75 0 0 1 0-1.06Z"})}),"Sign in"]})]})]})})}function bt({size:t=56}){return e.jsx("svg",{viewBox:"0 0 120 120",width:t,height:t,"aria-hidden":!0,children:e.jsxs("g",{fill:"none",stroke:"var(--c-accent)",strokeWidth:"13",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M28 92 L60 69 L92 92",opacity:"0.4"}),e.jsx("path",{d:"M28 68 L60 45 L92 68",opacity:"0.7"}),e.jsx("path",{d:"M28 44 L60 21 L92 44"})]})})}function Qt(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m5.5 4.5-3.5 3.5 3.5 3.5M10.5 4.5 14 8l-3.5 3.5"})})}function es(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"var(--c-accent)","aria-hidden":!0,children:e.jsx("path",{d:"m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002Z"})})}const ts=1e4,ne="en-US";function Fe(t){return(t??0)/ts}function ss(t){const s=Fe(t);return(s>0?Math.round(s):0).toLocaleString(ne)}function $e(t){const s=Fe(t);return s>0?s>=10?Math.round(s).toLocaleString(ne):s<.05?"<0.1":s.toFixed(1):"0"}function Re(t){return(t??0).toLocaleString(ne)}const as=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ye=["bg-[var(--c-line)]","bg-flame/25","bg-flame/50","bg-flame/75","bg-[var(--c-accent)]"];function rs(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}-${String(t.getUTCDate()).padStart(2,"0")}`}function ns(t){return t<=0?0:t<=2?1:t<=6?2:t<=14?3:4}function J(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:Re(t)}function Ne(t){const[s,a,r]=t.split("-").map(Number);return new Date(Date.UTC(s,a-1,r)).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function ls({activity:t,year:s,years:a,onYear:r}){const[n,l]=o.useState(null),c=(t==null?void 0:t.days)??{},{weeks:i,monthCols:h}=o.useMemo(()=>{var v;const d=new Date(Date.UTC(s,0,1)),g=new Date(d);g.setUTCDate(d.getUTCDate()-d.getUTCDay());const f=new Date(Date.UTC(s,11,31)),C=new Date(f);C.setUTCDate(f.getUTCDate()+(6-f.getUTCDay()));const N=[],p=[],w=new Date(g);let x=-1;for(;w<=C;){const u=[];let L=null;for(let _=0;_<7;_++){const q=w.getUTCFullYear()===s;if(_===0&&(L=q?w.getUTCMonth():null),q){const V=rs(w);u.push({key:V,count:((v=c[V])==null?void 0:v.count)??0,date:new Date(w)})}else u.push({key:null,count:0,date:null});w.setUTCDate(w.getUTCDate()+1)}L!=null&&L!==x?(p.push(as[L]),x=L):p.push(null),N.push(u)}return{weeks:N,monthCols:p}},[s,c]),m=n?c[n]??null:null,b=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"classic-card p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"classic-label",children:"activity"}),e.jsxs("div",{className:"mt-1 text-lg font-semibold tracking-tight text-[var(--c-text)]",children:[Re((t==null?void 0:t.total)??0)," request",((t==null?void 0:t.total)??0)===1?"":"s"," in ",s]})]}),a.length>1?e.jsx("div",{className:"flex flex-wrap gap-1",children:a.map(d=>e.jsx("button",{type:"button",onClick:()=>{l(null),r(d)},className:`rounded-md px-2.5 py-1 font-mono text-[12px] transition-colors ${d===s?"bg-[var(--c-accent)] text-white":"text-[var(--c-text2)] hover:bg-[var(--c-line)]"}`,children:d},d))}):null]}),e.jsx("div",{className:"mt-5 overflow-x-auto",children:e.jsxs("div",{className:"inline-flex flex-col gap-1",children:[e.jsx("div",{className:"flex gap-[3px] pl-8",children:h.map((d,g)=>e.jsx("div",{className:"w-[11px] font-mono text-[10px] text-[var(--c-text3)]",children:d?e.jsx("span",{className:"relative -left-[1px] whitespace-nowrap",children:d}):null},g))}),e.jsxs("div",{className:"flex gap-[3px]",children:[e.jsx("div",{className:"mr-1 flex w-7 flex-col gap-[3px]",children:["","Mon","","Wed","","Fri",""].map((d,g)=>e.jsx("div",{className:"h-[11px] font-mono text-[9px] leading-[11px] text-[var(--c-text3)]",children:d},g))}),i.map((d,g)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:d.map((f,C)=>{var v,u;if(!f.key)return e.jsx("div",{className:"h-[11px] w-[11px]"},C);const N=ns(f.count),p=n===f.key,w=(u=(v=c[f.key])==null?void 0:v.models)==null?void 0:u[0],x=f.count>0?`${Ne(f.key)} · ${f.count} request${f.count===1?"":"s"}${w?` · ${we(w.model)} ${w.count}`:""}`:`${Ne(f.key)} · no activity`;return e.jsx("button",{type:"button",title:x,onClick:()=>l(p?null:f.key),className:`h-[11px] w-[11px] rounded-[2px] ${Ye[N]} ${p?"ring-1 ring-ink ring-offset-1":""} transition-colors hover:ring-1 hover:ring-ink/40`},C)})},g))]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 pl-8 font-mono text-[10px] text-[var(--c-text3)]",children:[e.jsx("span",{className:"mr-1",children:"Less"}),Ye.map((d,g)=>e.jsx("span",{className:`h-[11px] w-[11px] rounded-[2px] ${d}`},g)),e.jsx("span",{className:"ml-1",children:"More"})]})]})}),n&&m?e.jsxs("div",{className:"mt-6 rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"font-mono text-[12px] text-[var(--c-text2)]",children:Ne(n)}),e.jsxs("div",{className:"font-mono text-[12px] text-[var(--c-text3)]",children:[m.count," req · ",J(m.input)," in · ",J(m.output)," out ·"," ",$e(m.cost_micros)," credits"]})]}),e.jsx("ul",{className:"mt-3 space-y-1.5",children:m.models.map(d=>e.jsxs("li",{className:"flex items-center justify-between gap-3 font-mono text-[12px]",children:[e.jsx("span",{className:"truncate text-[var(--c-text)]",children:we(d.model)}),e.jsxs("span",{className:"whitespace-nowrap text-[var(--c-text3)]",children:[d.count," · ",J(d.input+d.output)," tok"]})]},d.model))})]}):e.jsx("p",{className:"mt-4 font-mono text-[11px] text-[var(--c-text3)]",children:"Click a day to see its per-model breakdown."}),b.length?e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"classic-label mb-3",children:["by model · ",s]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[520px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"py-1.5 pr-3 font-normal",children:"model"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"requests"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"input"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"output"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"credits"}),e.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"reactions"})]})}),e.jsx("tbody",{children:b.map(d=>e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("td",{className:"py-1.5 pr-3 text-[var(--c-text)]",children:we(d.model)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:Re(d.count)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:J(d.input)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:J(d.output)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:$e(d.cost_micros)}),e.jsx("td",{className:"py-1.5 pl-3 text-right tabular-nums text-[var(--c-text3)]",children:e.jsxs("span",{className:"inline-flex items-center justify-end gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(os,{className:"text-[var(--c-text2)]"})," ",d.up]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(is,{className:"text-[var(--c-text2)]"})," ",d.down]})]})})]},d.model))})]})})]}):null]})}function we(t){const s=t||"unknown",a=s.indexOf("/");return a>=0?s.slice(a+1):s}function os({className:t=""}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"currentColor","aria-hidden":"true",className:t,children:e.jsx("path",{d:"M12.999 6.00002H10.672L11.207 4.21802C11.278 3.98102 11.314 3.73902 11.314 3.49602C11.314 2.12002 10.192 0.999023 8.81298 0.999023C8.42998 0.999023 8.08498 1.21202 7.91398 1.55402L5.82998 5.72202C5.74498 5.89202 5.57398 5.99802 5.38298 5.99802H3.00098C1.89798 5.99802 1.00098 6.89502 1.00098 7.99802V12.998C1.00098 14.101 1.89798 14.998 3.00098 14.998H11.163C12.727 14.998 13.283 13.796 13.565 12.893L14.908 8.59602C14.969 8.40102 15 8.19902 15 7.99602C15 6.89402 14.103 5.99802 12.999 5.99802V6.00002ZM1.99998 13V8.00002C1.99998 7.44902 2.44898 7.00002 2.99998 7.00002H3.99998V14H2.99998C2.44898 14 1.99998 13.551 1.99998 13ZM13.954 8.29802L12.611 12.596C12.247 13.761 11.769 13.999 11.163 13.999H5.00098V6.99902H5.38298C5.95498 6.99902 6.46898 6.68102 6.72498 6.17002L8.80898 2.00202C8.80898 2.00202 8.81098 2.00002 8.81298 2.00002C9.64098 2.00002 10.314 2.67102 10.314 3.49702C10.314 3.64202 10.292 3.78802 10.249 3.93202L9.52098 6.35702C9.47598 6.50802 9.50398 6.67202 9.59898 6.79902C9.69398 6.92602 9.84198 7.00102 9.99998 7.00102H12.999C13.551 7.00102 14 7.44802 14 7.99902C14 8.10002 13.984 8.20102 13.954 8.30002V8.29802Z"})})}function is({className:t=""}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"currentColor","aria-hidden":"true",className:t,children:e.jsx("path",{d:"M13 1H4.838C3.274 1 2.717 2.202 2.435 3.105L1.092 7.404C1.031 7.6 1 7.801 1 8.002C1 9.104 1.897 10 3.001 10H5.328L4.794 11.781C4.723 12.016 4.687 12.26 4.687 12.504C4.687 13.88 5.809 15.001 7.189 15.001C7.571 15.001 7.915 14.789 8.087 14.446L10.171 10.277C10.256 10.107 10.427 10.001 10.618 10.001H13C14.103 10.001 15 9.104 15 8.001V3C15 1.897 14.103 1 13 1ZM9.276 9.829L7.193 13.996L7.188 13.999C6.36 13.999 5.686 13.328 5.686 12.502C5.686 12.356 5.707 12.21 5.75 12.067L6.478 9.642C6.524 9.491 6.495 9.327 6.401 9.2C6.306 9.073 6.158 8.998 6 8.998H3.001C2.449 8.998 2 8.551 2 8C2 7.9 2.016 7.799 2.047 7.699L3.39 3.401C3.753 2.236 4.232 1.998 4.838 1.998H11V8.998H10.618C10.046 8.998 9.531 9.316 9.276 9.827V9.829ZM14 8C14 8.551 13.552 9 13 9H12V2H13C13.552 2 14 2.449 14 3V8Z"})})}const He="https://levelcode.ai",ue="/ai/",cs=512,ds=/^(?:[A-Za-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9A-Fa-f]{2})+$/,xs=/%2f|%5c/i,Ze=new Set(["auth","authorize_editor","checkout","billing","signout","csrf"]);function fe(t){if(typeof t!="string"||t.length<=ue.length||t.length>cs||!t.startsWith(ue)||!ds.test(t)||t.includes("//")||xs.test(t))return null;const s=t.split("?",1)[0];if(s.split("/").some(r=>hs(r))||us(s.split("/")[2]??""))return null;let a;try{a=new URL(t,He)}catch{return null}return a.origin!==He||!a.pathname.startsWith(ue)?null:t}function us(t){const s=a=>(/^[a-z0-9_]*/.exec(a.toLowerCase())??[""])[0];if(Ze.has(s(t)))return!0;try{return Ze.has(s(decodeURIComponent(t)))}catch{return!1}}function hs(t){const s=t.replace(/%2e/gi,".");return s==="."||s===".."}function ge(){return window.location.pathname+window.location.search}function be(t){const s=fe(t);return s?`/login?${new URLSearchParams({next:s})}`:"/login"}function ms({editorSigningIn:t,next:s,webEditor:a}){if(t)return{kind:"editor"};const r=fe(s);return r?{kind:"route",to:r.slice(ue.length-1)}:a.loading?{kind:"wait"}:a.enabled&&a.url?{kind:"href",to:a.url}:{kind:"route",to:"/account"}}const ps="/api/levelcode/v1/web_editor",fs=1e4,gs={enabled:!1,url:null,loading:!0},se={enabled:!1,url:null,loading:!1};function bs(t){if(typeof t!="string")return null;let s;try{s=new URL(t.trim())}catch{return null}if(s.username||s.password)return null;if(s.protocol==="https:")return s.href;const a=s.hostname,r=a==="localhost"||a==="127.0.0.1"||a==="[::1]"||a.endsWith(".localhost");return s.protocol==="http:"&&r?s.href:null}function vs(t){const s=new URL(t);return s.searchParams.set("signin","1"),s.href}function js(t){if(!t||typeof t!="object")return se;const{enabled:s,url:a}=t,r=bs(a);return s===!0&&r?{enabled:!0,url:vs(r),loading:!1}:se}let Pe=gs,Ge=!1;const Ie=new Set;function oe(t){Pe.loading&&(Pe=t,Ie.forEach(s=>s()))}function ys(){if(Ge)return;Ge=!0;const t=setTimeout(()=>oe(se),fs);D(ps).then(s=>{clearTimeout(t);try{oe(js(s))}catch{oe(se)}},()=>{clearTimeout(t),oe(se)})}function Ns(t){return Ie.add(t),ys(),()=>{Ie.delete(t)}}const ws=()=>Pe;function z(){return o.useSyncExternalStore(Ns,ws)}function ks(){const t=re(),{loading:s,profile:a}=W(),r=z(),[n,l]=o.useState(null),[c,i]=o.useState(null),[h,m]=o.useState(null),[b,d]=o.useState(new Date().getFullYear()),[g,f]=o.useState(null);o.useEffect(()=>{!s&&!a&&t(be(ge()),{replace:!0})},[s,a,t]),o.useEffect(()=>{if(!a)return;let x=!0;return D("/api/levelcode/v1/account/usage").then(v=>{x&&l(v)}).catch(()=>{x&&f("We couldn’t load your usage right now. Please try again shortly.")}),()=>{x=!1}},[a]),o.useEffect(()=>{if(!a)return;let x=!0;return D("/api/levelcode/v1/account/models").then(v=>{x&&i(v)}).catch(()=>{}),()=>{x=!1}},[a]),o.useEffect(()=>{if(!a)return;let x=!0;return D(`/api/levelcode/v1/account/activity?year=${b}`).then(v=>{x&&m(v)}).catch(()=>{}),()=>{x=!1}},[a,b]);async function C(){try{const x=await D("/ai/billing",{method:"POST"});x.url&&ae(x.url)}catch{f("Could not open billing. Please try again.")}}async function N(){try{await D("/ai/signout",{method:"POST"})}catch{}t("/login",{replace:!0})}if(s||!a)return e.jsx($,{children:e.jsx("main",{className:"mx-auto max-w-4xl px-5 py-12"})});const p=n?Ke(n.input_used,n.input_cap):0,w=n?Ke(n.output_used,n.output_cap):0;return e.jsx($,{children:e.jsxs("main",{className:"mx-auto max-w-4xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:a.name?`Hi, ${a.name}`:"Your account"}),a.email?e.jsx("p",{className:"mt-2 font-mono text-[13px] text-[var(--c-text3)]",children:a.email}):null]}),e.jsxs("span",{className:"flex flex-wrap items-center gap-4",children:[r.enabled&&r.url?e.jsx("a",{href:r.url,title:"Open LevelCode in your browser",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"Open in browser →"}):null,a.role==="admin"?e.jsxs(e.Fragment,{children:[e.jsx(j,{to:"/admin",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"System dashboard →"}),e.jsx(j,{to:"/admin/referrals",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"Referrals →"})]}):null,e.jsxs("span",{className:"rounded-[3px] border border-[var(--c-line)] bg-[var(--c-surface)] px-2.5 py-1 font-mono text-[12px] text-[var(--c-text2)]",children:["plan · ",(n==null?void 0:n.plan)??a.plan??"free"]})]})]}),g?e.jsx("div",{className:"classic-card mt-10 p-8 text-[15px] text-[var(--c-text2)]",children:g}):n?e.jsxs("div",{className:"mt-10 grid gap-5 sm:grid-cols-2",children:[e.jsx(ze,{label:"Input tokens",used:n.input_used,cap:n.input_cap,pct:p}),e.jsx(ze,{label:"Output tokens",used:n.output_used,cap:n.output_cap,pct:w}),e.jsx("div",{className:"classic-card p-6 sm:col-span-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"classic-label",children:"billing period resets"}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--c-text)]",children:Ss(n.period_end)}),e.jsxs("div",{className:"mt-1 font-mono text-[12px] text-[var(--c-text3)]",children:["overage policy · ",n.overage_policy]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",onClick:C,className:"classic-button--quiet",children:"Manage billing"}),e.jsx(j,{to:"/pricing",className:"classic-button",children:"Upgrade"})]})]})})]}):null,c&&c.models.length?e.jsx(Cs,{models:c}):null,e.jsx("div",{className:"mt-6",children:e.jsx(ls,{activity:h,year:b,years:(h==null?void 0:h.years)??[b],onYear:d})}),e.jsx("button",{type:"button",onClick:N,className:"mt-10 text-[13px] text-[var(--c-accent)] hover:underline",children:"Sign out"})]})})}function Cs({models:t}){const s=t.budget_micros||0,a=t.ceiling_micros??s,r=t.spent_micros||0,n=t.credits_remaining_micros||0,l=a0?Math.min(Math.round(r/a*100),100):0,h=ss,m=d=>Fe(d)>0?$e(d):"—",b=d=>d.includes("/")?d.slice(d.indexOf("/")+1):d;return e.jsxs("div",{className:"classic-card mt-5 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsx("div",{className:"classic-label",children:l?"usage available now":"compute credits"}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-[var(--c-text2)]",children:[h(r)," / ",h(a)," · ",i,"%"]})]}),e.jsxs("div",{className:"mt-1 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:[h(n),e.jsxs("span",{className:"text-sm font-normal text-[var(--c-text3)]",children:[" ","credits ",l?"available now":"left this period"]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-[var(--c-line)]",children:e.jsx("div",{className:`h-full rounded-full ${i>=100?"bg-red-500":"bg-[var(--c-accent)]"}`,style:{width:`${i}%`}})}),l&&c?e.jsxs("div",{className:"mt-2 font-mono text-[11px] text-[var(--c-text3)]",children:["More unlocks ",c.toLocaleDateString(void 0,{month:"short",day:"numeric"})," · ",h(s)," ","credits total this cycle"]}):null,e.jsx("div",{className:"mt-6 lineno",children:"models on your plan"}),e.jsx("div",{className:"mt-3 overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[460px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"py-1.5 pr-3 font-normal",children:"model"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"credits/turn"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"≈ turns left"}),e.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"status"})]})}),e.jsx("tbody",{children:t.models.map(d=>e.jsxs("tr",{className:`border-b border-[var(--c-line)] ${d.live?"":"opacity-55"}`,children:[e.jsx("td",{className:"py-1.5 pr-3 text-[var(--c-text)]",children:b(d.id)}),e.jsxs("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",title:`${d.multiplier}× the baseline model`,children:[m(d.per_turn_micros),e.jsxs("span",{className:"sr-only",children:[" credits per turn, ",d.multiplier,"× the baseline model"]})]}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:d.live?(d.turns_left??0).toLocaleString(ne):"—"}),e.jsx("td",{className:"py-1.5 pl-3 text-right",children:d.live?e.jsx("span",{className:"text-[11px] text-[var(--c-accent)]",children:"live"}):e.jsx("span",{className:"rounded bg-[var(--c-line)] px-1.5 py-0.5 text-[10px] text-[var(--c-text3)]",children:"soon"})})]},d.id))})]})})]})}function ze({label:t,used:s,cap:a,pct:r}){const n=r>=100;return e.jsxs("div",{className:"classic-card p-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"classic-label",children:t}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-[var(--c-text2)]",children:[r,"%"]})]}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:[Xe(s),e.jsxs("span",{className:"text-sm font-normal text-[var(--c-text3)]",children:[" / ",Xe(a)]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-[var(--c-line)]",children:e.jsx("div",{className:`h-full rounded-full ${n?"bg-red-500":"bg-[var(--c-accent)]"}`,style:{width:`${Math.min(r,100)}%`}})})]})}function Ke(t,s){return!s||s<=0?0:Math.round(t/s*100)}function Xe(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString(ne)}function Ss(t){if(!t)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}function Ls(){const t=re(),{loading:s,profile:a}=W(),[r,n]=o.useState(null),[l,c]=o.useState(null),[i,h]=o.useState("input"),[m,b]=o.useState("desc"),[d,g]=o.useState(""),[f,C]=o.useState(""),[N,p]=o.useState(null),w=(a==null?void 0:a.role)==="admin";o.useEffect(()=>{s||(a?w||t("/account",{replace:!0}):t(be(ge()),{replace:!0}))},[s,a,w,t]),o.useEffect(()=>{if(!w)return;let u=!0;return D("/api/levelcode/v1/admin/summary").then(L=>u&&n(L)).catch(()=>u&&p("Couldn’t load the admin summary.")),()=>{u=!1}},[w]),o.useEffect(()=>{if(!w)return;let u=!0;const L=new URLSearchParams({sort:i,dir:m,limit:"200"});return d.trim()&&L.set("q",d.trim()),f&&L.set("plan",f),D(`/api/levelcode/v1/admin/users?${L.toString()}`).then(_=>u&&c(_)).catch(()=>u&&p("Couldn’t load users.")),()=>{u=!1}},[w,i,m,d,f]);const x=o.useMemo(()=>Object.keys((r==null?void 0:r.plans)??{}).sort(),[r]);function v(u){i===u?b(L=>L==="desc"?"asc":"desc"):(h(u),b(u==="email"||u==="plan"?"asc":"desc"))}return s||!w?e.jsx($,{children:e.jsx("main",{className:"mx-auto max-w-6xl px-5 py-12"})}):e.jsx($,{children:e.jsxs("main",{className:"mx-auto max-w-6xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:"System dashboard"}),e.jsx("p",{className:"mt-2 text-[14px] text-[var(--c-text3)]",children:"tokens burned · plans · geography · login health"})]}),e.jsx(j,{to:"/admin/referrals",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Referrals →"})]}),N?e.jsx("div",{className:"classic-card mt-8 p-6 text-[14px] text-red-500",children:N}):null,e.jsxs("div",{className:"mt-10 grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Q,{label:"users",value:H(r==null?void 0:r.users),sub:`${H(r==null?void 0:r.active_users)} active`}),e.jsx(Q,{label:"requests",value:H(r==null?void 0:r.requests),sub:Je(r==null?void 0:r.cost_micros)}),e.jsx(Q,{label:"input tokens",value:ie(r==null?void 0:r.input)}),e.jsx(Q,{label:"output tokens",value:ie(r==null?void 0:r.output)}),e.jsx(Q,{label:"auth attempts",value:H(r==null?void 0:r.auth_attempts),sub:`${H(r==null?void 0:r.auth_failures)} failed`,alert:((r==null?void 0:r.auth_failures)??0)>0}),e.jsx(ke,{label:"plans",map:r==null?void 0:r.plans}),e.jsx(ke,{label:"countries",map:r==null?void 0:r.countries}),e.jsx(ke,{label:"auth failures · country",map:r==null?void 0:r.auth_failures_by_country,alert:!0})]}),e.jsxs("div",{className:"mt-10 flex flex-wrap items-center gap-3",children:[e.jsx("input",{value:d,onChange:u=>g(u.target.value),placeholder:"Search email…",className:"w-full max-w-xs rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2 font-mono text-[13px] text-[var(--c-text)] outline-none focus:border-[var(--c-accent)] sm:w-auto"}),e.jsxs("select",{value:f,onChange:u=>C(u.target.value),className:"rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2 font-mono text-[13px] text-[var(--c-text2)] outline-none focus:border-[var(--c-accent)]",children:[e.jsx("option",{value:"",children:"all plans"}),x.map(u=>e.jsx("option",{value:u,children:u},u))]}),e.jsxs("span",{className:"font-mono text-[12px] text-[var(--c-text3)]",children:[H(l==null?void 0:l.total)," users"]})]}),e.jsx("div",{className:"classic-card mt-4 overflow-x-auto p-0",children:e.jsxs("table",{className:"w-full min-w-[880px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx(U,{label:"email",col:"email",sort:i,dir:m,onClick:v,align:"left"}),e.jsx(U,{label:"plan",col:"plan",sort:i,dir:m,onClick:v,align:"left"}),e.jsx(U,{label:"input",col:"input",sort:i,dir:m,onClick:v}),e.jsx(U,{label:"output",col:"output",sort:i,dir:m,onClick:v}),e.jsx(U,{label:"requests",col:"requests",sort:i,dir:m,onClick:v}),e.jsx(U,{label:"cost",col:"cost",sort:i,dir:m,onClick:v}),e.jsx("th",{className:"px-3 py-2 text-left font-normal",children:"country"}),e.jsx(U,{label:"auth",col:"auth_attempts",sort:i,dir:m,onClick:v}),e.jsx(U,{label:"last seen",col:"last_seen",sort:i,dir:m,onClick:v}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"reach"})]})}),e.jsxs("tbody",{children:[((l==null?void 0:l.users)??[]).map(u=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] hover:bg-[var(--c-surface)]",children:[e.jsxs("td",{className:"px-3 py-2 text-[var(--c-text)]",children:[u.email,u.role==="admin"?e.jsx("span",{className:"ml-2 rounded border border-[var(--c-accent)] px-1.5 py-0.5 text-[10px] text-[var(--c-accent)]",children:"admin"}):null]}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:u.plan}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:ie(u.input)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:ie(u.output)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:H(u.requests)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:Je(u.cost_micros)}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:u.country??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:e.jsxs("span",{className:u.auth_failures>0?"text-red-500":"text-[var(--c-text3)]",children:[u.auth_attempts,u.auth_failures>0?` · ${u.auth_failures}✗`:""]})}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text3)]",children:Ms(u.last_seen_at)}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("a",{className:"text-[var(--c-accent)] underline decoration-[var(--c-line)] underline-offset-2 hover:decoration-[var(--c-accent)]",href:`mailto:${u.email}`,children:"email"})})]},u.id)),l&&l.users.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:10,className:"px-3 py-6 text-center text-[var(--c-text3)]",children:"No users match."})}):null]})]})})]})})}function U({label:t,col:s,sort:a,dir:r,onClick:n,align:l="right"}){const c=a===s;return e.jsx("th",{className:`px-3 py-2 font-normal ${l==="right"?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>n(s),className:`inline-flex items-center gap-1 ${c?"text-[var(--c-text)]":"hover:text-[var(--c-text)]"}`,children:[t,e.jsx("span",{className:"text-[9px]",children:c?r==="desc"?"▼":"▲":"↕"})]})})}function Q({label:t,value:s,sub:a,alert:r}){return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("div",{className:"classic-label",children:t}),e.jsx("div",{className:"mt-1 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:s}),a?e.jsx("div",{className:`mt-1 font-mono text-[11px] ${r?"text-red-500":"text-[var(--c-text3)]"}`,children:a}):null]})}function ke({label:t,map:s,alert:a}){const r=Object.entries(s??{}).sort((n,l)=>l[1]-n[1]);return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("div",{className:"classic-label",children:t}),r.length?e.jsx("ul",{className:"mt-2 space-y-1 font-mono text-[12px]",children:r.slice(0,5).map(([n,l])=>e.jsxs("li",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--c-text2)]",children:n}),e.jsx("span",{className:`tabular-nums ${a?"text-red-500":"text-[var(--c-text3)]"}`,children:l})]},n))}):e.jsx("div",{className:"mt-2 font-mono text-[12px] text-[var(--c-text3)]",children:"—"})]})}function H(t){return(t??0).toLocaleString()}function ie(t){const s=t??0;return s>=1e6?`${+(s/1e6).toFixed(1)}M`:s>=1e3?`${+(s/1e3).toFixed(0)}K`:s.toLocaleString()}function Je(t){return`$${((t??0)/1e6).toFixed(2)}`}function Ms(t){if(!t)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?"—":s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}const Oe={},vt=me.createContext(Oe);function As(t){const s=me.useContext(vt);return me.useMemo(function(){return typeof t=="function"?t(s):{...s,...t}},[s,t])}function Ts(t){let s;return t.disableParentContext?s=typeof t.components=="function"?t.components(Oe):t.components||Oe:s=As(t.components),me.createElement(vt.Provider,{value:s},t.children)}const jt=[{group:"Get started",items:[{title:"Overview",href:"/docs",blurb:"What LevelCode is, how the AI layer is wired, and where to go next."},{title:"Quickstart",href:"/docs/quickstart",blurb:"Install the editor, connect a model provider, and run your first agent task end to end."},{title:"Install and setup",href:"/docs/setup",blurb:"Download and verify a build, run from source, and handle macOS first-launch prompts."},{title:"In your browser",href:"/docs/browser",blurb:"Open LevelCode in a browser tab, choose a folder or a scratch workspace, and see what stays in the Mac app.",requiresWebEditor:!0}]},{group:"AI",items:[{title:"Chat",href:"/docs/chat",blurb:"Ask questions about your codebase, with context pulled in automatically or pinned by hand."},{title:"Agent",href:"/docs/agent",blurb:"The autonomous loop: planning, multi-file edits, approval-gated commands, self-verification, and checkpoints."},{title:"Edit",href:"/docs/edit",blurb:"Select code, describe the change, and review it as a diff before anything lands."},{title:"Autocomplete",href:"/docs/autocomplete",blurb:"Inline ghost-text completion as you type, and how to tune it."},{title:"Providers and models",href:"/docs/providers",blurb:"Bring your own key for any supported provider, run models locally with Ollama, or use the metered gateway."}]},{group:"MCP",items:[{title:"MCP servers",href:"/docs/mcp",blurb:"Connect Model Context Protocol servers to give the agent tools LevelCode doesn't ship, and the approval model that governs them."},{title:"Server recipes",href:"/docs/mcp-recipes",blurb:"Working configurations for GitHub, the filesystem, image generation, and hosted servers — plus how to keep API tokens out of settings.json."}]},{group:"The editor",items:[{title:"Power editing",href:"/docs/power-editing",blurb:"The Notepad++ pack: macros, column mode, line operations, encoding and line-ending control, big-file mode."},{title:"Customization",href:"/docs/customization",blurb:"The init script, package authoring with hot reload, keymap presets, and themes."},{title:"Import and updates",href:"/docs/import-and-updates",blurb:"Bring your settings over from VS Code, VSCodium, or Cursor, install extensions from Open VSX, and stay on the latest build."}]},{group:"Account",items:[{title:"Cloud and billing",href:"/docs/cloud",blurb:"Sign in, understand credits and usage, and decide between your own key and the metered gateway."}]},{group:"Help",items:[{title:"Troubleshooting",href:"/docs/troubleshooting",blurb:"Fixes for first-launch blocks, provider and key errors, agent and terminal problems, and update failures."}]}],yt=jt.flatMap(t=>t.items),Nt=(t,s)=>!t.requiresWebEditor||s.webEditor;function _s(t){return jt.map(s=>({...s,items:s.items.filter(a=>Nt(a,t))})).filter(s=>s.items.length>0)}function Es(t,s={webEditor:!1}){const a=yt.filter(n=>Nt(n,s)),r=a.findIndex(n=>n.href===t);return r===-1?{prev:null,next:null}:{prev:r>0?a[r-1]:null,next:re.jsxs("div",{className:"mb-6 last:mb-0",children:[e.jsx("p",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wide text-[var(--c-text3)]",children:r.group}),e.jsx("ul",{className:"space-y-0.5 border-l border-[var(--c-line)]",children:r.items.map(n=>{const l=s===n.href;return e.jsx("li",{children:e.jsx(j,{to:n.href,onClick:t,"aria-current":l?"page":void 0,className:`-ml-px block border-l py-1 pl-3 transition-colors ${l?"border-[var(--c-accent)] font-medium text-[var(--c-accent)]":"border-transparent text-[var(--c-text2)] hover:border-[var(--c-line)] hover:text-[var(--c-text)]"}`,children:n.title})},n.href)})})]},r.group))})}function $s(){const{pathname:t}=X(),[s,a]=o.useState(!1);return o.useEffect(()=>a(!1),[t]),e.jsxs("div",{className:"border-b border-[var(--c-line)] lg:hidden",children:[e.jsxs("button",{type:"button",onClick:()=>a(r=>!r),"aria-expanded":s,"aria-controls":"docs-mobile-nav",className:"flex w-full items-center gap-2 px-5 py-3 text-[14px] font-medium text-[var(--c-text)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:`text-[var(--c-text3)] transition-transform duration-150 ${s?"rotate-90":""}`,children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})}),"Documentation menu"]}),s?e.jsx("div",{id:"docs-mobile-nav",className:"px-5 pb-5",children:e.jsx(wt,{onNavigate:()=>a(!1)})}):null]})}function Rs(){return e.jsx("aside",{className:"hidden lg:block",children:e.jsx("div",{className:"sticky top-0 max-h-screen overflow-y-auto py-12 pr-6",children:e.jsx(wt,{})})})}function Ps({revision:t=0}){const{pathname:s}=X(),[a,r]=o.useState([]),[n,l]=o.useState("");return o.useEffect(()=>{const c=document.querySelector("article");if(!c)return;const i=Array.from(c.querySelectorAll("h2[id], h3[id]")).map(h=>{const m=h.cloneNode(!0);return m.querySelectorAll("a").forEach(b=>b.remove()),{id:h.id,text:(m.textContent??"").trim(),level:Number(h.tagName[1])}});r(h=>h.length===i.length&&h.every((m,b)=>m.id===i[b].id)?h:i)},[s,t]),o.useEffect(()=>{if(a.length===0)return;const c=()=>{let h=a[0].id;for(const m of a){const b=document.getElementById(m.id);b&&b.getBoundingClientRect().top<=120&&(h=m.id)}window.innerHeight+window.scrollY>=document.body.offsetHeight-2&&(h=a[a.length-1].id),l(h)};return c(),window.addEventListener("scroll",c,{passive:!0}),()=>window.removeEventListener("scroll",c)},[a]),a.length<2?null:e.jsxs("nav",{"aria-labelledby":"toc-heading",className:"text-[13.5px]",children:[e.jsx("p",{id:"toc-heading",className:"mb-3 font-semibold text-[var(--c-text)]",children:"On this page"}),e.jsx("ul",{className:"space-y-1.5 border-l border-[var(--c-line)]",children:a.map(c=>e.jsx("li",{children:e.jsx("a",{href:`#${c.id}`,"aria-current":n===c.id?"location":void 0,className:`-ml-px block border-l py-0.5 leading-snug transition-colors ${c.level===3?"pl-6":"pl-3"} ${n===c.id?"border-[var(--c-accent)] text-[var(--c-accent)]":"border-transparent text-[var(--c-text2)] hover:text-[var(--c-text)]"}`,children:c.text})},c.id))})]})}function kt(t,s=24){const a=Math.max(0,t.getBoundingClientRect().top+window.scrollY-s);return window.scrollTo({top:a,behavior:"instant"}),Math.abs(window.scrollY-a)<=2}function Is(){window.scrollTo({top:0,behavior:"instant"})}function Os(t){return t.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-")}function Bs({title:t,defaultOpen:s=!1,children:a}){const r=Os(t),n=o.useRef(null),[l,c]=o.useState(s);return o.useEffect(()=>{const i=()=>{decodeURIComponent(window.location.hash.slice(1))===r&&(c(!0),requestAnimationFrame(()=>{n.current&&kt(n.current)}))};return i(),window.addEventListener("hashchange",i),()=>window.removeEventListener("hashchange",i)},[r]),e.jsxs("details",{ref:n,id:r,open:l,onToggle:i=>c(i.currentTarget.open),className:"group scroll-mt-8 border-b border-[var(--c-line)] last:border-b-0 [&_>_summary_>_svg]:open:rotate-90",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 py-3 text-[15px] font-medium text-[var(--c-text)] marker:content-none hover:text-[var(--c-accent)] [&::-webkit-details-marker]:hidden",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:"shrink-0 text-[var(--c-text3)] transition-transform duration-150",children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})}),t]}),e.jsx("div",{className:"pb-4 pl-[20px]",children:a})]})}function qs({children:t}){return e.jsx("div",{className:"my-6 rounded-md border border-[var(--c-line)] px-4",children:t})}function Fs({title:t,href:s,children:a}){const r=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[15px] font-semibold text-[var(--c-text)]",children:[t,s?e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:"text-[var(--c-text3)] transition-transform duration-150 group-hover:translate-x-0.5 group-hover:text-[var(--c-accent)]",children:e.jsx("path",{d:"M8.22 2.97a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06l2.97-2.97H3.75a.75.75 0 0 1 0-1.5h7.44L8.22 4.03a.75.75 0 0 1 0-1.06Z"})}):null]}),a?e.jsx("span",{className:"mt-1.5 block text-[14px] leading-relaxed text-[var(--c-text2)]",children:a}):null]}),n="group block rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-4 no-underline transition-colors";return s?e.jsx(j,{to:s,className:`${n} hover:border-[var(--c-accent)]`,children:r}):e.jsx("div",{className:n,children:r})}function Us({cols:t=2,children:s}){const a=t===1?"sm:grid-cols-1":t===3?"sm:grid-cols-3":"sm:grid-cols-2";return e.jsx("div",{className:`my-6 grid grid-cols-1 gap-3 ${a}`,children:s})}const Ws={note:{wrap:"border-[var(--c-line)] bg-[var(--c-surface)]",icon:"text-[var(--c-text3)]",label:"Note",path:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"},tip:{wrap:"border-[#149963]/30 bg-[#149963]/[0.08]",icon:"text-[#149963]",label:"Tip",path:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"},info:{wrap:"border-[var(--c-accent)]/30 bg-[var(--c-accent)]/[0.07]",icon:"text-[var(--c-accent)]",label:"Info",path:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"},warning:{wrap:"border-[#d19a66]/40 bg-[#d19a66]/[0.1]",icon:"text-[#b3701a]",label:"Warning",path:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}};function ve({variant:t,children:s}){const a=Ws[t];return e.jsxs("div",{className:`my-5 flex gap-3 rounded-md border px-4 py-3 ${a.wrap}`,children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor","aria-hidden":!0,className:`mt-[3px] shrink-0 ${a.icon}`,children:e.jsx("path",{d:a.path})}),e.jsxs("div",{className:"min-w-0 text-[15px] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:[e.jsxs("span",{className:"sr-only",children:[a.label,": "]}),s]})]})}const Vs=({children:t})=>e.jsx(ve,{variant:"note",children:t}),Ys=({children:t})=>e.jsx(ve,{variant:"tip",children:t}),Hs=({children:t})=>e.jsx(ve,{variant:"info",children:t}),Zs=({children:t})=>e.jsx(ve,{variant:"warning",children:t});function Gs({children:t,...s}){const a=o.useRef(null),[r,n]=o.useState(!1),[l,c]=o.useState(null);o.useEffect(()=>{var h,m;c(((m=(h=a.current)==null?void 0:h.querySelector("pre"))==null?void 0:m.getAttribute("data-language"))??null)},[]);async function i(){var m,b;const h=((b=(m=a.current)==null?void 0:m.querySelector("pre"))==null?void 0:b.textContent)??"";try{await navigator.clipboard.writeText(h),n(!0),window.setTimeout(()=>n(!1),1600)}catch{}}return e.jsxs("figure",{ref:a,...s,className:"group relative my-5 overflow-hidden rounded-md border border-black/20 bg-[#0d1321] text-[#abb2bf] [&_code]:grid [&_code]:rounded-none [&_code]:border-0 [&_code]:bg-transparent [&_code]:p-0 [&_code]:font-mono [&_code]:text-[13.5px] [&_code]:leading-[1.65] [&_code]:text-inherit [&_pre]:overflow-x-auto [&_pre]:bg-transparent [&_pre]:py-4 [&_[data-line]]:px-4",children:[e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex items-center gap-2",children:[l?e.jsx("span",{className:"select-none font-mono text-[11px] uppercase tracking-wide text-[#7d8695] opacity-0 transition-opacity group-hover:opacity-100",children:l}):null,e.jsx("button",{type:"button",onClick:i,"aria-label":r?"Copied to clipboard":"Copy code",className:"rounded-[4px] border border-white/10 bg-white/5 px-2 py-1 font-mono text-[11px] text-[#b9c0cb] opacity-0 transition-all hover:border-white/25 hover:bg-white/10 focus-visible:opacity-100 group-hover:opacity-100",children:r?"Copied":"Copy"})]}),t]})}const Qe={cmd:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",opt:"⌥",shift:"⇧",enter:"↩",return:"↩",tab:"⇥",escape:"⎋",esc:"⎋",space:"Space",backspace:"⌫",delete:"⌦",up:"↑",down:"↓",left:"←",right:"→"};function zs(t){const s=t.trim().toLowerCase();return Qe[s]?Qe[s]:t.trim().length===1?t.trim().toUpperCase():t.trim()}function Ks({keys:t}){const s=t.trim().split(/\s+/);return e.jsx("span",{className:"inline-flex items-baseline gap-1 whitespace-nowrap align-baseline",children:s.map((a,r)=>e.jsx("kbd",{className:"inline-flex items-center rounded-[4px] border border-[var(--c-line)] bg-[var(--c-surface)] px-[6px] py-[2px] font-mono text-[12.5px] font-medium text-[var(--c-text)]",children:a.split("+").map(zs).join("")},`${a}-${r}`))})}function Xs({children:t}){return e.jsx(e.Fragment,{children:t})}function Js(t){var s;return o.isValidElement(t)&&typeof((s=t.props)==null?void 0:s.title)=="string"}function Qs({children:t}){const s=o.Children.toArray(t).filter(Js);return s.length===0?null:e.jsx("ol",{className:"my-6 list-none space-y-0 pl-0",children:s.map((a,r)=>e.jsxs("li",{className:"relative pb-6 pl-10 last:pb-0",children:[r*:first-child]:mt-0 [&>*:last-child]:mb-0",children:a.props.children})]},`${a.props.title}-${r}`))})}function ea({children:t}){return e.jsx(e.Fragment,{children:t})}function ta(t){var s;return o.isValidElement(t)&&typeof((s=t.props)==null?void 0:s.title)=="string"}function sa({children:t}){const s=o.Children.toArray(t).filter(ta),[a,r]=o.useState(0),n=o.useId();if(s.length===0)return null;const l=s[Math.min(a,s.length-1)];return e.jsxs("div",{className:"my-6",children:[e.jsx("div",{role:"tablist","aria-orientation":"horizontal",className:"flex flex-wrap gap-1 border-b border-[var(--c-line)]",children:s.map((c,i)=>{const h=i===a;return e.jsx("button",{type:"button",role:"tab",id:`${n}-tab-${i}`,"aria-selected":h,"aria-controls":`${n}-panel-${i}`,onClick:()=>r(i),className:`-mb-px border-b-2 px-3 py-2 text-[14px] font-medium transition-colors ${h?"border-[var(--c-accent)] text-[var(--c-text)]":"border-transparent text-[var(--c-text2)] hover:border-[var(--c-line)] hover:text-[var(--c-text)]"}`,children:c.props.title},`${c.props.title}-${i}`)})}),e.jsx("div",{role:"tabpanel",id:`${n}-panel-${a}`,"aria-labelledby":`${n}-tab-${a}`,className:"pt-4",children:l.props.children})]})}function Ce(t){const s=`h${t}`,a=t===2?"mt-12 text-[24px] font-semibold":t===3?"mt-9 text-[18.5px] font-semibold":"mt-7 text-[16px] font-semibold";return function({id:n,children:l,...c}){return e.jsxs(s,{id:n,className:`group mb-3 scroll-mt-8 text-[var(--c-text)] ${a}`,...c,children:[l,n?e.jsx("a",{href:`#${n}`,"aria-label":"Link to this section",className:"ml-2 text-[var(--c-text3)] opacity-0 transition-opacity hover:text-[var(--c-accent)] focus-visible:opacity-100 group-hover:opacity-100",children:"#"}):null]})}}const et="font-medium text-[var(--c-accent)] underline decoration-[var(--c-accent)]/30 underline-offset-2 transition-colors hover:decoration-[var(--c-accent)]",aa={h1:({children:t,...s})=>e.jsx("h1",{className:"mb-4 text-[34px] font-bold leading-tight tracking-tight text-[var(--c-text)]",...s,children:t}),h2:Ce(2),h3:Ce(3),h4:Ce(4),p:t=>e.jsx("p",{className:"my-4 text-[16px] leading-[1.7] pretty",...t}),a:({href:t="",children:s,...a})=>{if(t.startsWith("/"))return e.jsx(j,{to:t,className:et,...a,children:s});const r=!t.startsWith("#");return e.jsx("a",{href:t,className:et,...r?{target:"_blank",rel:"noopener noreferrer"}:{},...a,children:s})},ul:t=>e.jsx("ul",{className:"my-4 list-disc space-y-2 pl-5 marker:text-[var(--c-text3)]",...t}),ol:t=>e.jsx("ol",{className:"my-4 list-decimal space-y-2 pl-5 marker:text-[var(--c-text3)]",...t}),li:t=>e.jsx("li",{className:"leading-[1.7] [&>ol]:my-2 [&>ul]:my-2",...t}),strong:t=>e.jsx("strong",{className:"font-semibold text-[var(--c-text)]",...t}),code:t=>e.jsx("code",{className:"rounded-[3px] border border-[var(--c-line)] bg-[var(--c-surface)] px-[5px] py-[1.5px] font-mono text-[0.875em] text-[var(--c-text)]",...t}),figure:({children:t,...s})=>"data-rehype-pretty-code-figure"in s?e.jsx(Gs,{...s,children:t}):e.jsx("figure",{className:"my-6",...s,children:t}),blockquote:t=>e.jsx("blockquote",{className:"my-5 border-l-2 border-[var(--c-line)] pl-4 text-[var(--c-text2)] [&>p]:my-2",...t}),hr:()=>e.jsx("hr",{className:"my-10 border-[var(--c-line)]"}),table:t=>e.jsx("div",{className:"my-6 overflow-x-auto rounded-md border border-[var(--c-line)]",children:e.jsx("table",{className:"w-full border-collapse text-left text-[14.5px]",...t})}),thead:t=>e.jsx("thead",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",...t}),th:t=>e.jsx("th",{className:"px-4 py-2.5 font-semibold text-[var(--c-text)] [&_code]:text-[0.9em]",...t}),td:t=>e.jsx("td",{className:"border-t border-[var(--c-line)] px-4 py-2.5 align-top leading-[1.6] [&_code]:text-[0.9em]",...t}),Tabs:sa,Tab:ea,Accordion:Bs,AccordionGroup:qs,Card:Fs,CardGroup:Us,Steps:Qs,Step:Xs,Note:Vs,Tip:Ys,Info:Hs,Warning:Zs,Kbd:Ks};function ra(){const[t,s]=o.useState(0);return o.useEffect(()=>{const a=document.querySelector("article");if(!a)return;const r=new MutationObserver(()=>s(n=>n+1));return r.observe(a,{childList:!0,subtree:!0}),()=>r.disconnect()},[]),t}function na(t){o.useEffect(()=>{const s=yt.find(c=>c.href===t),a=document.title;document.title=s?`${s.title} — LevelCode Docs`:"LevelCode Docs";const r=document.querySelector('meta[name="description"]'),n=(r==null?void 0:r.hasAttribute("content"))??!1,l=(r==null?void 0:r.getAttribute("content"))??null;return r&&s&&r.setAttribute("content",s.blurb),()=>{document.title=a,r&&(n&&l!==null?r.setAttribute("content",l):r.removeAttribute("content"))}},[t])}function la(t,s,a){const r=o.useRef("");o.useEffect(()=>{const n=t+s;if(!s){r.current!==n&&(r.current=n,Is());return}if(r.current===n)return;const l=document.getElementById(decodeURIComponent(s.slice(1)));if(!l)return;const c=()=>{kt(l)&&(r.current=n)};c(),requestAnimationFrame(c)},[t,s,a])}function oa({children:t}){const{pathname:s,hash:a}=X(),r=ra();return na(s),la(s,a,r),e.jsxs($,{children:[e.jsx($s,{}),e.jsx("div",{className:"mx-auto max-w-[88rem] px-5",children:e.jsxs("div",{className:"lg:grid lg:grid-cols-[14rem_minmax(0,1fr)] lg:gap-10 xl:grid-cols-[14rem_minmax(0,1fr)_13rem]",children:[e.jsx(Rs,{}),e.jsxs("main",{className:"min-w-0 py-10 lg:py-12",children:[e.jsx("article",{className:"max-w-[46rem]",children:e.jsx(Ts,{components:aa,children:t})}),e.jsx("div",{className:"max-w-[46rem]",children:e.jsx(Ds,{})})]}),e.jsx("div",{className:"hidden xl:block",children:e.jsx("div",{className:"sticky top-0 max-h-screen overflow-y-auto py-12",children:e.jsx(Ps,{revision:r})})})]})})]})}const ia=o.lazy(()=>Ut(()=>import("./bundle-tvCSkI-U.js"),__vite__mapDeps([0,1])));function Ct({slug:t=""}){return e.jsx(oa,{children:e.jsx(o.Suspense,{fallback:e.jsx(ca,{}),children:e.jsx(ia,{slug:t})})})}function ca(){return e.jsxs("div",{"aria-hidden":!0,className:"animate-pulse",children:[e.jsx("div",{className:"h-9 w-2/3 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-6 h-4 w-full rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-11/12 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-4/5 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-10 h-6 w-1/3 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-5 h-4 w-full rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-10/12 rounded bg-[var(--c-surface)]"}),e.jsx("span",{className:"sr-only",children:"Loading documentation…"})]})}const da="https://github.com/levelcodeai/levelcode",xa="levelcode://levelcode.levelcode-ai/launch";function ua(){const{profile:t}=W(),s=z();return e.jsx("header",{className:"fixed inset-x-0 top-0 z-50 border-b border-rule bg-paper/85 backdrop-blur-md",children:e.jsxs("nav",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-5",children:[e.jsxs(j,{to:"/",className:"font-display text-[15px] font-bold tracking-tightest",children:["LevelCode ",e.jsx("span",{className:"font-medium text-faint",children:"Cloud"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j,{to:"/pricing",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Pricing"}),e.jsx("a",{href:da,target:"_blank",rel:"noreferrer",className:"hidden items-center gap-2 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:"GitHub"}),e.jsx(j,{to:"/download",className:"rounded-full bg-ink px-4 py-1.5 text-sm font-semibold text-paper transition-colors hover:bg-flame",children:"Download"}),t?e.jsxs(e.Fragment,{children:[t.role==="admin"?e.jsx(j,{to:"/admin",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Admin"}):null,e.jsxs("a",{href:xa,title:"Open the LevelCode editor (signs it into this account)",className:"inline-flex items-center gap-1 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink",children:["IDE ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}),s.enabled&&s.url?e.jsxs("a",{href:s.url,title:"Open LevelCode in your browser","aria-label":"Open LevelCode in your browser",className:"hidden items-center gap-1 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:["Browser ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}):null,e.jsx(j,{to:"/account",title:"Account","aria-label":"Account",className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-rule bg-card text-[12px] font-semibold text-ink transition-colors hover:border-ink",children:gt(t.name,t.email)})]}):e.jsx(j,{to:"/login",className:"hidden items-center gap-2 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:"Sign in"})]})]})})}function St(){if(typeof navigator>"u")return!1;const t=navigator.userAgent||"",s=/Mac/i.test(navigator.platform||"")||/Macintosh/.test(t),a=s&&(navigator.maxTouchPoints??0)>1;return s&&!a}async function ha(){var s,a;if(!St())return"not-mac";const t=navigator;try{const r=await((a=(s=t.userAgentData)==null?void 0:s.getHighEntropyValues)==null?void 0:a.call(s,["architecture"]));if((r==null?void 0:r.architecture)==="arm")return"arm64";if((r==null?void 0:r.architecture)==="x86")return"x64"}catch{}try{const r=document.createElement("canvas"),n=r.getContext("webgl")||r.getContext("experimental-webgl"),l=n==null?void 0:n.getExtension("WEBGL_debug_renderer_info"),c=l&&n?String(n.getParameter(l.UNMASKED_RENDERER_WEBGL)):"";if(/apple/i.test(c))return"arm64";if(/intel|amd|radeon/i.test(c))return"x64"}catch{}return"unknown-mac"}const tt="https://github.com/levelcodeai/levelcode/releases/latest",Se={arm64:`${tt}/download/LevelCode-arm64.dmg`,x64:`${tt}/download/LevelCode-x64.dmg`};function ma(){const[t,s]=o.useState("unknown-mac"),a=z();o.useEffect(()=>{let c=!0;return ha().then(i=>{c&&s(i)}),()=>{c=!1}},[]);const r=t==="x64"?"x64":"arm64",n=r==="arm64"?"Apple Silicon":"Intel",l=t==="not-mac";return e.jsxs(e.Fragment,{children:[e.jsx(ua,{}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-24",children:[e.jsx("div",{className:"lineno mb-4",children:"06 · download"}),e.jsxs("h1",{className:"font-display text-[clamp(2rem,5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-balance",children:["Download ",e.jsx("span",{className:"pp",children:"LevelCode"})," for macOS"]}),e.jsx("p",{className:"mt-5 max-w-xl text-[17px] leading-relaxed text-sub pretty",children:"The AI-native editor — your plan, keys, and usage in one place. Universal on any modern Mac; pick Intel if you’re on an older one."}),l?e.jsx("div",{className:"surface mt-8 p-5 text-[14px] text-sub",children:"LevelCode is a macOS app for now. Grab it on your Mac — or download a build below to move over."}):null,e.jsxs("div",{className:"mt-9 flex flex-col items-start gap-3",children:[e.jsxs("a",{href:Se[r],className:"btn-primary text-[15px]",download:!0,children:["Download for ",n," Mac"]}),e.jsx("p",{className:"font-mono text-[12px] text-faint",children:"Universal .dmg · latest release · macOS 12 Monterey or later"}),a.enabled?e.jsxs("p",{className:"text-[15px] text-sub",children:["Or"," ",e.jsx(j,{to:"/web",className:"text-ink underline decoration-ink/30 underline-offset-4 transition-colors hover:text-flame hover:decoration-flame",children:"open it in your browser"}),"."]}):null]}),e.jsx("div",{className:"mt-10 lineno",children:"all builds"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[e.jsx("a",{href:Se.arm64,className:"btn-ghost text-[14px]",download:!0,children:"Apple Silicon (M1–M4)"}),e.jsx("a",{href:Se.x64,className:"btn-ghost text-[14px]",download:!0,children:"Intel Mac (x64)"})]}),e.jsx("p",{className:"mt-4 font-mono text-[12px] text-faint",children:"Not sure which Mac you have? Apple menu → About This Mac. “Apple M…” chip → Apple Silicon; “Intel” → Intel."})]})]})}const O=t=>({t,c:"text-[#c58aff]"}),st=t=>({t,c:"text-[#7fd88f]"}),Z=t=>({t,c:"text-[#9fb4ff]"}),Le=t=>({t,c:"text-[#5b6172]"}),Me=t=>({t,c:"text-[#e6a86b]"}),y=t=>({t}),B=[{id:"generate",label:"Generate",file:"payments/refund_service.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Generate."})," Describe the change in plain language — LevelCode writes idiomatic code in your project’s style, right in the buffer."]}),chat:[{who:"you",text:"Add idempotency to RefundService — same request twice must not double-refund."},{who:"ai",text:"Adding an idempotency key check backed by Redis, with a 24h TTL. Writing it now…"}],code:[{no:"12",toks:[O("class"),y(" "),Z("RefundService")]},{no:"13",toks:[y(" "),O("def"),y(" "),Z("call"),y("(charge, key:)")]},{no:"14",toks:[y(" "),O("return"),y(" cached(key) "),O("if"),y(" seen?(key)")]},{no:"15",toks:[y(" result = gateway.refund(charge)")]},{no:"16",toks:[y(" remember(key, result, ttl: "),Me("24"),y(".hours)")]},{no:"17",toks:[y(" result")]},{no:"18",toks:[y(" "),O("end")]},{no:"19",toks:[O("end")]}]},{id:"refactor",label:"Refactor",file:"api/orders_controller.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Refactor."})," Select any block and ask. LevelCode restructures across files, keeping behavior identical and diffs reviewable."]}),chat:[{who:"you",text:"This controller does too much. Extract the pricing logic."},{who:"ai",text:"Extracting to app/services/pricing_calculator.rb and updating 3 call sites. Behavior unchanged — diff ready."}],code:[{no:"40",toks:[Le("# before: 62 lines in controller")]},{no:"41",toks:[O("def"),y(" "),Z("create")]},{no:"42",toks:[y(" total = "),Z("PricingCalculator")]},{no:"43",toks:[y(" .new(cart, coupon: params[:coupon])")]},{no:"44",toks:[y(" .total")]},{no:"45",toks:[y(" order = "),Z("Order"),y(".create!(total:)")]},{no:"46",toks:[y(" render json: order")]},{no:"47",toks:[O("end")]}]},{id:"explain",label:"Explain",file:"legacy/billing_engine.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Explain."})," Point at unfamiliar code — get a walkthrough of what it does, why it exists, and where it’s called from."]}),chat:[{who:"you",text:"What is this proration branch actually doing?"},{who:"ai",text:"It splits the billing period at the plan-change date, credits unused time on the old plan, and charges the remainder at the new rate. Called from 2 places — both webhooks."}],code:[{no:"88",toks:[O("if"),y(" plan_changed_mid_cycle?")]},{no:"89",toks:[y(" credit = unused_ratio * old_rate")]},{no:"90",toks:[y(" charge = remaining_ratio * new_rate")]},{no:"91",toks:[y(" invoice.adjust(credit:, charge:)")]},{no:"92",toks:[O("end")]},{no:"93",toks:[Le("# ← LevelCode: proration on plan change")]}]},{id:"test",label:"Test",file:"spec/refund_service_spec.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Test."})," LevelCode drafts the spec, runs it, reads the failure, and fixes the code — a full red-green loop without leaving the editor."]}),chat:[{who:"you",text:"Write specs for the double-refund case."},{who:"ai",text:"Spec written. Running… 1 failure: cache key ignored currency. Patched — all green ✓"}],code:[{no:"05",toks:[Z("it"),y(" "),st('"refunds only once per key"'),y(" "),O("do")]},{no:"06",toks:[y(" "),Me("2"),y(".times { service.call(charge, key:) }")]},{no:"07",toks:[y(" expect(gateway.refunds.count).to eq("),Me("1"),y(")")]},{no:"08",toks:[O("end")]},{no:"09",toks:[y("")]},{no:"10",toks:[st("✓ 14 examples, 0 failures — 0.42s")]}]},{id:"review",label:"Review",file:"PR #241 · fix race in webhook retry — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Review."})," Before you push, LevelCode flags edge cases, security issues, and style drift — like a senior reviewer on every commit."]}),chat:[{who:"you",text:"Review this PR before I push."},{who:"ai",text:"One real issue: retry loop can fire twice if the worker restarts between enqueue and ack. Suggesting a fix inline."}],code:[{no:"21",toks:[Le("# ⚠ LevelCode: not restart-safe")]},{no:"22",toks:[{t:"- retry_later(webhook)",c:"text-[#e06c75]"}]},{no:"23",toks:[{t:"+ ",c:"text-[#7fd88f]"},Z("WebhookRetryJob")]},{no:"24",toks:[{t:"+ ",c:"text-[#7fd88f]"},y(" .set(wait: backoff(attempt))")]},{no:"25",toks:[{t:"+ ",c:"text-[#7fd88f]"},y(" .perform_later(webhook.id,")]},{no:"26",toks:[{t:"+ ",c:"text-[#7fd88f]"},y(" lock: webhook.lock_token)")]}]}];function pa(){const[t,s]=o.useState(!1),[a,r]=o.useState(0),[n,l]=o.useState(!0),[c,i]=o.useState(!0),[h,m]=o.useState(0),[b,d]=o.useState(0),[g,f]=o.useState(0),[C,N]=o.useState(!1),[p,w]=o.useState(0),x=o.useRef(null),v=o.useRef(null),u=o.useRef([]),L=o.useRef([]),_=o.useRef([]),q=B[a],V=q.duration??9;o.useEffect(()=>{window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(s(!0),l(!1),d(B[a].code.length))},[]),o.useLayoutEffect(()=>{var M;const S=()=>{const k=u.current[a],T=v.current;if(!k||!T||!k.parentElement)return;const R=k.getBoundingClientRect(),Y=k.parentElement.getBoundingClientRect();T.style.width=`${R.width}px`,T.style.transform=`translateX(${R.left-Y.left}px)`};return S(),window.addEventListener("resize",S),(M=document.fonts)==null||M.ready.then(S).catch(()=>{}),()=>window.removeEventListener("resize",S)},[a,t]),o.useEffect(()=>{const S=x.current;if(!S)return;const M=new IntersectionObserver(([k])=>i(k.isIntersecting),{threshold:.25});return M.observe(S),()=>M.disconnect()},[]),o.useEffect(()=>{if(a===g)return;N(!0);const S=setTimeout(()=>{f(a),N(!1)},200);return()=>clearTimeout(S)},[a,g]),o.useEffect(()=>{if(t||(_.current.forEach(clearTimeout),_.current=[],!n||!c))return;const S=L.current[a],M=S?Array.from(S.querySelectorAll("[data-text]")):[];M.forEach(T=>T.textContent=""),d(0),w(T=>T+1);let k=300;return M.forEach(T=>{const R=T.dataset.text??"";for(let Y=1;Y<=R.length;Y++)k+=14,_.current.push(setTimeout(()=>T.textContent=R.slice(0,Y),k));k+=350}),B[a].code.forEach((T,R)=>{k+=320,_.current.push(setTimeout(()=>d(R+1),k))}),_.current.push(setTimeout(()=>r(T=>(T+1)%B.length),(B[a].duration??9)*1e3)),()=>{_.current.forEach(clearTimeout),_.current=[]}},[a,n,c,h,t]);const le=()=>{l(S=>{const M=!S;return M&&m(k=>k+1),M})},Ve=S=>t?B[S].code.length:S===a?b:0;return e.jsxs("div",{ref:x,className:"relative",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-1/2 top-1/2 h-[70%] w-[85%] -translate-x-1/2 -translate-y-1/2 rounded-full bg-flame/10 blur-3xl"}),e.jsxs("div",{role:"tablist","aria-label":"LevelCode capabilities",className:"relative mx-auto mb-6 flex w-max max-w-full gap-1 overflow-x-auto rounded-full border border-rule bg-card p-1.5 [scrollbar-width:none]",children:[e.jsx("span",{ref:v,"aria-hidden":!0,className:"absolute left-0 top-1.5 h-[calc(100%-12px)] rounded-full bg-flame shadow-[0_0_18px_rgb(var(--accent-rgb)/0.45)] transition-[transform,width] duration-300 ease-out"}),B.map((S,M)=>e.jsx("button",{ref:k=>{u.current[M]=k},role:"tab",id:`sc-tab-${S.id}`,"aria-selected":M===a,"aria-controls":`sc-pane-${S.id}`,onClick:()=>{M===a?m(k=>k+1):r(M)},onKeyDown:k=>{var T,R;k.key==="ArrowRight"&&((T=u.current[(M+1)%B.length])==null||T.focus()),k.key==="ArrowLeft"&&((R=u.current[(M-1+B.length)%B.length])==null||R.focus())},className:`relative z-10 whitespace-nowrap rounded-full px-5 py-2 text-sm font-semibold transition-colors ${M===a?"text-paper":"text-sub hover:text-ink"}`,children:S.label},S.id))]}),e.jsx("p",{"aria-live":"polite",className:`mx-auto mb-8 min-h-[48px] max-w-xl text-center text-[15px] leading-relaxed text-sub transition-opacity duration-200 ${C?"opacity-0":"opacity-100"}`,children:B[g].caption}),e.jsxs("div",{className:"shot-shadow relative overflow-hidden rounded-2xl border border-[#20232f] bg-[#0a0c16]",children:[e.jsxs("div",{className:"flex h-10 items-center gap-2 border-b border-[#1b1e2b] bg-[#0d1020] px-4",children:[e.jsxs("span",{className:"flex gap-1.5","aria-hidden":!0,children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#ff5f57]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#febc2e]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#28c840]"})]}),e.jsx("span",{className:"ml-2 truncate font-mono text-[12px] text-[#6b7280]",children:q.file}),e.jsx("span",{className:"ml-auto shrink-0 rounded-full border border-[#7d6bff]/40 bg-[#7d6bff]/15 px-2.5 py-0.5 font-mono text-[10.5px] text-[#c6bfff]",children:"AI session · live"})]}),e.jsxs("div",{className:"relative aspect-video bg-black/20",children:[B.map((S,M)=>e.jsx("div",{ref:k=>{L.current[M]=k},role:"tabpanel",id:`sc-pane-${S.id}`,"aria-labelledby":`sc-tab-${S.id}`,className:`absolute inset-0 transition-opacity duration-300 ${M===a?"opacity-100":"pointer-events-none opacity-0"}`,children:e.jsxs("div",{className:"grid h-full grid-cols-1 md:grid-cols-[minmax(200px,300px)_1fr]",children:[e.jsx("div",{className:"hidden flex-col gap-4 border-r border-[#1b1e2b] bg-black/15 p-5 font-mono text-[12.5px] leading-relaxed md:flex",children:S.chat.map((k,T)=>e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[10px] uppercase tracking-[0.14em] text-[#a99bff]",children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-[#7d6bff] shadow-[0_0_8px_rgba(125,107,255,0.9)]"}),k.who==="you"?"You":"LevelCode"]}),e.jsx("div",{"data-text":k.text,className:k.who==="you"?"text-[#c7cbe0]":"text-[#8b93ad]",children:t?k.text:""})]},T))}),e.jsx("div",{className:"overflow-hidden whitespace-pre p-5 font-mono text-[12px] leading-[1.9] text-[#c7cbe0] md:text-[13px]",children:S.code.slice(0,Ve(M)).map((k,T)=>e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-[2.6em] select-none text-[#3b4157]",children:k.no}),k.toks.map((R,Y)=>e.jsx("span",{className:R.c??"text-[#c7cbe0]",children:R.t},Y)),T===Ve(M)-1&&!t&&e.jsx("span",{className:"ml-px inline-block h-[1.05em] w-[2px] -translate-y-[1px] animate-caret bg-[#7d6bff] align-middle"})]},T))})]})},S.id)),!t&&e.jsx("button",{type:"button",onClick:le,"aria-label":n?"Pause showcase":"Play showcase",className:"absolute bottom-4 right-4 z-10 grid h-10 w-10 place-items-center rounded-full border border-white/20 bg-black/50 text-white backdrop-blur transition-colors hover:bg-[#7d6bff]/30",children:n?e.jsxs("svg",{viewBox:"0 0 16 16",className:"h-4 w-4 fill-current","aria-hidden":!0,children:[e.jsx("rect",{x:"3",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"9",y:"2",width:"4",height:"12",rx:"1"})]}):e.jsx("svg",{viewBox:"0 0 16 16",className:"h-4 w-4 fill-current","aria-hidden":!0,children:e.jsx("path",{d:"M4 2.5v11a1 1 0 0 0 1.53.85l9-5.5a1 1 0 0 0 0-1.7l-9-5.5A1 1 0 0 0 4 2.5z"})})}),e.jsx("div",{"aria-hidden":!0,className:"absolute inset-x-0 bottom-0 h-[3px]",children:e.jsx("i",{className:"block h-full w-0 bg-[#7d6bff] shadow-[0_0_10px_rgba(125,107,255,0.8)]",style:n&&c&&!t?{animation:`scfill ${V}s linear forwards`}:void 0},p)})]})]})]})}const fa={amber:"#e2a43c",blue:"#57a2e8",green:"#7cb85c"},ga={name:"Design a Key-Value Store",goal:"Build and test a distributed, highly-available key-value store — implement it in C.",reference:"https://bytebytego.com/courses/system-design-interview/design-a-key-value-store",w:1740,h:700,nodes:[{id:"req",label:"requirements",tier:"powerful",color:"amber",x:20,y:300},{id:"arch",label:"architecture",tier:"powerful",color:"amber",x:320,y:300},{id:"storage",label:"storage-engine",tier:"balanced",color:"amber",x:620,y:130},{id:"hash",label:"consistent-hash",tier:"balanced",color:"blue",x:620,y:245},{id:"repl",label:"replication+quorum",tier:"balanced",color:"amber",x:620,y:360},{id:"vclock",label:"vector-clocks",tier:"balanced",color:"amber",x:620,y:475},{id:"gossip",label:"gossip+failover",tier:"balanced",color:"blue",x:620,y:590},{id:"integrate",label:"integrate+server",tier:"balanced",color:"blue",x:920,y:300},{id:"tests",label:"tests",tier:"balanced",color:"green",x:1220,y:240},{id:"build",label:"build+validate",tier:"balanced",color:"green",x:1220,y:360},{id:"review",label:"review+run-guide",tier:"balanced",color:"amber",x:1520,y:300}],edges:[{from:"req",to:"arch"},{from:"arch",to:"storage"},{from:"arch",to:"hash"},{from:"arch",to:"repl"},{from:"arch",to:"vclock"},{from:"arch",to:"gossip"},{from:"storage",to:"integrate"},{from:"hash",to:"integrate"},{from:"repl",to:"integrate"},{from:"vclock",to:"integrate"},{from:"gossip",to:"integrate"},{from:"integrate",to:"tests"},{from:"integrate",to:"build"},{from:"tests",to:"review"},{from:"build",to:"review"}]},ba={name:"Real-time Gaming Leaderboard",goal:"Design and test a real-time gaming leaderboard — top 10 by score, a user's rank, and ±4 neighbours around them.",reference:"https://bytebytego.com/courses/system-design-interview/real-time-gaming-leaderboard",w:1740,h:640,nodes:[{id:"arch",label:"architecture",tier:"powerful",color:"amber",x:20,y:300},{id:"api",label:"public-api",tier:"balanced",color:"blue",x:320,y:130},{id:"gateway",label:"api-gateway",tier:"balanced",color:"blue",x:320,y:300},{id:"game",label:"game-service",tier:"balanced",color:"blue",x:320,y:470},{id:"relational",label:"relational-baseline",tier:"balanced",color:"amber",x:620,y:130},{id:"redis",label:"redis-sorted-set",tier:"balanced",color:"amber",x:620,y:300},{id:"nosql",label:"nosql-dynamodb",tier:"balanced",color:"amber",x:620,y:470},{id:"persist",label:"persistence-mysql",tier:"balanced",color:"amber",x:920,y:130},{id:"shard",label:"sharding",tier:"balanced",color:"blue",x:920,y:300},{id:"cache",label:"rank-cache",tier:"balanced",color:"amber",x:920,y:470},{id:"service",label:"leaderboard-service",tier:"balanced",color:"blue",x:1220,y:300},{id:"tests",label:"tests",tier:"balanced",color:"green",x:1520,y:300}],edges:[{from:"arch",to:"api"},{from:"arch",to:"gateway"},{from:"arch",to:"game"},{from:"api",to:"relational"},{from:"api",to:"redis"},{from:"gateway",to:"redis"},{from:"game",to:"redis"},{from:"relational",to:"redis"},{from:"redis",to:"persist"},{from:"redis",to:"nosql"},{from:"redis",to:"shard"},{from:"shard",to:"cache"},{from:"persist",to:"service"},{from:"cache",to:"service"},{from:"nosql",to:"service"},{from:"service",to:"tests"}]},ce=[ga,ba],va={"Design a Key-Value Store":"KV","Real-time Gaming Leaderboard":"LB"},ja=200,ee=44;function ya({preload:t=!1}){const[s,a]=o.useState(()=>t?ce[0]:null),[r,n]=o.useState(()=>t?ce[0].goal:""),[l,c]=o.useState(!1),[i,h]=o.useState(!1),[m,b]=o.useState(new Set),d=o.useRef(null),g=o.useRef(null),f=o.useRef([]),C=o.useCallback(x=>{a(x),n(x.goal),b(new Set)},[]),N=o.useCallback(()=>{s&&(f.current.forEach(clearTimeout),f.current=[],b(new Set),s.nodes.forEach((x,v)=>{const u=setTimeout(()=>{b(_=>new Set(_).add(x.id))},v*900),L=setTimeout(()=>{b(_=>{const q=new Set(_);return q.delete(x.id),q})},v*900+1600);f.current.push(u,L)}))},[s]);o.useEffect(()=>()=>f.current.forEach(clearTimeout),[]),o.useEffect(()=>{const x=g.current;!x||!s||(x.scrollLeft=0,x.scrollTop=Math.max(0,s.nodes[0].y+ee-x.clientHeight/2))},[s]);const p=x=>{x.preventDefault(),h(!1),c(!1);const v=x.dataTransfer.getData("text/levelcode-sketch"),u=ce.find(L=>L.name===v);u&&C(u)},w=x=>s==null?void 0:s.nodes.find(v=>v.id===x);return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[260px_1fr]",children:[e.jsxs("div",{className:"surface p-4",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.24em] text-flame",children:"template palette"}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-sub",children:"Drag a card onto the canvas to lay down a fully-configured agent topology."}),e.jsx("div",{className:"mt-4 space-y-3",children:ce.map(x=>e.jsxs("button",{type:"button",draggable:!0,onDragStart:v=>{v.dataTransfer.setData("text/levelcode-sketch",x.name),v.dataTransfer.effectAllowed="copy",c(!0)},onDragEnd:()=>c(!1),onClick:()=>C(x),className:"group w-full cursor-grab rounded-md border border-rule bg-paper p-3 text-left transition-colors hover:border-flame/60 active:cursor-grabbing",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"grid h-7 w-7 place-items-center rounded border border-flame/30 bg-flame/10 font-mono text-[13px] text-flame",children:va[x.name]??"◆"}),e.jsx("span",{className:"font-display text-[13.5px] font-semibold leading-tight text-ink",children:x.name})]}),e.jsxs("p",{className:"mt-2 font-mono text-[10px] uppercase tracking-[0.14em] text-faint",children:[x.nodes.length," agents · ",x.edges.length," links · bytebytego"]}),e.jsx("span",{className:"mt-2 inline-block font-mono text-[10px] text-flame/70 group-hover:text-flame",children:"⠿ drag onto canvas →"})]},x.name))})]}),e.jsxs("div",{ref:d,onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy",h(!0)},onDragLeave:()=>h(!1),onDrop:p,className:`relative min-h-[440px] overflow-hidden rounded-xl border bg-[#f2f0ea] transition-colors ${i?"border-flame/70":"border-rule"}`,children:[e.jsx("div",{"aria-hidden":!0,className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle, rgba(27,26,23,0.13) 1px, transparent 1.4px)",backgroundSize:"22px 22px"}}),s&&e.jsxs("div",{className:"relative z-10 flex items-center gap-2 border-b border-rule bg-card/80 px-3 py-2 backdrop-blur-sm",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-flame",children:"goal"}),e.jsx("input",{value:r,onChange:x=>n(x.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[12.5px] text-ink outline-none placeholder:text-faint",placeholder:"Describe what to build…"}),e.jsx("button",{type:"button",onClick:N,className:"shrink-0 rounded bg-flame px-3 py-1 font-mono text-[11px] font-semibold text-paper transition-colors hover:bg-flamedeep",children:"▶ Run"})]}),!s&&e.jsx("div",{className:"relative z-10 grid h-full min-h-[440px] place-items-center px-6 text-center",children:e.jsxs("div",{children:[e.jsx("div",{className:`mx-auto mb-4 grid h-14 w-14 place-items-center rounded-lg border-2 border-dashed transition-colors ${l||i?"border-flame text-flame":"border-faint/50 text-faint"}`,children:"⠿"}),e.jsx("p",{className:"font-display text-[15px] font-semibold text-ink",children:"Drop a template here"}),e.jsx("p",{className:"mx-auto mt-1.5 max-w-xs text-[12.5px] leading-relaxed text-sub",children:"Drag a template card in — or just click it — to materialise the full topology."})]})}),s&&e.jsx("div",{ref:g,className:"relative z-10 max-h-[420px] w-full overflow-auto p-3 md:max-h-none",children:e.jsxs("div",{className:"relative",style:{width:s.w,height:s.h},children:[e.jsx("svg",{className:"pointer-events-none absolute inset-0 h-full w-full",viewBox:`0 0 ${s.w} ${s.h}`,children:s.edges.map((x,v)=>{const u=w(x.from),L=w(x.to);if(!u||!L)return null;const _=u.x+ja,q=u.y+ee,V=L.x,le=L.y+ee;return e.jsx("path",{d:`M${_},${q} C ${_+70},${q} ${V-70},${le} ${V},${le}`,fill:"none",stroke:"#b9b4a8",strokeWidth:1.5},v)})}),s.nodes.map(x=>{const v=fa[x.color],u=m.has(x.id);return e.jsxs("div",{className:`sb-node absolute w-[200px] rounded-lg border bg-white p-3 shadow-[0_2px_10px_rgba(27,26,23,0.08)] ${u?"sb-node--running":""}`,style:{left:x.x,top:x.y,borderColor:u?"transparent":"#e2ddd2"},children:[u&&e.jsx("svg",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full overflow-visible",children:e.jsx("rect",{className:"sb-ants",x:"0.75",y:"0.75",rx:"8",fill:"none",stroke:"#65a34a",strokeWidth:"1.5",strokeDasharray:"6 6",style:{width:"calc(100% - 1.5px)",height:"calc(100% - 1.5px)"}})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 shrink-0 rounded-[3px] ${u?"sb-pulse":""}`,style:{background:u?"#65a34a":v}}),e.jsx("span",{className:"truncate text-[13px] font-semibold text-[#2a2822]",children:x.label}),u?e.jsx("span",{className:"ml-auto shrink-0 font-mono text-[9px] uppercase tracking-[0.14em] text-[#65a34a]",children:"running"}):e.jsx("span",{"aria-hidden":!0,className:"ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-[#3f3c34]/50"})]}),e.jsxs("p",{className:"mt-1 text-[11px] text-[#8a8578]",children:["tier: ",x.tier]}),e.jsx("span",{"aria-hidden":!0,className:"absolute -left-[5px] h-2.5 w-2.5 rounded-full border-2 border-[#8a8578] bg-white",style:{top:ee-5}}),e.jsx("span",{"aria-hidden":!0,className:"absolute -right-[5px] h-2.5 w-2.5 rounded-full border-2 border-[#8a8578] bg-white",style:{top:ee-5}})]},x.id)})]})}),s&&e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute bottom-3 right-3 z-10 flex items-center gap-1.5 font-mono text-[11px] text-sub",children:["−","99%","+","⤢","⇄ Tidy"].map(x=>e.jsx("span",{className:"rounded-md border border-[#e2ddd2] bg-white px-2 py-1 shadow-sm",children:x},x))})]})]})}const Lt=`${F}/releases/latest`,Mt=`${Lt}/download/LevelCode-arm64.dmg`,at=`${Lt}/download/LevelCode-x64.dmg`,rt="1.2.0";function Na(){const[t,s]=o.useState(()=>{try{return sessionStorage.getItem("lc-latest-version")||rt}catch{return rt}});return o.useEffect(()=>{try{if(sessionStorage.getItem("lc-latest-version"))return}catch{}let a=!0;return fetch("https://api.github.com/repos/levelcodeai/levelcode/releases/latest",{headers:{Accept:"application/vnd.github+json"}}).then(r=>r.ok?r.json():null).then(r=>{const n=String((r==null?void 0:r.tag_name)??"").replace(/^v/,"");if(a&&n){s(n);try{sessionStorage.setItem("lc-latest-version",n)}catch{}}}).catch(()=>{}),()=>{a=!1}},[]),t}function wa(){const[t,s]=o.useState(null);return o.useEffect(()=>{let a=!0;return D("/api/levelcode/v1/pricing").then(r=>{const n=(r.tiers??[]).filter(i=>i.price_cents>0);if(!a||n.length===0)return;const l=n.reduce((i,h)=>h.price_cents{}),()=>{a=!1}},[]),t}function nt(){const t=Na(),s=wa(),{profile:a}=W(),[r]=o.useState(St),n=`${F}/releases/tag/v${t}`;return e.jsxs($,{children:[e.jsx("section",{className:"lp-hero",children:e.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col items-center px-5 pb-14 pt-16 text-center sm:pb-16 sm:pt-24",children:[e.jsx(lt,{id:"lp-icon-hero",size:88}),e.jsx("h1",{className:"lp-h1 mt-8 text-balance",children:"The AI code editor that keeps you in control"}),e.jsx("p",{className:"lp-lead mt-5 max-w-2xl text-balance",children:"LevelCode plans, edits, and verifies work across your codebase. You review every change, and commands wait for your approval."}),e.jsx("div",{className:"mt-9",children:e.jsx(Ae,{isMac:r,profile:a})}),r?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-5 text-[15px] text-[var(--c-text2)]",children:"Free and open source. No account required."}),e.jsxs("p",{className:"mt-1.5 text-[13px] text-[var(--c-text3)]",children:["Version ",t," ·"," ",e.jsx("a",{href:n,className:"lp-link",children:"Release notes"})," ","· Intel Mac?"," ",e.jsx("a",{href:at,className:"lp-link",download:!0,children:"Download the x64 build"})]})]}):e.jsxs("p",{className:"mt-5 max-w-md text-[15px] text-[var(--c-text2)] pretty",children:["LevelCode is a desktop app for macOS. Open this page on your Mac to download it, or see"," ",e.jsx("a",{href:`${F}/releases`,className:"lp-link",children:"all builds"}),"."]})]})}),e.jsx("section",{"aria-label":"Why LevelCode is safe to adopt",children:e.jsx("ul",{className:"mx-auto grid max-w-5xl grid-cols-2 gap-x-6 gap-y-8 px-5 pb-16 md:grid-cols-4",children:La.map(l=>e.jsxs("li",{className:"flex flex-col items-center text-center",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:l.icon}),e.jsx("span",{className:"mt-2.5 text-[15px] font-semibold text-[var(--c-text)]",children:l.title}),e.jsx("span",{className:"mt-0.5 text-[13px] text-[var(--c-text3)]",children:l.detail})]},l.title))})}),e.jsx("section",{id:"agent",className:"scroll-mt-14",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 pb-24",children:[e.jsx("h2",{className:"sr-only",children:"LevelCode at work"}),e.jsx(pa,{})]})}),e.jsx("section",{id:"get-started",className:"scroll-mt-14 border-y border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Get started"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"LevelCode is free to use with your own API key. Add a plan when you want managed models."})]}),e.jsxs("div",{className:"mx-auto mt-12 grid max-w-4xl gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"lp-card flex flex-col p-7",children:[e.jsx("h3",{className:"text-[22px] font-semibold text-[var(--c-text)]",children:"Free"}),e.jsx("p",{className:"mt-1.5 text-[16px] pretty",children:"The complete editor, with your own API key or a local model."}),e.jsx("p",{className:"mt-7 flex h-12 items-end gap-2",children:e.jsx("span",{className:"text-[40px] font-semibold leading-none tracking-tight text-[var(--c-text)]",children:"$0"})}),e.jsx("div",{className:"mt-6 flex flex-1 items-end",children:r?e.jsx(Ae,{isMac:!0,profile:a,fullWidth:!0}):e.jsx(j,{to:"/docs/quickstart",className:"lp-cta lp-cta--quiet w-full",children:"Read the quickstart"})})]}),e.jsxs("div",{className:"lp-card flex flex-col p-7",children:[e.jsx("h3",{className:"text-[22px] font-semibold text-[var(--c-text)]",children:"LevelCode Cloud"}),e.jsx("p",{className:"mt-1.5 text-[16px] pretty",children:"Managed models with no key to set up, and the cost of every run shown in the editor."}),s?e.jsxs("p",{className:"mt-7 flex h-12 items-end gap-2",children:[e.jsx("span",{className:"pb-1 text-[15px] text-[var(--c-text3)]",children:"From"}),e.jsx("span",{className:"text-[40px] font-semibold leading-none tracking-tight text-[var(--c-text)]",children:s.amount}),e.jsxs("span",{className:"pb-1 text-[15px] text-[var(--c-text3)]",children:["/ ",s.interval]})]}):null,e.jsx("div",{className:"mt-6 flex flex-1 items-end",children:e.jsx(j,{to:"/pricing",className:"lp-cta lp-cta--quiet w-full",children:"View plans"})})]})]}),e.jsx("p",{className:"mt-8 text-center text-[14px] text-[var(--c-text3)]",children:"Every plan includes the full editor. Plans meter managed AI usage only."})]})}),e.jsxs("section",{id:"features",className:"scroll-mt-14",children:[e.jsxs("div",{className:"mx-auto max-w-6xl px-5 pb-10 pt-24 sm:pt-28",children:[e.jsx("h2",{className:"lp-h2 text-center text-balance",children:"An agent that shows its work"}),e.jsxs("div",{className:"mt-16 space-y-24 sm:mt-20 sm:space-y-28",children:[e.jsx(Te,{title:"From goal to verified change",body:"Describe the outcome you want. LevelCode plans the steps, edits across files, and runs the commands it needs. Before it reports back, it checks its changes against your type checker and linter, and runs the verify command you set.",visual:e.jsx(ka,{})}),e.jsx(Te,{flip:!0,title:"You decide what lands",body:"Every edit is tracked file by file, with Keep and Undo. Commands wait for your approval before they run, and each message is a checkpoint you can restore.",visual:e.jsx(Ca,{})})]})]}),e.jsxs("div",{id:"sketches",className:"mx-auto max-w-6xl scroll-mt-14 px-5 py-14 sm:py-16",children:[e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h3",{className:"lp-h3",children:"Coordinate a team of agents"}),e.jsx("p",{className:"lp-body mt-4 pretty",children:"Sketch a workflow on a canvas: place specialized agents, connect them, and run. Independent steps run in parallel, and each one reports its token usage and estimated cost."})]}),e.jsx("div",{className:"classic-demo-sketch mt-10",children:e.jsx(ya,{preload:!0})})]}),e.jsx("div",{className:"mx-auto max-w-6xl px-5 pb-24 pt-10 sm:pb-28",children:e.jsx(Te,{title:"Use the models you choose",body:"Bring your own API key for Anthropic, OpenAI, OpenRouter, and other providers, or run local models with Ollama for chat, edits, and autocomplete. Prefer a single bill? LevelCode Cloud adds managed models on a monthly plan.",visual:e.jsx(Sa,{})})})]}),e.jsx("section",{className:"border-y border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Works with the tools you already use"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"Keep your extensions, your settings, and your workflow."})]}),e.jsx("div",{className:"mt-12 grid gap-6 md:grid-cols-3",children:Ma.map(l=>e.jsxs("div",{className:"lp-card p-6",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:l.icon}),e.jsx("h3",{className:"mt-4 text-[18px] font-semibold text-[var(--c-text)]",children:l.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:l.body})]},l.title))}),e.jsx("p",{className:"mt-10 text-center",children:e.jsx(j,{to:"/docs",className:"lp-link text-[16px] font-medium",children:"Read the documentation →"})})]})}),e.jsx("section",{children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"A complete editor underneath"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"LevelCode is built on Code-OSS, the open-source project behind VS Code. The editing experience, keybindings, and extension model are the ones you already know."})]}),e.jsx("div",{className:"mt-14 grid gap-x-10 gap-y-10 sm:grid-cols-2 lg:grid-cols-3",children:Aa.map(l=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:l.icon}),e.jsx("h3",{className:"mt-3 text-[17px] font-semibold text-[var(--c-text)]",children:l.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:l.body})]},l.title))})]})}),e.jsx("section",{id:"security",className:"scroll-mt-14 border-y border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Security you can verify"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"LevelCode is designed so you can see what it does and decide what it is allowed to do."})]}),e.jsx("div",{className:"mt-12 grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:Ta.map(l=>e.jsxs("div",{className:"lp-card p-6",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:l.icon}),e.jsx("h3",{className:"mt-4 text-[18px] font-semibold text-[var(--c-text)]",children:l.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:l.body})]},l.title))}),e.jsxs("div",{className:"mt-10 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("a",{href:F,className:"lp-cta lp-cta--quiet",children:[e.jsx(_a,{}),"View the source on GitHub"]}),e.jsx(j,{to:"/privacy",className:"lp-cta lp-cta--quiet",children:"Read the privacy policy"})]})]})}),e.jsx("section",{id:"download",className:"lp-hero lp-hero--closing scroll-mt-14",children:e.jsxs("div",{className:"mx-auto flex max-w-3xl flex-col items-center px-5 py-24 text-center sm:py-28",children:[e.jsx(lt,{id:"lp-icon-closing",size:64,decorative:!0}),e.jsx("h2",{className:"lp-h2 mt-6 text-balance",children:"Start building with LevelCode"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"Free and open source. No account required."}),r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("a",{href:Mt,className:"lp-cta",download:!0,children:[e.jsx(Be,{}),"Download for Apple Silicon"]}),e.jsxs("a",{href:at,className:"lp-cta lp-cta--quiet",download:!0,children:[e.jsx(Be,{}),"Download for Intel"]})]}),e.jsxs("p",{className:"mt-5 text-[13px] text-[var(--c-text3)]",children:["Version ",t," ·"," ",e.jsx("a",{href:n,className:"lp-link",children:"Release notes"})," ","·"," ",e.jsx("a",{href:`${F}/releases`,className:"lp-link",children:"All releases"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-9",children:e.jsx(Ae,{isMac:r,profile:a})}),e.jsxs("p",{className:"mt-5 max-w-md text-[14px] text-[var(--c-text3)] pretty",children:["LevelCode runs on Apple Silicon and Intel Macs. Open this page on your Mac to download it, or see"," ",e.jsx("a",{href:`${F}/releases`,className:"lp-link",children:"all releases"}),"."]})]}),e.jsx("p",{className:"mt-12 max-w-xl text-[12px] text-[var(--c-text2)] pretty",children:"LevelCode is an independent project. It is not produced by, endorsed by, or affiliated with Microsoft."})]})})]})}function Ae({isMac:t,profile:s,fullWidth:a=!1}){const r=`lp-cta${a?" w-full":""}`;return t?e.jsxs("a",{href:Mt,className:r,download:!0,children:[e.jsx(Be,{}),"Download for macOS"]}):e.jsx(j,{to:s?"/account":"/login",className:r,children:s?"Your account":"Sign in"})}function Te({title:t,body:s,visual:a,flip:r=!1}){return e.jsxs("div",{className:"grid items-center gap-10 md:grid-cols-12 md:gap-12 lg:gap-16",children:[e.jsxs("div",{className:`md:col-span-5 lg:col-span-4 ${r?"md:order-2":""}`,children:[e.jsx("h3",{className:"lp-h3 text-balance",children:t}),e.jsx("p",{className:"lp-body mt-4 pretty",children:s})]}),e.jsx("div",{className:`md:col-span-7 lg:col-span-8 ${r?"md:order-1":""}`,children:a})]})}function ka(){return e.jsx("div",{className:"lp-stage",role:"img","aria-label":"LevelCode working through a task: it reads the relevant files, edits three of them, runs the tests, and verifies the result before reporting back.",children:e.jsxs("div",{className:"lp-pane w-full max-w-[460px] p-5","aria-hidden":!0,children:[e.jsx("p",{className:"lp-bubble",children:"Add rate limiting to the public API routes, then run the tests."}),e.jsxs("ul",{className:"mt-5 space-y-2.5 text-[14px] text-[var(--c-text)]",children:[e.jsx(de,{children:"Read 6 files, searched the workspace"}),e.jsxs(de,{children:["Edited 3 files ",e.jsx(Ue,{add:84,del:21})]}),e.jsxs(de,{children:["Ran ",e.jsx("code",{className:"lp-code",children:"npm test"})]}),e.jsx(de,{children:"Verified the edits"})]}),e.jsx("p",{className:"mt-5 border-t border-[var(--c-line)] pt-4 text-[13.5px] leading-relaxed text-[var(--c-text2)]",children:"Rate limiting is in place on every public route. The tests pass, and the change introduced no new type or lint problems."})]})})}function Ca(){return e.jsx("div",{className:"lp-stage",role:"img","aria-label":"A command waiting for approval with Run and Skip buttons, above a list of three changed files with Keep and Undo for each.",children:e.jsxs("div",{className:"flex w-full max-w-[480px] flex-col gap-4","aria-hidden":!0,children:[e.jsxs("div",{className:"lp-pane p-5",children:[e.jsx("p",{className:"text-[15px] font-semibold text-[var(--c-text)]",children:"Run this command?"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-[var(--c-text3)]",children:"LevelCode wants to run this in your terminal."}),e.jsx("p",{className:"lp-well mt-3",children:"npm test"}),e.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[e.jsxs("span",{className:"lp-btn",children:["Skip ",e.jsx("kbd",{children:"esc"})]}),e.jsxs("span",{className:"lp-btn lp-btn--primary",children:["Run ",e.jsx("kbd",{children:"⏎"})]})]})]}),e.jsxs("div",{className:"lp-pane p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:[e.jsx("span",{className:"text-[15px] font-semibold text-[var(--c-text)]",children:"3 files changed"}),e.jsx(Ue,{add:84,del:21}),e.jsxs("span",{className:"ml-auto flex gap-2",children:[e.jsx("span",{className:"lp-btn",children:"Undo all"}),e.jsx("span",{className:"lp-btn lp-btn--primary",children:"Keep all"})]})]}),e.jsxs("ul",{className:"mt-3 divide-y divide-[var(--c-line)] border-t border-[var(--c-line)]",children:[e.jsx(_e,{name:"routes/api.ts",add:41,del:9}),e.jsx(_e,{name:"middleware/rateLimit.ts",add:38,del:0}),e.jsx(_e,{name:"routes/api.test.ts",add:5,del:12})]})]})]})})}function Sa(){return e.jsx("div",{className:"lp-stage",role:"img","aria-label":"The model picker, grouped three ways: your own API key with a provider such as Anthropic, OpenAI, OpenRouter or Mistral; a local model with Ollama; or managed models on LevelCode Cloud.",children:e.jsxs("div",{className:"lp-pane w-full max-w-[440px] p-5","aria-hidden":!0,children:[e.jsx("p",{className:"text-[15px] font-semibold text-[var(--c-text)]",children:"Select model"}),e.jsx("p",{className:"lp-group mt-4",children:"Your API key"}),e.jsxs("ul",{className:"mt-1.5 space-y-1",children:[e.jsx(K,{name:"Anthropic",note:"Direct",selected:!0}),e.jsx(K,{name:"OpenAI",note:"Direct"}),e.jsx(K,{name:"OpenRouter",note:"Direct"}),e.jsx(K,{name:"Mistral",note:"Direct"})]}),e.jsx("p",{className:"lp-group mt-4",children:"On this Mac"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:e.jsx(K,{name:"Ollama",note:"Local"})}),e.jsx("p",{className:"lp-group mt-4",children:"LevelCode Cloud"}),e.jsx("ul",{className:"mt-1.5 space-y-1",children:e.jsx(K,{name:"Managed models",note:"Included in a plan"})})]})})}function de({children:t}){return e.jsxs("li",{className:"flex items-center gap-2.5",children:[e.jsxs("svg",{viewBox:"0 0 16 16",width:"16",height:"16",className:"shrink-0 text-[var(--lp-add)]","aria-hidden":!0,children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.35",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("path",{d:"M5.05 8.25 7 10.2l4.15-4.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("span",{className:"flex flex-wrap items-center gap-x-2",children:t})]})}function Ue({add:t,del:s}){return e.jsxs("span",{className:"font-mono text-[12.5px] tabular-nums",children:[e.jsxs("span",{className:"text-[var(--lp-add)]",children:["+",t]})," ",e.jsxs("span",{className:"text-[var(--lp-del)]",children:["−",s]})]})}function _e({name:t,add:s,del:a}){return e.jsxs("li",{className:"flex items-center gap-3 py-2.5",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12.5px] text-[var(--c-text)]",children:t}),e.jsx(Ue,{add:s,del:a}),e.jsxs("span",{className:"hidden gap-1.5 sm:flex",children:[e.jsx("span",{className:"lp-btn lp-btn--sm",children:"Undo"}),e.jsx("span",{className:"lp-btn lp-btn--sm lp-btn--primary",children:"Keep"})]})]})}function K({name:t,note:s,selected:a=!1}){return e.jsxs("li",{className:`lp-row ${a?"lp-row--on":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:`lp-radio ${a?"lp-radio--on":""}`}),e.jsx("span",{className:"text-[14px] text-[var(--c-text)]",children:t}),e.jsx("span",{className:"ml-auto text-[12.5px] text-[var(--c-text3)]",children:s})]})}const La=[{title:"Open source",detail:"MIT licensed",icon:e.jsx(E,{d:"M9 5 3 12l6 7m6-14 6 7-6 7"})},{title:"Built on Code-OSS",detail:"The open-source core of VS Code",icon:e.jsx(E,{d:"m12 3 9 5-9 5-9-5 9-5Zm-9 9 9 5 9-5M3 16l9 5 9-5"})},{title:"Notarized by Apple",detail:"Signed with a Developer ID",icon:e.jsx(E,{d:"M12 3 4.5 6v5.5c0 4.6 3.1 8.2 7.5 9.5 4.4-1.3 7.5-4.9 7.5-9.5V6L12 3Zm-3.2 9 2.3 2.3 4.1-4.6"})},{title:"Private by default",detail:"No telemetry",icon:e.jsx(E,{d:"M7 11V8a5 5 0 0 1 10 0v3M6 11h12v9H6v-9Zm6 3.5v2"})}],Ma=[{title:"Extensions",body:"Install language support, themes, and tools from Open VSX, the open extension registry, without leaving the editor.",icon:e.jsx(E,{d:"M12 3 4 7v10l8 4 8-4V7l-8-4Zm0 0v8m8-4-8 4M4 7l8 4"})},{title:"MCP servers",body:"Give the agent new tools through the Model Context Protocol. Every tool call asks before it runs, unless you choose to allow it.",icon:e.jsx(E,{d:"M9 3v5m6-5v5M6 8h12v3a6 6 0 0 1-12 0V8Zm6 9v4"})},{title:"Import from VS Code",body:"Bring your settings, keybindings, and snippets from VS Code, VSCodium, or Cursor in one step. Your existing files are backed up first.",icon:e.jsx(E,{d:"M12 3v12m0 0-4-4m4 4 4-4M4 20h16"})}],Aa=[{title:"Chat",body:"Ask questions about your codebase and get answers grounded in your files. Chat never edits them.",icon:e.jsx(E,{d:"M4 5h16v11H9l-5 4V5Z"})},{title:"Inline edits",body:"Select code, describe the change, and review it as a diff before anything lands.",icon:e.jsx(E,{d:"M4 20h4L19 9l-4-4L4 16v4Zm9.5-13.5 4 4"})},{title:"Autocomplete",body:"Suggestions appear as you type. Press Tab to accept one, or keep typing to dismiss it.",icon:e.jsx(E,{d:"M12 3a6 6 0 0 1 3.5 10.9c-.6.45-1 1.1-1 1.85V17h-5v-1.25c0-.75-.4-1.4-1-1.85A6 6 0 0 1 12 3ZM10 20h4"})},{title:"Power editing",body:"Keystroke macros, column editing, line operations, encoding control, and a mode for very large files.",icon:e.jsx(E,{d:"M4 5h16M4 9h10M4 13h16M4 17h7"})},{title:"Familiar keys and themes",body:"Keymap presets for Atom and Notepad++, with One Dark and One Light built in.",icon:e.jsx(E,{d:"M3 7h18v10H3V7Zm4 3.5h.01M11 10.5h.01M15 10.5h.01M7.5 14h9"})},{title:"Yours to extend",body:"Add your own commands with a startup script, or build a package and see changes as you save.",icon:e.jsx(E,{d:"M4 5h16v14H4V5Zm3.5 4.5 3 2.5-3 2.5M13 15h3.5"})}],Ta=[{title:"Open source",body:"LevelCode is MIT licensed and built on Code-OSS, the open-source project behind VS Code. The full source is on GitHub for you or your security team to review.",icon:e.jsx(E,{d:"M9 5 3 12l6 7m6-14 6 7-6 7"})},{title:"Signed and notarized",body:"Releases are signed with an Apple Developer ID and notarized by Apple, so macOS verifies the app before it opens.",icon:e.jsx(E,{d:"M12 3 4.5 6v5.5c0 4.6 3.1 8.2 7.5 9.5 4.4-1.3 7.5-4.9 7.5-9.5V6L12 3Zm-3.2 9 2.3 2.3 4.1-4.6"})},{title:"Your keys stay on your Mac",body:"API keys are stored in the macOS Keychain, never in a settings file. With your own key, requests go directly from your Mac to your provider.",icon:e.jsx(E,{d:"M8 19a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm2.8-6.8L20 3m-3.5 3.5 2.5 2.5M14 9l2 2"})},{title:"Approval before action",body:"Commands and third-party tools wait for your approval by default. A tool server defined by a repository cannot start until you approve its exact command.",icon:e.jsx(E,{d:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm-4-9 3 3 5-6"})},{title:"No telemetry",body:"Telemetry is off, and there is no setting that turns it on.",icon:e.jsx(E,{d:"M3 3l18 18M10.6 6.1A9.6 9.6 0 0 1 12 6c5 0 8.5 4.5 9 6-.3.9-1.2 2.3-2.7 3.6M6.3 7.8C4.4 9.1 3.3 10.9 3 12c.5 1.5 4 6 9 6 1.3 0 2.6-.3 3.7-.8M9.9 9.9a3 3 0 0 0 4.2 4.2"})},{title:"No account required",body:"Download and use the editor without signing up. An account is only needed for a LevelCode Cloud plan.",icon:e.jsx(E,{d:"M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm-7 9a7 7 0 0 1 14 0"})}];function E({d:t}){return e.jsx("svg",{viewBox:"0 0 24 24",width:"28",height:"28",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"inline-block",children:e.jsx("path",{d:t})})}function lt({id:t,size:s,decorative:a=!1}){const r=a?{"aria-hidden":!0}:{role:"img","aria-label":"LevelCode"};return e.jsxs("svg",{viewBox:"0 0 120 120",width:s,height:s,className:"lp-appicon",...r,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:t,x1:"0",y1:"104",x2:"0",y2:"14",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#5b3fd6"}),e.jsx("stop",{offset:".45",stopColor:"#7d6bff"}),e.jsx("stop",{offset:".75",stopColor:"#5fb4ff"}),e.jsx("stop",{offset:"1",stopColor:"#a8ecff"})]})}),e.jsx("rect",{width:"120",height:"120",rx:"27",fill:"#0a0c16"}),e.jsxs("g",{fill:"none",stroke:`url(#${t})`,strokeWidth:"13",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M28 92 L60 69 L92 92",opacity:".55"}),e.jsx("path",{d:"M28 68 L60 45 L92 68",opacity:".8"}),e.jsx("path",{d:"M28 44 L60 21 L92 44"})]})]})}function Be(){return e.jsx("svg",{viewBox:"0 0 814 1000",width:"15",height:"15",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M788 341c-6 4-107 61-107 187 0 146 128 198 132 199-1 3-20 70-67 138-42 60-86 120-153 120s-84-39-161-39c-75 0-102 40-163 40s-104-56-153-124C60 782 13 660 13 544c0-186 121-285 240-285 63 0 116 42 156 42 38 0 97-44 169-44 27 0 125 2 210 84zM554 172c31-37 53-88 53-139 0-7-1-14-2-20-50 2-110 34-146 76-29 32-55 83-55 135 0 8 1 16 2 18 3 1 8 2 13 2 45 0 102-30 135-72z"})})}function _a(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})})}const At="lc_attribution",Tt=["linkedin","youtube","ref","utm_source","utm_medium","utm_campaign","utm_content"],_t=120,Ea=40,pe=300,Da=40;function $a(t){if(!t||typeof t!="object")return null;const s=t,a={},r=s.params;if(r&&typeof r=="object")for(const c of Tt){const i=r[c];typeof i=="string"&&i&&(a[c]=i.slice(0,_t))}const n=typeof s.source=="string"?s.source.slice(0,Ea):"";if(Object.keys(a).length===0&&!n)return null;const l=(c,i)=>typeof c=="string"?c.slice(0,i):"";return{source:n||"other",params:a,landing:l(s.landing,pe),referrer:l(s.referrer,pe),ts:l(s.ts,Da)}}function Et(){try{const t=localStorage.getItem(At);return t?$a(JSON.parse(t)):null}catch{return null}}function Ra(){if(!(typeof window>"u"))try{if(Et())return;const t=new URLSearchParams(window.location.search),s={};for(const n of Tt){const l=t.get(n);l&&(s[n]=l.slice(0,_t))}if(Object.keys(s).length===0)return;const r={source:s.linkedin?"linkedin":s.youtube?"youtube":s.utm_source||s.ref||"other",params:s,landing:window.location.pathname.slice(0,pe),referrer:(document.referrer||"").slice(0,pe),ts:new Date().toISOString()};localStorage.setItem(At,JSON.stringify(r))}catch{}}function Dt(){return typeof window>"u"?null:Et()}function $t({redirectUri:t,codeChallenge:s,next:a}){return t&&s?null:fe(a)}function Pa(t,s,a,r){const{redirectUri:n,codeChallenge:l}=a,c=new URLSearchParams;n&&l&&(c.set("redirect_uri",n),c.set("code_challenge",l));const i=$t(a);i&&c.set("next",i),r&&c.set("attribution",JSON.stringify({source:r.source,params:r.params,landing:r.landing,ts:r.ts}));const h=c.toString();return`${t}/ai/auth/oauth/${s}${h?`?${h}`:""}`}function Ia(t,s,a,r){const n={email:t,code:s,redirect_uri:a.redirectUri,code_challenge:a.codeChallenge,attribution:r},l=$t(a);return l&&(n.next=l),n}function Oa({redirectUri:t,codeChallenge:s,next:a}){const[r,n]=o.useState("email"),[l,c]=o.useState(""),[i,h]=o.useState(""),[m,b]=o.useState(!1),[d,g]=o.useState(null);async function f(N){N.preventDefault(),b(!0),g(null);try{await D("/ai/auth/email",{body:{email:l}}),n("code")}catch(p){g(p instanceof te?p.message:"Couldn't send a code. Try again.")}finally{b(!1)}}async function C(N){N.preventDefault(),b(!0),g(null);try{const p=await D("/ai/auth/verify",{body:Ia(l,i,{redirectUri:t,codeChallenge:s,next:a},Dt())});if(!p.redirect)throw new te(422,"That code is invalid or has expired.");if(!p.redirect.startsWith("/")&&!/^https?:\/\//i.test(p.redirect)){const w=window.setTimeout(()=>{b(!1),g("Open LevelCode to finish signing in. If nothing happened, the editor may not be installed on this device.")},1500);window.addEventListener("pagehide",()=>window.clearTimeout(w),{once:!0}),ae(p.redirect);return}ae(p.redirect)}catch(p){g(p instanceof te?p.message:"That code is invalid or has expired."),b(!1)}}return r==="email"?e.jsxs("form",{onSubmit:f,className:"flex flex-col gap-3",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest text-[var(--c-text3)]",children:"Email"}),e.jsx("input",{type:"email",required:!0,autoFocus:!0,autoComplete:"email",value:l,onChange:N=>c(N.target.value),placeholder:"you@studio.dev",className:"rounded-[4px] border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2.5 text-[15px] text-[var(--c-text)] outline-none transition-colors focus:border-[var(--c-accent)]"})]}),d?e.jsx("p",{className:"text-[13px] text-red-500",children:d}):null,e.jsx("button",{type:"submit",disabled:m,className:"classic-button w-full",children:m?"Sending…":"Email me a sign-in code"})]}):e.jsxs("form",{onSubmit:C,className:"flex flex-col gap-3",children:[e.jsxs("p",{className:"text-[13px]",children:["We sent a 6-digit code to ",e.jsx("span",{className:"font-medium text-[var(--c-text)]",children:l}),". Enter it below."]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest text-[var(--c-text3)]",children:"Verification code"}),e.jsx("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]*",maxLength:6,required:!0,autoFocus:!0,value:i,onChange:N=>h(N.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",className:"rounded-[4px] border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2.5 text-center font-mono text-[22px] font-semibold tracking-[0.4em] text-[var(--c-text)] outline-none transition-colors focus:border-[var(--c-accent)]"})]}),d?e.jsx("p",{className:"text-[13px] text-red-500",children:d}):null,e.jsx("button",{type:"submit",disabled:m||i.length<6,className:"classic-button w-full",children:m?"Verifying…":"Verify & continue"}),e.jsxs("div",{className:"flex items-center justify-between text-[13px]",children:[e.jsx("button",{type:"button",onClick:f,disabled:m,className:"text-[var(--c-accent)] hover:underline",children:"Resend code"}),e.jsx("button",{type:"button",onClick:()=>{n("email"),h(""),g(null)},className:"text-[var(--c-accent)] hover:underline",children:"Use a different email"})]})]})}function Ba(t){return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(ot,{provider:"google",label:"Continue with Google",context:t,children:e.jsx(qa,{})}),e.jsx(ot,{provider:"github",label:"Continue with GitHub",context:t,children:e.jsx(Fa,{})})]})}function ot({provider:t,label:s,context:a,children:r}){return e.jsxs("a",{href:Pa(qe,t,a,Dt()),className:"classic-button--quiet w-full gap-2.5",children:[r,s]})}function qa(){return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",className:"shrink-0",children:[e.jsx("path",{fill:"#4285F4",d:"M17.64 9.2045c0-.6381-.0573-1.2518-.1636-1.8409H9v3.4814h4.8436c-.2086 1.125-.8427 2.0782-1.7959 2.7164v2.2581h2.9086c1.7018-1.5668 2.6837-3.874 2.6837-6.615z"}),e.jsx("path",{fill:"#34A853",d:"M9 18c2.43 0 4.4673-.806 5.9564-2.1805l-2.9086-2.2581c-.8059.54-1.8368.859-3.0478.859-2.344 0-4.3282-1.5832-5.036-3.7105H.9573v2.3318C2.4382 15.9832 5.4818 18 9 18z"}),e.jsx("path",{fill:"#FBBC05",d:"M3.964 10.71c-.18-.54-.2822-1.1168-.2822-1.71s.1023-1.17.2823-1.71V4.9582H.9573C.3477 6.1732 0 7.5477 0 9s.3477 2.8268.9573 4.0418L3.964 10.71z"}),e.jsx("path",{fill:"#EA4335",d:"M9 3.5795c1.3214 0 2.5077.4541 3.4405 1.346l2.5813-2.5814C13.4636.8918 11.426 0 9 0 5.4818 0 2.4382 2.0168.9573 4.9582L3.964 7.29C4.6718 5.1627 6.656 3.5795 9 3.5795z"})]})}function Fa(){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:"shrink-0",children:e.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}const Ua={session_expired:"Your sign-in session expired. Please try again.",link_expired:"That sign-in link expired. Please try again from the editor."};function Wa(){const t=re(),[s]=Wt(),a=s.get("redirect_uri"),r=s.get("code_challenge"),n=s.get("error"),l=a&&r?{redirectUri:a,codeChallenge:r}:null,c=!!l,i=!!l&&/^https?:\/\//i.test(l.redirectUri),h=fe(s.get("next")),{loading:m,profile:b}=W(),d=z(),[g,f]=o.useState("idle"),C=ms({editorSigningIn:c,next:h,webEditor:d}),N=C.kind,p="to"in C?C.to:null;if(o.useEffect(()=>{if(!m){if(!b){f("form");return}if(a&&r){f("completing");let x=!0;return D("/ai/authorize_editor",{method:"POST",body:{redirect_uri:a,code_challenge:r}}).then(v=>{x&&(v.redirect?ae(v.redirect):f("form"))}).catch(()=>{x&&f("form")}),()=>{x=!1}}N==="route"&&p?t(p,{replace:!0}):N==="href"&&p&&window.location.replace(p)}},[m,b,a,r,N,p,t]),g==="completing")return e.jsx($,{children:e.jsx("main",{className:"mx-auto flex max-w-5xl flex-col items-center px-5 py-24",children:e.jsxs("div",{className:"w-full max-w-md rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-8 text-center",children:[e.jsx("h1",{className:"text-xl font-semibold text-[var(--c-text)]",children:"Opening LevelCode…"}),e.jsx("p",{className:"mt-3 text-[14px] pretty",children:i?"Signing the editor into your account. You are being sent back to LevelCode.":"Signing the editor into your account. You can return to LevelCode — this tab can be closed."})]})})});const w=c||!!h||!d.loading;return g!=="form"||!w?e.jsx($,{children:e.jsx("main",{className:"mx-auto flex min-h-[60vh] max-w-5xl flex-col px-5 py-24"})}):e.jsx($,{children:e.jsx("main",{className:"mx-auto flex max-w-5xl flex-col items-center px-5 py-16",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-block",children:e.jsx(bt,{})}),e.jsxs("h1",{className:"mt-3 text-[28px] font-bold tracking-tight text-[var(--c-text)]",children:["Sign in to Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsx("p",{className:"mt-2 text-[15px] pretty",children:c?"Connect the editor to your account — you'll be sent back to LevelCode when you're done.":!h&&d.enabled?"LevelCode opens in this tab when you're done.":"Manage your plan, keys, and usage."})]}),e.jsxs("div",{className:"mt-8 rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-7",children:[n?e.jsx("div",{role:"alert",className:"mb-5 rounded-[4px] border border-red-500/50 bg-red-500/10 px-4 py-3 text-[13px] text-red-500",children:Ua[n]??"Sign-in failed. Please try again."}):null,e.jsx(Ba,{redirectUri:l==null?void 0:l.redirectUri,codeChallenge:l==null?void 0:l.codeChallenge,next:h}),e.jsxs("div",{className:"my-5 flex items-center gap-3 text-[var(--c-text3)]","aria-hidden":"true",children:[e.jsx("span",{className:"flex-1 border-t border-[var(--c-line)]"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",children:"or"}),e.jsx("span",{className:"flex-1 border-t border-[var(--c-line)]"})]}),e.jsx(Oa,{redirectUri:l==null?void 0:l.redirectUri,codeChallenge:l==null?void 0:l.codeChallenge,next:h})]}),e.jsxs("p",{className:"mt-5 text-center text-[13px] text-[var(--c-text3)]",children:["By continuing you agree to the"," ",e.jsx(j,{to:"/terms",className:"text-[var(--c-accent)] hover:underline",children:"Terms of Service"})," ","and"," ",e.jsx(j,{to:"/privacy",className:"text-[var(--c-accent)] hover:underline",children:"Privacy Policy"}),". Bring your own key — we never resell provider access."]})]})})})}function Va({tiers:t,authed:s,currentPlan:a}){const r=re(),[n,l]=o.useState(null),[c,i]=o.useState(null),h=d=>(d??"").trim().toLowerCase(),m=d=>s&&!!a&&h(a)===h(d.name);async function b(d){if(i(null),!s){r(be(ge()));return}l(d.key);try{const g=await D("/ai/checkout",{body:{lookup_key:d.key}});if(g.url){ae(g.url);return}if(g.status==="plan_changed"){r("/account?checkout=changed");return}i("Could not start checkout."),l(null)}catch(g){i(g instanceof te?g.message:"Could not start checkout."),l(null)}}return e.jsxs(e.Fragment,{children:[c?e.jsx("p",{className:"mb-4 text-center text-[13px] text-red-500",role:"alert",children:c}):null,e.jsx("div",{className:"grid gap-5 sm:grid-cols-2 lg:grid-cols-4",children:t.map((d,g)=>{const f=g===1,C=m(d);return e.jsxs("div",{className:`flex flex-col rounded-md border bg-[var(--c-bg)] p-6 ${C||f?"border-[var(--c-accent)]":"border-[var(--c-line)]"} ${C?"shadow-[0_0_0_1px_var(--c-accent)]":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--c-text)]",children:d.name}),C?e.jsx("span",{className:"rounded-[3px] bg-[var(--c-accent)] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-white",children:"current"}):f?e.jsx("span",{className:"rounded-[3px] border border-[var(--c-accent)] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-[var(--c-accent)]",children:"popular"}):null]}),e.jsxs("div",{className:"mt-4 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-3xl font-bold tracking-tight text-[var(--c-text)]",children:Ya(d.price_cents)}),e.jsxs("span",{className:"text-sm text-[var(--c-text3)]",children:["/",d.interval||"mo"]})]}),e.jsxs("dl",{className:"mt-5 space-y-1.5 font-mono text-[12px] text-[var(--c-text2)]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"input"}),e.jsx("dd",{className:"tabular-nums",children:it(d.input_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"output"}),e.jsx("dd",{className:"tabular-nums",children:it(d.output_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"turns"}),e.jsx("dd",{className:"tabular-nums",children:(d.turns??0).toLocaleString()})]})]}),e.jsx("ul",{className:"mt-5 flex-1 space-y-2 text-[13px] text-[var(--c-text2)]",children:(d.features??[]).map(N=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"mt-1.5 h-1 w-1 flex-none rounded-full bg-[var(--c-accent)]"}),e.jsx("span",{className:"pretty",children:N})]},N))}),C?e.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"classic-button--quiet mt-6 w-full cursor-default opacity-70",children:"✓ Current plan"}):e.jsx("button",{onClick:()=>b(d),disabled:n===d.key,className:`mt-6 w-full ${f?"classic-button":"classic-button--quiet"}`,children:n===d.key?"Starting…":s?"Choose plan":"Sign in to start"})]},d.key)})})]})}function Ya(t){const s=t/100;return`$${s%1===0?s.toFixed(0):s.toFixed(2)}`}function it(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString()}function Ha(){const{profile:t}=W(),[s,a]=o.useState([]),[r,n]=o.useState(null);return o.useEffect(()=>{let l=!0;return D("/api/levelcode/v1/pricing").then(c=>{l&&a(c.tiers??[])}).catch(()=>{l&&n("Pricing is temporarily unavailable. Please try again shortly.")}),()=>{l=!1}},[]),e.jsxs($,{children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-12 text-center",children:[e.jsx("h1",{className:"text-[30px] font-bold tracking-tight text-[var(--c-text)] sm:text-[36px]",children:"Plans that scale as you ship"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl pretty",children:"Every plan is bring-your-own-key by default — free, forever. Switch on the gateway and your monthly credit is all you pay; we never mark up the provider."})]})}),e.jsx("section",{children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-12",children:[r?e.jsx("div",{className:"rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-8 text-center text-[15px]",children:r}):e.jsx(Va,{tiers:s,authed:!!t,currentPlan:(t==null?void 0:t.plan)??null}),e.jsx("p",{className:"mt-10 text-center text-[13px] text-[var(--c-text3)]",children:"All plans include the full editor — it’s free and open source. Plans meter the managed AI gateway only."})]})})]})}function Rt({title:t,updated:s,intro:a,children:r}){return e.jsxs($,{children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-3xl px-5 py-10 text-center",children:[e.jsx("h1",{className:"text-[30px] font-bold tracking-tight text-[var(--c-text)] sm:text-[36px]",children:t}),e.jsxs("p",{className:"mt-2 text-[13px] text-[var(--c-text3)]",children:["Last updated: ",s]})]})}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-12",children:[e.jsx("p",{className:"text-[16px] leading-relaxed pretty",children:a}),e.jsx("div",{className:"mt-10 space-y-9",children:r})]})]})}function A({id:t,heading:s,children:a}){return e.jsxs("section",{id:t,className:"scroll-mt-24",children:[e.jsx("h2",{className:"text-xl font-semibold tracking-tight text-[var(--c-text)]",children:s}),e.jsx("div",{className:"mt-3 space-y-3 text-[15px] leading-relaxed pretty",children:a})]})}function Za(){return e.jsxs(Rt,{title:"Privacy Policy",updated:"July 9, 2026",intro:e.jsx(e.Fragment,{children:"This policy explains what LevelCode collects, how we use it, and who we share it with when you use the LevelCode editor and LevelCode Cloud (levelcode.ai). The most important thing to know: to generate AI responses, we send your prompts and selected code to third-party model providers."}),children:[e.jsxs(A,{id:"collect",heading:"1. What we collect",children:[e.jsxs("ul",{className:"list-disc space-y-1.5 pl-5",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Account"})," — your email and basic profile, and the authentication tokens the editor uses to talk to the service."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Prompts & code"})," — the prompts and code you submit to the AI gateway, so we can generate responses and meter usage."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Usage & billing"})," — model used, token counts, timestamps, plan, and spend, used to meter your allowance and support billing. Payments are handled by Stripe; we do not receive or store your full card number."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Technical"})," — IP address, device/browser info, and server logs, used for security and to operate the Service."]})]}),e.jsx("p",{children:"Product telemetry in the editor is off by default. If you use bring-your-own-key (BYOK), those requests go directly to your provider and your prompts and code do not pass through our gateway."})]}),e.jsx(A,{id:"use",heading:"2. How we use it",children:e.jsx("p",{children:"To provide, secure, and improve the Service — including generating AI responses, metering your usage against your plan, processing subscriptions, providing support, preventing abuse, and meeting legal obligations. We do not sell your personal information, and we do not use the content of your prompts or code to advertise to you."})}),e.jsxs(A,{id:"share",heading:"3. Who we share it with",children:[e.jsx("p",{children:"We share information only with service providers that help us run LevelCode:"}),e.jsxs("ul",{className:"list-disc space-y-1.5 pl-5",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"AI model providers & routing"})," — your prompts and selected code are sent to the AI provider(s) that generate your response, via our routing partner. They process this content to return a result and under their own terms and privacy policies."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Payments"})," — Stripe, to process subscriptions and payments."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Hosting & infrastructure"})," — our cloud hosting provider, which stores and serves the Service on our behalf."]})]}),e.jsx("p",{children:"We may also disclose information if required by law, to enforce our terms, or to protect the rights, safety, and security of LevelCode and its users. If we’re involved in a merger or acquisition, your information may transfer as part of that transaction."})]}),e.jsx(A,{id:"retention",heading:"4. Retention",children:e.jsxs("p",{children:["We keep account and billing records for as long as your account is active and as needed to meet legal, tax, and security obligations. Prompts, code, and usage records are retained only as long as needed to operate the Service and support your account, after which they are deleted or anonymized."," "]})}),e.jsx(A,{id:"cookies",heading:"5. Cookies",children:e.jsx("p",{children:"We use strictly necessary cookies to keep you signed in and to operate the site. We do not use third-party advertising cookies. Your browser settings let you control cookies, though the Service may not work properly without the essential ones."})}),e.jsx(A,{id:"security",heading:"6. Security",children:e.jsx("p",{children:"We use technical and organizational measures — including encryption in transit and access controls — to protect your information. No method of transmission or storage is perfectly secure, so we cannot guarantee absolute security."})}),e.jsx(A,{id:"rights",heading:"7. Your rights",children:e.jsx("p",{children:"Depending on where you live (for example, under GDPR or the CCPA), you may have the right to access, correct, delete, or export your personal information, and to object to or restrict certain processing. To make a request, email us at the address below; we will respond as required by applicable law."})}),e.jsx(A,{id:"children",heading:"8. Children",children:e.jsx("p",{children:"The Service is not directed to children under 13, and we do not knowingly collect their personal information. If you believe a child has provided us information, contact us and we will delete it."})}),e.jsx(A,{id:"international",heading:"9. International transfers",children:e.jsx("p",{children:"We and our providers may process your information in countries other than yours. Where required, we rely on appropriate safeguards for such transfers."})}),e.jsx(A,{id:"changes",heading:"10. Changes",children:e.jsx("p",{children:"We may update this policy from time to time. Material changes will be reflected in the date above and, where appropriate, communicated to you."})}),e.jsx(A,{id:"contact",heading:"11. Contact",children:e.jsxs("p",{children:["Privacy questions or requests? Email"," ",e.jsx("a",{href:"mailto:privacy@levelcode.ai",className:"text-[var(--c-accent)] hover:underline",children:"privacy@levelcode.ai"}),"."]})})]})}function Pt(t){const s=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${s}-${a}`}function ct(t){const s=new Date;return s.setDate(s.getDate()-t),Pt(s)}const he=()=>Pt(new Date),dt=/^\d{4}-\d{2}-\d{2}$/;function Ga(t,s){return!dt.test(t)||!dt.test(s)?"Pick both a start and an end date.":t>s?"The start date is after the end date.":s>he()?"The end date is in the future.":null}function za(){const t=re(),{loading:s,profile:a}=W(),[r,n]=o.useState(()=>ct(29)),[l,c]=o.useState(he),[i,h]=o.useState(null),[m,b]=o.useState(null),[d,g]=o.useState(!0),f=(a==null?void 0:a.role)==="admin";o.useEffect(()=>{s||(a?f||t("/account",{replace:!0}):t(be(ge()),{replace:!0}))},[s,a,f,t]);const C=Ga(r,l);if(o.useEffect(()=>{if(!f)return;if(C){g(!1);return}let p=!0;g(!0),b(null);const w=new URLSearchParams({from:r,to:l});return D(`/api/levelcode/v1/admin/referrals?${w.toString()}`).then(x=>{p&&(h(x),g(!1))}).catch(()=>{p&&(h(null),b("Couldn’t load the referral funnel."),g(!1))}),()=>{p=!1}},[f,r,l,C]),s||!f)return e.jsx($,{children:e.jsx("main",{className:"mx-auto max-w-5xl px-5 py-12"})});const N=(i==null?void 0:i.rows)??[];return e.jsx($,{children:e.jsxs("main",{className:"mx-auto max-w-5xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:"Referrals"}),e.jsx("p",{className:"mt-2 text-[14px] text-[var(--c-text3)]",children:"clicks · signups · paid, per marketing channel"})]}),e.jsx(j,{to:"/admin",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"← System dashboard"})]}),m?e.jsx("div",{className:"classic-card mt-8 p-6 text-[14px] text-red-500",children:m}):null,C?e.jsxs("div",{role:"alert",className:"mt-8 rounded-md border border-[#d19a66]/40 bg-[#d19a66]/[0.1] px-4 py-3 text-[14px] text-[var(--c-text)]",children:[C,i?" Showing the last loaded range below.":null]}):null,e.jsxs("div",{className:"mt-8 flex flex-wrap items-center gap-3",children:[e.jsx(xt,{label:"from",value:r,max:l,onChange:n}),e.jsx(xt,{label:"to",value:l,min:r,max:he(),onChange:c}),e.jsx("div",{className:"flex gap-2",children:[{label:"7d",days:6},{label:"30d",days:29},{label:"90d",days:89}].map(p=>e.jsx("button",{type:"button",onClick:()=>{n(ct(p.days)),c(he())},className:"rounded-md border border-[var(--c-line)] px-2.5 py-1.5 font-mono text-[12px] text-[var(--c-text2)] transition-colors hover:border-[var(--c-accent)] hover:text-[var(--c-text)]",children:p.label},p.label))})]}),e.jsxs("div",{className:"mt-6 grid gap-4 sm:grid-cols-3",children:[e.jsx(Ee,{label:"clicks",value:i==null?void 0:i.totals.clicks}),e.jsx(Ee,{label:"signups",value:i==null?void 0:i.totals.signups}),e.jsx(Ee,{label:"paid",value:i==null?void 0:i.totals.paid})]}),i?e.jsxs("p",{className:"mt-3 font-mono text-[12px] text-[var(--c-text3)]",children:["covering ",i.from," → ",i.to]}):null,e.jsx("div",{className:"classic-card mt-6 overflow-x-auto p-0",children:e.jsxs("table",{className:"w-full min-w-[620px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"px-3 py-2 font-normal",children:"channel"}),e.jsx("th",{className:"px-3 py-2 font-normal",children:"handle"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"clicks"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"signups"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"paid"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"click → signup"})]})}),e.jsxs("tbody",{children:[N.map(p=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] last:border-b-0 hover:bg-[var(--c-surface)]",children:[e.jsx("td",{className:"px-3 py-2 text-[var(--c-text)]",children:p.channel}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:p.handle??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:p.clicks}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text)]",children:p.signups}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:p.paid}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text3)]",children:p.clicks>0?`${(p.signups/p.clicks*100).toFixed(1)}%`:"—"})]},`${p.channel}-${p.handle??""}`)),i&&N.length===0&&!d?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-8 text-center text-[var(--c-text3)]",children:"No referral activity in this range."})}):null]})]})}),e.jsxs("div",{className:"mt-4 space-y-1.5 text-[12px] leading-relaxed text-[var(--c-text3)]",children:[i?e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:i.unattributed_signups})," ","signup",i.unattributed_signups===1?"":"s"," in this range carried no channel — organic, or the visitor’s browser dropped the stored attribution. They are not in the table."]}):null,e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:"paid"})," counts people who signed up in this range and are on a paid plan ",e.jsx("em",{children:"right now"})," — there is no “became paid” timestamp to measure conversions inside the range."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:"clicks"})," are matched to a channel through the short link’s current destination and exclude bots. Editing a link’s destination re-attributes its past clicks."]}),e.jsx("p",{children:"Clicks and signups are counted independently and joined only by channel name, so click → signup is a ratio between two populations, not a tracked journey."})]})]})})}function xt({label:t,value:s,min:a,max:r,onChange:n}){return e.jsxs("label",{className:"flex items-center gap-2 font-mono text-[12px] text-[var(--c-text3)]",children:[t,e.jsx("input",{type:"date",value:s,min:a,max:r,onChange:l=>n(l.target.value),className:"rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-2.5 py-1.5 font-mono text-[12px] text-[var(--c-text)] outline-none focus:border-[var(--c-accent)]"})]})}function Ee({label:t,value:s}){return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("p",{className:"classic-label",children:t}),e.jsx("p",{className:"mt-1 text-[26px] font-bold tabular-nums text-[var(--c-text)]",children:s===void 0?"—":s.toLocaleString("en-US")})]})}function Ka(){return e.jsxs(Rt,{title:"Terms of Service",updated:"July 9, 2026",intro:e.jsxs(e.Fragment,{children:["These Terms govern your use of LevelCode — the LevelCode editor and the LevelCode Cloud service at levelcode.ai (together, the “Service”). By creating an account or using the Service, you agree to these Terms and to our"," ",e.jsx("a",{href:"/privacy",className:"text-[var(--c-accent)] hover:underline",children:"Privacy Policy"}),"."]}),children:[e.jsx(A,{heading:"1. The Service",children:e.jsx("p",{children:"LevelCode is an AI-native code editor and a metered AI gateway. On a paid plan or the free tier, the editor sends your prompts and selected code to our gateway, which routes them to third-party AI model providers to generate responses. You may also use your own provider API key (“bring-your-own-key” / BYOK); in that mode requests go directly to your provider and do not run through our gateway or metering."})}),e.jsx(A,{heading:"2. Eligibility & accounts",children:e.jsx("p",{children:"You must be at least 13 years old (and, if under the age of majority where you live, have your parent or guardian’s consent) to use the Service. You are responsible for your account and for keeping your credentials and API keys secure. Notify us promptly of any unauthorized use."})}),e.jsxs(A,{heading:"3. Plans, billing & usage limits",children:[e.jsx("p",{children:"Paid plans are subscriptions billed in advance through our payment processor (Stripe) and renew automatically each period until canceled. You can cancel anytime; cancellation takes effect at the end of the current billing period, and, except where required by law, payments are non-refundable."}),e.jsx("p",{children:"Each plan includes a monthly usage allowance, expressed as approximate model “turns.” To keep the Service reliable, that allowance is metered and may be made available progressively over the billing cycle rather than all at once (rolling usage windows) — heavy use may be paced or, on some plans, temporarily served by a lighter model until more of your allowance becomes available or the period renews. We show your current usage and when more becomes available in your account. We may change plans, prices, allowances, or limits prospectively, with notice for existing subscribers."})]}),e.jsxs(A,{heading:"4. Your content and code",children:[e.jsx("p",{children:"You retain all rights to the code, prompts, and other content you submit (“Your Content”). You grant us a limited license to process, transmit, and store Your Content solely to operate and improve the Service — including sending it to the AI model providers needed to generate responses. We do not claim ownership of Your Content or of the outputs generated for you."}),e.jsx("p",{children:"You are responsible for having the rights to submit Your Content and for ensuring your use complies with any licenses that apply to code you work on."})]}),e.jsx(A,{heading:"5. AI output — no warranty",children:e.jsx("p",{children:"AI-generated code and text may be inaccurate, insecure, or unsuitable for your purpose, and similar outputs may be generated for other users. You are responsible for reviewing, testing, and deciding whether to use any output. The Service is not a substitute for professional judgment, and outputs are not legal, financial, security, or other professional advice."})}),e.jsxs(A,{heading:"6. Acceptable use",children:[e.jsx("p",{children:"You agree not to use the Service to:"}),e.jsxs("ul",{className:"list-disc space-y-1 pl-5",children:[e.jsx("li",{children:"break the law or infringe others’ rights;"}),e.jsx("li",{children:"generate malware, or content intended to harm, harass, defraud, or deceive;"}),e.jsx("li",{children:"abuse, overload, reverse-engineer, or circumvent the gateway, metering, or usage limits;"}),e.jsx("li",{children:"resell or provide the Service to third parties except as expressly permitted; or"}),e.jsx("li",{children:"violate the terms of the underlying AI providers or other third-party services."})]})]}),e.jsx(A,{heading:"7. Third-party services",children:e.jsx("p",{children:"The Service relies on third parties — including the AI model providers and routing partner behind our gateway, our payment processor, and our hosting provider. Your use of the Service through these providers is also subject to their terms, and we are not responsible for their acts or omissions."})}),e.jsx(A,{heading:"8. Intellectual property & open source",children:e.jsx("p",{children:"The LevelCode name, site, and service are owned by us or our licensors. The editor is built on open-source software, which remains governed by its own licenses; nothing here restricts your rights under those licenses. Except for those open-source components and Your Content, you may not copy, modify, or create derivative works of the Service without permission."})}),e.jsx(A,{heading:"9. Disclaimers & limitation of liability",children:e.jsx("p",{children:"The Service is provided “as is” and “as available,” without warranties of any kind to the fullest extent permitted by law. To the extent permitted by law, we are not liable for indirect, incidental, or consequential damages, and our total liability for any claim relating to the Service will not exceed the amount you paid us for the Service in the twelve months before the claim."})}),e.jsx(A,{heading:"10. Termination",children:e.jsx("p",{children:"You may stop using the Service at any time. We may suspend or terminate access if you violate these Terms or to protect the Service or other users. Sections that by their nature should survive termination (for example, ownership, disclaimers, and limitations of liability) will survive."})}),e.jsx(A,{heading:"11. Changes to these Terms",children:e.jsx("p",{children:"We may update these Terms from time to time. If we make material changes we will update the date above and, where appropriate, notify you. Your continued use of the Service after changes take effect means you accept the updated Terms."})}),e.jsx(A,{heading:"12. Governing law",children:e.jsx("p",{children:"These Terms are governed by the laws of [governing-law jurisdiction], without regard to conflict-of-laws rules, and any disputes will be resolved in the courts located there. "})}),e.jsx(A,{heading:"13. Contact",children:e.jsxs("p",{children:["Questions about these Terms? Email"," ",e.jsx("a",{href:"mailto:legal@levelcode.ai",className:"text-[var(--c-accent)] hover:underline",children:"legal@levelcode.ai"}),"."]})})]})}const I={lede:"The real LevelCode workbench, running in a browser tab. Explorer, editor tabs, themes, the chat panel and the agent are all there. Nothing to install.",signIn:"Sign in with your LevelCode account. The gateway plan and usage are the same as in the Mac app. The editor takes this tab to your account and back, and if you are already signed in there you come straight back.",works:[{title:"The workbench",body:"Explorer, editor tabs, themes and the chat panel."},{title:"The agent",body:"It can read, search, create, edit and delete files in the open workspace. Its changes are applied at once and offered for Keep or Undo."},{title:"A terminal for your files",body:"LevelCode Shell is bash with about eighty built-in commands (grep, sed, awk, find, sort, jq, diff and more) over the files you have open. It does not run programs, so there is no Node, npm, git or Python in it. The agent runs its commands there too, and what they change is offered for Keep or Undo."},{title:"Your account",body:"The gateway plan and usage are the same as in the Mac app."},{title:"Your own key",body:"Use a provider key of your own instead of the gateway. It is kept encrypted in this browser, and requests go from the browser to the provider, so the provider has to accept requests from a web page."},{title:"Your files",body:"Open a folder from your computer, or work in a scratch workspace saved in your browser."}],staysInMacApp:["Running programs: Node, npm, git, Python, test runners and builds","Background commands and dev servers","MCP servers that start local processes","Installing extensions"],folder:{title:"Open a folder from your computer",body:"LevelCode uses the File System Access API, so edits go straight to the folder you picked. Available in Chrome and Edge."},scratch:{title:"Use a scratch workspace",body:"A workspace that is saved in your browser. It works in every modern browser, including Safari and Firefox. Clearing the site's data in your browser removes it."},browsers:[{name:"Chrome",folder:!0},{name:"Edge",folder:!0},{name:"Safari",folder:!1},{name:"Firefox",folder:!1}],privacy:{title:"What goes to the model",files:"Files stay in your browser or on your computer.",model:"The text you send in chat and the files you ask LevelCode to read go to the model through the LevelCode gateway, the same as in the Mac app."}};function Xa(){const{enabled:t,url:s,loading:a}=z();if(Qa(t),a)return e.jsx($,{children:e.jsx("main",{"aria-busy":"true",className:"mx-auto min-h-[60vh] max-w-5xl px-5 py-24"})});if(!t||!s)return e.jsx(Ja,{});const r=new URL(s).host;return e.jsx($,{children:e.jsxs("main",{children:[e.jsxs("section",{className:"lp-hero",children:[e.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col items-center px-5 pb-12 pt-16 text-center sm:pb-14 sm:pt-24",children:[e.jsx("h1",{className:"lp-h1 text-balance",children:"LevelCode in your browser"}),e.jsx("p",{className:"lp-lead mt-5 max-w-2xl text-balance",children:I.lede}),e.jsx("div",{className:"mt-9",children:e.jsx(ut,{url:s})}),e.jsx("p",{className:"mt-5 max-w-md text-[15px] text-[var(--c-text2)] pretty",children:I.signIn})]}),e.jsx("div",{className:"mx-auto max-w-5xl px-5 pb-20 sm:pb-24",children:e.jsx(er,{host:r})})]}),e.jsx("section",{className:"border-y border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"What works here, and what stays in the Mac app"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"The browser edition covers the workbench and the agent’s work on your files. A few things stay in the Mac app."})]}),e.jsxs("div",{className:"lp-card mx-auto mt-12 grid max-w-4xl divide-y divide-[var(--c-line)] md:grid-cols-2 md:divide-x md:divide-y-0",children:[e.jsxs("div",{className:"p-7",children:[e.jsx("h3",{className:"text-[22px] font-semibold leading-snug text-[var(--c-text)]",children:"Works in your browser"}),e.jsx("ul",{className:"mt-6 space-y-5",children:I.works.map(n=>e.jsxs("li",{className:"flex gap-3",children:[e.jsx("span",{className:"mt-[3px] shrink-0 text-[var(--lp-add)]",children:e.jsx(It,{})}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[16px] font-semibold text-[var(--c-text)]",children:n.title}),e.jsx("span",{className:"mt-0.5 block text-[15px] text-[var(--c-text2)] pretty",children:n.body})]})]},n.title))})]}),e.jsxs("div",{className:"p-7",children:[e.jsx("h3",{className:"text-[22px] font-semibold leading-snug text-[var(--c-text)]",children:"Stays in the Mac app"}),e.jsx("ul",{className:"mt-6 space-y-4",children:I.staysInMacApp.map(n=>e.jsxs("li",{className:"flex gap-3 text-[16px] text-[var(--c-text)]",children:[e.jsx("span",{className:"mt-[3px] shrink-0 text-[var(--c-text3)]",children:e.jsx(Ot,{})}),n]},n))}),e.jsx("p",{className:"mt-8",children:e.jsx(j,{to:"/download",className:"lp-link text-[15px] font-medium",children:"Download LevelCode for Mac →"})})]})]})]})}),e.jsx("section",{children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 sm:py-24",children:[e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Where your files live"}),e.jsx("p",{className:"lp-lead mt-4 text-balance",children:"There are two ways to work with files in the browser."})]}),e.jsxs("div",{className:"mx-auto mt-12 grid max-w-4xl gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"lp-card p-7",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:e.jsx(tr,{})}),e.jsx("h3",{className:"mt-4 text-[20px] font-semibold leading-snug text-[var(--c-text)]",children:I.folder.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:I.folder.body})]}),e.jsxs("div",{className:"lp-card p-7",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:e.jsx(sr,{})}),e.jsx("h3",{className:"mt-4 text-[20px] font-semibold leading-snug text-[var(--c-text)]",children:I.scratch.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:I.scratch.body})]})]}),e.jsx("div",{className:"mx-auto mt-6 max-w-4xl",children:e.jsx("div",{className:"lp-card overflow-x-auto px-5 py-3 sm:px-7",children:e.jsxs("table",{className:"w-full border-collapse text-left text-[15px]",children:[e.jsx("caption",{className:"sr-only",children:"Which browsers can open a folder, and which can use a scratch workspace"}),e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--c-line)] text-[13px] text-[var(--c-text3)]",children:[e.jsx("th",{scope:"col",className:"py-2.5 pr-4 font-medium",children:"Browser"}),e.jsx("th",{scope:"col",className:"px-4 py-2.5 font-medium",children:"Open a folder"}),e.jsx("th",{scope:"col",className:"py-2.5 pl-4 font-medium",children:"Scratch workspace"})]})}),e.jsx("tbody",{children:I.browsers.map(n=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] last:border-b-0",children:[e.jsx("th",{scope:"row",className:"py-3 pr-4 font-medium text-[var(--c-text)]",children:n.name}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(ht,{yes:n.folder})}),e.jsx("td",{className:"py-3 pl-4",children:e.jsx(ht,{yes:!0})})]},n.name))})]})})}),e.jsx("div",{className:"mx-auto mt-6 max-w-4xl",children:e.jsxs("div",{className:"lp-card flex flex-col gap-4 p-7 sm:flex-row sm:items-start sm:gap-5",children:[e.jsx("span",{className:"shrink-0 text-[var(--c-accent)]",children:e.jsx(Bt,{})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[20px] font-semibold leading-snug text-[var(--c-text)]",children:I.privacy.title}),e.jsxs("p",{className:"mt-1.5 text-[15px] pretty",children:[I.privacy.files," ",I.privacy.model]}),e.jsx("p",{className:"mt-3",children:e.jsx(j,{to:"/privacy",className:"lp-link text-[15px] font-medium",children:"Read the privacy policy"})})]})]})})]})}),e.jsx("section",{className:"lp-hero lp-hero--closing border-t border-[var(--c-line)]",children:e.jsxs("div",{className:"mx-auto flex max-w-3xl flex-col items-center px-5 py-24 text-center sm:py-28",children:[e.jsx("h2",{className:"lp-h2 text-balance",children:"Start in your browser"}),e.jsx("p",{className:"lp-lead mt-4 max-w-xl text-balance",children:"Sign in with your LevelCode account, then open a folder or a scratch workspace."}),e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsx(ut,{url:s}),e.jsx(j,{to:"/download",className:"lp-cta lp-cta--quiet",children:"Download for Mac"})]}),e.jsx("p",{className:"mt-6 text-[14px] text-[var(--c-text3)]",children:e.jsx(j,{to:"/docs/browser",className:"lp-link",children:"Read the browser edition guide"})})]})})]})})}function Ja(){return e.jsx($,{children:e.jsx("main",{children:e.jsx("section",{className:"lp-hero",children:e.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col items-center px-5 pb-28 pt-20 text-center sm:pt-28",children:[e.jsx("h1",{className:"lp-h1 text-balance",children:"LevelCode in your browser"}),e.jsx("p",{className:"lp-lead mt-5 text-balance",children:"The browser edition is not available right now."}),e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsx(j,{to:"/download",className:"lp-cta",children:"Download LevelCode for Mac"}),e.jsx(j,{to:"/docs",className:"lp-cta lp-cta--quiet",children:"Read the documentation"})]})]})})})})}function ut({url:t}){return e.jsxs("a",{href:t,className:"lp-cta",children:["Open LevelCode",e.jsx("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M3 8h10m-4-4 4 4-4 4"})})]})}function ht({yes:t}){return t?e.jsxs("span",{className:"inline-flex items-center gap-2 text-[var(--c-text)]",children:[e.jsx("span",{className:"text-[var(--lp-add)]",children:e.jsx(It,{})}),"Yes"]}):e.jsxs("span",{className:"inline-flex items-center gap-2 text-[var(--c-text3)]",children:[e.jsx(Ot,{}),"No"]})}function Qa(t){o.useEffect(()=>{if(!t)return;const s=document.title;document.title="LevelCode in your browser";const a=document.querySelector('meta[name="description"]'),r=(a==null?void 0:a.hasAttribute("content"))??!1,n=(a==null?void 0:a.getAttribute("content"))??null;return a==null||a.setAttribute("content",I.lede),()=>{document.title=s,a&&(r&&n!==null?a.setAttribute("content",n):a.removeAttribute("content"))}},[t])}const xe="text-[#c58aff]",mt="text-[#9fb4ff]",pt="text-[#7fd88f]";function er({host:t}){return e.jsx("div",{className:"lp-stage",role:"img","aria-label":"LevelCode open in a browser tab: the file explorer, a file in the editor, and the chat panel with the agent's steps.",children:e.jsxs("div",{className:"shot-shadow w-full max-w-[940px] overflow-hidden rounded-xl border border-[var(--c-line)] bg-[var(--c-bg)] text-left","aria-hidden":!0,children:[e.jsxs("div",{className:"flex items-end gap-3 border-b border-[var(--c-line)] bg-[var(--c-surface)] px-3 pt-2.5",children:[e.jsxs("span",{className:"flex gap-1.5 self-center pb-2",children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[var(--c-line)]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[var(--c-line)]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[var(--c-line)]"})]}),e.jsxs("span",{className:"relative -mb-px flex items-center gap-2 rounded-t-lg border border-b-0 border-[var(--c-line)] bg-[var(--c-bg)] px-3.5 py-2 text-[12.5px] font-medium text-[var(--c-text)]",children:[e.jsx(bt,{size:14}),"LevelCode"]})]}),e.jsxs("div",{className:"flex items-center gap-2.5 border-b border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2",children:[e.jsxs("span",{className:"flex gap-2 text-[var(--c-text3)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M10 3 5 8l5 5"})}),e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-50",children:e.jsx("path",{d:"m6 3 5 5-5 5"})})]}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 rounded-full bg-[var(--lp-well)] px-3.5 py-1.5 font-mono text-[12px] text-[var(--c-text2)]",children:[e.jsx("span",{className:"shrink-0 text-[var(--c-text3)]",children:e.jsx(Bt,{size:12})}),e.jsx("span",{className:"truncate",children:t})]})]}),e.jsxs("div",{className:"grid bg-[#0a0c16] md:grid-cols-[minmax(0,1fr)_262px] lg:grid-cols-[172px_minmax(0,1fr)_262px]",children:[e.jsxs("div",{className:"hidden border-r border-[#1b1e2b] bg-[#0d1020] px-3 py-3.5 font-mono text-[12px] lg:block",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.14em] text-[#6b7280]",children:"Explorer"}),e.jsxs("ul",{className:"mt-3 space-y-1 text-[#8b93ad]",children:[e.jsxs("li",{className:"flex items-center gap-1.5 text-[#c7cbe0]",children:[e.jsx(ft,{open:!0}),"my-blog"]}),e.jsxs("li",{className:"flex items-center gap-1.5 pl-3",children:[e.jsx(ft,{open:!0}),"src"]}),e.jsx("li",{className:"-mx-3 bg-[#7d6bff]/15 py-0.5 pl-11 text-[#e2defe]",children:"slug.ts"}),e.jsx("li",{className:"pl-8",children:"post.ts"}),e.jsx("li",{className:"pl-8",children:"index.ts"}),e.jsx("li",{className:"pl-3",children:"package.json"}),e.jsx("li",{className:"pl-3",children:"README.md"})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex border-b border-[#1b1e2b] bg-[#0d1020] font-mono text-[12px]",children:[e.jsx("span",{className:"border-r border-[#1b1e2b] border-t-2 border-t-[#7d6bff] bg-[#0a0c16] px-4 py-2 text-[#e2defe]",children:"slug.ts"}),e.jsx("span",{className:"border-r border-[#1b1e2b] px-4 py-2 text-[#6b7280]",children:"post.ts"})]}),e.jsxs("div",{className:"overflow-hidden whitespace-pre px-3 py-4 font-mono text-[11px] leading-[1.95] text-[#c7cbe0] sm:px-4 sm:text-[12px] md:text-[12.5px]",children:[e.jsxs(G,{no:"1",children:[e.jsx("span",{className:xe,children:"import"})," ","{ words }"," ",e.jsx("span",{className:xe,children:"from"})," ",e.jsx("span",{className:pt,children:'"./text"'}),";"]}),e.jsx(G,{no:"2"}),e.jsxs(G,{no:"3",children:[e.jsx("span",{className:xe,children:"export function"})," ",e.jsx("span",{className:mt,children:"slugify"}),"(title) ","{"]}),e.jsxs(G,{no:"4",children:[" ",e.jsx("span",{className:xe,children:"return"})," ",e.jsx("span",{className:mt,children:"words"}),"(title)"]}),e.jsxs(G,{no:"5",children:[" ",".map((w) => w.toLowerCase())"]}),e.jsxs(G,{no:"6",children:[" ",".join(",e.jsx("span",{className:pt,children:'"-"'}),");"]}),e.jsxs(G,{no:"7",children:["}",e.jsx("span",{className:"ml-px inline-block h-[1.05em] w-[2px] -translate-y-[1px] animate-caret bg-[#7d6bff] align-middle"})]})]})]}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-4 border-t border-[#1b1e2b] bg-[#0d1020]/60 p-4 text-[13px] leading-relaxed md:border-l md:border-t-0",children:[e.jsxs("div",{className:"flex items-center justify-between font-mono text-[10px] uppercase tracking-[0.14em] text-[#a99bff]",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[#7d6bff] shadow-[0_0_8px_rgba(125,107,255,0.9)]"}),"LevelCode"]}),e.jsx("span",{className:"rounded-full border border-[#7d6bff]/40 bg-[#7d6bff]/15 px-2 py-0.5 normal-case tracking-normal text-[#c6bfff]",children:"Agent"})]}),e.jsx("p",{className:"rounded-lg bg-[#171a2b] px-3 py-2.5 text-[#c7cbe0]",children:"Rename makeSlug to slugify everywhere it is used."}),e.jsxs("ul",{className:"space-y-2 text-[#8b93ad]",children:[e.jsx(De,{children:"Searched the workspace"}),e.jsx(De,{children:"Read 4 files"}),e.jsxs(De,{children:["Edited 3 files ",e.jsx("span",{className:"ml-1 font-mono text-[12px] text-[#7fd88f]",children:"+6"})," ",e.jsx("span",{className:"font-mono text-[12px] text-[#f47067]",children:"−6"})]})]}),e.jsx("p",{className:"border-t border-[#1b1e2b] pt-3 text-[#8b93ad]",children:"Renamed makeSlug in 3 files."})]})]})]})})}function G({no:t,children:s}){return e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-[2.4em] select-none text-[#3b4157]",children:t}),s]})}function De({children:t}){return e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsxs("svg",{viewBox:"0 0 16 16",width:"15",height:"15",className:"mt-[3px] shrink-0 text-[#7fd88f]",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.35",fill:"none",stroke:"currentColor",strokeWidth:"1"}),e.jsx("path",{d:"M5.05 8.25 7 10.2l4.15-4.35",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("span",{children:t})]})}function ft({open:t}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"10",height:"10",fill:"currentColor",className:t?"rotate-90":"",children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})})}function It(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m3.5 8.5 3 3 6-7"})})}function Ot(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":!0,children:e.jsx("path",{d:"M4 8h8"})})}function We({d:t,size:s=28}){return e.jsx("svg",{viewBox:"0 0 24 24",width:s,height:s,fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"inline-block",children:e.jsx("path",{d:t})})}const tr=()=>e.jsx(We,{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),sr=()=>e.jsx(We,{d:"M3 6a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6Zm0 4h18M8 4v6"}),Bt=({size:t=28})=>e.jsx(We,{size:t,d:"M7 11V8a5 5 0 0 1 10 0v3M6 11h12v9H6v-9Zm6 3.5v2"});function ar(){return e.jsxs(Vt,{children:[e.jsx(P,{path:"/",element:e.jsx(nt,{})}),e.jsx(P,{path:"/login",element:e.jsx(Wa,{})}),e.jsx(P,{path:"/pricing",element:e.jsx(Ha,{})}),e.jsx(P,{path:"/account",element:e.jsx(ks,{})}),e.jsx(P,{path:"/admin",element:e.jsx(Ls,{})}),e.jsx(P,{path:"/admin/referrals",element:e.jsx(za,{})}),e.jsx(P,{path:"/terms",element:e.jsx(Ka,{})}),e.jsx(P,{path:"/privacy",element:e.jsx(Za,{})}),e.jsx(P,{path:"/download",element:e.jsx(ma,{})}),e.jsx(P,{path:"/web",element:e.jsx(Xa,{})}),e.jsx(P,{path:"/docs",element:e.jsx(Ct,{})}),e.jsx(P,{path:"/docs/:slug",element:e.jsx(nr,{})}),e.jsx(P,{path:"*",element:e.jsx(nt,{})})]})}const rr={hackability:"customization"};function nr(){const{slug:t}=Yt(),{hash:s}=X(),a=t?rr[t]:void 0;return a?e.jsx(Ht,{to:`/docs/${a}${s}`,replace:!0}):e.jsx(Ct,{slug:t})}Ra();Zt(document.getElementById("root")).render(e.jsx(o.StrictMode,{children:e.jsx(Gt,{basename:"/ai",children:e.jsx(ar,{})})}));export{As as u}; diff --git a/app/assets/interface/main-BWYE5mJA.js b/app/assets/interface/main-DXpkyJDZ.js similarity index 99% rename from app/assets/interface/main-BWYE5mJA.js rename to app/assets/interface/main-DXpkyJDZ.js index 99b37ba1..0a6504a9 100644 --- a/app/assets/interface/main-BWYE5mJA.js +++ b/app/assets/interface/main-DXpkyJDZ.js @@ -13,7 +13,7 @@ import{r as l,u as Je,j as e,R as q,a as zt,t as Yr,b as Ra,L as X,c as xr,d as */var Xr;function zc(){if(Xr)return ye;Xr=1;var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,n=t?Symbol.for("react.fragment"):60107,r=t?Symbol.for("react.strict_mode"):60108,i=t?Symbol.for("react.profiler"):60114,o=t?Symbol.for("react.provider"):60109,d=t?Symbol.for("react.context"):60110,c=t?Symbol.for("react.async_mode"):60111,u=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,h=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,p=t?Symbol.for("react.memo"):60115,y=t?Symbol.for("react.lazy"):60116,g=t?Symbol.for("react.block"):60121,f=t?Symbol.for("react.fundamental"):60117,b=t?Symbol.for("react.responder"):60118,j=t?Symbol.for("react.scope"):60119;function w(k){if(typeof k=="object"&&k!==null){var N=k.$$typeof;switch(N){case a:switch(k=k.type,k){case c:case u:case n:case i:case r:case h:return k;default:switch(k=k&&k.$$typeof,k){case d:case m:case y:case p:case o:return k;default:return N}}case s:return N}}}function v(k){return w(k)===u}return ye.AsyncMode=c,ye.ConcurrentMode=u,ye.ContextConsumer=d,ye.ContextProvider=o,ye.Element=a,ye.ForwardRef=m,ye.Fragment=n,ye.Lazy=y,ye.Memo=p,ye.Portal=s,ye.Profiler=i,ye.StrictMode=r,ye.Suspense=h,ye.isAsyncMode=function(k){return v(k)||w(k)===c},ye.isConcurrentMode=v,ye.isContextConsumer=function(k){return w(k)===d},ye.isContextProvider=function(k){return w(k)===o},ye.isElement=function(k){return typeof k=="object"&&k!==null&&k.$$typeof===a},ye.isForwardRef=function(k){return w(k)===m},ye.isFragment=function(k){return w(k)===n},ye.isLazy=function(k){return w(k)===y},ye.isMemo=function(k){return w(k)===p},ye.isPortal=function(k){return w(k)===s},ye.isProfiler=function(k){return w(k)===i},ye.isStrictMode=function(k){return w(k)===r},ye.isSuspense=function(k){return w(k)===h},ye.isValidElementType=function(k){return typeof k=="string"||typeof k=="function"||k===n||k===u||k===i||k===r||k===h||k===x||typeof k=="object"&&k!==null&&(k.$$typeof===y||k.$$typeof===p||k.$$typeof===o||k.$$typeof===d||k.$$typeof===m||k.$$typeof===f||k.$$typeof===b||k.$$typeof===j||k.$$typeof===g)},ye.typeOf=w,ye}var Zr;function _c(){return Zr||(Zr=1,gn.exports=zc()),gn.exports}var fn,Jr;function Lc(){if(Jr)return fn;Jr=1;var t=_c(),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},s={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},n={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},r={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};i[t.ForwardRef]=n,i[t.Memo]=r;function o(y){return t.isMemo(y)?r:i[y.$$typeof]||a}var d=Object.defineProperty,c=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,m=Object.getOwnPropertyDescriptor,h=Object.getPrototypeOf,x=Object.prototype;function p(y,g,f){if(typeof g!="string"){if(x){var b=h(g);b&&b!==x&&p(y,b,f)}var j=c(g);u&&(j=j.concat(u(g)));for(var w=o(y),v=o(g),k=0;k");const r=Object.assign(Object.assign({},{doNotUpdate:!0}),a),[i,o]=l.useState(()=>s.getAll(r));Rc()&&l.useLayoutEffect(()=>{function m(){const h=s.getAll(r);Tc(t||null,h,i)&&o(h)}return s.addChangeListener(m),()=>{s.removeChangeListener(m)}},[s,i]);const d=l.useMemo(()=>s.set.bind(s),[s]),c=l.useMemo(()=>s.remove.bind(s),[s]),u=l.useMemo(()=>s.update.bind(s),[s]);return[i,d,c,u]}function Tc(t,a,s){if(!t)return!0;for(let n of t)if(a[n]!==s[n])return!0;return!1}const he="https://thin.ly",$s="https://thin.ly",$c=async t=>{const a={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};try{const s=await fetch(`${he}/users`,a);return s.ok?[s,null]:s.status===422?[null,"User already exists."]:[null,`Server side error: ${(await s.json()).message}`]}catch(s){return[null,`Server down: ${s}`]}},Pc=async t=>{const a={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};try{const s=await fetch(`${he}/users/sign_in`,a);return s.ok?[s,null]:s.status===401?[null,"Invalid email or password"]:[null,`Server side error: ${(await s.json()).message}`]}catch(s){return[null,`Server down: ${s}`]}},Mc=async t=>{const a={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};try{const s=await fetch(`${he}/users/auth/google`,a);return s.ok?[s,null]:s.status===401?[null,"Google sign-in was rejected. Please try again."]:[null,`Server side error: ${(await s.json()).message}`]}catch(s){return[null,`Server down: ${s}`]}},ol=async t=>{const a={method:"DELETE",headers:{"Content-Type":"application/json",Authorization:t}};try{const s=await fetch(`${he}/users/sign_out`,a);return s.ok?[s,""]:s.status===401?["","Invalid email or password"]:["",`Server side error: ${(await s.json()).message}`]}catch(s){return["",`Server down: ${s}`]}},ya=async t=>{const a={method:"GET",headers:{"Content-Type":"application/json",Authorization:t}};try{const s=await fetch(`${he}/api/v1/current_user`,a);return s.ok?[s,""]:s.status===401?["","Invalid email or password"]:["",`Server side error: ${(await s.json()).message}`]}catch(s){return["",`Server down: ${s}`]}},cl=async(t,a)=>{const s=new FormData;s.append("avatar",a);const n={method:"PATCH",headers:{Authorization:t},body:s};try{const r=await fetch(`${he}/api/v1/user/avatar`,n);return r.ok?[await r.json(),""]:["",(await r.json()).message||"Failed to upload avatar"]}catch(r){return["",`Server down: ${r}`]}},dl=async t=>{const a={method:"DELETE",headers:{"Content-Type":"application/json",Authorization:t}};try{const s=await fetch(`${he}/api/v1/user/avatar`,a);return s.ok?[s,""]:["",(await s.json()).message||"Failed to delete avatar"]}catch(s){return["",`Server down: ${s}`]}},ka="/features",Ac="/resources",gr="/about",hs="/contact_us",it="/register",Qe="/login",Tt="/",Dc="/branding",fr="/pages/create",ul="/settings/profile",Ic="/:handle",br=t=>`/@${t.replace(/^@/,"")}`,Vt="/pages",Oc="/analytics",dt="/plans",Fc="/settings",Bc="/stats",Re="/governance",Ht="/governance/campaigns",Ta="/terms",It="/privacy_policy",vr="/cookie_policy",Ps="/user_policy",Ve=({children:t,allowedRoles:a})=>{const[s,n,r]=je(["token","email","plan"]),[i,o]=l.useState(null),[d,c]=l.useState(!0),u=Je();return l.useEffect(()=>{const m=async()=>{try{const[h,x]=await ya(s.token);if(x)console.error("Error fetching user:",x),r("token"),u(Qe);else if(h){const p=await h.json();o(p.user),n("email",p.user.email),n("plan",p.user.plan)}else console.error("Unexpected response structure"),r("token"),u(Qe)}catch(h){console.error("Fetch error:",h),r("token"),u(Qe)}finally{c(!1)}};s.token?m():u(Qe)},[s.token,u,r,n]),d?"":i?a&&!a.includes(i.role)?e.jsx("h1",{children:"Error 404 -- Page Not Found"}):t:e.jsx("h1",{children:"Error 404 -- Page Not Found"})},ml=typeof document<"u"?q.useLayoutEffect:()=>{};function Uc(t){const a=l.useRef(null);return ml(()=>{a.current=t},[t]),l.useCallback((...s)=>{const n=a.current;return n==null?void 0:n(...s)},[])}const $a=t=>{var a;return(a=t==null?void 0:t.ownerDocument)!==null&&a!==void 0?a:document},_t=t=>t&&"window"in t&&t.window===t?t:$a(t).defaultView||window;function hl(t){var a,s,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(a=0;a"u"||window.navigator==null?!1:((a=window.navigator.userAgentData)===null||a===void 0?void 0:a.brands.some(s=>t.test(s.brand)))||t.test(window.navigator.userAgent)}function Wc(t){var a;return typeof window<"u"&&window.navigator!=null?t.test(((a=window.navigator.userAgentData)===null||a===void 0?void 0:a.platform)||window.navigator.platform):!1}function pl(t){let a=null;return()=>(a==null&&(a=t()),a)}const Vc=pl(function(){return Wc(/^Mac/i)}),Gc=pl(function(){return Hc(/Android/i)});function qc(t){return t.mozInputSource===0&&t.isTrusted?!0:Gc()&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}class Yc{isDefaultPrevented(){return this.nativeEvent.defaultPrevented}preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPropagationStopped=()=>!0}isPropagationStopped(){return!1}persist(){}constructor(a,s){this.nativeEvent=s,this.target=s.target,this.currentTarget=s.currentTarget,this.relatedTarget=s.relatedTarget,this.bubbles=s.bubbles,this.cancelable=s.cancelable,this.defaultPrevented=s.defaultPrevented,this.eventPhase=s.eventPhase,this.isTrusted=s.isTrusted,this.timeStamp=s.timeStamp,this.type=a}}function xl(t){let a=l.useRef({isFocused:!1,observer:null});ml(()=>{const n=a.current;return()=>{n.observer&&(n.observer.disconnect(),n.observer=null)}},[]);let s=Uc(n=>{t==null||t(n)});return l.useCallback(n=>{if(n.target instanceof HTMLButtonElement||n.target instanceof HTMLInputElement||n.target instanceof HTMLTextAreaElement||n.target instanceof HTMLSelectElement){a.current.isFocused=!0;let r=n.target,i=o=>{a.current.isFocused=!1,r.disabled&&s(new Yc("blur",o)),a.current.observer&&(a.current.observer.disconnect(),a.current.observer=null)};r.addEventListener("focusout",i,{once:!0}),a.current.observer=new MutationObserver(()=>{if(a.current.isFocused&&r.disabled){var o;(o=a.current.observer)===null||o===void 0||o.disconnect();let d=r===document.activeElement?null:document.activeElement;r.dispatchEvent(new FocusEvent("blur",{relatedTarget:d})),r.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:d}))}}),a.current.observer.observe(r,{attributes:!0,attributeFilter:["disabled"]})}},[s])}function Kc(t){let{isDisabled:a,onFocus:s,onBlur:n,onFocusChange:r}=t;const i=l.useCallback(c=>{if(c.target===c.currentTarget)return n&&n(c),r&&r(!1),!0},[n,r]),o=xl(i),d=l.useCallback(c=>{const u=$a(c.target);c.target===c.currentTarget&&u.activeElement===c.target&&(s&&s(c),r&&r(!0),o(c))},[r,s,o]);return{focusProps:{onFocus:!a&&(s||r||n)?d:void 0,onBlur:!a&&(n||r)?i:void 0}}}let Pa=null,Wn=new Set,ha=new Map,At=!1,Vn=!1;const Xc={Tab:!0,Escape:!0};function yr(t,a){for(let s of Wn)s(t,a)}function Zc(t){return!(t.metaKey||!Vc()&&t.altKey||t.ctrlKey||t.key==="Control"||t.key==="Shift"||t.key==="Meta")}function ps(t){At=!0,Zc(t)&&(Pa="keyboard",yr("keyboard",t))}function Xe(t){Pa="pointer",(t.type==="mousedown"||t.type==="pointerdown")&&(At=!0,yr("pointer",t))}function gl(t){qc(t)&&(At=!0,Pa="virtual")}function fl(t){t.target===window||t.target===document||(!At&&!Vn&&(Pa="virtual",yr("virtual",t)),At=!1,Vn=!1)}function bl(){At=!1,Vn=!0}function Gn(t){if(typeof window>"u"||ha.get(_t(t)))return;const a=_t(t),s=$a(t);let n=a.HTMLElement.prototype.focus;a.HTMLElement.prototype.focus=function(){At=!0,n.apply(this,arguments)},s.addEventListener("keydown",ps,!0),s.addEventListener("keyup",ps,!0),s.addEventListener("click",gl,!0),a.addEventListener("focus",fl,!0),a.addEventListener("blur",bl,!1),typeof PointerEvent<"u"?(s.addEventListener("pointerdown",Xe,!0),s.addEventListener("pointermove",Xe,!0),s.addEventListener("pointerup",Xe,!0)):(s.addEventListener("mousedown",Xe,!0),s.addEventListener("mousemove",Xe,!0),s.addEventListener("mouseup",Xe,!0)),a.addEventListener("beforeunload",()=>{vl(t)},{once:!0}),ha.set(a,{focus:n})}const vl=(t,a)=>{const s=_t(t),n=$a(t);a&&n.removeEventListener("DOMContentLoaded",a),ha.has(s)&&(s.HTMLElement.prototype.focus=ha.get(s).focus,n.removeEventListener("keydown",ps,!0),n.removeEventListener("keyup",ps,!0),n.removeEventListener("click",gl,!0),s.removeEventListener("focus",fl,!0),s.removeEventListener("blur",bl,!1),typeof PointerEvent<"u"?(n.removeEventListener("pointerdown",Xe,!0),n.removeEventListener("pointermove",Xe,!0),n.removeEventListener("pointerup",Xe,!0)):(n.removeEventListener("mousedown",Xe,!0),n.removeEventListener("mousemove",Xe,!0),n.removeEventListener("mouseup",Xe,!0)),ha.delete(s))};function Jc(t){const a=$a(t);let s;return a.readyState!=="loading"?Gn(t):(s=()=>{Gn(t)},a.addEventListener("DOMContentLoaded",s)),()=>vl(t,s)}typeof document<"u"&&Jc();function yl(){return Pa!=="pointer"}const Qc=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function e0(t,a,s){var n;const r=typeof window<"u"?_t(s==null?void 0:s.target).HTMLInputElement:HTMLInputElement,i=typeof window<"u"?_t(s==null?void 0:s.target).HTMLTextAreaElement:HTMLTextAreaElement,o=typeof window<"u"?_t(s==null?void 0:s.target).HTMLElement:HTMLElement,d=typeof window<"u"?_t(s==null?void 0:s.target).KeyboardEvent:KeyboardEvent;return t=t||(s==null?void 0:s.target)instanceof r&&!Qc.has(s==null||(n=s.target)===null||n===void 0?void 0:n.type)||(s==null?void 0:s.target)instanceof i||(s==null?void 0:s.target)instanceof o&&(s==null?void 0:s.target.isContentEditable),!(t&&a==="keyboard"&&s instanceof d&&!Xc[s.key])}function t0(t,a,s){Gn(),l.useEffect(()=>{let n=(r,i)=>{e0(!!(s!=null&&s.isTextInput),r,i)&&t(yl())};return Wn.add(n),()=>{Wn.delete(n)}},a)}function a0(t){let{isDisabled:a,onBlurWithin:s,onFocusWithin:n,onFocusWithinChange:r}=t,i=l.useRef({isFocusWithin:!1}),o=l.useCallback(u=>{i.current.isFocusWithin&&!u.currentTarget.contains(u.relatedTarget)&&(i.current.isFocusWithin=!1,s&&s(u),r&&r(!1))},[s,r,i]),d=xl(o),c=l.useCallback(u=>{!i.current.isFocusWithin&&document.activeElement===u.target&&(n&&n(u),r&&r(!0),i.current.isFocusWithin=!0,d(u))},[n,r,d]);return a?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:c,onBlur:o}}}let xs=!1,bn=0;function qn(){xs=!0,setTimeout(()=>{xs=!1},50)}function Qr(t){t.pointerType==="touch"&&qn()}function s0(){if(!(typeof document>"u"))return typeof PointerEvent<"u"?document.addEventListener("pointerup",Qr):document.addEventListener("touchend",qn),bn++,()=>{bn--,!(bn>0)&&(typeof PointerEvent<"u"?document.removeEventListener("pointerup",Qr):document.removeEventListener("touchend",qn))}}function Ms(t){let{onHoverStart:a,onHoverChange:s,onHoverEnd:n,isDisabled:r}=t,[i,o]=l.useState(!1),d=l.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;l.useEffect(s0,[]);let{hoverProps:c,triggerHoverEnd:u}=l.useMemo(()=>{let m=(p,y)=>{if(d.pointerType=y,r||y==="touch"||d.isHovered||!p.currentTarget.contains(p.target))return;d.isHovered=!0;let g=p.currentTarget;d.target=g,a&&a({type:"hoverstart",target:g,pointerType:y}),s&&s(!0),o(!0)},h=(p,y)=>{if(d.pointerType="",d.target=null,y==="touch"||!d.isHovered)return;d.isHovered=!1;let g=p.currentTarget;n&&n({type:"hoverend",target:g,pointerType:y}),s&&s(!1),o(!1)},x={};return typeof PointerEvent<"u"?(x.onPointerEnter=p=>{xs&&p.pointerType==="mouse"||m(p,p.pointerType)},x.onPointerLeave=p=>{!r&&p.currentTarget.contains(p.target)&&h(p,p.pointerType)}):(x.onTouchStart=()=>{d.ignoreEmulatedMouseEvents=!0},x.onMouseEnter=p=>{!d.ignoreEmulatedMouseEvents&&!xs&&m(p,"mouse"),d.ignoreEmulatedMouseEvents=!1},x.onMouseLeave=p=>{!r&&p.currentTarget.contains(p.target)&&h(p,"mouse")}),{hoverProps:x,triggerHoverEnd:h}},[a,s,n,r,d]);return l.useEffect(()=>{r&&u({currentTarget:d.target},d.pointerType)},[r]),{hoverProps:c,isHovered:i}}function As(t={}){let{autoFocus:a=!1,isTextInput:s,within:n}=t,r=l.useRef({isFocused:!1,isFocusVisible:a||yl()}),[i,o]=l.useState(!1),[d,c]=l.useState(()=>r.current.isFocused&&r.current.isFocusVisible),u=l.useCallback(()=>c(r.current.isFocused&&r.current.isFocusVisible),[]),m=l.useCallback(p=>{r.current.isFocused=p,o(p),u()},[u]);t0(p=>{r.current.isFocusVisible=p,u()},[],{isTextInput:s});let{focusProps:h}=Kc({isDisabled:n,onFocusChange:m}),{focusWithinProps:x}=a0({isDisabled:!n,onFocusWithinChange:m});return{isFocused:i,isFocusVisible:d,focusProps:n?x:h}}var n0=Object.defineProperty,r0=(t,a,s)=>a in t?n0(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,vn=(t,a,s)=>(r0(t,typeof a!="symbol"?a+"":a,s),s);let i0=class{constructor(){vn(this,"current",this.detect()),vn(this,"handoffState","pending"),vn(this,"currentId",0)}set(a){this.current!==a&&(this.handoffState="pending",this.currentId=0,this.current=a)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},$t=new i0;function Xt(t){return $t.isServer?null:t instanceof Node?t.ownerDocument:t!=null&&t.hasOwnProperty("current")&&t.current instanceof Node?t.current.ownerDocument:document}function Ds(t){typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t).catch(a=>setTimeout(()=>{throw a}))}function kt(){let t=[],a={addEventListener(s,n,r,i){return s.addEventListener(n,r,i),a.add(()=>s.removeEventListener(n,r,i))},requestAnimationFrame(...s){let n=requestAnimationFrame(...s);return a.add(()=>cancelAnimationFrame(n))},nextFrame(...s){return a.requestAnimationFrame(()=>a.requestAnimationFrame(...s))},setTimeout(...s){let n=setTimeout(...s);return a.add(()=>clearTimeout(n))},microTask(...s){let n={current:!0};return Ds(()=>{n.current&&s[0]()}),a.add(()=>{n.current=!1})},style(s,n,r){let i=s.style.getPropertyValue(n);return Object.assign(s.style,{[n]:r}),this.add(()=>{Object.assign(s.style,{[n]:i})})},group(s){let n=kt();return s(n),this.add(()=>n.dispose())},add(s){return t.includes(s)||t.push(s),()=>{let n=t.indexOf(s);if(n>=0)for(let r of t.splice(n,1))r()}},dispose(){for(let s of t.splice(0))s()}};return a}function Ma(){let[t]=l.useState(kt);return l.useEffect(()=>()=>t.dispose(),[t]),t}let Me=(t,a)=>{$t.isServer?l.useEffect(t,a):l.useLayoutEffect(t,a)};function mt(t){let a=l.useRef(t);return Me(()=>{a.current=t},[t]),a}let ve=function(t){let a=mt(t);return q.useCallback((...s)=>a.current(...s),[a])};function l0(t){let a=t.width/2,s=t.height/2;return{top:t.clientY-s,right:t.clientX+a,bottom:t.clientY+s,left:t.clientX-a}}function o0(t,a){return!(!t||!a||t.righta.right||t.bottoma.bottom)}function kl({disabled:t=!1}={}){let a=l.useRef(null),[s,n]=l.useState(!1),r=Ma(),i=ve(()=>{a.current=null,n(!1),r.dispose()}),o=ve(d=>{if(r.dispose(),a.current===null){a.current=d.currentTarget,n(!0);{let c=Xt(d.currentTarget);r.addEventListener(c,"pointerup",i,!1),r.addEventListener(c,"pointermove",u=>{if(a.current){let m=l0(u);n(o0(m,a.current.getBoundingClientRect()))}},!1),r.addEventListener(c,"pointercancel",i,!1)}}});return{pressed:s,pressProps:t?{}:{onPointerDown:o,onPointerUp:i,onClick:i}}}let c0=l.createContext(void 0);function Aa(){return l.useContext(c0)}function Yn(...t){return Array.from(new Set(t.flatMap(a=>typeof a=="string"?a.split(" "):[]))).filter(Boolean).join(" ")}function ut(t,a,...s){if(t in a){let r=a[t];return typeof r=="function"?r(...s):r}let n=new Error(`Tried to handle "${t}" but there is no handler defined. Only defined handlers are: ${Object.keys(a).map(r=>`"${r}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,ut),n}var gs=(t=>(t[t.None=0]="None",t[t.RenderStrategy=1]="RenderStrategy",t[t.Static=2]="Static",t))(gs||{}),yt=(t=>(t[t.Unmount=0]="Unmount",t[t.Hidden=1]="Hidden",t))(yt||{});function Ae(){let t=u0();return l.useCallback(a=>d0({mergeRefs:t,...a}),[t])}function d0({ourProps:t,theirProps:a,slot:s,defaultTag:n,features:r,visible:i=!0,name:o,mergeRefs:d}){d=d??m0;let c=jl(a,t);if(i)return Za(c,s,n,o,d);let u=r??0;if(u&2){let{static:m=!1,...h}=c;if(m)return Za(h,s,n,o,d)}if(u&1){let{unmount:m=!0,...h}=c;return ut(m?0:1,{0(){return null},1(){return Za({...h,hidden:!0,style:{display:"none"}},s,n,o,d)}})}return Za(c,s,n,o,d)}function Za(t,a={},s,n,r){let{as:i=s,children:o,refName:d="ref",...c}=yn(t,["unmount","static"]),u=t.ref!==void 0?{[d]:t.ref}:{},m=typeof o=="function"?o(a):o;"className"in c&&c.className&&typeof c.className=="function"&&(c.className=c.className(a)),c["aria-labelledby"]&&c["aria-labelledby"]===c.id&&(c["aria-labelledby"]=void 0);let h={};if(a){let x=!1,p=[];for(let[y,g]of Object.entries(a))typeof g=="boolean"&&(x=!0),g===!0&&p.push(y.replace(/([A-Z])/g,f=>`-${f.toLowerCase()}`));if(x){h["data-headlessui-state"]=p.join(" ");for(let y of p)h[`data-${y}`]=""}}if(i===l.Fragment&&(Object.keys(gt(c)).length>0||Object.keys(gt(h)).length>0))if(!l.isValidElement(m)||Array.isArray(m)&&m.length>1){if(Object.keys(gt(c)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${n} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(gt(c)).concat(Object.keys(gt(h))).map(x=>` - ${x}`).join(` `),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(x=>` - ${x}`).join(` `)].join(` -`))}else{let x=m.props,p=x==null?void 0:x.className,y=typeof p=="function"?(...b)=>Yn(p(...b),c.className):Yn(p,c.className),g=y?{className:y}:{},f=jl(m.props,gt(yn(c,["ref"])));for(let b in h)b in f&&delete h[b];return l.cloneElement(m,Object.assign({},f,h,u,{ref:r(h0(m),u.ref)},g))}return l.createElement(i,Object.assign({},yn(c,["ref"]),i!==l.Fragment&&u,i!==l.Fragment&&h),m)}function u0(){let t=l.useRef([]),a=l.useCallback(s=>{for(let n of t.current)n!=null&&(typeof n=="function"?n(s):n.current=s)},[]);return(...s)=>{if(!s.every(n=>n==null))return t.current=s,a}}function m0(...t){return t.every(a=>a==null)?void 0:a=>{for(let s of t)s!=null&&(typeof s=="function"?s(a):s.current=a)}}function jl(...t){if(t.length===0)return{};if(t.length===1)return t[0];let a={},s={};for(let n of t)for(let r in n)r.startsWith("on")&&typeof n[r]=="function"?(s[r]!=null||(s[r]=[]),s[r].push(n[r])):a[r]=n[r];if(a.disabled||a["aria-disabled"])for(let n in s)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(n)&&(s[n]=[r=>{var i;return(i=r==null?void 0:r.preventDefault)==null?void 0:i.call(r)}]);for(let n in s)Object.assign(a,{[n](r,...i){let o=s[n];for(let d of o){if((r instanceof Event||(r==null?void 0:r.nativeEvent)instanceof Event)&&r.defaultPrevented)return;d(r,...i)}}});return a}function Is(...t){if(t.length===0)return{};if(t.length===1)return t[0];let a={},s={};for(let n of t)for(let r in n)r.startsWith("on")&&typeof n[r]=="function"?(s[r]!=null||(s[r]=[]),s[r].push(n[r])):a[r]=n[r];for(let n in s)Object.assign(a,{[n](...r){let i=s[n];for(let o of i)o==null||o(...r)}});return a}function ze(t){var a;return Object.assign(l.forwardRef(t),{displayName:(a=t.displayName)!=null?a:t.name})}function gt(t){let a=Object.assign({},t);for(let s in a)a[s]===void 0&&delete a[s];return a}function yn(t,a=[]){let s=Object.assign({},t);for(let n of a)n in s&&delete s[n];return s}function h0(t){return q.version.split(".")[0]>="19"?t.props.ref:t.ref}let p0="button";function x0(t,a){var s;let n=Aa(),{disabled:r=n||!1,autoFocus:i=!1,...o}=t,{isFocusVisible:d,focusProps:c}=As({autoFocus:i}),{isHovered:u,hoverProps:m}=Ms({isDisabled:r}),{pressed:h,pressProps:x}=kl({disabled:r}),p=Is({ref:a,type:(s=o.type)!=null?s:"button",disabled:r||void 0,autoFocus:i},c,m,x),y=l.useMemo(()=>({disabled:r,hover:u,focus:d,active:h,autofocus:i}),[r,u,d,h,i]);return Ae()({ourProps:p,theirProps:o,slot:y,defaultTag:p0,name:"Button"})}let g0=ze(x0);function f0(t,a,s){let[n,r]=l.useState(s),i=t!==void 0,o=l.useRef(i),d=l.useRef(!1),c=l.useRef(!1);return i&&!o.current&&!d.current?(d.current=!0,o.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!i&&o.current&&!c.current&&(c.current=!0,o.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[i?t:n,ve(u=>(i||r(u),a==null?void 0:a(u)))]}function b0(t){let[a]=l.useState(t);return a}function wl(t={},a=null,s=[]){for(let[n,r]of Object.entries(t))Cl(s,Nl(a,n),r);return s}function Nl(t,a){return t?t+"["+a+"]":a}function Cl(t,a,s){if(Array.isArray(s))for(let[n,r]of s.entries())Cl(t,Nl(a,n.toString()),r);else s instanceof Date?t.push([a,s.toISOString()]):typeof s=="boolean"?t.push([a,s?"1":"0"]):typeof s=="string"?t.push([a,s]):typeof s=="number"?t.push([a,`${s}`]):s==null?t.push([a,""]):wl(s,a,t)}function v0(t){var a,s;let n=(a=t==null?void 0:t.form)!=null?a:t.closest("form");if(n){for(let r of n.elements)if(r!==t&&(r.tagName==="INPUT"&&r.type==="submit"||r.tagName==="BUTTON"&&r.type==="submit"||r.nodeName==="INPUT"&&r.type==="image")){r.click();return}(s=n.requestSubmit)==null||s.call(n)}}let y0="span";var Gt=(t=>(t[t.None=1]="None",t[t.Focusable=2]="Focusable",t[t.Hidden=4]="Hidden",t))(Gt||{});function k0(t,a){var s;let{features:n=1,...r}=t,i={ref:a,"aria-hidden":(n&2)===2?!0:(s=r["aria-hidden"])!=null?s:void 0,hidden:(n&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(n&4)===4&&(n&2)!==2&&{display:"none"}}};return Ae()({ourProps:i,theirProps:r,slot:{},defaultTag:y0,name:"Hidden"})}let ja=ze(k0),j0=l.createContext(null);function w0({children:t}){let a=l.useContext(j0);if(!a)return q.createElement(q.Fragment,null,t);let{target:s}=a;return s?zt.createPortal(q.createElement(q.Fragment,null,t),s):null}function N0({data:t,form:a,disabled:s,onReset:n,overrides:r}){let[i,o]=l.useState(null),d=Ma();return l.useEffect(()=>{if(n&&i)return d.addEventListener(i,"reset",n)},[i,a,n]),q.createElement(w0,null,q.createElement(C0,{setForm:o,formId:a}),wl(t).map(([c,u])=>q.createElement(ja,{features:Gt.Hidden,...gt({key:c,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:a,disabled:s,name:c,value:u,...r})})))}function C0({setForm:t,formId:a}){return l.useEffect(()=>{if(a){let s=document.getElementById(a);s&&t(s)}},[t,a]),a?null:q.createElement(ja,{features:Gt.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let n=s.closest("form");n&&t(n)}})}let S0=l.createContext(void 0);function Sl(){return l.useContext(S0)}function El(t){let a=t.parentElement,s=null;for(;a&&!(a instanceof HTMLFieldSetElement);)a instanceof HTMLLegendElement&&(s=a),a=a.parentElement;let n=(a==null?void 0:a.getAttribute("disabled"))==="";return n&&E0(s)?!1:n}function E0(t){if(!t)return!1;let a=t.previousElementSibling;for(;a!==null;){if(a instanceof HTMLLegendElement)return!1;a=a.previousElementSibling}return!0}let zl=Symbol();function z0(t,a=!0){return Object.assign(t,{[zl]:a})}function He(...t){let a=l.useRef(t);l.useEffect(()=>{a.current=t},[t]);let s=ve(n=>{for(let r of a.current)r!=null&&(typeof r=="function"?r(n):r.current=n)});return t.every(n=>n==null||(n==null?void 0:n[zl]))?void 0:s}let Os=l.createContext(null);Os.displayName="DescriptionContext";function _l(){let t=l.useContext(Os);if(t===null){let a=new Error("You used a component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(a,_l),a}return t}function _0(){var t,a;return(a=(t=l.useContext(Os))==null?void 0:t.value)!=null?a:void 0}function kr(){let[t,a]=l.useState([]);return[t.length>0?t.join(" "):void 0,l.useMemo(()=>function(s){let n=ve(i=>(a(o=>[...o,i]),()=>a(o=>{let d=o.slice(),c=d.indexOf(i);return c!==-1&&d.splice(c,1),d}))),r=l.useMemo(()=>({register:n,slot:s.slot,name:s.name,props:s.props,value:s.value}),[n,s.slot,s.name,s.props,s.value]);return q.createElement(Os.Provider,{value:r},s.children)},[a])]}let L0="p";function R0(t,a){let s=l.useId(),n=Aa(),{id:r=`headlessui-description-${s}`,...i}=t,o=_l(),d=He(a);Me(()=>o.register(r),[r,o.register]);let c=n||!1,u=l.useMemo(()=>({...o.slot,disabled:c}),[o.slot,c]),m={ref:d,...o.props,id:r};return Ae()({ourProps:m,theirProps:i,slot:u,defaultTag:L0,name:o.name||"Description"})}let T0=ze(R0),Ll=Object.assign(T0,{});var ft=(t=>(t.Space=" ",t.Enter="Enter",t.Escape="Escape",t.Backspace="Backspace",t.Delete="Delete",t.ArrowLeft="ArrowLeft",t.ArrowUp="ArrowUp",t.ArrowRight="ArrowRight",t.ArrowDown="ArrowDown",t.Home="Home",t.End="End",t.PageUp="PageUp",t.PageDown="PageDown",t.Tab="Tab",t))(ft||{});let Fs=l.createContext(null);Fs.displayName="LabelContext";function Rl(){let t=l.useContext(Fs);if(t===null){let a=new Error("You used a