import{bI as c,bg as f,r as o,y as g,bH as y,bo as S,bw as A,bx as h,j as e,D as j,q as r,b1 as L}from"./index-46ma1THH.js";import{c as k,d as C}from"./scope.selectors-C6FB6Cbj.js";import{A as K}from"./ApiForm-DiiRmSSB.js";import{A as P}from"./ApiKeyPopup-Dimbgh98.js";const F=()=>{const p=c(k),l=c(C),{state:a={}}=f(),[u,m]=o.useState(""),[d,i]=g(),s=y(),n=S();A(h.createAPI),o.useEffect(()=>(s.scope.fetch(),()=>{s.api.clear()}),[s]);const b=o.useCallback(async x=>{const{data:t}=await s.api.create({data:x});t!=null&&t.key&&(m(t.key),i())},[s,i]);return l?e.jsx(j,{}):e.jsxs(e.Fragment,{children:[e.jsx(P,{isOpen:d,onClose:i,onSave:()=>n((a==null?void 0:a.redirectUrl)??r.account.api.list),createdKey:u}),e.jsx(L,{mb:"15px",ml:"-12px",intent:"inline",alignSelf:"flex-start",onClick:()=>n(r.account.api.list),children:"⇽ all API keys"}),e.jsx(K,{isLoading:p,onSubmit:b})]})};export{F as default};
