1import{iZ as y,hm as B,hZ as e,M as H,P as V,U,X as $,ib as w,r as m,iq as I,eQ as A,jS as R,k4 as h,k5 as N,iW as u,eV as P,fG as D,fg as q}from"./index-D04aio-r.js";import{C as G}from"./index-CBMyeA0S.js";import{a as Q,t as W}from"./zod-geqXdhPU.js";import{u as X}from"./useSettingsCacheUpdate-CeFwMOjA.js";import{c as Z}from"./compact-CU4PNV0P.js";import{F as J,c as T,d as F,e as S,a as _,f as k}from"./ShadcnForm-BNKupssf.js";import{I as Y}from"./Input-DHyEO0-w.js";import{S as ee}from"./ShadcnSwitch-CkyfIU57.js";import{V as n,aO as se,aj as te,T as ae,cB as z,b_ as M,aT as oe}from"./index.min-DqM6n_B9.js";import{t as ie}from"./truncate-AnJzmrIX.js";import{u as ne}from"./useScreenSize-BEPGl4iJ.js";import{A as re}from"./AixContentHeader-pxmQ4NoZ.js";import{A as ce}from"./AixContentBody-fQxHHTvZ.js";import{T as le,d as me,e as E,c as g,a as de,b as C}from"./ShadcnTable-D0ANkqxE.js";import{A as O}from"./AixAlertDialog-B4pgk3JR.js";import{A as pe}from"./AppLayout-Szr5jlpX.js";import"./ShadcnLabel-MragvuuG.js";import"./AixDrawerSwitcher-D41cYW5q.js";import"./_isIterateeCall-DtjUgCb3.js";import"./clock-CjwqgSVJ.js";import"./ShadcnSeparator-Cywnz346.js";import"./ShadcnSidebar-CcFML6pV.js";import"./ShadcnSkeleton-DSmN0vHW.js";import"./chevron-left-DkAqb8DK.js";import"./ShadcnAlertDialog-CIPoWHxZ.js";import"./ShadcnBadge-bx-Pzfol.js";import"./GradientBackground-CE4URicP.js";import"./PageLoading-BBgE9Zdd.js";import"./Logo-BWgbhxtJ.js";
1import"./CustomHead-B5FxR42g.js";import"./draftJotai-DQYuv8fM.js";import"./ShadcnCheckbox-92pAQifO.js";import"./check-B_z0h917.js";import"./ShadcnDropDownMenu-CDosLHU_.js";import"./chevron-right-Dl6YQr4T.js";import"./index-CxeoeHDb.js";import"./index-CGdagJvn.js";import"./ShadcnTextarea-Cwm6ln5J.js";import"./TopUpModal-A-E0v9Cy.js";import"./subscription-C8Q96QLQ.js";import"./crypto-BX1xTAsC.js";import"./stripe.esm-dkXHr68O.js";import"./Tooltip-B1bz1H2k.js";import"./isNil-CHIgUVhi.js";import"./prismaTypings-DW8Hx9Vn.js";import"./chevron-down-i3Wj6aME.js";import"./find-CVDvtCjo.js";import"./send-Ct-BUx38.js";import"./circle-alert-WnyPIyXg.js";import"./ShadcnCard-B1kp8rMd.js";import"./ShadcnTabs-B9RDPswh.js";import"./index-DYvv3epU.js";import"./coerce-B8myVSW-.js";const L=[{name:"content.read",description:"Grants the ability to view content."},{name:"content.write",description:"Allows creating new content (text, video)."},{name:"content.schedule",description:"Permits scheduling content across different media platforms."},{name:"content.manage",description:"Allows uploading content."}],xe=I({name:R().min(5).max(1e3),scopes:I({content_read:A(),content_write:A(),content_schedule:A(),content_manage:A()})}),ue=({apiKey:a,...c})=>{const{createApiKey:d,updateApiKey:p,isCreating:j,isUpdating:v}=X(),l=a?.id?"Save":"Create",i=Q({resolver:W(xe),defaultValues:{name:a?.name??"",scopes:L.reduce((t,o)=>(t[y(o.name,".","_")]=B(a?.scopes?.items,o.name),t),{})}});i.watch();const f=t=>{const o=Z(w(t.scopes,(r,b)=>{const K=y(b,"_",".");return r?K:null}));a?.id?p.mutate({id:a.id,name:t.name,scopes:o},{onSuccess:()=>c.onOpenChange?.(!1),onError:()=>h.error("Failed to update API Key! Please try again later!")}):d.mutate({name:t.name,scopes:o},{onSuccess:r=>{c.onSuccess?.(r,void 0),c.onOpenChange?.(!1)},onError:()=>h.error("Failed to create API Key! Please try again later!")})},x=v;return e.jsx(H,{...c,children:e.jsxs(V,{children:[e.jsx(U,{children:e.jsx($,{children:`${l} API Key Name`})}),e.jsx(J,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(f),className:"flex w-full flex-col gap-y-4",children:[e.jsx(T,{control:i.control,name:"name",render:({field:t})=>e.jsxs(F,{children:[e.jsx(S,{children:"API Key Name"}),e.jsx(_,{children:e.jsx(Y,{placeholder:"API Key Name...",...t,className:"resize-none"})}),e.jsx(k,{})]})}),e.jsxs("div",{className:"my-4 flex flex-col gap-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-muted-foreground",children:"Scopes"}),w(L,t=>e.jsx(T,{control:i.control,name:`scopes.${y(t.name,".","_")}`,render:({field:o})=>e.jsxs(F,{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx(S,{className:"text-md",children:t.name}),e.jsx(S,{className:"text-xs",children:t.description})]}),e.jsx(_,{className:"",children:e.jsx(ee,{checked:!!o.value,onCheckedChange:r=>{i.setValue(`scopes.${y(t.name,".","_")}`,r)}})}),e.jsx(k,{})]})}))]}),e.jsxs(m,{loading:x||j,type:"submit",children:[l," API Key"]})]})})]})})},he=()=>{const{breakpoint:a}=ne(),c=N.useContext(),[d,p]=u.useState(),[j,v]=u.useState(!1),[l,i]=u.useState(),[f,x]=u.useState(!1),[t,o]=u.useState(void 0),{data:r}=N.auth.getPrivateApiKeys.useQuery(),{mutateAsync:b,isLoading:K}=N.auth.deleteApiKey.useMutation({onSuccess:async s=>{await c.auth.getPrivateApiKeys.invalidate(),p(void 0),h.success("Successfully deleted the API Key!")},onError:s=>{h.error(s.message||"Failed to delete the API Key! Please try again later!")}});return e.jsxs(e.Fragment,{children:[e.jsx(re,{title:"API Keys",icon:e.jsx(n,{icon:te}),backUrl:"/",right:e.jsx(e.Fragment,{children:e.jsx(m,{type:"button",size:"sm",leftIcon:e.jsx(n,{icon:se,size:16}),onClick:()=>x(!0),children:"New API Key"})})}),e.jsx(ce,{innerClassName:"flex-1",children:e.jsxs(le,{containerClassName:"flex-1",children:[!a.md&&e.jsx(me,{children:e.jsxs(E,{children:[e.jsx(g,{children:"Name"}),e.jsx(g,{children:"Key"}),e.jsx(g,{children:"Created At"}),e.jsx(g,{className:"text-right",children:"Action"})]})}),e.jsx(de,{children:w(r,s=>e.jsxs(E,{className:q("cursor-pointer",{}),children:[e.jsx(C,{className:"font-medium",children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:s.name}),a.md&&e.jsx("span",{className:"text-muted-foreground",children:D(s.createdAt).format("MMM DD, YYYY")})]})}),!a.md&&e.jsx(C,{children:`vm_live_*********************_${s.checksum}`}),!a.md&&e.jsx(C,{children:D(s.createdAt).format("MMM DD, YYYY")}),e.jsx(C,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(m,{variant:"secondary",size:"icon",onClick:()=>{x(!0),o(s)},leftIcon:e.jsx(n,{icon:oe,size:16})}),e.jsx(m,{variant:"secondary",size:"icon",className:"text-destructive",onClick:()=>p(s),leftIcon:e.jsx(n,{icon:M,size:16})})]})})]},s.id))})]})}),!!f&&e.jsx(ue,{open:!!f,apiKey:t,onOpenChange:s=>{s||(x(!1),o(void 0))},onSuccess:(s,fe)=>{i(s)}}),e.jsx(O,{open:!!l,onOpenChange:s=>!s&&i(void 0),title:"Copy API Key",description:e.jsxs("div",{className:"flex flex-col w-full gap-4",children:[e.jsx("div",{children:"Please copy your API Key now. This API Key will only be viewable once."}),e.jsx(Y,{disabled:!0,value:j?l?.secretApiKey:"**********************************"}),j?e.jsx(G,{text:l?.secretApiKey||"",onCopy:()=>h.info("Copied API Key to clipboard!"),children:e.jsx(m,{variant:"default",className:"flex-grow",leftIcon:e.jsx(n,{icon:z,size:16}),children:"Copy Key"})}):e.jsx(e.Fragment,{children:e.jsx(m,{variant:"default",className:"flex-grow",leftIcon:e.jsx(n,{icon:z,size:16}),onClick:s=>{s.preventDefault(),v(!0)},children:"Reveal"})})]}),cancelLabel:"Dismiss",actionClassName:P({variant:"destructive"}),icon:e.jsx(n,{icon:ae,size:36})}),e.jsx(O,{open:!!d,onOpenChange:s=>!s&&p(void 0),title:"Delete API Key",description:e.jsxs(e.Fragment,{children:["Are you sure you want to delete this key"," ",e.jsx("b",{children:ie(d?.name,{length:120,omission:"..."})}),"?"]}),cancelLabel:"No, Cancel",actionLabel:"Yes, I'm Sure",actionClassName:P({variant:"destructive"}),icon:e.jsx(n,{icon:M,size:36}),loading:K,onActionClick:async s=>{s.preventDefault(),await b({id:d?.id??""})}})]})},je=()=>e.jsx(he,{});function fs(){return e.jsx(pe,{children:e.jsx(je,{})})}
1export{fs as component}; 2//# sourceMappingURL=api-keys-DF_baZ7e.js.map
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.