import{bw as b,r as c,Q as i,b as m,f as C,aV as f,Z as P,q as _,s as g,bU as I,aD as L,aL as u,bC as v,j as e,L as D,m as j,aG as d,c1 as k,B as a,e as y,bD as M}from"./index-dP1W1_bd.js";import{s as S,a as N,b as E}from"./scope.selectors-C6FB6Cbj.js";import{c as K}from"./utils-3BV3J1PE.js";import"./storage-connector-BuEuJyVA.js";import"./useDownload-C3yCvYJa.js";import"./useProject-CXVt1xnE.js";import"./length-BzpOfCdE.js";import"./FileUploaderButton-frSujVRY.js";import"./uniq-98MdbBvs.js";import"./uniqBy-6mvKp2Ip.js";import"./dumbPluralize-CcxDsNiu.js";import"./zipObj-DEkcXp9d.js";const R={td:{whiteSpace:"nowrap",textAlign:"left",pr:0},"td:nth-of-type(1)":{pl:"20px"},"td:nth-of-type(6)":{pr:"20px",svg:{fontSize:"14px"}},">table>tbody>tr:first-of-type":{mb:"0px"}},z=(t,n)=>{const s=b(),o=c.useMemo(()=>t.map(({scope:r})=>[i,n.length===r.length?m:i,i,m,m,C]),[t,n]),p=c.useMemo(()=>t.map(({name:r,scope:l,prefix:h,created:x,modified:w})=>[{children:r},{...l.length===n.length?{children:"full scope",gray:!0}:{children:K(l.map(A=>A.toLowerCase()).join(", "),65)}},{children:h},{gray:!0,children:f(new Date(x),"yyyy-MM-dd")},{gray:!0,children:f(new Date(w),"yyyy-MM-dd")},{intent:"ghost",icon:P.edit,tooltip:"Edit",onClick:()=>s(_(g.account.api.edit,"",{name:r}))}]),[t,s,n]);return c.useMemo(()=>[o,p],[o,p])},B=c.memo(I),X=()=>{const t=L(),n=u(S),s=u(N).sort((h,x)=>h.name.localeCompare(x.name));v(M.api);const o=b(),p=u(E),[r,l]=z(s,n);return c.useEffect(()=>{t.api.fetch(),t.scope.fetch()},[t]),p?e.jsx(D,{}):s.length?e.jsxs(e.Fragment,{children:[e.jsxs(j,{width:"1000px",title:"API keys",contentProps:{pb:0,overflow:"auto"},actions:e.jsx(d,{href:k("/user_guides/projects/api_key/create_api_key/"),external:!0,target:"_blank",p:0,intent:"inline",children:"documentation↗"}),children:[e.jsxs(a,{mb:"25x",children:[e.jsxs(a,{width:"100%",children:[e.jsx(i,{primary:!0,children:s.length}),e.jsx(i,{ml:"5px",children:s.length>1?" API keys":" API key"})]}),e.jsx(d,{minWidth:"105px",onClick:()=>o(g.account.api.create),children:"New API key"})]}),e.jsx(y,{mt:"20px",mx:"-20px",sx:R,children:e.jsx(B,{legend:["name","scope","API key prefix","creation","modification"],middleColumn:1,groupComponents:r,groupProps:l})})]}),e.jsx(y,{sx:{height:"20px",width:"100%",backgroundColor:"grayShade3",opacity:0},children:"invisible block margin"})]}):e.jsxs(j,{title:"API keys",actions:e.jsx(d,{href:k("/user_guides/projects/api_key/create_api_key/"),target:"_blank",external:!0,p:0,intent:"inline",children:"documentation↗"}),children:[e.jsxs(a,{mb:"25x",children:[e.jsxs(a,{width:"100%",children:[e.jsx(i,{primary:!0,children:"0"}),e.jsx(i,{ml:"5px",children:"API keys"})]}),e.jsx(d,{minWidth:"105px",onClick:()=>o(g.account.api.create),children:"New API key"})]}),e.jsx(y,{mt:"20px",mx:"-20px",children:e.jsx(a,{height:"50px",mt:"30px",justifyContent:"center",children:e.jsx(m,{fontSize:"18px",gray:!0,children:"No API keys defined"})})})]})};export{X as default};
