import{r as d,Y as f,c as u,j as o,d as x,E as P,a as j,x as h}from"../assets/ErrorMessage-8QLNWn9X.js";import{P as C}from"../assets/PowersList-DlQF89aJ.js";import"../styles.js";function I(){const{addListener:s,callApi:e}=d.useContext(f),[n,t]=d.useState(!0),[l,r]=d.useState([]),[i,m]=d.useState(),c=d.useCallback(async()=>{t(!0);try{const{powers:a}=await e("listInstalledPowers");r(a)}catch(a){m(a)}finally{t(!1)}},[e]);d.useEffect(()=>{c();const a=s("onPowerInstalled",()=>{c()}),p=s("onPowerUninstalled",()=>{c()});return()=>{a(),p()}},[s,c]);const w=d.useCallback(()=>{e("addCustomPower")},[e]);return{isLoading:n,installedPowers:l,installedPowersError:i,handleAddCustomPowerClick:w}}function E(s){const e=u.c(4),{onClick:n}=s;let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=o.jsx("div",{className:"add-custom-power-icon",children:o.jsx(x,{type:"add"})}),e[0]=t):t=e[0];let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsxs("div",{className:"add-custom-power-content",children:[o.jsx("div",{className:"add-custom-power-label",children:"Add Custom Power"}),o.jsx("div",{className:"add-custom-power-description",children:"Import from url, folder or build your own"})]}),e[1]=l):l=e[1];let r;return e[2]!==n?(r=o.jsxs("div",{className:"add-custom-power",onClick:n,children:[t,l]}),e[2]=n,e[3]=r):r=e[3],r}function b(){const s=u.c(6),{isLoading:e,installedPowers:n,installedPowersError:t,handleAddCustomPowerClick:l}=I();if(t){let i;return s[0]!==t?(i=o.jsx(P,{error:t}),s[0]=t,s[1]=i):i=s[1],i}let r;return s[2]!==l||s[3]!==n||s[4]!==e?(r=!e&&o.jsx(C,{firstItem:o.jsx(E,{onClick:l}),powers:n}),s[2]=l,s[3]=n,s[4]=e,s[5]=r):r=s[5],r}j.createRoot(document.getElementById("root")).render(o.jsx(d.StrictMode,{children:o.jsx(h,{editorApi:window.vscode,children:o.jsx(b,{})})}));
