import{s as l}from"./chunk-DZLz74EQ.js";import{t as h}from"./react-BcIddLXZ.js";import{t as x}from"./jsx-runtime-DvsdsEjx.js";import{u}from"./hotkeys-Lbk6RHir.js";import{r as v}from"./requests-D3Z6okhb.js";import{t as n}from"./use-toast-BiL_AQz9.js";import{t as d}from"./kbd-CZFOBQmt.js";var e=l(x(),1);const m=(r,a)=>{n(a?{title:"Failed to add package",description:a,variant:"danger"}:{title:"Package added",description:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{children:["The package ",(0,e.jsx)(d,{className:"inline",children:r})," and its dependencies has been added to your environment."]}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:"Some Python packages may require a kernel restart to see changes."})]})})},k=(r,a)=>{n(a?{title:"Failed to upgrade package",description:a,variant:"danger"}:{title:"Package upgraded",description:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{children:["The package ",(0,e.jsx)(d,{className:"inline",children:r})," has been upgraded."]}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:"Some Python packages may require a kernel restart to see changes."})]})})},f=(r,a)=>{n(a?{title:"Failed to remove package",description:a,variant:"danger"}:{title:"Package removed",description:(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{children:["The package ",(0,e.jsx)(d,{className:"inline",children:r})," has been removed from your environment."]}),(0,e.jsx)("div",{className:"text-xs text-muted-foreground mt-1",children:"Some Python packages may require a kernel restart to see changes."})]})})};var j=l(h(),1);function y(){let[r,a]=(0,j.useState)(!1),{addPackage:g}=v();return{loading:r,handleInstallPackages:async(o,t)=>{a(!0);try{for(let[s,i]of o.entries()){let c=await g({package:i});c.success?m(i):m(i,c.error),s<o.length-1&&await new Promise(p=>setTimeout(p,1e3))}t==null||t()}catch(s){u.error(s)}finally{a(!1)}}}}export{f as n,k as r,y as t};
