import{a as v,u as b,r as m,f as N,b as u,j as e,E as j,W as y,P as C,X as S,c as k}from"./index-CUDottTv.js";import{B as h}from"./badge-BOfEUuSW.js";import{B as w}from"./textarea-DAwdLdON.js";import{S as A}from"./status-dot-C1nxHZIG.js";import{W as z}from"./wifi-B9CHDUUG.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=v("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);function L({appName:s,runtimeProject:n,onRemove:i}){const r=(n==null?void 0:n.isConnected)??!1;return e.jsx("div",{className:k("border rounded-lg p-4 transition-colors",r?"border-green-500/30 bg-green-500/5":"border-border-muted bg-bg-surface"),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(A,{color:r?"green":"gray",size:"md",pulse:r}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-medium text-text-primary truncate",children:s}),e.jsx(h,{variant:r?"green":"default",size:"sm",children:r?"Connected":"Disconnected"})]}),n&&e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[11px] text-text-muted",children:[n.sessions.length>0&&e.jsxs("span",{children:[n.sessions.length," session",n.sessions.length!==1?"s":""]}),e.jsxs("span",{children:[n.eventCount.toLocaleString()," events"]})]})]}),e.jsx("button",{type:"button",onClick:()=>i(s),className:"p-1.5 rounded-md text-text-muted hover:text-red hover:bg-red-500/10 transition-colors cursor-pointer",title:"Remove SDK link",children:e.jsx(S,{size:14})})]})})}function B({project:s}){const n=b(t=>t.projects),[i,r]=m.useState(""),o=s.runtimeApps??(s.runtimescopeProject?[s.runtimescopeProject]:[]),x=N(n,{runtimescopeProject:s.runtimescopeProject,runtimeApps:s.runtimeApps,name:s.name}),p=x.filter(t=>t.isConnected).length,c=n.filter(t=>!o.some(a=>a.toLowerCase()===t.appName.toLowerCase())),l=m.useCallback(t=>{const a=t.trim();if(!a||o.some(f=>f.toLowerCase()===a.toLowerCase()))return;const d=[...o,a];u.getState().updateProject(s.id,{runtimeApps:d}),r("")},[o,s.id]),g=m.useCallback(t=>{const a=o.filter(d=>d!==t);u.getState().updateProject(s.id,{runtimeApps:a.length?a:void 0})},[o,s.id]);return o.length===0&&c.length===0?e.jsx(j,{icon:e.jsx(D,{size:40,strokeWidth:1.25}),title:"No SDK Installations",description:"Connect the RuntimeScope SDK in your app to see live telemetry. SDK instances will be automatically linked when they connect."}):e.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-5",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[p>0?e.jsx(z,{size:16,className:"text-green"}):e.jsx(y,{size:16,className:"text-text-muted"}),e.jsxs("span",{className:"text-sm font-medium text-text-primary",children:[p," of ",o.length," connected"]})]})}),e.jsx("div",{className:"space-y-2",children:o.map(t=>{const a=x.find(d=>d.appName.toLowerCase()===t.toLowerCase());return e.jsx(L,{appName:t,runtimeProject:a,onRemove:g},t)})}),c.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-text-muted uppercase tracking-wider font-medium mb-2",children:"Available SDK Instances"}),e.jsx("div",{className:"space-y-1",children:c.map(t=>e.jsxs("button",{type:"button",onClick:()=>l(t.appName),className:"w-full flex items-center gap-3 px-3 py-2 rounded-lg border border-dashed border-border-muted hover:border-accent/40 hover:bg-accent-muted/30 transition-colors cursor-pointer",children:[e.jsx(C,{size:14,className:"text-text-tertiary"}),e.jsx("span",{className:"font-mono text-xs text-text-secondary",children:t.appName}),t.isConnected&&e.jsx(h,{variant:"green",size:"sm",children:"Live"}),e.jsxs("span",{className:"ml-auto text-[10px] text-text-muted",children:[t.eventCount," events"]})]},t.appName))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:i,onChange:t=>r(t.target.value),onKeyDown:t=>t.key==="Enter"&&l(i),placeholder:"Add SDK app name manually...",className:"flex-1 h-8 px-3 rounded-md border border-border-muted bg-bg-surface text-sm text-text-primary placeholder:text-text-muted outline-none focus:border-accent/40 font-mono"}),i.trim()&&e.jsx(w,{size:"sm",onClick:()=>l(i),children:"Add"})]})]})}export{B as SdkPage};
