import{r as n,bI as i,bH as m,aZ as j,bo as A,j as e,D as S,$ as b,f as l,L as c,dS as L,cM as k,a3 as K,a5 as I,b1 as $,q as v}from"./index-46ma1THH.js";import{s as w,c as C,d as D}from"./scope.selectors-C6FB6Cbj.js";import{r as E}from"./randomString-D3iDJlGT.js";const F=()=>{const[s,o]=n.useState(),t=i(w),u=i(C),y=i(D),a=m(),[x,f]=n.useState(!0);return n.useEffect(()=>{a.scope.fetch()},[a.scope]),n.useEffect(()=>{async function h(){var p,d;const g={name:`default_apiKey_${E().substring(5)}`,scope:t},r=await a.api.create({data:g});(p=r.data)!=null&&p.key&&o((d=r.data)==null?void 0:d.key)}t&&t.length>0&&h()},[a.api,t]),j(u||y,100,f),{apiKey:s,isLoading:x}},H=()=>{const{apiKey:s,isLoading:o}=F(),t=A();return o?e.jsx(S,{}):e.jsxs(b,{flexDirection:"column",width:"830px",mt:"140px",children:[e.jsx(l,{fontSize:"18px",fontFamily:"Inter",fontWeight:"bold",textAlign:"center",children:"Save your Api key"}),e.jsx(c,{mt:"40px",sx:{div:{borderStyle:"none"}},children:e.jsxs(L,{children:[s&&e.jsx(l,{fontSize:"12px",fontFamily:"Inter",fontWeight:"500",mb:"20px",children:"Copy this API key and paste it directly in your code to connect to Hopsworks"}),e.jsx(c,{children:s?e.jsx(k,{height:"auto",copyButton:!0,title:"API key",language:"shell",content:s}):e.jsx(c,{children:e.jsx(K,{width:"100%",type:I.error,content:"Failed to generate Api key",cta:e.jsx($,{onClick:()=>{t(v.account.api.list)},intent:"inline",children:"Go to Api keys"})})})})]})})]})};export{H as default};
