import{bh as i,r as n,w as h,bf as m,b4 as f,bb as k,j as e,L as g,be as j,q as o,c as r,cu as A,aa as S,ab as P,b6 as I,bc as w}from"./index-CK33qGU_.js";import{c as C,d as L}from"./scope.selectors-C6FB6Cbj.js";import{A as v}from"./ApiForm-BibKU_LP.js";const K=()=>{const l=i(C),p=i(L),[u,d]=n.useState(""),[b,t]=h(),s=m(),c=f();k(w.createAPI),n.useEffect(()=>(s.scope.fetch(),()=>{s.api.clear()}),[s]);const x=n.useCallback(async y=>{const{data:a}=await s.api.create({data:y});a!=null&&a.key&&(d(a.key),t())},[s,t]);return p?e.jsx(g,{}):e.jsxs(e.Fragment,{children:[e.jsxs(j,{title:"Save the key",secondaryText:"Your API key has been generated.",isOpen:b,onClose:t,closeOnBackdropClick:!1,secondaryButtonProps:{children:"I saved the API key",onClick:()=>c(o.account.api.list)},closeOnEsc:!1,children:[e.jsx(r,{sx:{wordBreak:"break-all"},children:e.jsx(A,{copyButton:!0,content:u,title:"API key"})}),e.jsx(r,{my:"20px",children:e.jsx(S,{content:"Save this API key securely. It will not be accessible afterwards.",type:P.warning})})]}),e.jsx(I,{mb:"15px",ml:"-12px",intent:"inline",alignSelf:"flex-start",onClick:()=>c(o.account.api.list),children:"⇽ all API keys"}),e.jsx(v,{isLoading:l,onSubmit:x})]})};export{K as default};
