import{r as n,bX as i,bW as m,aK as j,bx as A,j as e,L as k,q as S,d as l,F as c,bk as b,bU as K,a4 as L,a5 as F,aJ as I,x as v}from"./index-C6OVXshM.js";import{s as w,c as C,d as E}from"./scope.selectors-C6FB6Cbj.js";import{r as D}from"./randomString-D3iDJlGT.js";const G=()=>{const[s,o]=n.useState(),t=i(w),u=i(C),x=i(E),a=m(),[y,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_${D().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||x,100,f),{apiKey:s,isLoading:y}},N=()=>{const{apiKey:s,isLoading:o}=G(),t=A();return o?e.jsx(k,{}):e.jsxs(S,{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(b,{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(L,{width:"100%",type:F.error,content:"Failed to generate Api key",cta:e.jsx(I,{onClick:()=>{t(v.account.api.list)},intent:"inline",children:"Go to Api keys"})})})})]})})]})};export{N as default};
