1import{e as be,j as e,r as l,a7 as H,a9 as Ce,ac as we,i as d,aC as V,t as j,B as n}from"./index.r2-Ed8qmjX1.js";import{C as w,a as P,b as R,c as _,d as Pe}from"./card.r2-DjV_W7qX.js";import{B as O}from"./badge.r2-CSJmzdQ9.js";import{I as Se}from"./input.r2-y21fH3nT.js";import{L as S}from"./label.r2-BP-b1A3D.js";import{g as ke,h as U,i as Ie,j as Te,k as Ee,l as Ke,m as G,n as Re,o as _e,D as Oe,a as Me,b as Le,c as Fe,d as $e,e as qe}from"./dialog.r2-YCJiHQ3B.js";import{S as M,a as L,b as F,c as $,d as x}from"./select.r2-C7o0pnVF.js";import{D as k}from"./DashboardLayout.r2-8SWgGsLq.js";import{t as g}from"./index.r2-BKszOKWd.js";import{L as I}from"./loader-circle.r2-BHUbk1XN.js";import{S as q}from"./shield.r2-CGWLU-Y8.js";import{P as ze}from"./plus.r2-CA6w2Iz6.js";import{m as z}from"./proxy.r2-o2z13Jp0.js";import{T as Be}from"./triangle-alert.r2-CR-c--iw.js";import{E as He}from"./eye.r2-C_nib1Q_.js";import{C as Ve}from"./copy.r2-0bfbLGrN.js";import{K as B}from"./key.r2-C2BipvXS.js";import{C as Ue}from"./clock.r2-CpigWQ5u.js";import{T as Ge}from"./trash-2.r2-C_kiLlbC.js";import"./index.r2-C4oJmfCS.js";import"./chevron-up.r2-eMG3sOPl.js";import"./external-link.r2-DKQXGNLz.js";import"./glass.r2-CDMi0Fd8.js";import"./answerText.r2-BlXRKHkX.js";import"./cardVerify.r2-8qxJyEYx.js";import"./sovTools.r2-DxXVM2v3.js";import"./mcpHttp.r2-d7eI7gTo.js";import"./tabs.r2-DESqOhE8.js";import"./circle-check.r2-B3SXFkcU.js";import"./download.r2-x1G3RCkd.js";import"./TalkPanel.r2-C0Fsz4N7.js";import"./aguiTalk.r2--PcxBxgb.js";import"./uiTools.r2-C9ICe4Yu.js";import"./shield-alert.r2-BuyLEWu-.js";import"./wrench.r2-B51e2CRu.js";import"./useLiveJson.r2-CFvnyfor.js";import"./coins.r2-C4i9J1Sz.js";import"./arrow-right.r2-DaYJWqWf.js";import"./dashboardView.r2-BAysO9o0.js";import"./workspaceMenu.r2-EesyWpcF.js";import"./scale.r2-Cj9kKPvY.js";import"./plug-zap.r2-H-POoi35.js";import"./pin.r2-BgncHSno.js";const Qe=be("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var Q="AlertDialog",[Ye]=we(Q,[U]),c=U(),Y=s=>{const{__scopeAlertDialog:a,...t}=s,i=c(a);return e.jsx(ke,{...i,...t,modal:!0})};Y.displayName=Q;var Je="AlertDialogTrigger",We=l.forwardRef((s,a)=>{const{__scopeAlertDialog:t,...i}=s,o=c(t);return e.jsx(_e,{...o,...i,ref:a})});We.displayName=Je;var Xe="AlertDialogPortal",J=s=>{const{__scopeAlertDialog:a,...t}=s,i=c(a);return e.jsx(Ie,{...i,...t})};J.displayName=Xe;var Ze="AlertDialogOverlay",W=l.forwardRef((s,a)=>{const{__scopeAlertDialog:t,...i}=s,o=c(t);return e.jsx(Re,{...o,...i,ref:a})});W.displayName=Ze;var X="AlertDialogContent",[es,ss]=Ye(X),Z=l.forwardRef((s,a)=>{const{__scopeAlertDialog:t,children:i,...o}=s,p=c(t),u=l.useRef(null),f=H(a,u),h=l.useRef(null);return e.jsx(es,{scope:t,cancelRef:h,children:e.jsx(Te,{role:"alertdialog",...p,...o,ref:f,onOpenAutoFocus:Ce(o.onOpenAutoFocus,m=>{m.preventDefault(),h.current?.focus({preventScroll:!0})}),onPointerDownOutside:m=>m.preventDefault(),onInteractOutside:m=>m.preventDefault(),children:i})})});Z.displayName=X;var as="AlertDialogTitle",ee=l.forwardRef((s,a)=>{const{__scopeAlertDialog:t,...i}=s,o=c(t);return e.jsx(Ee,{...o,...i,ref:a})});ee.displayName=as;var ts="AlertDialogDescription",se=l.forwardRef((s,a)=>{const{__scopeAlertDialog:t,...i}=s,o=c(t);return e.jsx(Ke,{...o,...i,ref:a})});se.displayName=ts;var rs="AlertDialogAction",ae=l.forwardRef((s,a)=>{const{__scopeAlertDialog:t,...i}=s,o=c(t);return e.jsx(G,{...o,...i,ref:a})});ae.displayName=rs;var te="AlertDialogCancel",re=l.forwardRef((s,a)=>{const{__scopeAlertDialog:t,...i}=s,{cancelRef:o}=ss(te,t),p=c(t),u=H(a,o);return e.jsx(G,{...p,...i,ref:u})});re.displayName=te;var is=Y,ls=J,ie=W,le=Z,oe=ae,ne=re,ce=ee,de=se;const os=is,ns=ls,me=l.forwardRef(({className:s,...a},t)=>e.jsx(ie,{className:d("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...a,ref:t}));me.displayName=ie.displayName;const xe=l.forwardRef(({className:s,...a},t)=>e.jsxs(ns,{children:[e.jsx(me,{}),e.jsx(le,{ref:t,className:d("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
1nded-lg",s),...a})]}));xe.displayName=le.displayName;const pe=({className:s,...a})=>e.jsx("div",{className:d("flex flex-col space-y-2 text-center sm:text-left",s),...a});pe.displayName="AlertDialogHeader";const ue=({className:s,...a})=>e.jsx("div",{className:d("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...a});ue.displayName="AlertDialogFooter";const ge=l.forwardRef(({className:s,...a},t)=>e.jsx(ce,{ref:t,className:d("text-lg font-semibold",s),...a}));ge.displayName=ce.displayName;const he=l.forwardRef(({className:s,...a},t)=>e.jsx(de,{ref:t,className:d("text-sm text-muted-foreground",s),...a}));he.displayName=de.displayName;const fe=l.forwardRef(({className:s,...a},t)=>e.jsx(oe,{ref:t,className:d(V(),s),...a}));fe.displayName=oe.displayName;const je=l.forwardRef(({className:s,...a},t)=>e.jsx(ne,{ref:t,className:d(V({variant:"outline"}),"mt-2 sm:mt-0",s),...a}));je.displayName=ne.displayName;const cs={free:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300",pro:"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300",enterprise:"bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-300"};function Zs(){const{data:s,isLoading:a}=j.auth.me.useQuery(),[t,i]=l.useState(!1),[o,p]=l.useState(""),[u,f]=l.useState("free"),[h,m]=l.useState("90"),[y,T]=l.useState(null),[N,ye]=l.useState(!1),[v,A]=l.useState(null),{data:D,isLoading:Ne,refetch:E}=j.apiKeys.list.useQuery(),b=j.apiKeys.create.useMutation({onSuccess:r=>{T(r.key),i(!1),p(""),f("free"),E(),g.success("API key created!",{description:"Make sure to copy your key now - you won't be able to see it again."})},onError:r=>{g.error("Failed to create API key",{description:r.message})}}),K=j.apiKeys.delete.useMutation({onSuccess:()=>{E(),A(null),g.success("API key deleted")},onError:r=>{g.error("Failed to delete API key",{description:r.message})}}),ve=()=>{if(!o.trim()){g.error("Please enter a name for your API key");return}b.mutate({name:o,tier:u,expiresInDays:parseInt(h)||void 0})},Ae=r=>{navigator.clipboard.writeText(r),g.success("Copied to clipboard")},C=r=>r?new Date(r).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never";return Ne?e.jsx(k,{children:e.jsx("div",{className:"flex items-center justify-center h-96",children:e.jsx(I,{className:"h-8 w-8 animate-spin text-primary"})})}):!a&&!s?e.jsx(k,{children:e.jsxs("div",{className:"p-6 flex flex-col items-center justify-center min-h-[50vh] text-center space-y-4",children:[e.jsx(q,{className:"h-10 w-10 text-muted-foreground"}),e.jsx("h1",{className:"text-2xl font-semibold",children:"Sign in required"}),e.jsx("p",{className:"text-muted-foreground max-w-md",children:"API key management is available to signed-in accounts only."}),e.jsx(n,{asChild:!0,children:e.jsx("a",{href:"/login",children:"Sign in"})})]})}):e.jsxs(k,{children:[e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"API Keys"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage API keys for programmatic access to CSOAI services"})]}),e.jsxs(n,{onClick:()=>i(!0),className:"gap-2",children:[e.jsx(ze,{className:"h-4 w-4"}),"Create API Key"]})]}),y&&e.jsx(z.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},children:e.jsx(w,{className:"border-amber-500 bg-amber-50 dark:bg-amber-950",children:e.jsx(P,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Be,{className:"h-5 w-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-amber-900 dark:text-amber-100",children:"Save your API key now!"}),e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300 mb-3",children:"This is the only time you'll be able to see this key. Store it securely."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 bg-white dark:bg-gray-900 px-3 py-2 rounded border font-mono text-sm",children:N?y:"â¢".repeat(40)}),e.jsx(n,{variant:"outline",size:"icon",onClick:()=>ye(!N),children:N?e.jsx(Qe,{className:"h-4 w-4"}):e.jsx(He,{className:"h-4 w-4"})}),e.jsx(n,{variant:"outline",size:"icon",onClick:()=>Ae(y),children:e.jsx(Ve,{className:"h-4 w-4"})})]})]}),e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>T(null),children:"Dismiss"})]})})})}),e.jsxs(w,{children:[e.jsxs(R,{children:[e.jsx(_,{className:"text-lg",children:"Your API Keys"}),e.jsx(Pe,{children:"API keys are used to authenticate requests to the CSOAI API"})]}),e.jsx(P,{children:!D||D.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(B,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-medium text-lg mb-2",children:"No API keys yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Create an API key to start using the CSOAI API"}),e.jsx(n,{onClick:()=>i(!0),children:"Create your first API key"})]}):e.jsx("div",{className:"space-y-3",children:D.map((r,De)=>e.jsx(z.div,{initial:{opacity:0,y:10}
1,animate:{opacity:1,y:0},transition:{delay:De*.05},children:e.jsxs("div",{className:`flex items-center justify-between p-4 rounded-lg border ${r.isActive?"bg-card":"opacity-50 bg-muted/50"}`,children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(B,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium",children:r.name}),e.jsx(O,{className:cs[r.tier],variant:"secondary",children:r.tier}),!r.isActive&&e.jsx(O,{variant:"destructive",children:"Revoked"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mt-1",children:[e.jsxs("span",{className:"font-mono",children:[r.keyPrefix,"..."]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(q,{className:"h-3 w-3"}),r.rateLimit,"/min"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ue,{className:"h-3 w-3"}),"Created ",C(r.createdAt)]}),r.expiresAt&&e.jsxs("span",{className:"flex items-center gap-1",children:["Expires ",C(r.expiresAt)]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r.lastUsedAt&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last used ",C(r.lastUsedAt)]}),e.jsx(n,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>A(r.id),disabled:!r.isActive,children:e.jsx(Ge,{className:"h-4 w-4"})})]})]})},r.id))})})]}),e.jsxs(w,{children:[e.jsx(R,{children:e.jsx(_,{className:"text-lg",children:"API Usage"})}),e.jsx(P,{children:e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50",children:[e.jsx("div",{className:"text-2xl font-bold",children:"Free"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"100 requests/min"}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Basic access"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-blue-50 dark:bg-blue-950",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:"Pro"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"500 requests/min"}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Priority support"})]}),e.jsxs("div",{className:"p-4 rounded-lg bg-purple-50 dark:bg-purple-950",children:[e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:"Enterprise"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"1000 requests/min"}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Dedicated support"})]})]})})]})]}),e.jsx(Oe,{open:t,onOpenChange:i,children:e.jsxs(Me,{children:[e.jsxs(Le,{children:[e.jsx(Fe,{children:"Create API Key"}),e.jsx($e,{children:"Create a new API key for programmatic access to CSOAI services."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"keyName",children:"Key Name"}),e.jsx(Se,{id:"keyName",placeholder:"e.g., Production Server",value:o,onChange:r=>p(r.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"keyTier",children:"Tier"}),e.jsxs(M,{value:u,onValueChange:r=>f(r),children:[e.jsx(L,{children:e.jsx(F,{})}),e.jsxs($,{children:[e.jsx(x,{value:"free",children:"Free (100 req/min)"}),e.jsx(x,{value:"pro",children:"Pro (500 req/min)"}),e.jsx(x,{value:"enterprise",children:"Enterprise (1000 req/min)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"keyExpiry",children:"Expiration"}),e.jsxs(M,{value:h,onValueChange:m,children:[e.jsx(L,{children:e.jsx(F,{})}),e.jsxs($,{children:[e.jsx(x,{value:"30",children:"30 days"}),e.jsx(x,{value:"90",children:"90 days"}),e.jsx(x,{value:"180",children:"180 days"}),e.jsx(x,{value:"365",children:"1 year"})]})]})]})]}),e.jsxs(qe,{children:[e.jsx(n,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(n,{onClick:ve,disabled:b.isPending,children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Key"})]})]})}),e.jsx(os,{open:!!v,onOpenChange:r=>!r&&A(null),children:e.jsxs(xe,{children:[e.jsxs(pe,{children:[e.jsx(ge,{children:"Delete API Key?"}),e.jsx(he,{children:"This action cannot be undone. Any applications using this key will no longer be able to authenticate."})]}),e.jsxs(ue,{children:[e.jsx(je,{children:"Cancel"}),e.jsx(fe,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>v&&K.mutate({id:v}),children:K.isPending?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete Key"})]})]})})]})}export{Zs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.