1import{r,j as t,P as w,ar as v,as as C}from"./index-BS6_cqLd.js";import{C as R}from"./chevron-down-BMKgdhBQ.js";import{C as S}from"./chevron-up-dBcQygn9.js";function D({onExecute:m,execResults:c,isExecuting:n}){const[o,u]=r.useState(""),[l,h]=r.useState("python"),[b,d]=r.useState(null),[x,g]=r.useState(new Set),f=r.useRef(null),i=async()=>{if(!(!o.trim()||n))try{await m(o,l)}catch{}},y=e=>{(e.ctrlKey||e.metaKey)&&e.key==="Enter"&&(e.preventDefault(),i())},j=(e,s)=>{navigator.clipboard.writeText(e),d(s),setTimeout(()=>{d(null)},2e3)},N=e=>{g(s=>{const a=new Set(s);return a.has(e)?a.delete(e):a.add(e),a})};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsxs("div",{className:"border-b border-border-default p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsxs("select",{value:l,onChange:e=>h(e.target.value),className:"bg-bg-tertiary text-text-primary text-xs rounded px-2 py-1 border border-border-default",children:[t.jsx("option",{value:"python",children:"Python"}),t.jsx("option",{value:"bash",children:"Bash"})]}),t.jsxs("button",{onClick:i,disabled:n||!o.trim(),className:"flex items-center gap-1 px-3 py-1 rounded text-xs font-medium bg-accent-green/10 border border-accent-green/30 text-accent-green hover:bg-accent-green/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[t.jsx(w,{className:"w-3 h-3"}),n?"Running...":"Run"]}),t.jsx("span",{className:"text-text-muted text-xs ml-auto",children:"Ctrl+Enter to run"})]}),t.jsx("textarea",{ref:f,value:o,onChange:e=>u(e.target.value),onKeyDown:y,placeholder:l==="python"?'print("Hello, ARSMA!")':'echo "Hello, ARSMA!"',className:"w-full h-32 bg-bg-primary text-text-primary font-mono text-sm p-3 rounded border border-border-default resize-y focus:outline-none focus:border-accent-cyan/50",spellCheck:!1})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:[c.length===0&&t.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:"Run code to see results here"}),c.map((e,s)=>t.jsxs("div",{className:"border border-border-default rounded-lg overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-bg-tertiary cursor-pointer",onClick:()=>N(s),children:[t.jsxs("span",{className:"text-xs text-text-secondary",children:["Run #",s+1,t.jsxs("span",{className:`ml-2 ${e.exit_code===0?"text-accent-green":"text-red-400"}`,children:["exit: ",e.exit_code]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:a=>{a.stopPropagation(),j(e.stdout+e.stderr,s)},className:"p-1 rounded hover:bg-bg-primary transition-colors",title:"Copy output",children:b===s?t.jsx(v,{className:"w-3 h-3 text-accent-green"}):t.jsx(C,{className:"w-3 h-3 text-text-muted"})}),x.has(s)?t.jsx(R,{className:"w-3 h-3 text-text-muted"}):t.jsx(S,{className:"w-3 h-3 text-text-muted"})]})]}),!x.has(s)&&t.jsxs("div",{className:"p-3 space-y-2",children:[e.stdout&&t.jsx("pre",{className:"text-xs text-text-primary font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-60 overflow-y-auto",children:e.stdout}),e.stderr&&t.jsx("pre",{className:"text-xs text-red-400 font-mono whitespace-pre-wrap bg-red-500/5 p-2 rounded max-h-40 overflow-y-auto",children:e.stderr}),e.images.map((a,p)=>t.jsx("img",{src:`data:image/png;base64,${a}`,alt:`Plot ${p+1}`,className:"w-full bg-white rounded"},p)),!e.stdout&&!e.stderr&&e.images.length===0&&t.jsx("p",{className:"text-text-muted text-xs italic",children:"No output"})]})]},s))]})]})}export{D as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.