PageSourceSearch

https://app.ustechautomations.com/assets/index-O22EOTC-.js

js ustechautomations.com collected 2026-09-26 00:53:25 UTC 93,115 bytes, 1 lines download raw bytes

1var e=Object.defineProperty,s=(s,a,i)=>((s,a,i)=>a in s?e(s,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[a]=i)(s,"symbol"!=typeof a?a+"":a,i);import{a,p as i,A as n,I as l,O as t,B as r,H as c}from"./chunk-6CSD65Y2-xYubHBmU.js";import{B as d,R as o,P as h,I as m,co as _,cp as u,cq as x,cr as j,cs as p,ct as v,bc as g,cJ as N,r as f,s as b,c6 as y,t as w,u as C,v as S,z as k,G as A,cu as E,g as I,l as L,m as P,n as D,o as F,p as T,J as M,K as q,aj as U,ak as R,al as $,am as V,an as G,N as z,cK as B,q as O,cL as H,cM as W,bA as Q,cN as K,a5 as J,cf as Y,cO as X,cP as Z,a4 as ee,bU as se,ac as ae,ad as ie,ae as ne,A as le,b4 as te,cQ as re,a9 as ce,b8 as de,cR as oe,ag as he,b as me,a as _e,O as ue,cS as xe,Q as je,V as pe,X as ve,Y as ge,Z as Ne,_ as fe,$ as be,W as ye,h as we,k as Ce,f as Se,cT as ke,M as Ae,j as Ee,T as Ie,c as Le,d as Pe,e as De,cU as Fe,bE as Te,bj as Me,aw as qe,a3 as Ue,y as Re,a6 as $e,cV as Ve,cW as Ge}from"./CoreLayout-V9PVLCM0.js";import{B as ze,aF as Be,H as Oe,I as He,W as We,aG as Qe,G as Ke,aH as Je,aI as Ye}from"./voiceStore-D_K9cjIr.js";import{U as Xe,M as Ze}from"./user-BccZgP0Q.js";import{C as es,a as ss,b as as,c as is,d as ns}from"./card-C2UeeBp1.js";import{C as ls,a as ts}from"./loader-circle-Mux4UJzI.js";import{E as rs,a as cs,d as ds,C as os}from"./index-BcwKVuK3.js";import"./index-BfJR_dAR.js";import{S as hs}from"./skeleton-HiKLIgRk.js";import"./overlayFocus-BmDVzTk_.js";import"./AuthContextDefinition-CrUuQ85U.js";import"./createLucideIcon-B7UGDY3i.js";function ms(e,s=20,i=300){const[n,l]=a.useState(""),[t,r]=a.useState("");a.useEffect(()=>{const e=setTimeout(()=>r(n),i);return()=>clearTimeout(e)},[n,i]),a.useEffect(()=>{e({page:1,limit:s,search:t})},[e,s,t]);const c=a.useCallback(a=>{e({page:a,limit:s,search:t})},[e,s,t]);return{searchQuery:n,setSearchQuery:l,debouncedSearch:t,handlePageChange:c}}const _s={solo:{id:"solo",displayName:"Solo",description:"Take one recurring task off your plate and let it run on a schedule.",priceMonthly:117,priceAnnual:96,limits:{workflows:3,executions_per_day:3,api_calls_per_flow_per_day:50,storage_gb:1,support_hours_per_month:0},features:["3 active flows","1 scheduled run/day per flow","Up to 50 API calls/flow/day","1GB data storage","Flow templates library","Email support (48hr response)","Community access"]},growth:{id:"growth",displayName:"Growth",description:"Hand off several daily processes to workflows your team adjusts as you grow.",priceMonthly:447,priceAnnual:372,limits:{workflows:5,executions_per_day:6,api_calls_per_flow_per_day:150,storage_gb:5,support_hours_per_month:1},features:["5 active flows","2 scheduled runs/day (3x allowed 15 days/month)","Up to 150 API calls/flow/day","5GB data storage","1 hour support/month","Priority email (24hr response)","Flow templates library"],highlighted:!0},scale:{id:"scale",displayName:"Scale",description:"Run your core operations on hourly workflows with our engineers a call away.",priceMonthly:1647,priceAnnual:1371,limits:{workflows:10,executions_per_day:24,api_calls_per_flow_per_day:500,storage_gb:25,support_hours_per_month:4},features:["10 active flows","Hourly runs (burst to 3x/hr for half the month)","Up to 500 API calls/flow/day","25GB data storage","Flow templates library","4 hours support/month","30-min onboarding call","Priority queue for executions","Advanced analytics dashboard"]},enterprise:{id:"enterprise",displayName:"Performance",description:"Run up to 100 active workflows with dedicated support for your team.",priceMonthly:5997,priceAnnual:4998,limits:{workflows:100,executions_per_day:-1,api_calls_per_flow_per_day:-1,storage_gb:100,support_hours_per_month:8,local_llm_enabled:!0,sla_guarantee:!0},features:["100 active flows","Unlimited scheduled runs","Unlimited API calls","100GB data storage","Flow templates library","8 hours support/month","Custom workflow onboarding session","Local LLM support (Ollama, LM Studio)","Dedicated Slack channel","Custom SLA","Custom integrations"],badge:"Dedicated Support"}},us=["solo","growth","scale","enterprise"],xs={standard:"solo",premium:"scale",enterprise:"enterprise"},js="_container_1tby0_8",ps="_header_1tby0_15",vs="_title_1tby0_22",gs="_subtitle_1tby0_29",Ns="_headerActions_1tby0_35",fs="_searchContainer_1tby0_42",bs="_searchInputWrapper_1tby0_50",ys="_resultCount_1tby0_73",ws="_errorBanner_1tby0_79",Cs="_tableContainer_1tby0_93",Ss="_accountCell_1tby0_101",ks="_avatar_1tby0_107",As="_avatarImage_1tby0_120",Es="_accountInfo_1tby0_126",Is="_accountName_1tby0_132",Ls="_accountSlug_1tby0_141",Ps="_statCell_1tby0_150",Ds="_ownerName_1tby0_158",Fs="_badgeEnterprise_1tby0_164",Ts="_badgeScale_1tby0_169",Ms="_badgeGrowth_1tby0_174",qs="_badgeSolo_1tby0_179",Us="_emptyCell_1tby0_196",Rs="_pagination_1tby0_203",$s="_paginationInfo_1tby0_212",Vs="_paginationControls_1tby0_217",Gs="_skeletonAccount_1tby0_223",zs="_skeletonAvatar_1tby0_229",Bs="_skeletonInfo_1tby0_237",Os="_skeletonName_1tby0_243",Hs="_skeletonSlug_1tby0_251",Ws="_skeletonBadge_1tby0_259",Qs="_skeletonText_1tby0_267",Ks="_spinning_1tby0_285",Js="_dialog_1tby0_299",Ys="_membersDialog_1tby0_303",Xs="_formGrid_1tby0_307",Zs="_formField_1tby0_314",ea="_dialogFooter_1tby0_320",sa="_membersContent_1tby0_327",aa="_membersHeader_1tby0_331",ia="_membersCount_1tby0_338",na="_membersList_1tby0_343",la="_memberItem_1tby0_351",ta="_memberInfo_1tby0_361",ra="_memberName_1tby0_368",ca="_memberEmail_1tby0_377",da="_roleBadge_1tby0_385",oa="_removeMemberBtn_1tby0_389",ha="_loadingMembers_1tby0_398",ma="_noMembers_1tby0_399",_a=e=>{if(!e)return"Never";return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})},ua=({plan:e})=>{const s=xs[a=e]||a||"solo";var a;const n=_s[s],l=n?.displayName||e;switch(s){case"enterprise":return i.jsxs(O,{className:Fs,children:[i.jsx(H,{className:"h-3 w-3 mr-1"}),l]});case"scale":return i.jsx(O,{className:Ts,children:l});case"growth":return i.jsx(O,{className:Ms,children:l});default:return i.jsx(O,{variant:"secondary",className:qs,children:l})}},xa=()=>{const{showSuccess:e,showError:s}=ze(),{users:n,fetchUsers:l}=Be(),{allAccounts:t,accountMembers:r,pagination:c,isLoadingAll:H,isLoadingMembers:W,error:Q,loadAllAccounts:K,createAccount:J,updateAccount:Y,deleteAccount:X,loadAccountMembers:Z,assignMember:ee,removeMember:se,clearError:ae}=Oe(),{searchQuery:ie,setSearchQuery:ne,debouncedSearch:le,handlePageChange:te}=ms(K),[re,ce]=a.useState(!1),[de,oe]=a.useState({name:"",description:"",plan:"solo"}),[he,me]=a.useState(!1),[_e,ue]=a.useState(!1),[xe,je]=a.useState(null),[pe,ve]=a.useState({name:"",description:"",plan:"solo"}),[ge,Ne]=a.useState(!1),[fe,be]=a.useState(null),[ye,we]=a.useState(!1),[Ce,Se]=a.useState({user_id:"",role:"member"});a.useEffect(()=>{l({page:1,limit:100})},[l]);const ke=a.useCallback(async a=>{a.preventDefault(),me(!0);try{await J({name:de.name,description:de.description||void 0,plan:de.plan}),ce(!1),oe({name:"",description:"",plan:"solo"}),e(`Account "${de.name}" has been created.`)}catch(i){s(i instanceof Error?i.message:"Failed to create account")}finally{me(!1)}},[J,de,e,s]),Ae=a.useCallback(e=>{je(e),ve({name:e.name,description:e.description||"",plan:e.plan}),ue(!0)},[]),Ee=a.useCallback(async a=>{if(a.preventDefault(),xe)try{await Y(xe.id,{name:pe.name,description:pe.description||void 0,plan:pe.plan}),ue(!1),je(null),e(`Account "${pe.name}" has been updated.`)}catch(i){s(i instanceof Error?i.message:"Failed to update account")}},[xe,pe,Y,e,s]),Ie=a.useCallback(async a=>{if(window.confirm(`Are you sure you want to delete "${a.name}"? This will also delete all associated workflows.`))try{await X(a.id),e(`Account "${a.name}" has been deleted.`)}catch(i){s(i instanceof Error?i.message:"Failed to delete account")}},[X,e,s]),Le=a.useCallback(async e=>{be(e),await Z(e.id),Ne(!0)}
1,[Z]),Pe=a.useCallback(async a=>{if(a.preventDefault(),fe)try{await ee(fe.id,{user_id:Ce.user_id,role:Ce.role}),we(!1),Se({user_id:"",role:"member"}),e("User has been assigned to the account."),Z(fe.id)}catch(i){s(i instanceof Error?i.message:"Failed to assign user")}},[fe,Ce,ee,Z,e,s]),De=a.useCallback(async a=>{if(fe&&window.confirm(`Remove ${a.name||a.email} from this account?`))try{await se(fe.id,a.user_id),e("User has been removed from the account.")}catch(i){s(i instanceof Error?i.message:"Failed to remove user")}},[fe,se,e,s]);return i.jsxs("div",{className:js,children:[i.jsxs("div",{className:ps,children:[i.jsxs("div",{children:[i.jsx("h1",{className:vs,children:"Client Accounts"}),i.jsx("p",{className:gs,children:"Manage client organizations and their team members"})]}),i.jsxs("div",{className:Ns,children:[i.jsxs(d,{variant:"outline",onClick:()=>K({page:1,limit:20,search:le}),disabled:H,children:[i.jsx(o,{className:`h-4 w-4 mr-2 ${H?Ks:""}`}),"Refresh"]}),i.jsxs(d,{onClick:()=>ce(!0),children:[i.jsx(h,{className:"h-4 w-4 mr-2"}),"New Account"]})]})]}),i.jsxs("div",{className:fs,children:[i.jsx("div",{className:bs,children:i.jsx(m,{type:"text",placeholder:"Search accounts...",value:ie,onChange:e=>ne(e.target.value),icon:"Search"})}),i.jsxs("div",{className:ys,children:[c?.total??t.length," account",1!==(c?.total??t.length)?"s":""]})]}),Q&&i.jsxs("div",{className:ws,children:[i.jsx("span",{children:Q}),i.jsx(d,{variant:"ghost",size:"sm",onClick:ae,children:"Dismiss"})]}),i.jsx("div",{className:Cs,children:i.jsxs(_,{children:[i.jsx(u,{children:i.jsxs(x,{children:[i.jsx(j,{children:"Account"}),i.jsx(j,{children:"Plan"}),i.jsx(j,{children:"Members"}),i.jsx(j,{children:"Workflows"}),i.jsx(j,{children:"Owner"}),i.jsx(j,{children:"Created"}),i.jsx(j,{className:"w-12"})]})}),i.jsx(p,{children:H?Array.from({length:5}).map((e,s)=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsxs("div",{className:Gs,children:[i.jsx("div",{className:zs}),i.jsxs("div",{className:Bs,children:[i.jsx("div",{className:Os}),i.jsx("div",{className:Hs})]})]})}),i.jsx(v,{children:i.jsx("div",{className:Ws})}),i.jsx(v,{children:i.jsx("div",{className:Qs})}),i.jsx(v,{children:i.jsx("div",{className:Qs})}),i.jsx(v,{children:i.jsx("div",{className:Qs})}),i.jsx(v,{children:i.jsx("div",{className:Qs})}),i.jsx(v,{})]},s)):t&&0!==t.length?t.map(e=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsxs("div",{className:Ss,children:[i.jsx("div",{className:ks,children:e.avatar_url?i.jsx("img",{src:e.avatar_url,alt:"",className:As}):i.jsx(g,{className:"h-4 w-4"})}),i.jsxs("div",{className:Es,children:[i.jsx("span",{className:Is,children:e.name}),i.jsxs("span",{className:Ls,children:["/",e.slug]})]})]})}),i.jsx(v,{children:i.jsx(ua,{plan:e.plan})}),i.jsx(v,{children:i.jsxs("div",{className:Ps,children:[i.jsx(N,{className:"h-3.5 w-3.5"}),e.member_count??0]})}),i.jsx(v,{children:e.workflow_count??0}),i.jsx(v,{children:i.jsx("span",{className:Ds,children:e.owner_name||e.owner_email||"—"})}),i.jsx(v,{children:_a(e.created_at)}),i.jsx(v,{children:i.jsxs(f,{children:[i.jsx(b,{asChild:!0,children:i.jsxs(d,{variant:"ghost",size:"icon",children:[i.jsx(y,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Actions"})]})}),i.jsxs(w,{align:"end",children:[i.jsxs(C,{onClick:()=>Le(e),children:[i.jsx(N,{className:"h-4 w-4 mr-2"}),"View Members"]}),i.jsxs(C,{onClick:()=>Ae(e),children:[i.jsx(S,{className:"h-4 w-4 mr-2"}),"Edit Details"]}),i.jsx(k,{}),i.jsxs(C,{onClick:()=>Ie(e),variant:"destructive",children:[i.jsx(A,{className:"h-4 w-4 mr-2"}),"Delete Account"]})]})]})})]},e.id)):i.jsx(x,{children:i.jsx(v,{colSpan:7,className:Us,children:le?`No accounts found matching "${le}"`:"No accounts found. Create your first client account."})})})]})}),c&&c.pages>1&&i.jsxs("div",{className:Rs,children:[i.jsxs("div",{className:$s,children:["Page ",c.page," of ",c.pages]}),i.jsxs("div",{className:Vs,children:[i.jsxs(d,{variant:"outline",size:"sm",onClick:()=>te(c.page-1),disabled:c.page<=1||H,children:[i.jsx(E,{className:"h-4 w-4 mr-1"}),"Previous"]}),i.jsxs(d,{variant:"outline",size:"sm",onClick:()=>te(c.page+1),disabled:c.page>=c.pages||H,children:["Next",i.jsx(I,{className:"h-4 w-4 ml-1"})]})]})]}),i.jsx(L,{open:re,onOpenChange:ce,children:i.jsxs(P,{className:Js,children:[i.jsxs(D,{children:[i.jsx(F,{children:"Create Client Account"}),i.jsx(T,{children:"Create a new client organization to manage their workflows."})]}),i.jsxs("form",{onSubmit:ke,children:[i.jsxs("div",{className:Xs,children:[i.jsxs("div",{className:Zs,children:[i.jsx(M,{htmlFor:"create-name",children:"Account Name *"}),i.jsx(m,{id:"create-name",type:"text",value:de.name,onChange:e=>oe({...de,name:e.target.value}),placeholder:"Acme Corporation",required:!0})]}),i.jsxs("div",{className:Zs,children:[i.jsx(M,{htmlFor:"create-description",children:"Description"}),i.jsx(q,{id:"create-description",value:de.description,onChange:e=>oe({...de,description:e.target.value}),placeholder:"Brief description of the client...",rows:2})]}),i.jsxs("div",{className:Zs,children:[i.jsx(M,{htmlFor:"create-plan",children:"Plan"}),i.jsxs(U,{value:de.plan,onValueChange:e=>oe({...de,plan:e}),children:[i.jsx(R,{children:i.jsx($,{placeholder:"Select plan"})}),i.jsx(V,{children:us.map(e=>i.jsxs(G,{value:e,children:[_s[e].displayName," - $",_s[e].priceMonthly,"/mo"]},e))})]})]})]}),i.jsxs(z,{className:ea,children:[i.jsx(d,{type:"button",variant:"outline",onClick:()=>ce(!1),children:"Cancel"}),i.jsx(d,{type:"submit",disabled:he||!de.name,children:he?"Creating...":"Create Account"})]})]})]})}),i.jsx(L,{open:_e,onOpenChange:ue,children:i.jsxs(P,{className:Js,children:[i.jsxs(D,{children:[i.jsx(F,{children:"Edit Account"}),i.jsx(T,{children:"Update the account details."})]}),i.jsxs("form",{onSubmit:Ee,children:[i.jsxs("div",{className:Xs,children:[i.jsxs("div",{className:Zs,children:[i.jsx(M,{htmlFor:"edit-name",children:"Account Name *"}),i.jsx(m,{id:"edit-name",type:"text",value:pe.name,onChange:e=>ve({...pe,name:e.target.value}),required:!0})]}),i.jsxs("div",{className:Zs,children:[i.jsx(M,{htmlFor:"edit-description",children:"Description"}),i.jsx(q,{id:"edit-description",value:pe.description,onChange:e=>ve({...pe,description:e.target.value}),rows:2})]}),i.jsxs("div",{className:Zs,children:[i.jsx(M,{htmlFor:"edit-plan",children:"Plan"}),i.jsxs(U,{value:pe.plan,onValueChange:e=>ve({...pe,plan:e}),children:[i.jsx(R,{children:i.jsx($,{})}),i.jsx(V,{children:us.map(e=>i.jsxs(G,{value:e,children:[_s[e].displayName," - $",_s[e].priceMonthly,"/mo"]},e))})]})]})]}),i.jsxs(z,{className:ea,children:[i.jsx(d,{type:"button",variant:"outline",onClick:()=>ue(!1),children:"Cancel"}),i.jsx(d,{type:"submit",disabled:!pe.name,children:"Save Changes"})]})]})]})}),i.jsx(L,{open:ge,onOpenChange:Ne,children:i.jsxs(P,{className:Ys,children:[i.jsxs(D,{children:[i.jsxs(F,{children:[fe?.name," - Members"]}),i.jsx(T,{children:"Manage users assigned to this account."})]}),i.jsxs("div",{className:sa,children:[i.jsxs("div",{className:aa,children:[i.jsxs("span",{className:ia,children:[r.length," member",1!==r.length?"s":""]}),i.jsxs(d,{size:"sm",onClick:()=>we(!0),children:[i.jsx(B,{className:"h-4 w-4 mr-2"}),"Add Member"]})]}),W?i.jsx("div",{className:ha,children:"Loading members..."}
1):0===r.length?i.jsx("div",{className:ma,children:"No members yet. Add users to this account."}):i.jsx("div",{className:na,children:r.map(e=>i.jsxs("div",{className:la,children:[i.jsxs("div",{className:ta,children:[i.jsx("span",{className:ra,children:e.name||e.email}),i.jsx("span",{className:ca,children:e.email})]}),i.jsx(O,{variant:"outline",className:da,children:e.role}),i.jsx(d,{variant:"ghost",size:"icon",onClick:()=>De(e),className:oa,children:i.jsx(A,{className:"h-4 w-4"})})]},e.id))})]}),i.jsx(z,{children:i.jsx(d,{variant:"outline",onClick:()=>Ne(!1),children:"Close"})})]})}),i.jsx(L,{open:ye,onOpenChange:we,children:i.jsxs(P,{className:Js,children:[i.jsxs(D,{children:[i.jsx(F,{children:"Add Member"}),i.jsxs(T,{children:["Assign a user to ",fe?.name,"."]})]}),i.jsxs("form",{onSubmit:Pe,children:[i.jsxs("div",{className:Xs,children:[i.jsxs("div",{className:Zs,children:[i.jsx(M,{htmlFor:"assign-user",children:"User *"}),i.jsxs(U,{value:Ce.user_id,onValueChange:e=>Se({...Ce,user_id:e}),children:[i.jsx(R,{children:i.jsx($,{placeholder:"Select user"})}),i.jsx(V,{children:n.filter(e=>!e.is_invitation&&!r.some(s=>s.user_id===e.id)).map(e=>i.jsx(G,{value:e.id||"",children:e.name||e.email},e.id))})]})]}),i.jsxs("div",{className:Zs,children:[i.jsx(M,{htmlFor:"assign-role",children:"Role"}),i.jsxs(U,{value:Ce.role,onValueChange:e=>Se({...Ce,role:e}),children:[i.jsx(R,{children:i.jsx($,{})}),i.jsxs(V,{children:[i.jsx(G,{value:"viewer",children:"Viewer"}),i.jsx(G,{value:"member",children:"Member"}),i.jsx(G,{value:"admin",children:"Admin"}),i.jsx(G,{value:"owner",children:"Owner"})]})]})]})]}),i.jsxs(z,{className:ea,children:[i.jsx(d,{type:"button",variant:"outline",onClick:()=>we(!1),children:"Cancel"}),i.jsx(d,{type:"submit",disabled:!Ce.user_id,children:"Add Member"})]})]})]})})]})},ja="_container_unhql_9",pa="_sidebar_unhql_16",va="_sidebarCollapsed_unhql_24",ga="_sidebarHeader_unhql_29",Na="_logoContainer_unhql_37",fa="_logoIcon_unhql_44",ba="_logoText_unhql_51",ya="_collapseButton_unhql_58",wa="_nav_unhql_63",Ca="_navLink_unhql_72",Sa="_navLinkActive_unhql_88",ka="_navLinkCollapsed_unhql_97",Aa="_navIcon_unhql_102",Ea="_navContent_unhql_108",Ia="_navLabel_unhql_115",La="_navDescription_unhql_121",Pa="_sidebarFooter_unhql_134",Da="_backButton_unhql_139",Fa="_backButtonCollapsed_unhql_145",Ta="_main_unhql_150",Ma=[{to:"/admin",icon:Q,label:"Dashboard",description:"Overview and statistics"},{to:"/admin/users",icon:N,label:"Users",description:"Manage user accounts"},{to:"/admin/accounts",icon:g,label:"Accounts",description:"Client organizations"},{to:"/admin/quotas",icon:K,label:"Quotas",description:"Execution limits"},{to:"/admin/forge",icon:J,label:"Forge",description:"Flow Forge usage"},{to:"/admin/credentials",icon:Y,label:"Credentials",description:"API keys and secrets"},{to:"/admin/healing",icon:X,label:"Self-Healing",description:"Diagnosis and repair"},{to:"/admin/audit-logs",icon:Z,label:"Audit Logs",description:"Activity history"}],qa=()=>{const[e,s]=a.useState(!1),r=n();return i.jsxs("div",{className:ja,children:[i.jsxs("aside",{className:ee(pa,e&&va),children:[i.jsxs("div",{className:ga,children:[i.jsxs("div",{className:Na,children:[i.jsx(W,{className:fa}),!e&&i.jsx("span",{className:ba,children:"Admin Panel"})]}),i.jsx(d,{variant:"ghost",size:"icon",onClick:()=>s(!e),className:ya,"aria-label":e?"Expand sidebar":"Collapse sidebar",children:e?i.jsx(I,{className:"h-4 w-4"}):i.jsx(E,{className:"h-4 w-4"})})]}),i.jsx("nav",{className:wa,children:Ma.map(s=>i.jsxs(l,{to:s.to,end:"/admin"===s.to,className:({isActive:s})=>ee(Ca,s&&Sa,e&&ka),title:e?s.label:void 0,children:[i.jsx(s.icon,{className:Aa}),!e&&i.jsxs("div",{className:Ea,children:[i.jsx("span",{className:Ia,children:s.label}),i.jsx("span",{className:La,children:s.description})]})]},s.to))}),i.jsx("div",{className:Pa,children:i.jsxs(d,{variant:"ghost",className:ee(Da,e&&Fa),onClick:()=>r("/core/flows"),children:[i.jsx(se,{className:"h-4 w-4"}),!e&&i.jsx("span",{children:"Back to App"})]})})]}),i.jsx("main",{className:Ta,children:i.jsx(t,{})})]})},Ua="_container_dte39_5",Ra="_header_dte39_16",$a="_title_dte39_23",Va="_subtitle_dte39_30",Ga="_tabsList_dte39_39",za="_tabTrigger_dte39_52",Ba="_tabIcon_dte39_75",Oa="_filters_dte39_81",Ha="_filterGroup_dte39_89",Wa="_filterIcon_dte39_95",Qa="_filterSelect_dte39_101",Ka="_dateInput_dte39_105",Ja="_dateSeparator_dte39_109",Ya="_resultCount_dte39_114",Xa="_errorBanner_dte39_121",Za="_tableContainer_dte39_135",ei="_timeCell_dte39_143",si="_relativeTime_dte39_148",ai="_absoluteTime_dte39_154",ii="_adminCell_dte39_160",ni="_adminIcon_dte39_166",li="_actionBadge_dte39_173",ti="_actionIcon_dte39_179",ri="_target_dte39_185",ci="_details_dte39_191",di="_ipAddress_dte39_201",oi="_emptyCell_dte39_208",hi="_pagination_dte39_215",mi="_paginationInfo_dte39_224",_i="_paginationControls_dte39_229",ui="_skeleton_dte39_235",xi="_skeletonBadge_dte39_243",ji="_spinning_dte39_257",pi={ADMIN_ACCESS_GRANTED:{icon:W,label:"Admin Access",variant:"default"},ADMIN_ACCESS_DENIED:{icon:W,label:"Access Denied",variant:"destructive"},USER_CREATED:{icon:B,label:"User Created",variant:"secondary"},USER_UPDATED:{icon:He,label:"User Updated",variant:"secondary"}
1,USER_DELETED:{icon:oe,label:"User Deleted",variant:"destructive"},USER_VIEW:{icon:Xe,label:"User Viewed",variant:"outline"},RATE_LIMIT_UPDATED:{icon:le,label:"Rate Limit",variant:"secondary"},CREDENTIAL_CREATED:{icon:de,label:"Credential Created",variant:"secondary"},CREDENTIAL_UPDATED:{icon:de,label:"Credential Updated",variant:"secondary"},CREDENTIAL_DELETED:{icon:de,label:"Credential Deleted",variant:"destructive"},SETTINGS_UPDATED:{icon:He,label:"Settings Updated",variant:"secondary"},STATS_VIEW:{icon:ce,label:"Stats Viewed",variant:"outline"}},vi=e=>new Date(e).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),gi=e=>{const s=new Date(e),a=(new Date).getTime()-s.getTime(),i=Math.floor(a/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const n=Math.floor(i/60);if(n<24)return`${n}h ago`;const l=Math.floor(n/24);return l<7?`${l}d ago`:vi(e)},Ni=({action:e})=>{const s=pi[e]||{icon:le,label:e.replace(/_/g," "),variant:"outline"},a=s.icon;return i.jsxs(O,{variant:s.variant,className:li,children:[i.jsx(a,{className:ti}),s.label]})},fi=()=>{const{auditLogs:e,auditLogsPagination:s,isLoadingAuditLogs:n,userActivityLogs:l,userActivityPagination:t,isLoadingUserActivity:r,error:c,fetchAuditLogs:h,fetchUserActivityLogs:g,clearError:N}=Be(),[f,b]=a.useState(""),[y,w]=a.useState(""),[C,S]=a.useState(""),[k,A]=a.useState("admin");a.useEffect(()=>{"admin"===k?h({page:1,limit:50,action:f||void 0,startDate:y||void 0,endDate:C||void 0}):g({page:1,limit:50,startDate:y||void 0,endDate:C||void 0})},[k,h,g,f,y,C]);const L=a.useCallback(e=>{"admin"===k?h({page:e,limit:s.limit,action:f||void 0,startDate:y||void 0,endDate:C||void 0}):g({page:e,limit:t.limit,startDate:y||void 0,endDate:C||void 0})},[k,h,g,s.limit,t.limit,f,y,C]),P="admin"===k?s:t,D="admin"===k?n:r,F=a.useCallback(()=>{b(""),w(""),S("")},[]),T=Object.keys(pi);return i.jsxs("div",{className:Ua,children:[i.jsxs("div",{className:Ra,children:[i.jsxs("div",{children:[i.jsx("h1",{className:$a,children:"Audit Logs"}),i.jsx("p",{className:Va,children:"Track admin actions and platform user activity"})]}),i.jsxs(d,{variant:"outline",onClick:()=>"admin"===k?h({page:1,limit:50,action:f||void 0,startDate:y||void 0,endDate:C||void 0}):g({page:1,limit:50,startDate:y||void 0,endDate:C||void 0}),disabled:D,children:[i.jsx(o,{className:`h-4 w-4 mr-2 ${D?ji:""}`}),"Refresh"]})]}),i.jsxs(ae,{value:k,onValueChange:e=>A(e),children:[i.jsxs(ie,{className:Ga,children:[i.jsxs(ne,{value:"admin",className:za,children:[i.jsx(W,{className:Ba}),"Admin Actions"]}),i.jsxs(ne,{value:"activity",className:za,children:[i.jsx(le,{className:Ba}),"User Activity"]})]}),i.jsxs("div",{className:Oa,children:[i.jsxs("div",{className:Ha,children:[i.jsx(te,{className:Wa}),i.jsx(m,{type:"date",value:y,onChange:e=>w(e.target.value),className:Ka,"aria-label":"Start date"}),i.jsx("span",{className:Ja,children:"to"}),i.jsx(m,{type:"date",value:C,onChange:e=>S(e.target.value),className:Ka,"aria-label":"End date"})]}),"admin"===k&&i.jsxs("div",{className:Ha,children:[i.jsx(re,{className:Wa}),i.jsxs(U,{value:f||"all",onValueChange:e=>b("all"===e?"":e),children:[i.jsx(R,{className:Qa,children:i.jsx($,{placeholder:"All Actions"})}),i.jsxs(V,{children:[i.jsx(G,{value:"all",children:"All Actions"}),T.map(e=>i.jsx(G,{value:e,children:pi[e]?.label||e},e))]})]})]}),(f||y||C)&&i.jsx(d,{variant:"ghost",size:"sm",onClick:F,children:"Clear Filters"}),i.jsxs("div",{className:Ya,children:[P?.total??0," log",1!==(P?.total??0)?"s":""]})]}),c&&i.jsxs("div",{className:Xa,children:[i.jsx("span",{children:c}),i.jsx(d,{variant:"ghost",size:"sm",onClick:N,children:"Dismiss"})]}),i.jsx(he,{value:"admin",children:i.jsx("div",{className:Za,children:i.jsxs(_,{children:[i.jsx(u,{children:i.jsxs(x,{children:[i.jsx(j,{children:"Time"}),i.jsx(j,{children:"Admin"}),i.jsx(j,{children:"Action"}),i.jsx(j,{children:"Target"}),i.jsx(j,{children:"Details"}),i.jsx(j,{children:"IP Address"})]})}),i.jsx(p,{children:n?Array.from({length:5}).map((e,s)=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsx("div",{className:ui})}),i.jsx(v,{children:i.jsx("div",{className:ui})}),i.jsx(v,{children:i.jsx("div",{className:xi})}),i.jsx(v,{children:i.jsx("div",{className:ui})}),i.jsx(v,{children:i.jsx("div",{className:ui})}),i.jsx(v,{children:i.jsx("div",{className:ui})})]},s)):e&&0!==e.length?e.map(e=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsxs("div",{className:ei,children:[i.jsx("span",{className:si,children:gi(e.created_at)}),i.jsx("span",{className:ai,children:vi(e.created_at)})]})}),i.jsx(v,{children:i.jsxs("div",{className:ii,children:[i.jsx(Xe,{className:ni}),i.jsx("span",{children:e.admin_email})]})}),i.jsx(v,{children:i.jsx(Ni,{action:e.action})}),i.jsx(v,{children:e.target_type&&e.target_id?i.jsxs("span",{className:ri,children:[e.target_type,": ",e.target_id.substring(0,8),"..."]}):"-"}),i.jsx(v,{children:e.details?i.jsxs("code",{className:ci,children:[JSON.stringify(e.details).substring(0,50),JSON.stringify(e.details).length>50?"...":""]}):"-"}),i.jsx(v,{children:i.jsx("span",{className:di,children:e.ip_address||"-"})})]},e.id)):i.jsx(x,{children:i.jsx(v,{colSpan:6,className:oi,children:"No audit logs found"})})})]})})}),i.jsx(he,{value:"activity",children:i.jsx("div",{className:Za,children:i.jsxs(_,{children:[i.jsx(u,{children:i.jsxs(x,{children:[i.jsx(j,{children:"Time"}),i.jsx(j,{children:"User"}),i.jsx(j,{children:"Activity"}),i.jsx(j,{children:"IP Address"})]})}),i.jsx(p,{children:r?Array.from({length:5}).map((e,s)=>i.jsx(x,{children:Array.from({length:4}).map((e,s)=>i.jsx(v,{children:i.jsx("div",{className:ui})},s))}
1,s)):l&&0!==l.length?l.map(e=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsxs("div",{className:ei,children:[i.jsx("span",{className:si,children:gi(e.created_at)}),i.jsx("span",{className:ai,children:vi(e.created_at)})]})}),i.jsx(v,{children:i.jsxs("div",{className:ii,children:[i.jsx(Xe,{className:ni}),i.jsx("span",{children:e.user_email||"system"})]})}),i.jsx(v,{children:e.metadata?.description||e.action.replace(/^activity\./,"").replace(/_/g," ")}),i.jsx(v,{children:i.jsx("span",{className:di,children:e.ip_address||"-"})})]},e.id)):i.jsx(x,{children:i.jsx(v,{colSpan:4,className:oi,children:"No user activity found"})})})]})})})]}),(P?.totalPages??0)>1&&i.jsxs("div",{className:hi,children:[i.jsxs("div",{className:mi,children:["Page ",P?.page??1," of ",P?.totalPages??1]}),i.jsxs("div",{className:_i,children:[i.jsxs(d,{variant:"outline",size:"sm",onClick:()=>L((P?.page??1)-1),disabled:(P?.page??1)<=1||D,children:[i.jsx(E,{className:"h-4 w-4 mr-1"}),"Previous"]}),i.jsxs(d,{variant:"outline",size:"sm",onClick:()=>L((P?.page??1)+1),disabled:(P?.page??1)>=(P?.totalPages??1)||D,children:["Next",i.jsx(I,{className:"h-4 w-4 ml-1"})]})]})]})]})},bi="_container_275ch_5",yi="_header_275ch_12",wi="_title_275ch_19",Ci="_subtitle_275ch_26",Si="_headerActions_275ch_32",ki="_statsRow_275ch_38",Ai="_statCard_275ch_44",Ei="_statContent_275ch_48",Ii="_statIcon_275ch_55",Li="_statValue_275ch_61",Pi="_statLabel_275ch_69",Di="_errorBanner_275ch_76",Fi="_errorContent_275ch_89",Ti="_tableContainer_275ch_96",Mi="_credentialName_275ch_103",qi="_credentialIcon_275ch_109",Ui="_name_275ch_117",Ri="_description_275ch_123",$i="_envVar_275ch_130",Vi="_emptyCell_275ch_138",Gi="_skeleton_275ch_145",zi="_spinning_275ch_159",Bi="_dialog_275ch_169",Oi="_formGrid_275ch_173",Hi="_formField_275ch_180",Wi="_formFieldFull_275ch_186 _formField_275ch_180",Qi="_valueInputWrapper_275ch_191",Ki="_toggleValueBtn_275ch_201",Ji="_dialogFooter_275ch_205",Yi=[{value:"api_key",label:"API Key"},{value:"oauth",label:"OAuth Token"},{value:"database",label:"Database Connection"},{value:"service_account",label:"Service Account"},{value:"webhook",label:"Webhook Secret"},{value:"other",label:"Other"}],Xi=[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"google",label:"Google Cloud"},{value:"aws",label:"AWS"},{value:"azure",label:"Azure"},{value:"stripe",label:"Stripe"},{value:"twilio",label:"Twilio"},{value:"sendgrid",label:"SendGrid"},{value:"github",label:"GitHub"},{value:"custom",label:"Custom"}];function Zi(e){if(!e)return"Never";return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}const en=()=>{const{isLoadingAdminCredentials:e,adminError:s,fetchAdminCredentials:n,createAdminCredential:l,updateAdminCredential:t,deleteAdminCredential:r,clearError:c}=We(),g=Qe(),[N,E]=a.useState(!1),[I,B]=a.useState(null),[H,Q]=a.useState({name:"",credential_type:"",provider:"",env_var_name:"",description:"",value:""}),[K,J]=a.useState(!1);a.useEffect(()=>{n()},[n]),a.useEffect(()=>{N||(B(null),Q({name:"",credential_type:"",provider:"",env_var_name:"",description:"",value:""}),J(!1))},[N]),a.useEffect(()=>{I&&Q({name:I.name,credential_type:I.credentialType,provider:I.provider||"",env_var_name:I.envVarName||"",description:I.description||"",value:""})},[I]);const X=a.useCallback(async e=>{e.preventDefault();try{if(I){const e={name:H.name,credential_type:H.credential_type,provider:H.provider||null,env_var_name:H.env_var_name||null,description:H.description||null,...H.value&&{value:H.value}};await t(I.id,e)}else{const e={name:H.name,credential_type:H.credential_type,provider:H.provider||null,env_var_name:H.env_var_name||null,description:H.description||null,value:H.value};await l(e)}E(!1)}catch(s){}},[H,I,l,t]),Z=a.useCallback(async e=>{try{await r(e)}catch(s){}},[r]),ee=a.useCallback(e=>{B(e),E(!0)},[]),se=e=>{if(!e)return"-";const s=Xi.find(s=>s.value===e);return s?.label||e},ae=e=>{const s=Yi.find(s=>s.value===e);return s?.label||e};return i.jsxs("div",{className:bi,children:[i.jsxs("div",{className:yi,children:[i.jsxs("div",{children:[i.jsx("h1",{className:wi,children:"Credential Vault"}),i.jsx("p",{className:Ci,children:"Manage API keys, secrets, and service credentials"})]}),i.jsxs("div",{className:Si,children:[i.jsxs(d,{variant:"outline",onClick:()=>n(),disabled:e,children:[i.jsx(o,{className:`h-4 w-4 mr-2 ${e?zi:""}`}),"Refresh"]}),i.jsxs(d,{onClick:()=>E(!0),children:[i.jsx(h,{className:"h-4 w-4 mr-2"}),"Add Credential"]})]})]}),i.jsxs("div",{className:ki,children:[i.jsx(es,{className:Ai,children:i.jsxs(ss,{className:Ei,children:[i.jsx(Y,{className:Ii}),i.jsxs("div",{children:[i.jsx("span",{className:Li,children:g.length}),i.jsx("span",{className:Pi,children:"Total Credentials"})]})]})}),i.jsx(es,{className:Ai,children:i.jsxs(ss,{className:Ei,children:[i.jsx(W,{className:Ii}),i.jsxs("div",{children:[i.jsx("span",{className:Li,children:g.filter(e=>e.isActive).length}),i.jsx("span",{className:Pi,children:"Active"})]})]})})]}),s&&i.jsxs("div",{className:Di,children:[i.jsxs("div",{className:Fi,children:[i.jsx(me,{className:"w-4 h-4 flex-shrink-0"}),i.jsx("span",{children:s})]}),i.jsx(d,{variant:"ghost",size:"sm",onClick:c,children:i.jsx(ls,{className:"w-4 h-4"})})]}),i.jsx("div",{className:Ti,children:i.jsxs(_,{children:[i.jsx(u,{children:i.jsxs(x,{children:[i.jsx(j,{children:"Name"}),i.jsx(j,{children:"Type"}),i.jsx(j,{children:"Provider"}),i.jsx(j,{children:"Env Variable"}),i.jsx(j,{children:"Status"}),i.jsx(j,{children:"Last Rotated"}),i.jsx(j,{className:"w-12"})]})}),i.jsx(p,{children:e?Array.from({length:3}).map((e,s)=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsx("div",{className:Gi})}),i.jsx(v,{children:i.jsx("div",{className:Gi})}),i.jsx(v,{children:i.jsx("div",{className:Gi})}),i.jsx(v,{children:i.jsx("div",{className:Gi})}),i.jsx(v,{children:i.jsx("div",{className:Gi})}),i.jsx(v,{children:i.jsx("div",{className:Gi})}),i.jsx(v,{})]}
1,s)):0===g.length?i.jsx(x,{children:i.jsx(v,{colSpan:7,className:Vi,children:'No credentials found. Click "Add Credential" to create one.'})}):g.map(e=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsxs("div",{className:Mi,children:[i.jsx(Y,{className:qi}),i.jsxs("div",{children:[i.jsx("span",{className:Ui,children:e.name}),e.description&&i.jsx("span",{className:Ri,children:e.description})]})]})}),i.jsx(v,{children:ae(e.credentialType)}),i.jsx(v,{children:se(e.provider)}),i.jsx(v,{children:e.envVarName?i.jsx("code",{className:$i,children:e.envVarName}):"-"}),i.jsx(v,{children:e.isActive?i.jsxs(O,{variant:"success",children:[i.jsx(_e,{className:"w-3 h-3 mr-1"}),"Active"]}):i.jsxs(O,{variant:"secondary",children:[i.jsx(ls,{className:"w-3 h-3 mr-1"}),"Inactive"]})}),i.jsx(v,{children:Zi(e.lastRotatedAt)}),i.jsx(v,{children:i.jsxs(f,{children:[i.jsx(b,{asChild:!0,children:i.jsx(d,{variant:"ghost",size:"icon",children:i.jsx(y,{className:"h-4 w-4"})})}),i.jsxs(w,{align:"end",children:[i.jsxs(C,{onClick:()=>ee(e),children:[i.jsx(S,{className:"h-4 w-4 mr-2"}),"Edit"]}),i.jsx(k,{}),i.jsxs(ue,{children:[i.jsx(xe,{asChild:!0,children:i.jsxs(C,{onSelect:e=>e.preventDefault(),variant:"destructive",children:[i.jsx(A,{className:"h-4 w-4 mr-2"}),"Delete"]})}),i.jsxs(je,{children:[i.jsxs(pe,{children:[i.jsx(ve,{children:"Delete Credential"}),i.jsxs(ge,{children:["Are you sure you want to delete “",e.name,"”? This action cannot be undone."]})]}),i.jsxs(Ne,{children:[i.jsx(fe,{children:"Cancel"}),i.jsx(be,{onClick:()=>Z(e.id),variant:"destructive",children:"Delete"})]})]})]})]})]})})]},e.id))})]})}),i.jsx(L,{open:N,onOpenChange:E,children:i.jsxs(P,{className:Bi,children:[i.jsxs(D,{children:[i.jsx(F,{children:I?"Edit Credential":"Add New Credential"}),i.jsx(T,{children:I?"Update the credential details below.":"Create a new managed credential. The actual secret value is stored securely."})]}),i.jsxs("form",{onSubmit:X,children:[i.jsxs("div",{className:Oi,children:[i.jsxs("div",{className:Hi,children:[i.jsx(M,{htmlFor:"name",children:"Name *"}),i.jsx(m,{id:"name",value:H.name,onChange:e=>Q({...H,name:e.target.value}),placeholder:"e.g., Production OpenAI Key",required:!0})]}),i.jsxs("div",{className:Hi,children:[i.jsx(M,{htmlFor:"credential_type",children:"Type *"}),i.jsxs(U,{value:H.credential_type,onValueChange:e=>Q({...H,credential_type:e}),children:[i.jsx(R,{children:i.jsx($,{placeholder:"Select type"})}),i.jsx(V,{children:Yi.map(e=>i.jsx(G,{value:e.value,children:e.label},e.value))})]})]}),i.jsxs("div",{className:Hi,children:[i.jsx(M,{htmlFor:"provider",children:"Provider"}),i.jsxs(U,{value:H.provider,onValueChange:e=>Q({...H,provider:e}),children:[i.jsx(R,{children:i.jsx($,{placeholder:"Select provider"})}),i.jsx(V,{children:Xi.map(e=>i.jsx(G,{value:e.value,children:e.label},e.value))})]})]}),i.jsxs("div",{className:Hi,children:[i.jsx(M,{htmlFor:"env_var_name",children:"Environment Variable"}),i.jsx(m,{id:"env_var_name",value:H.env_var_name,onChange:e=>Q({...H,env_var_name:e.target.value.toUpperCase()}),placeholder:"e.g., OPENAI_API_KEY"})]}),i.jsxs("div",{className:Wi,children:[i.jsxs(M,{htmlFor:"value",children:["Secret Value ",I?"(leave empty to keep current)":"*"]}),i.jsxs("div",{className:Qi,children:[i.jsx(m,{id:"value",type:K?"text":"password",value:H.value,onChange:e=>Q({...H,value:e.target.value}),placeholder:I?"Enter new value to update":"e.g., sk-...",required:!I}),i.jsx(d,{type:"button",variant:"ghost",size:"icon",className:Ki,onClick:()=>J(!K),children:K?i.jsx(rs,{className:"h-4 w-4"}):i.jsx(cs,{className:"h-4 w-4"})})]})]}),i.jsxs("div",{className:Wi,children:[i.jsx(M,{htmlFor:"description",children:"Description"}),i.jsx(q,{id:"description",value:H.description,onChange:e=>Q({...H,description:e.target.value}),placeholder:"Optional description for this credential",rows:2})]})]}),i.jsxs(z,{className:Ji,children:[i.jsx(d,{type:"button",variant:"outline",onClick:()=>E(!1),children:"Cancel"}),i.jsx(d,{type:"submit",disabled:e||!H.name||!H.credential_type||!I&&!H.value,children:e?"Saving...":I?"Update":"Create"})]})]})]})})]})},sn="_container_1ub5j_8",an="_header_1ub5j_17",nn="_title_1ub5j_25",ln="_subtitle_1ub5j_32",tn="_statsGrid_1ub5j_39",rn="_statCard_1ub5j_47",cn="_statLink_1ub5j_52",dn="_statHeader_1ub5j_62",on="_statHeaderContent_1ub5j_66",hn="_statTitle_1ub5j_72",mn="_statIcon_1ub5j_78",_n="_statDescription_1ub5j_84",un="_statContent_1ub5j_88",xn="_statValue_1ub5j_92",jn="_statTrend_1ub5j_99",pn="_trendIconPositive_1ub5j_107",vn="_trendIconNegative_1ub5j_113",gn="_trendPositive_1ub5j_119",Nn="_trendNegative_1ub5j_124",fn="_trendLabel_1ub5j_129",bn="_skeletonTitle_1ub5j_134",yn="_skeletonIcon_1ub5j_142",wn="_skeletonValue_1ub5j_150",Cn="_skeletonTrend_1ub5j_158",Sn="_systemSection_1ub5j_177",kn="_sectionTitle_1ub5j_181",An="_systemGrid_1ub5j_188",En="_systemItem_1ub5j_194",In="_systemIcon_1ub5j_203",Ln="_systemLabel_1ub5j_209",Pn="_systemValue_1ub5j_215",Dn="_actionsSection_1ub5j_223",Fn="_actionsGrid_1ub5j_227",Tn="_actionCard_1ub5j_233",Mn="_actionIcon_1ub5j_250",qn="_actionLabel_1ub5j_256",Un="_errorContainer_1ub5j_262",Rn="_errorIcon_1ub5j_271",$n="_errorTitle_1ub5j_278",Vn="_errorMessage_1ub5j_285",Gn="_noData_1ub5j_292",zn="_spinning_1ub5j_300",Bn=({title:e,value:s,description:a,icon:n,trend:l,href:t})=>{const c=i.jsxs(es,{className:rn,children:[i.jsxs(as,{className:dn,children:[i.jsxs("div",{className:on,children:[i.jsx(is,{className:hn,children:e}),i.jsx(n,{className:mn})]}),i.jsx(ns,{className:_n,children:a})]}),i.jsxs(ss,{className:un,children:[i.jsx("div",{className:xn,children:s}),l&&i.jsxs("div",{className:jn,children:[void 0!==l.isPositive&&(l.isPositive?i.jsx(Se,{className:pn}):i.jsx(ke,{className:vn})),i.jsxs("span",{className:l.isPositive?gn:Nn,children:[l.value>0?"+":"",l.value]}),i.jsx("span",{className:fn,children:l.label})]})]})]});return t?i.jsx(r,{to:t,className:cn,children:c}):c},On=()=>i.jsxs(es,{className:rn,children:[i.jsxs(as,{className:dn,children:[i.jsx("div",{className:bn}),i.jsx("div",{className:yn})]}),i.jsxs(ss,{className:un,children:[i.jsx("div",{className:wn}),i.jsx("div",{className:Cn})]})]}),Hn=()=>{const{stats:e,isLoadingStats:s,error:n,fetchStats:l,clearError:t}=Be();a.useEffect(()=>{l()},[l]);const c=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString();return n?i.jsx("div",{className:sn,children:i.jsxs("div",{className:Un,children:[i.jsx(ls,{className:Rn}),i.jsx("h2",{className:$n,children:"Failed to load dashboard"}),i.jsx("p",{className:Vn,children:n}),i.jsxs(d,{onClick:()=>{t(),l()},children:[i.jsx(o,{className:"h-4 w-4 mr-2"}),"Retry"]})]})}):i.jsxs("div",{className:sn,children:[i.jsxs("div",{className:an,children:[i.jsxs("div",{children:[i.jsx("h1",{className:nn,children:"Admin Dashboard"}),i.jsx("p",{className:ln,children:"Platform overview and system statistics"})]}),i.jsxs(d,{variant:"outline",onClick:()=>l(),disabled:s,children:[i.jsx(o,{className:`h-4 w-4 mr-2 ${s?zn:""}`}),"Refresh"]})]}),i.jsx("div",{className:tn,children:s?i.jsxs(i.Fragment,{children:[i.jsx(On,{}),i.jsx(On,{}),i.jsx(On,{}),i.jsx(On,{}),i.jsx(On,{}),i.jsx(On,{})]}):e?.users&&e?.workflows&&e?.executions&&e?.credentials?i.jsxs(i.Fragment,{children:[i.jsx(Bn,{title:"Total Users",value:c(e.users.total??0),description:"Registered accounts",icon:N,trend:{value:e.users.new_last_7_days??0,label:"this week",isPositive:(e.users.new_last_7_days??0)>0},href:"/admin/users"}),i.jsx(Bn,{title:"Active Users",value:c(e.users.active??0),description:"Users active in last 30 days",icon:le}),i.jsx(Bn,{title:"Workflows",value:c(e.workflows.total??0),description:`${e.workflows.active??0} active`,icon:ye}),i.jsx(Bn,{title:"Executions",value:c(e.executions.total??0),description:"Total workflow runs",icon:we,trend:{value:e.executions.last_24_hours??0,label:"last 24h",isPositive:!0}}),i.jsx(Bn,{title:"Success Rate",value:(e=>{if(!e||0===e.executions.total)return"0%";return`${(e.executions.successful/e.executions.total*100).toFixed(1)}%`})(e),description:`${e.executions.successful??0} successful`,icon:_e}),i.jsx(Bn,{title:"Credentials",value:c(e.credentials.total??0),description:`${e.credentials.active??0} active`,icon:Y,href:"/admin/credentials"})]}):i.jsx("div",{className:Gn,children:i.jsx("p",{children:"No statistics available"})})}),e?.system&&i.jsxs("div",{className:Sn,children:[i.jsx("h2",{className:kn,children:"System Status"}),i.jsxs("div",{className:An,children:[i.jsxs("div",{className:En,children:[i.jsx(Ce,{className:In}),i.jsxs("div",{children:[i.jsx("span",{className:Ln,children:"Uptime"}),i.jsx("span",{className:Pn,children:(e=>{const s=Math.floor(e/86400),a=Math.floor(e%86400/3600);return s>0?`${s}d ${a}h`:`${a}h`})(e.system.uptime??0)})]})]}),i.jsxs("div",{className:En,children:[i.jsx(le,{className:In}),i.jsxs("div",{children:[i.jsx("span",{className:Ln,children:"Environment"}),i.jsx("span",{className:Pn,children:e.system.environment??"unknown"})]})]}),i.jsxs("div",{className:En,children:[i.jsx(_e,{className:In}),i.jsxs("div",{children:[i.jsx("span",{className:Ln,children:"Version"}),i.jsx("span",{className:Pn,children:e.system.version??"0.0.0"})]})]})]})]}),i.jsxs("div",{className:Dn,children:[i.jsx("h2",{className:kn,children:"Qu
1ick Actions"}),i.jsxs("div",{className:Fn,children:[i.jsxs(r,{to:"/admin/users",className:Tn,children:[i.jsx(N,{className:Mn}),i.jsx("span",{className:qn,children:"Manage Users"})]}),i.jsxs(r,{to:"/admin/credentials",className:Tn,children:[i.jsx(Y,{className:Mn}),i.jsx("span",{className:qn,children:"Credential Vault"})]}),i.jsxs(r,{to:"/admin/audit-logs",className:Tn,children:[i.jsx(le,{className:Mn}),i.jsx("span",{className:qn,children:"View Audit Logs"})]})]})]})]})},Wn="_container_1ad6k_6",Qn="_header_1ad6k_14",Kn="_headerTitle_1ad6k_21",Jn="_title_1ad6k_27",Yn="_subtitle_1ad6k_34",Xn="_settingsCard_1ad6k_40",Zn="_formGrid_1ad6k_44",el="_formGroup_1ad6k_50",sl="_formActions_1ad6k_56",al="_searchContainer_1ad6k_64",il="_searchInput_1ad6k_69",nl="_tableContainer_1ad6k_73",ll="_emptyState_1ad6k_77",tl="_errorContainer_1ad6k_83",rl="_errorIcon_1ad6k_92",cl="_errorTitle_1ad6k_99",dl="_errorMessage_1ad6k_105",ol="_spinning_1ad6k_111",hl=[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"google",label:"Google"}],ml=/(opus|fable|gpt-5-pro|gpt-5\.1|gemini-3-pro)/,_l=1e5;function ul(e){return ml.test(e)}function xl(e){return`$${e.toFixed(2)}`}const jl=()=>{const[e,s]=a.useState(null),[n,l]=a.useState([]),[t,r]=a.useState("anthropic"),[c,h]=a.useState(""),[g,N]=a.useState(""),[f,b]=a.useState("20"),[y,w]=a.useState(""),[C,S]=a.useState(!0),[k,A]=a.useState(!1),[E,I]=a.useState(null),L=a.useCallback(async()=>{S(!0),I(null);try{const[e,a]=await Promise.all([Ke.get("/admin/forge/settings"),Ke.get("/admin/forge/usage")]);s(e),r(e.provider),h(e.model),N(e.model),b(String(e.monthlyRequestCap)),l(Array.isArray(a)?a:[])}catch(e){I(e instanceof Error?e.message:"Failed to load data")}finally{S(!1)}},[]);a.useEffect(()=>{L()},[L]);const P=e?.modelsByProvider[t]??[],D=n.filter(e=>e.email.toLowerCase().includes(y.trim().toLowerCase()));return E&&!e?i.jsx("div",{className:Wn,children:i.jsxs("div",{className:tl,children:[i.jsx(ls,{className:rl}),i.jsx("h2",{className:cl,children:"Failed to load Forge dashboard"}),i.jsx("p",{className:dl,children:E}),i.jsxs(d,{onClick:L,children:[i.jsx(o,{className:"h-4 w-4 mr-2"}),"Retry"]})]})}):i.jsxs("div",{className:Wn,children:[i.jsxs("div",{className:Qn,children:[i.jsxs("div",{children:[i.jsxs("div",{className:Kn,children:[i.jsx("h1",{className:Jn,children:"Forge"}),e?.circuitOpen&&i.jsx(O,{variant:"destructive",children:"Paused"})]}),i.jsx("p",{className:Yn,children:"Flow Forge usage"})]}),i.jsxs(d,{variant:"outline",onClick:L,disabled:C,children:[i.jsx(o,{className:ee("h-4 w-4 mr-2",C&&ol)}),"Refresh"]})]}),E&&e&&i.jsx("p",{className:dl,children:E}),i.jsxs(es,{className:Xn,children:[i.jsx(as,{children:i.jsx(is,{children:"Model settings"})}),i.jsx(ss,{children:e?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:Zn,children:[i.jsxs("div",{className:el,children:[i.jsx(M,{htmlFor:"forge-provider",children:"Provider"}),i.jsxs(U,{value:t,onValueChange:s=>(s=>{r(s);const a=e?.modelsByProvider[s]??[];a.includes(c)||h(a[0]??"")})(s),children:[i.jsx(R,{id:"forge-provider","aria-label":"Provider",children:i.jsx($,{placeholder:"Select provider"})}),i.jsx(V,{children:hl.map(s=>i.jsx(G,{value:s.value,disabled:!1===e.configuredProviders[s.value],children:s.label},s.value))})]})]}),i.jsxs("div",{className:el,children:[i.jsx(M,{htmlFor:"forge-model",children:"Model"}),i.jsxs(U,{value:c,onValueChange:h,disabled:0===P.length,children:[i.jsx(R,{id:"forge-model","aria-label":"Model",children:i.jsx($,{placeholder:"Select model"})}),i.jsx(V,{children:P.map(e=>i.jsx(G,{value:e,children:e},e))})]})]}),i.jsxs("div",{className:el,children:[i.jsx(M,{htmlFor:"forge-monthly-cap",children:"Monthly request cap"}),i.jsx(m,{id:"forge-monthly-cap",type:"number",min:0,max:_l,step:1,value:f,onChange:e=>b(e.target.value)})]})]}),i.jsxs("div",{className:sl,children:[i.jsx(d,{onClick:async()=>{const e=Number.parseInt(f,10);if(!(!Number.isInteger(e)||e<0||e>_l)&&c&&(!ul(c)||ul(g)||window.confirm("This model is significantly more expensive. Save anyway?"))){A(!0),I(null);try{await Ke.put("/admin/forge/settings",{provider:t,model:c,monthlyRequestCap:e}),N(c),await L()}catch(s){I(s instanceof Error?s.message:"Failed to save settings")}finally{A(!1)}}},disabled:k||!c,children:"Save"}),e.circuitOpen&&i.jsx(d,{variant:"outline",onClick:async()=>
1{if(window.confirm("Reset the Forge provider circuit and resume included usage?")){A(!0),I(null);try{await Ke.post("/admin/forge/circuit/reset"),await L()}catch(e){I(e instanceof Error?e.message:"Failed to reset circuit")}finally{A(!1)}}},disabled:k,children:"Reset circuit"})]})]}):i.jsx("p",{className:ll,children:"Loading settings…"})})]}),i.jsxs(es,{children:[i.jsx(as,{children:i.jsx(is,{children:"Usage this month"})}),i.jsxs(ss,{children:[i.jsx("div",{className:al,children:i.jsx(m,{placeholder:"Filter by email...",value:y,onChange:e=>w(e.target.value),className:il})}),C?i.jsx("div",{className:ll,children:i.jsx("p",{children:"Loading usage…"})}):0===D.length?i.jsx("div",{className:ll,children:i.jsx("p",{children:"No Forge usage this month"})}):i.jsx("div",{className:nl,children:i.jsxs(_,{children:[i.jsx(u,{children:i.jsxs(x,{children:[i.jsx(j,{children:"User email"}),i.jsx(j,{children:"Account name"}),i.jsx(j,{children:"Platform turns"}),i.jsx(j,{children:"BYOK turns"}),i.jsx(j,{children:"Remaining free"}),i.jsx(j,{children:"Tokens today"}),i.jsx(j,{children:"Est. $ today"}),i.jsx(j,{children:"Est. $ this month"}),i.jsx(j,{children:"Last model"})]})}),i.jsx(p,{children:D.map(e=>i.jsxs(x,{children:[i.jsx(v,{children:e.email}),i.jsx(v,{children:e.accountName??"—"}),i.jsx(v,{children:e.platformTurns}),i.jsx(v,{children:e.byokTurns}),i.jsx(v,{children:e.remaining}),i.jsx(v,{children:e.tokensToday.toLocaleString()}),i.jsx(v,{children:xl(e.costTodayUsd)}),i.jsx(v,{children:xl(e.costMonthUsd)}),i.jsx(v,{children:e.lastModel})]},e.userId))})]})})]})]})]})};function pl(...e){const s=e[0];if(1===e.length)return s;const i=()=>{const i=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const n=i.reduce((s,{useScope:a,scopeName:i})=>({...s,...a(e)[`__scope${i}`]}),{});return a.useMemo(()=>({[`__scope${s.scopeName}`]:n}),[n])}};return i.scopeName=s.scopeName,i}var vl=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,s)=>{const n=ds(`Primitive.${s}`),l=a.forwardRef((e,a)=>{const{asChild:l,...t}=e,r=l?n:s;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),i.jsx(r,{...t,ref:a})});return l.displayName=`Primitive.${s}`,{...e,[s]:l}},{}),gl="Progress",[Nl]=function(e,s=[]){let n=[];const l=()=>{const s=n.map(e=>a.createContext(e));return function(i){const n=i?.[e]||s;return a.useMemo(()=>({[`__scope${e}`]:{...i,[e]:n}}),[i,n])}};return l.scopeName=e,[function(s,l){const t=a.createContext(l);t.displayName=s+"Context";const r=n.length;n=[...n,l];const c=s=>{const{scope:n,children:l,...c}=s,d=n?.[e]?.[r]||t,o=a.useMemo(()=>c,Object.values(c));return i.jsx(d.Provider,{value:o,children:l})};return c.displayName=s+"Provider",[c,function(i,n){const c=n?.[e]?.[r]||t,d=a.useContext(c);if(d)return d;if(void 0!==l)return l;throw new Error(`\`${i}\` must be used within \`${s}\``)}]},pl(l,...s)]}(gl),[fl,bl]=Nl(gl),yl=a.forwardRef((e,s)=>{const{__scopeProgress:a,value:n=null,max:l,getValueLabel:t=Sl,...r}=e;(l||0===l)&&El(l);const c=El(l)?l:100;null!==n&&Il(n,c);const d=Il(n,c)?n:null,o=Al(d)?t(d,c):void 0;return i.jsx(fl,{scope:a,value:d,max:c,children:i.jsx(vl.div,{"aria-valuemax":c,"aria-valuemin":0,"aria-valuenow":Al(d)?d:void 0,"aria-valuetext":o,role:"progressbar","data-state":kl(d,c),"data-value":d??void 0,"data-max":c,...r,ref:s})})});yl.displayName=gl;var wl="ProgressIndicator",Cl=a.forwardRef((e,s)=>{const{__scopeProgress:a,...n}=e,l=bl(wl,a);return i.jsx(vl.div,{"data-state":kl(l.value,l.max),"data-value":l.value??void 0,"data-max":l.max,...n,ref:s})});function Sl(e,s){return`${Math.round(e/s*100)}%`}function kl(e,s){return null==e?"indeterminate":e===s?"complete":"loading"}function Al(e){return"number"==typeof e}function El(e){return Al(e)&&!isNaN(e)&&e>0}function Il(e,s){return Al(e)&&!isNaN(e)&&e<=s&&e>=0}Cl.displayName=wl;var Ll=yl,Pl=Cl;const Dl=a.forwardRef(({className:e,value:s,...a},n)=>{const l=Math.min(100,Math.max(0,s??0));return i.jsx(Ll,{ref:n,className:ee("relative h-2 w-full overflow-hidden rounded-full bg-muted",e),value:l,...a,children:i.jsx(Pl,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-l}%)`}})})});Dl.displayName=Ll.displayName;const Fl={accountId:"account_id",workflowId:"workflow_id",scope1Enabled:"scope1_enabled",scope2Enabled:"scope2_enabled",scope3Enabled:"scope3_enabled",maxCostPerDayUsd:"max_cost_per_day_usd",autoApplyConfidenceThreshold:"auto_apply_confidence_threshold",suggestConfidenceThreshold:"suggest_confidence_threshold",notifyOnSuggestion:"notify_on_suggestion",notifyOnAutoApply:"notify_on_auto_apply",notifyOnPrCreated:"notify_on_pr_created",
1notificationChannels:"notification_channels"},Tl=new Set(["id","account_id","workflow_id","enabled","mode","auto_apply_confidence_threshold","suggest_confidence_threshold","scope1_enabled","scope2_enabled","scope3_enabled","auto_reexecute","max_healing_attempts_per_hour","max_cost_per_day_usd","notify_on_suggestion","notify_on_auto_apply","notify_on_pr_created","notification_channels"]);function Ml(e){const s={};for(const[a,i]of Object.entries(e)){const e=Fl[a]??a;Tl.has(e)&&(s[e]=i)}return s}function ql(e){return null!==e&&"object"==typeof e&&"success"in e&&"data"in e?e.data:e}const Ul=new class{constructor(){s(this,"baseEndpoint","/healing")}async getEvents(e={}){return Ke.get(`${this.baseEndpoint}/events`,e)}async getSuggestions(e={}){return Ke.get(`${this.baseEndpoint}/suggestions`,e)}async getSuggestion(e){return ql(await Ke.get(`${this.baseEndpoint}/suggestions/${e}`))}async applySuggestion(e){return ql(await Ke.post(`${this.baseEndpoint}/suggestions/${e}/apply`))}async dismissSuggestion(e,s){await Ke.post(`${this.baseEndpoint}/suggestions/${e}/dismiss`,{reason:s})}async getActions(e={}){return Ke.get(`${this.baseEndpoint}/actions`,e)}async rollbackAction(e,s){await Ke.post(`${this.baseEndpoint}/actions/${e}/rollback`,{reason:s})}async getConfig(e){const s=e?{workflow_id:e}:{};return Ml(ql(await Ke.get(`${this.baseEndpoint}/config`,s)))}async updateConfig(e){return Ml(ql(await Ke.put(`${this.baseEndpoint}/config`,e)))}async getGitHubPRs(e={}){return Ke.get(`${this.baseEndpoint}/github-prs`,e)}async getStats(){return ql(await Ke.get(`${this.baseEndpoint}/stats`))}},Rl=Je()(Ye((e,s)=>{let a=0,i=0,n=0,l=0;return{events:[],suggestions:[],actions:[],githubPrs:[],config:null,stats:null,eventsTotal:0,suggestionsTotal:0,actionsTotal:0,isLoading:!1,error:null,fetchEvents:async s=>{const a=++l;e({isLoading:!0,error:null});try{const i=await Ul.getEvents(s);if(a!==l)return;e({events:i.data,eventsTotal:i.total,isLoading:!1})}catch(i){if(a!==l)return;e({error:i instanceof Error?i.message:"Failed to fetch events",isLoading:!1})}},fetchSuggestions:async s=>{const i=++a;e({isLoading:!0,error:null});try{const n=await Ul.getSuggestions(s);if(i!==a)return;e({suggestions:n.data,suggestionsTotal:n.total,isLoading:!1})}catch(n){if(i!==a)return;e({error:n instanceof Error?n.message:"Failed to fetch suggestions",isLoading:!1})}},fetchActions:async s=>{const a=++i;e({isLoading:!0,error:null});try{const n=await Ul.getActions(s);if(a!==i)return;e({actions:n.data,actionsTotal:n.total,isLoading:!1})}catch(n){if(a!==i)return;e({error:n instanceof Error?n.message:"Failed to fetch actions",isLoading:!1})}},fetchConfig:async s=>{try{const a=await Ul.getConfig(s);e({config:a})}catch(a){e({error:a instanceof Error?a.message:"Failed to fetch config"})}},fetchStats:async()=>{try{const s=await Ul.getStats();e({stats:s})}catch(s){e({error:s instanceof Error?s.message:"Failed to fetch stats"})}},fetchGitHubPRs:async s=>{const a=++n;try{const i=await Ul.getGitHubPRs(s);if(a!==n)return;e({githubPrs:i.data})}catch(i){if(a!==n)return;e({error:i instanceof Error?i.message:"Failed to fetch PRs"})}},applySuggestion:async s=>{const a=await Ul.applySuggestion(s);return e(e=>({suggestions:e.suggestions.map(e=>e.id===s?{...e,status:"applied"}:e),actions:[a,...e.actions],actionsTotal:e.actionsTotal+1})),a},dismissSuggestion:async(s,a)=>{await Ul.dismissSuggestion(s,a),e(e=>({suggestions:e.suggestions.map(e=>e.id===s?{...e,status:"dismissed"}:e)}))},rollbackAction:async(s,a)=>{await Ul.rollbackAction(s,a),e(e=>({actions:e.actions.map(e=>e.id===s?{...e,status:"rolled_back"}:e)}))},updateConfig:async s=>{const a=await Ul.updateConfig(s);e({config:a})},addEvent:s=>{e(e=>e.events.some(e=>e.id===s.id)?{events:e.events.map(e=>e.id===s.id?s:e)}:{events:[s,...e.events],eventsTotal:e.eventsTotal+1})},addSuggestion:s=>{e(e=>e.suggestions.some(e=>e.id===s.id)?{suggestions:e.suggestions.map(e=>e.id===s.id?s:e)}:{suggestions:[s,...e.suggestions],suggestionsTotal:e.suggestionsTotal+1})}}},{name:"HealingStore"})),$l="_container_1df2l_9",Vl="_header_1df2l_16",Gl="_title_1df2l_25",zl="_subtitle_1df2l_32",Bl="_headerActions_1df2l_38",Ol="_toggleGroup_1df2l_45",Hl="_modeSelect_1df2l_51",Wl="_statsBar_1df2l_58",Ql="_statCell_1df2l_68",Kl="_statVal_1df2l_86",Jl="_statLbl_1df2l_94",Yl="_statBar_1df2l_100",Xl="_statBarFill_1df2l_108",Zl="_errorBanner_1df2l_116",et="_tabs_1df2l_129",st="_suggestionCell_1df2l_134",at="_suggestionTitle_1df2l_141",it="_suggestionMeta_1df2l_150",nt="_actionBtnGroup_1df2l_159",lt="_rollbackInline_1df2l_166",tt="_prLink_1df2l_174",rt="_filterRow_1df2l_189",ct="_filterSelect_1df2l_195",dt="_confidenceCell_1df2l_202",ot="_tableScroll_1df2l_210",ht="_emptyState_1df2l_215",mt="_emptyMessage_1df2l_224",_t="_emptyHint_1df2l_231",ut="_spinning_1df2l_238",xt={workflow:"Workflow",account:"Account",platform:"Platform"},jt={pending:"secondary",auto_approved:"default",applied:"outline",dismissed:"destructive",failed:"destructive",rolled_back:"destructive"},pt={merged:"default",open:"secondary",draft:"outline",closed:"destructive"},vt=[{value:"all",label:"All statuses"},{value:"pending",label:"Pending"},{value:"auto_approved",label:"Auto-approved"},{value:"applied",label:"Applied"},{value:"dismissed",label:"Dismissed"},{value:"failed",label:"Failed"}],gt=[{value:"all",label:"All scopes"},{value:"workflow",label:"Workflow"},{value:"account",label:"Account"},{value:"platform",label:"Platform"}],Nt=({value:e})=>{const s=Math.round(100*e);return i.jsx(Ie,{delayDuration:200,children:i.jsxs(Le,{children:[i.jsx(Pe,{asChild:!0,children:i.jsxs("div",{className:dt,children:[i.jsx(Dl,{value:s,className:"h-1.5 w-14"}),i.jsxs("span",{className:"font-mono text-xs",children:[s,"%"]})]})}),i.jsx(De,{side:"left",children:i.jsxs("p",{children:[s,"% confidence"]})})]})})},ft=()=>i.jsx("div",{className:Wl,children:Array.from({length:8}).map((e,s)=>i.jsxs("div",{className:Ql,children:[i.jsx(hs,{className:"h-5 w-10 mb-1"}),i.jsx(hs,{className:"h-3 w-14"})]},s))}),bt=()=>{const{suggestions:e,actions:s,githubPrs:n,stats:l,config:t,error:r,fetchSuggestions:c,fetchActions:h,fetchStats:g,fetchGitHubPRs:N,fetchConfig:f,applySuggestion:b,dismissSuggestion:y,rollbackAction:w,updateConfig:C}=Rl(),[S,k]=a.useState("suggestions"),[A,E]=a.useState(""),[I,L]=a.useState(null),[P,D]=a.use
1State("pending"),[F,T]=a.useState("all"),[M,q]=a.useState(new Set),[z,B]=a.useState(!1),[H,W]=a.useState(!0),[Q,K]=a.useState(!1),[J,Y]=a.useState("suggest");a.useEffect(()=>{t?.mode&&"disabled"!==t.mode&&Y(t.mode)},[t?.mode]),a.useEffect(()=>{W(!0),Promise.all([g(),c({status:"pending",limit:20}),h({limit:20}),N({limit:20}),f()]).finally(()=>W(!1))},[g,c,h,N,f]);const X=a.useCallback(()=>{K(!0),Promise.all([g(),c({status:"all"===P?void 0:P,scope:"all"===F?void 0:F,limit:20}),h({limit:20}),N({limit:20})]).finally(()=>K(!1))},[g,c,h,N,P,F]),Z=a.useCallback(e=>{D(e),c({status:"all"===e?void 0:e,scope:"all"===F?void 0:F,limit:20})},[c,F]),ee=a.useCallback(e=>{T(e),c({status:"all"===P?void 0:P,scope:"all"===e?void 0:e,limit:20})},[c,P]),se=a.useCallback(async e=>{q(s=>new Set(s).add(e));try{await b(e),g(),c({status:"all"===P?void 0:P,scope:"all"===F?void 0:F,limit:20})}catch(s){Rl.setState({error:s instanceof Error?s.message:"Failed to apply suggestion"})}finally{q(s=>{const a=new Set(s);return a.delete(e),a})}},[b,g,c,P,F]),le=a.useCallback(async e=>{q(s=>new Set(s).add(e));try{await y(e),g(),c({status:"all"===P?void 0:P,scope:"all"===F?void 0:F,limit:20})}catch(s){Rl.setState({error:s instanceof Error?s.message:"Failed to dismiss suggestion"})}finally{q(s=>{const a=new Set(s);return a.delete(e),a})}},[y,g,c,P,F]),te=a.useCallback(async e=>{if(A.trim()){q(s=>new Set(s).add(e));try{await w(e,A),L(null),E(""),g(),h({limit:20})}catch(s){Rl.setState({error:s instanceof Error?s.message:"Failed to rollback action"})}finally{q(s=>{const a=new Set(s);return a.delete(e),a})}}},[w,A,g,h]),re=a.useCallback(async e=>{B(!0);try{await C({enabled:e,mode:e?J:"disabled"})}catch(s){Rl.setState({error:s instanceof Error?s.message:"Failed to update config"})}finally{B(!1)}},[C,J]),ce=a.useCallback(async e=>{const s=e;B(!0);try{await C({mode:s,enabled:"disabled"!==s})}catch(a){Rl.setState({error:a instanceof Error?a.message:"Failed to update mode"})}finally{B(!1)}},[C]);return i.jsxs("div",{className:$l,children:[i.jsxs("div",{className:Vl,children:[i.jsxs("div",{children:[i.jsx("h1",{className:Gl,children:"Self-Healing"}),i.jsx("p",{className:zl,children:"Autonomous workflow diagnosis and repair"})]}),i.jsxs("div",{className:Bl,children:[t&&i.jsxs("div",{className:Ol,children:[i.jsx(Ae,{checked:t.enabled,onCheckedChange:re,disabled:z,"aria-label":"Toggle healing system"}),i.jsxs(U,{value:t.mode,onValueChange:ce,disabled:z,children:[i.jsx(R,{className:Hl,children:i.jsx($,{})}),i.jsxs(V,{children:[i.jsx(G,{value:"suggest",children:"Suggest"}),i.jsx(G,{value:"auto_apply",children:"Auto-apply"}),i.jsx(G,{value:"disabled",children:"Disabled"})]})]})]}),i.jsxs(d,{variant:"outline",size:"sm",onClick:X,disabled:Q,children:[i.jsx(o,{className:`h-3.5 w-3.5 mr-1.5 ${Q?ut:""}`}),"Refresh"]})]})]}),r&&i.jsxs("div",{className:Zl,children:[i.jsx(os,{className:"h-4 w-4 shrink-0"}),i.jsx("span",{children:r})]}),H&&!l?i.jsx(ft,{}):l?i.jsxs("div",{className:Wl,children:[i.jsxs("div",{className:Ql,children:[i.jsx("span",{className:Kl,children:l.totalEvents}),i.jsx("span",{className:Jl,children:"Events"})]}),i.jsxs("div",{className:Ql,children:[i.jsx("span",{className:Kl,children:l.totalSuggestions}),i.jsx("span",{className:Jl,children:"Suggestions"})]}),i.jsxs("div",{className:Ql,children:[i.jsx("span",{className:Kl,children:l.totalApplied}),i.jsx("span",{className:Jl,children:"Applied"})]}),i.jsxs("div",{className:Ql,children:[i.jsxs("span",{className:Kl,children:[(100*l.successRate).toFixed(0),"%"]}),i.jsx("span",{className:Jl,children:"Success rate"}),i.jsx("div",{className:Yl,children:i.jsx("div",{className:Xl,style:{width:`${Math.min(100,100*l.successRate)}%`}})})]}),i.jsxs("div",{className:Ql,children:[i.jsxs("span",{className:Kl,children:[l.estimatedTimeSavedMinutes,"m"]}),i.jsx("span",{className:Jl,children:"Time saved"})]}),i.jsxs("div",{className:Ql,children:[i.jsxs("span",{className:Kl,children:["$",l.totalCostUsd.toFixed(2)]}),i.jsx("span",{className:Jl,children:"AI cost (30d)"})]}),i.jsxs("div",{className:Ql,children:[i.jsx("span",{className:Kl,children:l.activePRs}),i.jsx("span",{className:Jl,children:"Active PRs"})]}),i.jsxs("div",{className:Ql,children:[i.jsx("span",{className:Kl,children:l.mergedPRs}),i.jsx("span",{className:Jl,children:"Merged PRs"})]})]}):null,i.jsxs(ae,{value:S,onValueChange:k,className:et,children:[i.jsxs(ie,{children:[i.jsxs(ne,{value:"suggestions",children:["Suggestions",e.length>0&&i.jsx(O,{variant:"secondary",className:"ml-1.5 px-1.5 py-0 text-[10px] leading-4",children:e.length})]}),i.jsx(ne,{value:"actions",children:"Actions"}),i.jsx(ne,{value:"prs",children:"GitHub PRs"})]}),i.jsxs(he,{value:"suggestions",className:"mt-4 space-y-3",children:[i.jsxs("div",{className:rt,children:[i.jsxs(U,{value:P,onValueChange:Z,children:[i.jsx(R,{className:ct,children:i.jsx($,{placeholder:"Status"})}),i.jsx(V,{children:vt.map(e=>i.jsx(G,{value:e.value,children:e.label},e.value))})]}),i.jsxs(U,{value:F,onValueChange:ee,children:[i.jsx(R,{className:ct,children:i.jsx($,{placeholder:"Scope"})}),i.jsx(V,{children:gt.map(e=>i.jsx(G,{value:e.value,children:e.label},e.value))})]})]}),0!==e.length||H||Q?i.jsx(es,{children:i.jsxs(Ee,{className:ot,children:[i.jsxs(_,{children:[i.jsx(u,{children:i.jsxs(x,{children:[i.jsx(j,{children:"Status"}),i.jsx(j,{children:"Title"}),i.jsx(j,{children:"Scope"}),i.jsx(j,{className:"text-right",children:"Confidence"}),i.jsx(j,{children:"Date"}),i.jsx(j,{className:"text-right",children:"Actions"})]})}),i.jsx(p,{children:e.map(e=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsx(O,{variant:jt[e.status]??"secondary",className:"text-xs",children:e.status.replace(/_/g," ")})}),i.jsx(v,{children:i.jsx(Ie,{delayDuration:300,children:i.jsxs(Le,{children:[i.jsx(Pe,{asChild:!0,children:i.jsxs("div",{className:st,children:[i.jsx("span",{className:at,children:e.title}),e.root_cause_analysis&&i.jsx("span",{className:it,children:e.root_cause_analysis})]})}),e.root_cause_analysis&&i.jsx(De,{side:"bottom",className:"max-w-xs",children:i.jsx("p",{className:"text-xs",children:e.root_cause_analysis})})]})})}),i.jsx(v,{children:i.jsx(O,{variant:"outline",className:"text-xs",children:xt[e.scope]??e.scope})}),i.jsx(v,{className:"text-right",children:i.jsx(Nt,{value:e.confidence})}),i.jsx(v,{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date(e.created_at).toLocaleDateString()}),i.jsx(v,{className:"text-right",children:("pending"===e.status||"auto_approved"===e.status)&&i.jsxs("div",{className:nt,children:[i.jsxs(d,{size:"sm",variant:"default",onClick:()=>se(e.id),disabled:M.has(e.id),children:[i.jsx(ts,{className:"h-3 w-3 mr-1"}),"Apply"]}),i.jsxs(d,{size:"sm",variant:"ghost",onClick:()=>le(e.id),disabled:M.has(e.id),children:[i.jsx(ls,{className:"h-3 w-3 mr-1"}),"Dismiss"]})]})})]},e.id))})]}),i.jsx(Fe,{orientation:"horizontal"})]})}):i.jsx(yt,{message:"No suggestions match filters",hint:"all"!==P?'Change status to "All statuses" to see everything':void 0})]}),i.jsx(he,{value:"actions",className:"mt-4",children:0!==s.length||H||Q?i.jsx(es,{children:i.jsxs(Ee,{className:ot,children:[i.jsxs(_,{children:[i.jsx(u,{children:i.jsxs(x,{children:[i.jsx(j,{children:"Status"}),i.jsx(j,{children:"Type"}),i.jsx(j,{children:"Scope"}),i.jsx(j,{children:"Applied By"}),i.jsx(j,{children:"Date"}),i.jsx(j,{className:"text-right",children:"Actions"})]})}),i.jsx(p,{children:s.map(e=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsx(O,{variant:"applied"===e.status?"default":"destructive",className:"text-xs",children:e.status.replace(/_/g," ")})}),i.jsx(v,{className:"text-sm",children:e.action_type.replace(/_/g," ")}),i.jsx(v,{children:i.jsx(O,{variant:"outline",className:"text-xs",children:xt[e.scope]??e.scope})}),i.jsx(v,{className:"text-sm",children:e.applied_by}),i.jsx(v,{className:"text-xs text-muted-foreground whitespace-nowrap",children:new Date(e.created_at).toLocaleDateString()}),i.jsx(v,{className:"text-right",children:"applied"===e.status&&i.jsx(i.Fragment,{children:I===e.id?i.jsxs("div",{className:lt,children:[i.jsx(m,{"aria-label":"Rollback reason",placeholder:"Reason...",value:A,onChange:e=>E(e.target.value),className:"h-8 text-xs w-36"}),i.jsx(d,{size:"sm",variant:"destructive",onClick:()=>te(e.id),disabled:!A.trim()||M.has(e.id),children:"Confirm"}),i.jsx(d,{size:"sm",variant:"ghost",onClick:()=>{L(null),E("")},children:"Cancel"})]}):i.jsxs(d,{size:"sm",variant:"ghost",onClick:()=>{L(e.id),E("")},children:[i.jsx(Te,{className:"h-3 w-3 mr-1"}),"Rollback"]})})})]},e.id))})]}),i.jsx(Fe,{orientation:"horizontal"})]})}):i.jsx(yt,{message:"No actions recorded yet"})}),i.jsx(he,{value:"prs",className:"mt-4",children:0!==n.length||H||Q?i.jsx(es,{children:i.jsxs(Ee,{className:ot,children:[i.jsxs(_,{children:[i.jsx(u,{children:i.jsxs(x,{children:[i.jsx(j,{children:"PR"}),i.jsx(j,{children:"Title"}),i.jsx(j,{children:"State"}),i.jsx(j,{className:"text-right",children:"Confidence"}),i.jsx(j,{children:"Impact"}),i.jsx(j,{className:"text-right",children:"Link"})]})}),i.jsx(p,{children:n.map(e=>i.jsxs(x,{children:[i.jsx(v,{className:"font-mono text-xs text-muted-foreground",children:e.pr_number?`#${e.pr_number}`:"—"}),i.jsx(v,{children:i.jsx(Ie,{delayDuration:300,children:i.jsxs(Le,{children:[i.jsx(Pe,{asChild:!0,children:i.jsxs("div",{className:st,children:[i.jsx("span",{className:at,children:e.pr_title}),i.jsx("span",{className:it,children:e.affected_file_path})]})}),i.jsxs(De,{side:"bottom",className:"max-w-xs",children:[i.jsx("p",{className:"text-xs font-medium",children:e.pr_title}),i.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.affected_file_path})]})]})})}),i.jsx(v,{children:i.jsx(O,{variant:pt[e.pr_state]??"secondary",className:"text-xs",children:e.pr_state})}),i.jsx(v,{className:"text-right",children:i.jsx(Nt,{value:e.confidence})}),i.jsxs(v,{className:"text-xs text-muted-foreground whitespace-nowrap",children:[e.affected_workflow_count," workflows, ",e.affected_account_count," accounts"]}),i.jsx(v,{className:"text-right",children:e.pr_url&&i.jsx(Ie,{delayDuration:200,children:i.jsxs(Le,{children:[i.jsx(Pe,{asChild:!0,children:i.jsx("a",{href:e.pr_url,target:"_blank",rel:"noopener noreferrer","aria-label":"Open PR on GitHub",className:tt,children:i.jsx(Me,{className:"h-3.5 w-3.5"})})}),i.jsx(De,{children:i.jsx("p",{children:"Open PR on GitHub"})})]})})})]},e.id))})]}),i.jsx(Fe,{orientation:"horizontal"})]})}):i.jsx(yt,{message:"No GitHub PRs yet"})})]})]})},yt=({message:e,hint:s})=>i.jsxs("div",{className:ht,children:[i.jsx("p",{className:mt,children:e}),s&&i.jsx("p",{className:_t,children:s})]}),wt="_container_n1f44_7",Ct="_header_n1f44_16",St="_title_n1f44_24",kt="_subtitle_n1f44_31",At="_alertsCard_n1f44_38",Et="_alertsTitle_n1f44_44",It="_alertsIcon_n1f44_52",Lt="_alertsSummary_n1f44_57",Pt="_alertGroup_n1f44_63",Dt="_alertGroupLabel_n1f44_69",Ft="_alertList_n1f44_79",Tt="_alertItem_n1f44_85",Mt="_alertItemCritical_n1f44_93",qt="_alertMore_n1f44_101",Ut="_searchContainer_n1f44_107",Rt="_accountsList_n1f44_113",$t="_accountCard_n1f44_120",Vt="_accountCardWarning_n1f44_128",Gt="_accountHeader_n1f44_132",zt="_accountHeaderContent_n1f44_137",Bt="_accountInfo_n1f44_144",Ot="_accountName_n1f44_152",Ht="_accountId_n1f44_161",Wt="_accountStats_n1f44_167",Qt="_utilizationBadge_n1f44_173",Kt="_utilizationIcon_n1f44_182",Jt="_utilizationValue_n1f44_188",Yt="_utilizationWarning_n1f44_193",Xt="_utilizationCritical_n1f44_197",Zt="_throttledBadge_n1f44_201",er="_throttledIcon_n1f44_213",sr="_expandIcon_n1f44_218",ar="_accountContent_n1f44_224",ir="_quotaGrid_n1f44_230",nr="_progressContainer_n1f44_238",lr="_progressHeader_n1f44_244",tr="_progressLabel_n1f44_251",rr="_progressValue_n1f44_257",cr="_progressTrack_n1f44_262",dr="_progressFill_n1f44_269",or="_progressWarning_n1f44_284",hr="_progressCritical_n1f44_288",mr="_progressWarningText_n1f44_292",_r="_warningsList_n1f44_298",ur="_warningItem_n1f44_308",xr="_warningIcon_n1f44_316",jr="_accountActions_n1f44_323",pr="_modalOverlay_n1f44_329",vr="_modal_n1f44_329",gr="_modalHeader_n1f44_348",Nr="_modalTitle_n1f44_352",fr="_modalSubtitle_n1f44_358",br="_modalContent_n1f44_364",yr="_modalError_n1f44_368",wr="_formGroup_n1f44_380",Cr="_formLabel_n1f44_384",Sr="_modalFooter_n1f44_391",kr="_skeletonCard_n1f44_399",Ar="_skeletonTitle_n1f44_403",Er="_skeletonSubtitle_n1f44_411",Ir="_emptyState_n1f44_421",Lr="_errorContainer_n1f44_428",Pr="_errorIcon_n1f44_437",Dr="_errorTitle_n1f44_444",Fr="_errorMessage_n1f44_450",Tr="_spinning_n1f44_457",Mr=({value:e,max:s,label:a,showWarning:n})=>{const l=s>0?Math.min(e/s*100,100):0,t=l>=80,r=l>=95;return i.jsxs("div",{className:nr,children:[i.jsxs("div",{className:lr,children:[i.jsx("span",{className:tr,children:a}
1),i.jsxs("span",{className:rr,children:[e.toLocaleString()," / ",s.toLocaleString()]})]}),i.jsx("div",{className:cr,children:i.jsx("div",{className:ee(dr,r&&hr,t&&!r&&or),style:{transform:`scaleX(${l/100})`}})}),n&&t&&i.jsx("span",{className:mr,children:r?"Critical":"Approaching limit"})]})},qr=({account:e,onEdit:s,expanded:a,onToggle:n})=>{const{quota:l}=e,t=Math.max(l.concurrent.utilizationPercent,l.hourly.utilizationPercent,l.daily.utilizationPercent);return i.jsxs(es,{className:ee($t,e.isApproachingLimit&&Vt),children:[i.jsx(as,{className:Gt,onClick:n,children:i.jsxs("div",{className:zt,children:[i.jsxs("div",{className:Bt,children:[i.jsx(is,{className:Ot,children:e.accountName}),i.jsx(ns,{className:Ht,children:e.accountId})]}),i.jsxs("div",{className:Wt,children:[i.jsxs("div",{className:Qt,children:[i.jsx(K,{className:Kt}),i.jsxs("span",{className:ee(Jt,t>=80&&Yt,t>=95&&Xt),children:[t,"%"]})]}),l.isThrottled&&i.jsxs("span",{className:Zt,children:[i.jsx(me,{className:er}),"Throttled"]}),a?i.jsx(qe,{className:sr}):i.jsx(Ue,{className:sr})]})]})}),a&&i.jsxs(ss,{className:ar,children:[i.jsxs("div",{className:ir,children:[i.jsx(Mr,{value:l.concurrent.current,max:l.concurrent.max,label:"Concurrent",showWarning:!0}),i.jsx(Mr,{value:l.hourly.current,max:l.hourly.max,label:"Hourly",showWarning:!0}),i.jsx(Mr,{value:l.daily.current,max:l.daily.max,label:"Daily",showWarning:!0})]}),e.warnings.length>0&&i.jsx("div",{className:_r,children:e.warnings.map((e,s)=>i.jsxs("div",{className:ur,children:[i.jsx(me,{className:xr}),i.jsx("span",{children:e})]},s))}),i.jsx("div",{className:jr,children:i.jsxs(d,{variant:"outline",size:"sm",onClick:()=>s(e.accountId),children:[i.jsx(He,{className:"h-4 w-4 mr-2"}),"Edit Quotas"]})})]})]})},Ur=({accountId:e,accountName:s,currentConfig:n,onSave:l,onClose:t})=>{const[r,c]=a.useState(n.maxConcurrentExecutions.toString()),[o,h]=a.use
1State(n.maxExecutionsPerHour.toString()),[_,u]=a.useState(n.maxExecutionsPerDay.toString()),[x,j]=a.useState(!1),[p,v]=a.useState(null);return i.jsx("div",{className:pr,onClick:t,children:i.jsxs("div",{className:vr,onClick:e=>e.stopPropagation(),children:[i.jsxs("div",{className:gr,children:[i.jsx("h2",{className:Nr,children:"Edit Quota Limits"}),i.jsxs("p",{className:fr,children:[s," (",e,")"]})]}),i.jsxs("div",{className:br,children:[p&&i.jsxs("div",{className:yr,children:[i.jsx(ls,{className:"h-4 w-4"}),i.jsx("span",{children:p})]}),i.jsxs("div",{className:wr,children:[i.jsx("label",{className:Cr,children:"Max Concurrent Executions"}),i.jsx(m,{type:"number",min:"1",value:r,onChange:e=>c(e.target.value)})]}),i.jsxs("div",{className:wr,children:[i.jsx("label",{className:Cr,children:"Max Executions Per Hour"}),i.jsx(m,{type:"number",min:"1",value:o,onChange:e=>h(e.target.value)})]}),i.jsxs("div",{className:wr,children:[i.jsx("label",{className:Cr,children:"Max Executions Per Day"}),i.jsx(m,{type:"number",min:"1",value:_,onChange:e=>u(e.target.value)})]})]}),i.jsxs("div",{className:Sr,children:[i.jsx(d,{variant:"outline",onClick:t,disabled:x,children:"Cancel"}),i.jsx(d,{onClick:async()=>{v(null),j(!0);try{const e={},s=parseInt(r,10),a=parseInt(o,10),i=parseInt(_,10);if(s!==n.maxConcurrentExecutions){if(isNaN(s)||s<1)throw new Error("Concurrent limit must be a positive number");e.maxConcurrentExecutions=s}if(a!==n.maxExecutionsPerHour){if(isNaN(a)||a<1)throw new Error("Hourly limit must be a positive number");e.maxExecutionsPerHour=a}if(i!==n.maxExecutionsPerDay){if(isNaN(i)||i<1)throw new Error("Daily limit must be a positive number");e.maxExecutionsPerDay=i}await l(e),t()}catch(e){v(e instanceof Error?e.message:"Failed to save")}finally{j(!1)}},disabled:x,children:x?"Saving...":"Save Changes"})]})]})})},Rr=()=>{const[e,s]=a.useState([]),[n,l]=a.useState(null),[t,r]=a.useState(!0),[c,h]=a.useState(null),[_,u]=a.useState(""),[x,j]=a.useState(new Set),[p,v]=a.useState(null),g=a.useCallback(async()=>{r(!0),h(null);try{const[e,a]=await Promise.all([Ke.get("/admin/quotas"),Ke.get("/admin/quotas/alerts")]);s(e.data),l(a)}catch(e){h(e instanceof Error?e.message:"Failed to load data")}finally{r(!1)}},[]);a.useEffect(()=>{g()},[g]);const N=async e=>{try{const s=await Ke.get(`/admin/quotas/${e}`);v({accountId:e,accountName:s.account.name,config:s.config})}catch(s){}},f=e.filter(e=>e.accountName.toLowerCase().includes(_.toLowerCase())||e.accountId.toLowerCase().includes(_.toLowerCase()));return c?i.jsx("div",{className:wt,children:i.jsxs("div",{className:Lr,children:[i.jsx(ls,{className:Pr}),i.jsx("h2",{className:Dr,children:"Failed to load quota dashboard"}),i.jsx("p",{className:Fr,children:c}),i.jsxs(d,{onClick:g,children:[i.jsx(o,{className:"h-4 w-4 mr-2"}),"Retry"]})]})}):i.jsxs("div",{className:wt,children:[i.jsxs("div",{className:Ct,children:[i.jsxs("div",{children:[i.jsx("h1",{className:St,children:"Quota Dashboard"}),i.jsx("p",{className:kt,children:"Monitor execution quotas and rate limits"})]}),i.jsxs(d,{variant:"outline",onClick:g,disabled:t,children:[i.jsx(o,{className:ee("h-4 w-4 mr-2",t&&Tr)}),"Refresh"]})]}),n&&n.totalAlerts>0&&i.jsxs(es,{className:At,children:[i.jsx(as,{children:i.jsxs(is,{className:Et,children:[i.jsx(me,{className:It}),n.totalAlerts," Alert",1!==n.totalAlerts?"s":""]})}),i.jsx(ss,{children:i.jsxs("div",{className:Lt,children:[n.approachingLimit.length>0&&i.jsxs("div",{className:Pt,children:[i.jsxs("span",{className:Dt,children:[i.jsx(Se,{className:"h-4 w-4"}),"Approaching Limit (",n.approachingLimit.length,")"]}),i.jsxs("div",{className:Ft,children:[n.approachingLimit.slice(0,3).map(e=>i.jsx("span",{className:Tt,children:e.accountName},e.accountId)),n.approachingLimit.length>3&&i.jsxs("span",{className:qt,children:["+",n.approachingLimit.length-3," more"]})]})]}),n.throttled.length>0&&i.jsxs("div",{className:Pt,children:[i.jsxs("span",{className:Dt,children:[i.jsx(Ce,{className:"h-4 w-4"}),"Throttled (",n.throttled.length,")"]}),i.jsxs("div",{className:Ft,children:[n.throttled.slice(0,3).map(e=>i.jsx("span",{className:Mt,children:e.accountId},e.accountId)),n.throttled.length>3&&i.jsxs("span",{className:qt,children:["+",n.throttled.length-3," more"]})]})]})]})})]}),i.jsx("div",{className:Ut,children:i.jsx(m,{icon:"Search",placeholder:"Search accounts...",value:_,onCh
1ange:e=>u(e.target.value)})}),i.jsx("div",{className:Rt,children:t?Array.from({length:3}).map((e,s)=>i.jsx(es,{className:kr,children:i.jsxs(as,{children:[i.jsx("div",{className:Ar}),i.jsx("div",{className:Er})]})},s)):0===f.length?i.jsx("div",{className:Ir,children:i.jsx("p",{children:"No accounts found"})}):f.map(e=>i.jsx(qr,{account:e,onEdit:N,expanded:x.has(e.accountId),onToggle:()=>{return s=e.accountId,void j(e=>{const a=new Set(e);return a.has(s)?a.delete(s):a.add(s),a});var s}},e.accountId))}),p&&i.jsx(Ur,{accountId:p.accountId,accountName:p.accountName,currentConfig:p.config,onSave:async e=>{p&&(await Ke.put(`/admin/quotas/${p.accountId}`,e),await g())},onClose:()=>v(null)})]})},$r="_container_h3eou_5",Vr="_header_h3eou_12",Gr="_backButton_h3eou_16",zr="_profileCard_h3eou_21",Br="_profileHeader_h3eou_25",Or="_avatar_h3eou_31",Hr="_avatarImage_h3eou_43",Wr="_avatarIcon_h3eou_49",Qr="_profileInfo_h3eou_55",Kr="_email_h3eou_60",Jr="_badges_h3eou_67",Yr="_activeBadge_h3eou_74",Xr="_statsGrid_h3eou_80",Zr="_statItem_h3eou_89",ec="_statIcon_h3eou_95",sc="_statValue_h3eou_101",ac="_statLabel_h3eou_108",ic="_settingsCard_h3eou_115",nc="_settingsContent_h3eou_119",lc="_settingRow_h3eou_125",tc="_settingInfo_h3eou_134",rc="_settingDescription_h3eou_139",cc="_rateLimitsCard_h3eou_146",dc="_rateLimitsHeader_h3eou_150",oc="_rateLimitsGrid_h3eou_156",hc="_rateLimitItem_h3eou_161",mc="_rateLimitDescription_h3eou_167",_c="_rateLimitInputWrapper_h3eou_173",uc="_rateLimitInput_h3eou_173",xc="_rateLimitUnit_h3eou_183",jc="_loading_h3eou_189",pc="_loadingIcon_h3eou_198",vc="_errorContainer_h3eou_211",gc="_errorActions_h3eou_221",Nc=[{resource_type:"api_requests",limit_value:1e3,period_seconds:3600},{resource_type:"workflow_executions",limit_value:100,period_seconds:3600},{resource_type:"file_uploads",limit_value:50,period_seconds:3600}],fc={api_requests:{label:"API Requests",description:"Maximum API requests per hour"},workflow_executions:{label:"Workflow Executions",description:"Maximum workflow runs per hour"},file_uploads:{label:"File Uploads",description:"Maximum file uploads per hour"}},bc=e=>{if(!e)return"Never";return new Date(e).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},yc=()=>{const{userId:e}=c(),s=n(),{selectedUser:l,userRateLimits:t,isLoading:r,error:h,fetchUser:_,updateUser:u,updateUserRateLimits:x,clearError:j}=Be(),[p,v]=a.useState([]),[g,N]=a.useState(!1),[f,b]=a.useState(!1);a.useEffect(()=>{e&&_(e)},[e,_]),a.useEffect(()=>{t.length>0?v(t.map(e=>({resource_type:e.resource_type,limit_value:e.limit_value,period_seconds:e.period_seconds}))):v(Nc),N(!1)},[t]);const y=a.useCallback((e,s)=>{v(a=>a.map(a=>a.resource_type===e?{...a,limit_value:s}:a)),N(!0)},[]),w=a.useCallback(async()=>{if(e){b(!0);try{await x(e,p),N(!1)}catch(s){}finally{b(!1)}}},[e,p,x]),C=a.useCallback(async s=>{if(l&&e)try{await u(e,{[s]:!l[s]})}catch(a){}},[l,e,u]);return e?r&&!l?i.jsx("div",{className:$r,children:i.jsxs("div",{className:jc,children:[i.jsx(o,{className:pc}),i.jsx("span",{children:"Loading user details..."})]})}):h&&!l?i.jsx("div",{className:$r,children:i.jsxs("div",{className:vc,children:[i.jsx("p",{children:h}),i.jsxs("div",{className:gc,children:[i.jsx(d,{variant:"outline",onClick:()=>s("/admin/users"),children:"Back to Users"}),i.jsx(d,{onClick:()=>{j(),_(e)},children:"Retry"})]})]})}):l?i.jsxs("div",{className:$r,children:[i.jsx("div",{className:Vr,children:i.jsxs(d,{variant:"ghost",onClick:()=>s("/admin/users"),className:Gr,children:[i.jsx(se,{className:"h-4 w-4 mr-2"}),"Back to Users"]})}),i.jsxs(es,{className:zr,children:[i.jsx(as,{children:i.jsxs("div",{className:Br,children:[i.jsx("div",{className:Or,children:l.avatar?i.jsx("img",{src:l.avatar,alt:"",className:Hr}):i.jsx(Xe,{className:Wr})}),i.jsxs("div",{className:Qr,children:[i.jsx(is,{children:l.name||"No name"}),i.jsxs(ns,{className:Kr,children:[i.jsx(Ze,{className:"h-4 w-4"}),l.email]}),i.jsxs("div",{className:Jr,children:[l.is_admin&&i.jsx(O,{variant:"default",children:"Admin"}),l.is_active?i.jsx(O,{variant:"secondary",className:Yr,children:"Active"}):i.jsx(O,{variant:"outline",children:"Inactive"}),l.email_verified&&i.jsx(O,{variant:"outline",children:"Verified"}),l.two_factor_enabled&&i.jsx(O,{variant:"outline",children:"2FA Enabled"})]})]})]})}),i.jsx(ss,{children:i.jsxs("div",{className:Xr,children:[i.jsxs("div",{className:Zr,children:[i.jsx(le,{className:ec}),i.jsxs("div",{children:[i.jsx("span",{className:sc,children:l.workflow_count}),i.jsx("span",{className:ac,children:"Workflows"})]})]}),i.jsxs("div",{className:Zr,children:[i.jsx(K,{className:ec}),i.jsxs("div",{children:[i.jsx("span",{className:sc,children:l.execution_count}),i.jsx("span",{className:ac,children:"Executions"})]})]}),i.jsxs("div",{className:Zr,children:[i.jsx(te,{className:ec}),i.jsxs("div",{children:[i.jsx("span",{className:sc,children:bc(l.created_at)}),i.jsx("span",{className:ac,children:"Joined"})]})]}),i.jsxs("div",{className:Zr,children:[i.jsx(Ce,{className:ec}),i.jsxs("div",{children:[i.jsx("span",{className:sc,children:bc(l.last_login_at)}),i.jsx("span",{className:ac,children:"Last Login"})]})]})]})})]}),i.jsxs(es,{className:ic,children:[i.jsxs(as,{children:[i.jsx(is,{children:"Account Settings"}),i.jsx(ns,{children:"Manage account status and permissions"})]}),i.jsxs(ss,{className:nc,children:[i.jsxs("div",{className:lc,children:[i.jsxs("div",{className:tc,children:[i.jsx(M,{htmlFor:"is-active",children:"Account Active"}),i.jsx("p",{className:rc,children:"Inactive accounts cannot log in or use the platform"})]}),i.jsx(Ae,{id:"is-active",checked:l.is_active,onCheckedChange:()=>C("is_active")})]}),i.jsxs("div",{className:lc,children:[i.jsxs("div",{className:tc,children:[i.jsx(M,{htmlFor:"is-admin",children:"Admin Access"}),i.jsx("p",{className:rc,children:"Admins have full access to the admin panel"})]}),i.jsx(Ae,{id:"is-admin",checked:l.is_admin,onCheckedChange:()=>C("is_admin")})]})]})]}),i.jsxs(es,{className:cc,children:[i.jsxs(as,{className:dc,children:[i.jsxs("div",{children:[i.jsx(is,{children:"Rate Limits"}),i.jsx(ns,{children:"Configure per-user rate limits"})]}),i.jsxs(d,{onClick:w,disabled:!g||f,children:[i.jsx(Re,{className:"h-4 w-4 mr-2"}),f?"Saving...":"Save Changes"]})]}),i.jsx(ss,{children:i.jsx("div",{className:oc,children:p.map(e=>{const s=fc[e.resource_type]||{label:e.resource_type,description:""};return i.jsxs("div",{className:hc,children:[i.jsx(M,{htmlFor:e.resource_type,children:s.label}),i.jsx("p",{className:mc,children:s.description}),i.jsxs("div",{className:_c,children:[i.jsx(m,{id:e.resource_type,type:"number",min:0,value:e.limit_value,onChange:s=>y(e.resource_type,parseInt(s.target.value)||0),className:uc}),i.jsx("span",{className:xc,children:"/ hour"})]})]},e.resource_type)})})})]})]}):i.jsx("div",{className:$r,children:i.jsxs("div",{className:vc,children:[i.jsx("p",{children:"User not found"}),i.jsx(d,{onClick:()=>s("/admin/users"),children:"Back to Users"})]})}):i.jsx("div",{className:$r,children:i.jsxs("div",{className:vc,children:[i.jsx("p",{children:"Invalid user ID"}),i.jsx(d,{onClick:()=>s("/admin/users"),children:"Back to Users"})]})})},wc="_container_m3jqw_8",Cc="_header_m3jqw_15",Sc="_title_m3jqw_22",kc="_subtitle_m3jqw_29",Ac="_searchContainer_m3jqw_36",Ec="_searchInputWrapper_m3jqw_44",Ic="_resultCount_m3jqw_67",Lc="_errorBanner_m3jqw_73",Pc="_tableContainer_m3jqw_87",Dc="_userCell_m3jqw_95",Fc="_avatar_m3jqw_101",Tc="_avatarImage_m3jqw_113",Mc="_avatarInitial_m3jqw_119",qc="_userInfo_m3jqw_125",Uc="_userName_m3jqw_131",Rc="_userEmail_m3jqw_140",$c="_badgeAdmin_m3jqw_149",Vc="_badgeActive_m3jqw_154",Gc="_badgeInactive_m3jqw_159",zc="_badgePending_m3jqw_165",Bc="_badgeExpired_m3jqw_171",Oc="_invitationRow_m3jqw_177",Hc="_avatarPending_m3jqw_185",Wc="_invitationLabel_m3jqw_191",Qc="_emptyCell_m3jqw_199",Kc="_pagination_m3jqw_206",Jc="_paginationInfo_m3jqw_215",Yc="_paginationControls_m3jqw_220",Xc="_skeletonUser_m3jqw_226",Zc="_skeletonAvatar_m3jqw_232",ed="_skeletonInfo_m3jqw_240",sd="_skeletonName_m3jqw_246",ad="_skeletonEmail_m3jqw_254",id="_skeletonBadge_m3jqw_262",nd="_skeletonText_m3jqw_270",ld="_spinning_m3jqw_288",td="_headerActions_m3jqw_302",rd="_inviteDialog_m3jqw_309",cd="_inviteFormGrid_m3jqw_313",dd="_formField_m3jqw_320",od="_dialogFooter_m3jqw_346",hd=e=>{if(!e)return"Never";return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})},md=({user:e})=>
1{switch(e.status||(e.is_active?"active":"suspended")){case"pending":return i.jsxs(O,{variant:"outline",className:zc,children:[i.jsx(Ce,{className:"h-3 w-3 mr-1"}),"Pending"]});case"expired":return i.jsxs(O,{variant:"destructive",className:Bc,children:[i.jsx(os,{className:"h-3 w-3 mr-1"}),"Expired"]});case"suspended":return i.jsxs(O,{variant:"secondary",className:Gc,children:[i.jsx(ls,{className:"h-3 w-3 mr-1"}),"Suspended"]});default:return e.is_admin?i.jsxs(O,{variant:"default",className:$c,children:[i.jsx(W,{className:"h-3 w-3 mr-1"}),"Admin"]}):i.jsxs(O,{variant:"secondary",className:Vc,children:[i.jsx(ts,{className:"h-3 w-3 mr-1"}),"Active"]})}},_d=()=>{const e=n(),{showSuccess:s,showError:l}=ze(),{users:t,usersPagination:r,isLoadingUsers:c,isLoading:h,error:g,fetchUsers:N,updateUser:S,deleteUser:q,inviteUser:O,createOAuthUser:H,cancelInvitation:W,clearError:Q}=Be(),{searchQuery:K,setSearchQuery:J,debouncedSearch:Y,handlePageChange:X}=ms(N),[Z,ee]=a.useState(!1),[se,ae]=a.useState({email:"",name:"",role:"user",loginMethod:"email"}),ie=a.useCallback(s=>{s&&e(`/admin/users/${s}`)},[e]),ne=a.useCallback(async e=>{if(e.id)try{await S(e.id,{is_active:!e.is_active}),s(`${e.email} has been ${e.is_active?"suspended":"reactivated"}.`)}catch(a){l(a instanceof Error?a.message:"Failed to update user")}},[S,s,l]),le=a.useCallback(async e=>{if(e&&window.confirm("Are you sure you want to delete this user? This action cannot be undone."))try{await q(e),s("The user has been deleted successfully.")}catch(a){l(a instanceof Error?a.message:"Failed to delete user")}},[q,s,l]),te=a.useCallback(async(e,a)=>{if(e&&window.confirm(`Cancel the invitation for ${a}?`))try{await W(e),s(`The invitation for ${a} has been cancelled.`),N({page:1,limit:20,search:Y})}catch(i){l(i instanceof Error?i.message:"Failed to cancel invitation")}},[W,s,l,N,Y]),re=a.useCallback(async e=>{try{await O(e.email,e.name||void 0,e.role),s(`A new invitation has been sent to ${e.email}.`),N({page:1,limit:20,search:Y})}catch(a){l(a instanceof Error?a.message:"Failed to resend invitation")}},[O,s,l,N,Y]),ce=a.useCallback(async e=>{e.preventDefault();try{"oauth"===se.loginMethod?(await H(se.email,se.name||void 0,se.role),s(`${se.email} has been added as a Google Sign-In user. They can now sign in with their Google account.`)):(await O(se.email,se.name||void 0,se.role),s(`An invitation has been sent to ${se.email}.`)),ee(!1),ae({email:"",name:"",role:"user",loginMethod:"email"}),N({page:1,limit:20,search:Y})}catch(a){l(a instanceof Error?a.message:"An error occurred while adding the user.")}},[O,H,se,N,Y,s,l]);return a.useEffect(()=>{Z||ae({email:"",name:"",role:"user",loginMethod:"email"})},[Z]),i.jsxs("div",{className:wc,children:[i.jsxs("div",{className:Cc,children:[i.jsxs("div",{children:[i.jsx("h1",{className:Sc,children:"User Management"}),i.jsx("p",{className:kc,children:"Manage user accounts, permissions, and access"})]}),i.jsxs("div",{className:td,children:[i.jsxs(d,{variant:"outline",onClick:()=>N({page:1,limit:20,search:Y}),disabled:c,children:[i.jsx(o,{className:`h-4 w-4 mr-2 ${c?ld:""}`}),"Refresh"]}),i.jsxs(d,{onClick:()=>ee(!0),children:[i.jsx(B,{className:"h-4 w-4 mr-2"}),"Invite User"]})]})]}),i.jsxs("div",{className:Ac,children:[i.jsx("div",{className:Ec,children:i.jsx(m,{type:"text",placeholder:"Search by email or name...",value:K,onChange:e=>J(e.target.value),icon:"Search"})}),i.jsxs("div",{className:Ic,children:[r?.total??0," user",1!==(r?.total??0)?"s":""]})]}),g&&i.jsxs("div",{className:Lc,children:[i.jsx("span",{children:g}),i.jsx(d,{variant:"ghost",size:"sm",onClick:Q,children:"Dismiss"})]}),i.jsx("div",{className:Pc,children:i.jsxs(_,{children:[i.jsx(u,{children:i.jsxs(x,{children:[i.jsx(j,{children:"User"}),i.jsx(j,{children:"Status"}),i.jsx(j,{children:"Workflows"}),i.jsx(j,{children:"Executions"}),i.jsx(j,{children:"Created"}),i.jsx(j,{children:"Last Login"}),i.jsx(j,{className:"w-12"})]})}),i.jsx(p,{children:c?Array.from({length:5}).map((e,s)=>i.jsxs(x,{children:[i.jsx(v,{children:i.jsxs("div",{className:Xc,children:[i.jsx("div",{className:Zc}),i.jsxs("div",{className:ed,children:[i.jsx("div",{className:sd}),i.jsx("div",{className:ad})]})]})}),i.jsx(v,{children:i.jsx("div",{className:id})}),i.jsx(v,{children:i.jsx("div",{className:nd})}),i.jsx(v,{children:i.jsx("div",{className:nd})}),i.jsx(v,{children:i.jsx("div",{className:nd})}),i.jsx(v,{children:i.jsx("div",{className:nd})}),i.jsx(v,{})]},s)):t&&0!==t.length?t.map(e=>i.jsxs(x,{className:e.is_invitation?Oc:"",children:[i.jsx(v,{children:i.jsxs("div",{className:Dc,children:[i.jsx("div",{className:`${Fc} ${e.is_invitation?Hc:""}`,children:e.avatar?i.jsx("img",{src:e.avatar,alt:"",className:Tc}):e.is_invitation?i.jsx(Ze,{className:"h-4 w-4"}):i.jsx("span",{className:Mc,children:(e.name||e.email)[0].toUpperCase()})}),i.jsxs("div",{className:qc,children:[i.jsxs("span",{className:Uc,children:[e.name||"No name",e.is_invitation&&i.jsx("span",{className:Wc,children:" (Invited)"})]}),i.jsx("span",{className:Rc,children:e.email})]})]})}),i.jsx(v,{children:i.jsx(md,{user:e})}),i.jsx(v,{children:e.is_invitation?"—":e.workflow_count}),i.jsx(v,{children:e.is_invitation?"—":e.execution_count}),i.jsx(v,{children:hd(e.created_at)}),i.jsx(v,{children:e.is_invitation?"—":hd(e.last_login_at)}),i.jsx(v,{children:i.jsxs(f,{children:[i.jsx(b,{asChild:!0,children:i.jsxs(d,{variant:"ghost",size:"icon",children:[i.jsx(y,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"Actions"})]})}),i.jsx(w,{align:"end",children:e.is_invitation?i.jsxs(i.Fragment,{children:[i.jsxs(C,{onClick:()=>re(e),children:[i.jsx($e,{className:"h-4 w-4 mr-2"}),"Resend Invitation"]}),i.jsx(k,{}),i.jsxs(C,{onClick:()=>te(e.invitation_id,e.email),variant:"destructive",children:[i.jsx(ls,{className:"h-4 w-4 mr-2"}),"Cancel Invitation"]})]}):i.jsxs(i.Fragment,{children:[i.jsxs(C,{onClick:()=>ie(e.id),children:[i.jsx(cs,{className:"h-4 w-4 mr-2"}),"View Details"]}
1),i.jsx(C,{onClick:()=>ne(e),disabled:!!e.is_admin,children:e.is_active?i.jsxs(i.Fragment,{children:[i.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Suspend"]}):i.jsxs(i.Fragment,{children:[i.jsx(Ge,{className:"h-4 w-4 mr-2"}),"Reactivate"]})}),i.jsx(k,{}),i.jsxs(C,{onClick:()=>le(e.id),disabled:!!e.is_admin,variant:"destructive",children:[i.jsx(A,{className:"h-4 w-4 mr-2"}),"Delete User"]})]})})]})})]},e.id||e.invitation_id||e.email)):i.jsx(x,{children:i.jsx(v,{colSpan:7,className:Qc,children:Y?`No users found matching "${Y}"`:"No users found"})})})]})}),(r?.totalPages??0)>1&&i.jsxs("div",{className:Kc,children:[i.jsxs("div",{className:Jc,children:["Page ",r?.page??1," of ",r?.totalPages??1]}),i.jsxs("div",{className:Yc,children:[i.jsxs(d,{variant:"outline",size:"sm",onClick:()=>X((r?.page??1)-1),disabled:(r?.page??1)<=1||c,children:[i.jsx(E,{className:"h-4 w-4 mr-1"}),"Previous"]}),i.jsxs(d,{variant:"outline",size:"sm",onClick:()=>X((r?.page??1)+1),disabled:(r?.page??1)>=(r?.totalPages??1)||c,children:["Next",i.jsx(I,{className:"h-4 w-4 ml-1"})]})]})]}),i.jsx(L,{open:Z,onOpenChange:ee,children:i.jsxs(P,{className:rd,children:[i.jsxs(D,{children:[i.jsx(F,{children:"Add User"}),i.jsx(T,{children:"oauth"===se.loginMethod?"Create a user account that can sign in with Google.":"Send an invitation email so the user can set up their password."})]}),i.jsxs("form",{onSubmit:ce,children:[i.jsxs("div",{className:cd,children:[i.jsxs("div",{className:dd,children:[i.jsx(M,{htmlFor:"invite-login-method",children:"Login Method"}),i.jsxs(U,{value:se.loginMethod,onValueChange:e=>ae({...se,loginMethod:e}),children:[i.jsx(R,{children:i.jsx($,{placeholder:"Select login method"})}),i.jsxs(V,{children:[i.jsx(G,{value:"email",children:"Email Invitation"}),i.jsx(G,{value:"oauth",children:"Google Sign-In"})]})]})]}),i.jsxs("div",{className:dd,children:[i.jsx(M,{htmlFor:"invite-email",children:"oauth"===se.loginMethod?"Google Email *":"Email *"}),i.jsx(m,{id:"invite-email",type:"email",value:se.email,onChange:e=>ae({...se,email:e.target.value}),placeholder:"oauth"===se.loginMethod?"[email protected]":"[email protected]",required:!0})]}),i.jsxs("div",{className:dd,children:[i.jsx(M,{htmlFor:"invite-name",children:"Name (optional)"}),i.jsx(m,{id:"invite-name",type:"text",value:se.name,onChange:e=>ae({...se,name:e.target.value}),placeholder:"John Doe"})]}),i.jsxs("div",{className:dd,children:[i.jsx(M,{htmlFor:"invite-role",children:"Role"}),i.jsxs(U,{value:se.role,onValueChange:e=>ae({...se,role:e}),children:[i.jsx(R,{children:i.jsx($,{placeholder:"Select role"})}),i.jsxs(V,{children:[i.jsx(G,{value:"user",children:"User"}),i.jsx(G,{value:"admin",children:"Admin"})]})]})]})]}),i.jsxs(z,{className:od,children:[i.jsx(d,{type:"button",variant:"outline",onClick:()=>ee(!1),children:"Cancel"}),i.jsx(d,{type:"submit",disabled:h||!se.email,children:h?"oauth"===se.loginMethod?"Creating...":"Sending...":"oauth"===se.loginMethod?"Create User":"Send Invitation"})]})]})]})})]})};export{xa as AccountsManagement,qa as AdminLayout,fi as AuditLogs,en as CredentialVault,Hn as Dashboard,jl as ForgeDashboard,bt as HealingDashboard,Rr as QuotaDashboard,yc as UserDetail,_d as UserManagement};

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.