1import{r as l,j as e,Y as J,f as N,X as Q,L as V,c as Ct,G as St,B as Ke,Z as At,C as Tt,i as Dt,l as _t,_ as Lt,k as Et,$ as Pt,a as Mt,a0 as It,a1 as Rt,o as Ot,a2 as $t,a3 as Ft,a4 as Kt,y as he,a5 as pe,a6 as Z,a7 as zt,S as Ut,a8 as Bt,p as Yt,a9 as qt,aa as Vt}from"./index-C86sjUM7.js";import{d as Ht}from"./integrations-DtPDPoSE.js";import{C as Xe}from"./chart-column-C1wJcOix.js";import{i as Gt,g as Xt}from"./monitoringHub-BRSFAgjF.js";import{K as $}from"./key-vksBdnFe.js";import{S as Wt}from"./search-C0pTPwzI.js";import{P as Zt}from"./plus-B1ssUL0Q.js";import{T as _,R as B}from"./trash-2-C-9C-yvi.js";import{C as ze}from"./credit-card-COOTe5nr.js";import{C as Jt}from"./coins-B9LRrHDx.js";import{C as Ue}from"./clock-D-xVB89G.js";import{D as Qt}from"./download-BjVXJSVp.js";import{U as Be}from"./user-x-Cri30fGj.js";import{F as es}from"./funnel-DKwgPUsk.js";const ts=[{key:"runs",label:"Runs",icon:Xe}],Ye=[{textClassName:"text-sky-300",chipClassName:"bg-sky-400",segmentClassName:"bg-sky-400/90"},{textClassName:"text-indigo-300",chipClassName:"bg-indigo-400",segmentClassName:"bg-indigo-400/90"},{textClassName:"text-teal-300",chipClassName:"bg-teal-400",segmentClassName:"bg-teal-400/90"},{textClassName:"text-rose-300",chipClassName:"bg-rose-400",segmentClassName:"bg-rose-400/90"},{textClassName:"text-amber-300",chipClassName:"bg-amber-400",segmentClassName:"bg-amber-400/90"},{textClassName:"text-violet-300",chipClassName:"bg-violet-400",segmentClassName:"bg-violet-400/90"},{textClassName:"text-cyan-300",chipClassName:"bg-cyan-400",segmentClassName:"bg-cyan-400/90"},{textClassName:"text-orange-300",chipClassName:"bg-orange-400",segmentClassName:"bg-orange-400/90"},{textClassName:"text-pink-300",chipClassName:"bg-pink-400",segmentClassName:"bg-pink-400/90"},{textClassName:"text-lime-300",chipClassName:"bg-lime-400",segmentClassName:"bg-lime-400/90"},{textClassName:"text-fuchsia-300",chipClassName:"bg-fuchsia-400",segmentClassName:"bg-fuchsia-400/90"},{textClassName:"text-emerald-300",chipClassName:"bg-emerald-400",segmentClassName:"bg-emerald-400/90"}],ss={CLOUDPERMISSIONSCONTEXT:"Cloud Perms",EMAILANALYZER:"Email",STATICMALWAREANALYZER:"Malware",URLDETONATOR:"URL",ONPREMISESLICENSE:"On-Prem",AIEXPOSURE:"AI Exposure"};function as(s){return ss[s]??s.charAt(0)+s.slice(1).toLowerCase()}function ls(s){return[...new Set((Array.isArray(s)?s:[]).map(r=>r.run_type).filter(Boolean))].sort().map((r,x)=>({key:r,label:as(r),...Ye[x%Ye.length]}))}function rs(s){const c=new Date,r=Array.from({length:12},(h,o)=>{const m=new Date(c.getFullYear(),c.getMonth()-11+o,1);return{key:`${m.getFullYear()}-${String(m.getMonth()+1).padStart(2,"0")}`,date:m,shortLabel:m.toLocaleDateString(void 0,{month:"short"}),fullLabel:m.toLocaleDateString(void 0,{month:"short",year:"numeric"}),totalRuns:0,totalCredits:0,byTool:{}}}),x=new Map(r.map(h=>[h.key,h]));return Array.isArray(s)&&s.forEach(h=>{const o=String(h.month_bucket||"").slice(0,7),m=x.get(o);if(!m)return;const p=Number(h.count)||0,S=Number(h.credits_total)||0;if(m.totalRuns+=p,m.totalCredits+=S,h.run_type){const b=m.byTool[h.run_type]??{runs:0,credits:0};b.runs+=p,b.credits+=S,m.byTool[h.run_type]=b}}),r}function ns(s,c){return c==="credits"?s.totalCredits:s.totalRuns}function be(s,c,r){const x=s.byTool[c];return x?r==="credits"?x.credits:x.runs:0}function Y(s,c,r={}){const{compact:x=!1,average:h=!1}=r,o=Number.isFinite(s)?s:0;return x&&o>=1e3?new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1}).format(o):new Intl.NumberFormat(void 0,{minimumFractionDigits:h&&!Number.isInteger(o)?1:0,maximumFractionDigits:h?1:0}).format(o)}function is(s){return s==="credits"?"credits":"runs"}function os(s){return s==="credits"?"Stacked by tool and scaled by credit usage.":"Stacked by tool and scaled by run count."}function We({usageData:s=[],loading:c=!1}){const[r,x]=l.useState("runs"),[h,o]=l.useState(null),m=ls(s),p=rs(s).map(a=>({...a,metricTotal:ns(a,r)})),S=Math.max(...p.map(a=>a.metricTotal),1),b=p.reduce((a,f)=>a+f.metricTotal,0);return e.jsxs("section",{className:"overflow-hidden rounded-2xl border border-slate-800 bg-slate-900",children:[e.jsxs("div",{className:"flex flex-col gap-4 border-b border-slate-800 p-5 sm:flex-row sm:items-start sm:justify-between sm:p-6",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-bold text-white",children:[e.jsx(Xe,{className:"h-5 w-5 text-cyan-400"}),"Usage Trends"]}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Runs per month, stacked by tool."})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("div",{className:"inline-flex flex-wrap items-center gap-1 rounded-full border border-slate-700 bg-slate-950/70 p-1",children:ts.map(a=>{const f=a.icon,u=r===a.key;return e.jsxs("button",{type:"button",onClick:()=>x(a.key),className:`inline-flex items-center gap-2 rounded-full px-3 py-2 text-xs font-medium transition-colors sm:text-sm ${u?"bg-cyan-500/15 text-cyan-200":"text-slate-400 hover:text-white"}`,children:[e.jsx(f,{className:"h-3.5 w-3.5"}),a.label]},a.key)})})})]}),e.jsx("div",{className:"space-y-6 p-5 sm:p-6",children:e.jsxs("div",{className:"rounded-2xl border border-slate-800 bg-slate-950/50 p-4 sm:p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-white",children:"Monthly Usage Mix"}),e.jsx("p",{className:"text-xs text-slate-500",children:os(r)})]}),e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-cyan-500/20 bg-cyan-500/10 px-3 py-1 text-xs font-medium text-cyan-300",children:[e.jsx(J,{className:"h-3.5 w-3.5"}),Y(b)," ",is(r)]})]}),c?e.jsx("div",{className:"flex h-44 items-center justify-center text-slate-600 text-sm",children:"Loading..."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative h-44 overflow-visible rounded-lg border border-slate-800 bg-slate-950/50",children:[[25,50,75].map(a=>e.jsx("div",{className:"absolute left-0 right-0 border-t border-slate-800/70",style:{bottom:`${a}%`}},a)),e.jsx("div",{className:"absolute inset-0 grid items-end gap-2 px-4 pb-1",style:{gridTemplateColumns:`repeat(${p.length}, minmax(0, 1fr))`},children:p.map((a,f)=>{const u=a.metricTotal===0?0:Math.max(8,a.metricTotal/S*100),w=m.map(i=>({...i,value:be(a,i.key,r)})).filter(i=>i.value>0),y=h===a.key,F=p.length,n=f<2?"left-0":f>F-3?"right-0":"left-1/2 -translate-x-1/2";return e.jsxs("div",{className:"relative flex h-full cursor-default items-end",style:{padding:"0 15%"},onMouseEnter:()=>o(a.key),onMouseLeave:()=>o(null),children:[y&&a.metricTotal>0&&e.jsxs("div",{className:`pointer-events-none absolute bottom-full ${n} z-20 mb-2 w-40 rounded-xl border border-slate-700 bg-slate-900 p-3 shadow-xl sm:w-44`,children:[e.jsx("p",{className:"mb-2 text-xs font-semibold text-white",children:a.fullLabel}),e.jsx("div",{className:"space-y-1",children:m.map(i=>{const g=be(a,i.key,r);return g===0?null:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:`h-2 w-2 flex-shrink-0 rounded-full ${i.chipClassName}`}),e.jsx("span",{className:"truncate text-[11px] text-slate-400",children:i.label})]}),e.jsx("span",{className:`text-[11px] font-medium tabular-nums ${i.textClassName}`,children:Y(g,r,{compact:!0})})]},i.key)})}),e.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-slate-800 pt-2",children:[e.jsx("span",{className:"text-[11px] text-slate-500",children:"Total"}),e.jsx("span",{className:"text-[11px] font-semibold tabular-nums text-white",children:Y(a.metricTotal,r,{compact:!0})})]})]}),a.metricTotal===0?e.jsx("div",{className:"w-full border-t-2 border-dashed border-slate-800"}):e.jsx("div",{className:`flex w-full flex-col justify-end overflow-hidden transition-opacity ${y?"o
1pacity-100":"opacity-85"}`,style:{height:`${u}%`},children:w.map(i=>e.jsx("div",{className:i.segmentClassName,style:{height:`${i.value/a.metricTotal*100}%`}},`${a.key}-${i.key}`))})]},a.key)})})]}),e.jsx("div",{className:"mt-2 grid gap-2 px-4",style:{gridTemplateColumns:`repeat(${p.length}, minmax(0, 1fr))`},children:p.map(a=>e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-sm font-semibold text-white",children:Y(a.metricTotal,r,{compact:!0})}),e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-slate-500",children:a.shortLabel})]},a.key))})]}),e.jsx("div",{className:"mt-5 flex flex-wrap gap-3",children:m.map(a=>{const f=p.reduce((u,w)=>u+be(w,a.key,r),0);return f===0?null:e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-full border border-slate-800 bg-slate-900/80 px-3 py-1.5 text-xs",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${a.chipClassName}`}),e.jsx("span",{className:"text-slate-300",children:a.label}),e.jsx("span",{className:a.textClassName,children:Y(f,r,{compact:!0})})]},a.key)})})]})})]})}We.propTypes={usageData:N.arrayOf(N.shape({month_bucket:N.string,count:N.number,credits_total:N.number,run_type:N.string})),loading:N.bool};const q=8,cs={browser_extension:St,email_extension:Ct};function qe(s){return s?.api_key_id||s?.id||s?.key_id||null}function Ve(s){if(!s)return"Unknown";const c=new Date(s);return Number.isNaN(c.getTime())?String(s):c.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function He(s){const c=new Date(s?.created_date);return Number.isNaN(c.getTime())?0:c.getTime()}function fe({isOpen:s,onClose:c,apiKeys:r,loading:x,onDelete:h,createHref:o}){const[m,p]=l.useState(""),[S,b]=l.useState(1),[a,f]=l.useState(s);s!==a&&(f(s),s&&(p(""),b(1))),l.useEffect(()=>{if(!s)return;const n=i=>{i.key==="Escape"&&c()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[s,c]);const u=l.useMemo(()=>{const n=(Array.isArray(r)?r.slice():[]).sort((g,j)=>He(j)-He(g)),i=m.trim().toLowerCase();return i?n.filter(g=>{const j=(g.name||"").toLowerCase(),v=(g.attribution||"").toLowerCase(),A=(qe(g)||"").toLowerCase();return j.includes(i)||v.includes(i)||A.includes(i)}):n},[r,m]),w=Math.max(1,Math.ceil(u.length/q)),y=Math.min(S,w),F=u.slice((y-1)*q,y*q);return s?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-sm",onMouseDown:n=>{n.target===n.currentTarget&&c()},children:e.jsxs("div",{className:"bg-slate-900 border border-slate-800 rounded-2xl w-full max-w-2xl shadow-2xl flex flex-col max-h-[85vh]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 p-5 sm:p-6 border-b border-slate-800",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[e.jsx($,{className:"w-5 h-5 text-emerald-400"}),"API Keys"]}),e.jsxs("p",{className:"mt-1 text-sm text-slate-400",children:["Create keys for individual users or projects. Each key has a display name and a seat assignment â the assigned member email appears as the submitter on runs and drives seat billing. Keys tagged ",e.jsx("span",{className:"text-cyan-300",children:"Monitor"})," are scoped extension keys managed in the Monitoring Hub."]})]}),e.jsx("button",{type:"button",onClick:c,className:"shrink-0 rounded-md p-1 text-slate-400 hover:text-white hover:bg-slate-800 transition-colors","aria-label":"Close",children:e.jsx(Q,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex flex-col gap-3 p-5 sm:p-6 border-b border-slate-800 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Wt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-500 pointer-events-none"}),e.jsx("input",{type:"text",value:m,onChange:n=>{p(n.target.value),b(1)},placeholder:"Search by name or id",className:"w-full rounded-lg border border-slate-700 bg-slate-950/60 pl-9 pr-3 py-2 text-sm text-white placeholder-slate-500 focus:border-emerald-400/50 focus:outline-none focus:ring-2 focus:ring-emerald-400/20"})]}),e.jsxs(V,{to:o,className:"inline-flex items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-blue-500",children:[e.jsx(Zt,{className:"h-4 w-4"}),"New API Key"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:x&&(!Array.isArray(r)||r.length===0)?e.jsx("div",{className:"p-8 text-center text-slate-400",children:"Loading API keys..."}):u.length===0?e.jsx("div",{className:"p-8 text-center text-sm text-slate-500",children:m.trim().length>0?`No keys match "${m.trim()}".`:"No API keys yet. Create one to access Blue Lantern programmatically."}):e.jsx("ul",{className:"divide-y divide-slate-800/70",children:F.map(n=>{const i=qe(n),g=n.name?.trim()||n.attribution?.trim(),j=n.attribution?.trim(),v=Gt(n)?Xt(n.key_type):null,A=v?cs[n.key_type]||Ke:null;return e.jsxs("li",{className:"flex items-center justify-between gap-3 px-5 py-3 sm:px-6",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:`rounded-lg p-2 ${v?"bg-cyan-500/10 text-cyan-400":"bg-emerald-500/10 text-emerald-400"}`,children:v?e.jsx(Ke,{className:"h-4 w-4"}):e.jsx($,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium text-white truncate",children:g||e.jsx("span",{className:"text-slate-400 italic",children:"Unnamed key"})}),v&&e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-cyan-500/10 px-2 py-0.5 text-[11px] font-medium text-cyan-300",children:[e.jsx(A,{className:"h-3 w-3"}),"Monitor · ",v.label]})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-slate-500",children:[i&&e.jsxs("span",{className:"font-mono",title:i,children:["ID: ",i.slice(0,8)]}),e.jsxs("span",{title:j?"Runs bill to this memberâs seat when they are seated":"No seat assigned",children:["Seat: ",j||"Unassigned"]}),e.jsxs("span",{children:["Created ",Ve(n.created_date)]}),e.jsxs("span",{children:["Expires ",Ve(n.expiration_date)]})]})]})]}),e.jsxs("button",{type:"button",onClick:()=>h(n),className:"shrink-0 inline-flex items-center gap-1 rounded-md border border-red-400/30 bg-red-500/10 px-2.5 py-1.5 text-xs font-medium text-red-300 transition-colors hover:bg-red-500/20","aria-label":`Revoke ${g||"API key"}`,children:[e.jsx(_,{className:"w-3 h-3"}),"Revoke"]})]}
1,i||n.user_id)})})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 sm:px-6 py-3 border-t border-slate-800 text-xs text-slate-400",children:[e.jsx("span",{children:u.length===0?"0 keys":`${(y-1)*q+1}-${Math.min(y*q,u.length)} of ${u.length}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>b(n=>Math.max(1,n-1)),disabled:y<=1,className:"inline-flex items-center gap-1 rounded-md border border-slate-700 bg-slate-900 px-2 py-1 text-xs font-medium text-slate-300 transition-colors hover:border-slate-600 hover:bg-slate-800 disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Previous page",children:[e.jsx(At,{className:"w-3 h-3"}),"Prev"]}),e.jsxs("span",{className:"px-2 tabular-nums",children:["Page ",y," of ",w]}),e.jsxs("button",{type:"button",onClick:()=>b(n=>Math.min(w,n+1)),disabled:y>=w,className:"inline-flex items-center gap-1 rounded-md border border-slate-700 bg-slate-900 px-2 py-1 text-xs font-medium text-slate-300 transition-colors hover:border-slate-600 hover:bg-slate-800 disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Next page",children:["Next",e.jsx(Tt,{className:"w-3 h-3"})]})]})]})]})}):null}fe.propTypes={isOpen:N.bool.isRequired,onClose:N.func.isRequired,apiKeys:N.array,loading:N.bool,onDelete:N.func.isRequired,createHref:N.string};fe.defaultProps={apiKeys:[],loading:!1,createHref:"/request-api-key"};function ds(s){if(!s)return!1;const c=new Date(String(s).replace(" ","T"));if(Number.isNaN(c.getTime()))return!1;const r=new Date;return c.getFullYear()===r.getFullYear()&&c.getMonth()===r.getMonth()&&c.getDate()===r.getDate()}function ms(s){if(!s)return"Not yet accepted";const c=s.replace(" ","T"),r=new Date(c);return Number.isNaN(r.getTime())?s:r.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Ge(s){return s?.api_key_id||s?.id||s?.key_id||null}const Ss=()=>{const{getValidToken:s,accessToken:c,clearTokens:r}=Dt(),{seatLicensed:x,seatMonitored:h,seatSubscription:o,refreshSeatStatus:m}=_t(),[p,S]=l.useState([]),[b]=Lt(),[a,f]=l.useState(null),{activeAccount:u,accounts:w,setActiveAccount:y}=Et(),{start:F}=Pt(),n=Mt(),i=(u?.account_type??"personal")==="personal",g=!i&&u?.role==="admin",[j,v]=l.useState(!1),[A,T]=l.useState(""),[H,ge]=l.useState(!1),[Ze,ee]=l.useState(!1),[te,Je]=l.useState(null),[G,Ne]=l.useState(!1),[Qe,et]=l.useState(null),ye=async()=>{Ne(!0),T("");try{const t=await qt(s);if(t?.portal_url){window.location.assign(t.portal_url);return}T("Could not open the billing portal.")}catch(t){T(t.message||"Could not open the billing portal.")}finally{Ne(!1)}};l.useEffect(()=>{let t=!1;return It(s).then(d=>{t||Je(d)}).catch(()=>{}),()=>{t=!0}},[s]);const je=te?.unitAmount!=null?`$${(te.unitAmount/100).toFixed(0)}/${te.interval||"month"}`:"$15/month",K=(o?.cancel_at_period_end?o.current_period_end:null)||Qe,tt=async()=>{ge(!0),T("");try{const t=await Bt(s);ee(!1),t?.cancel_at_period_end&&t?.current_period_end&&et(t.current_period_end),await m()}catch(t){T(t?.status===502?"Couldn't confirm the cancellation with Stripe â nothing changed, please try again.":t.message||"Could not cancel the Seat License.")}finally{ge(!1)}};l.useEffect(()=>{const t=Ht(b);t&&(f(t),n("/account",{replace:!0}))},[b,n]),l.useEffect(()=>{if(o?.plan!=="seat")return;let t=!1;return Rt(s).then(d=>{t||S(d)}).catch(()=>{}),()=>{t=!0}},[o?.plan,s]);const we=async()=>{v(!0),T("");try{const t=await Yt(s,{email:h?void 0:L?.email,seats:o?.seats_used??1});if(t?.checkout_url){window.location.assign(t.checkout_url);return}await m()}catch(t){T(t.message||"Could not start the Seat License purchase.")}finally{v(!1)}},{runs:ve,runsLoading:st,accountData:L,accountLoading:at,apiKeys:se,apiKeyLoading:ke,usage:lt,usageLoading:rt,refreshRuns:nt,refreshAccountData:it,refreshApiKeyStatus:Ce,refreshUsage:ot}=Ot(),[D,ct]=l.useState([]),[P,Se]=l.useState([]),[M,dt]=l.useState({name:"",balance:0,kycStatus:"pending",termsAccepted:!1,lastTermsAcceptedTime:null}),I=P.length>0,[ae,mt]=l.useState(!1),X=st||at||ke;l.useEffect(()=>{nt(),it(),Ce(),ot()},[]),l.useEffect(()=>{ct($t(ve))},[ve]),l.useEffect(()=>{L&&dt(t=>({...t,name:L.first_name||t.name,balance:L.credits??t.balance,termsAccepted:L.terms_accepted??t.termsAccepted,lastTermsAcceptedTime:L.last_terms_accepted_time??t.lastTermsAcceptedTime}))},[L]),l.useEffect(()=>{Array.isArray(se)&&Se(se)},[se]);const[xt,le]=l.useState(!1),[ut,Ae]=l.useState(!1),[re,Te]=l.useState(null),[ne,ie]=l.useState(!1),[De,R]=l.useState(""),[ht,W]=l.useState(!1),[oe,ce]=l.useState(!1),[_e,k]=l.useState(""),[Le,O]=l.useState([]),[pt,Ee]=l.useState(!1),[de,me]=l.useState(!1),[Pe,z]=l.useState(""),[xe,Me]=l.useState(""),bt=t=>{Te(t),R(""),Ae(!0)},ue=()=>{Ae(!1),Te(null),R("")},ft=()=>{k(""),O([]),W(!0)},gt=()=>{z(""),O([]),Me(""),Ee(!0)},Ie=()=>{Ee(!1),z(""),O([])},Re=async t=>{const d=await t.json().catch(()=>({}));return{message:d?.message||"",blockers:Array.isArray(d?.result?.blockers)?d.result.blockers:[]}},Nt=async()=>{me(!0),z(""),O([]);const t=s();if(!t){me(!1),n("/login");return}try{const d=await fetch("https://api.bluelanternsecurity.io/accounts",{method:"DELETE",headers:{Authorization:`${t}`,"Content-Type":"application/json","X-Account-Id":u.account_id},body:JSON.stringify({confirm_name:xe.trim()})});if(d.ok){const E=w.find(kt=>kt.account_type==="personal");E?y(E.account_id):window.location.reload();return}const{message:C,blockers:U}=await Re(d);O(U),z(C||"Failed to delete the organization. Please try again.")}catch(d){console.error("Error deleting organization",d),z("An unexpected error occurred. Please try again.")}me(!1)},yt=async()=>{const t=Ge(re);if(!t){R("Unable to determine which key to revoke. Please refresh and try again.");return}ie(!0),R("");const d=s();if(!d){ie(!1),n("/login");return}try{(await fetch("https://api.bluelanternsecurity.io/api-keys",{method:"DELETE",headers:{Authorization:`${d}`,"Content-Type":"application/json"},body:JSON.stringify({api_key_id:t})})).ok?(Se(U=>U.filter(E=>Ge(E)!==t)),ue(),Ce()):R("Failed to revoke API key. Please try again.")}catch(C){console.error("Error deleting API key",C),R("An unexpected error occurred while revoking the API key. Please try again.")}finally{ie(!1)}},jt=async()=>
1{if(I){k("Revoke all active API keys before deleting your account.");return}ce(!0),k("");const t=s();if(!t){ce(!1),n("/login");return}try{const d=await fetch("https://api.bluelanternsecurity.io/delete-account",{method:"POST",headers:{Authorization:`${t}`,"Content-Type":"application/json"},body:JSON.stringify({access_token:c})});if(d.ok){r(),n("/login");return}else if(d.status===409){const{blockers:C}=await Re(d);O(C),k("Resolve the items below before deleting your account.")}else k("Failed to delete account. Please try again or contact support.")}catch(d){console.error("Error deleting account",d),k("An unexpected error occurred. Please try again.")}ce(!1)},Oe=t=>{switch(t?.toUpperCase()){case"COMPLETED":case"COMPLETE":case"SUCCESS":return"text-emerald-400 bg-emerald-400/10 border-emerald-400/20";case"FILTERED":return"text-violet-400 bg-violet-400/10 border-violet-400/20";case"FAILED":case"FAILURE":return"text-red-400 bg-red-400/10 border-red-400/20";case"QUEUED":case"PENDING":return"text-yellow-400 bg-yellow-400/10 border-yellow-400/20";default:return"text-slate-400 bg-slate-400/10 border-slate-400/20"}},$e=t=>{switch(t?.toUpperCase()){case"COMPLETED":case"COMPLETE":case"SUCCESS":return e.jsx(pe,{className:"w-4 h-4"});case"FILTERED":return e.jsx(es,{className:"w-4 h-4"});case"FAILED":case"FAILURE":return e.jsx(Z,{className:"w-4 h-4"});default:return e.jsx(Ue,{className:"w-4 h-4"})}},Fe=D.slice(0,ae?void 0:5),wt=Ft(D),vt=()=>{Vt(D)};return e.jsxs("div",{className:"min-h-screen bg-slate-950 px-4 pb-12 pt-24 text-white sm:px-6",children:[e.jsxs("div",{className:"max-w-7xl mx-auto space-y-6 sm:space-y-8",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-3xl border border-slate-800 bg-slate-900 p-6 shadow-2xl sm:p-8",children:[e.jsx("div",{className:"absolute top-0 right-0 -mr-20 -mt-20 w-96 h-96 bg-blue-500/10 rounded-full blur-3xl pointer-events-none"}),e.jsx("div",{className:"absolute bottom-0 left-0 -ml-20 -mb-20 w-80 h-80 bg-purple-500/10 rounded-full blur-3xl pointer-events-none"}),e.jsxs("div",{className:"relative z-10 flex flex-col justify-between gap-6 md:flex-row md:items-center",children:[e.jsxs("div",{"data-tour":"account-summary",children:[e.jsx("h1",{className:"mb-2 text-2xl font-bold text-white sm:text-3xl",children:"Account Overview"}),e.jsxs("p",{className:"text-slate-400",children:["Welcome back, ",M.name]}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:I?e.jsxs("button",{type:"button",onClick:()=>le(!0),className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 transition-colors text-xs font-medium",children:[e.jsx($,{className:"w-3 h-3"}),"Manage API Keys (",P.length,")"]}):e.jsxs(V,{to:"/request-api-key",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-blue-500/10 border border-blue-500/20 text-blue-400 hover:bg-blue-500/20 transition-colors text-xs font-medium group",children:[e.jsx($,{className:"w-3 h-3"}),"Request API Key",e.jsx("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity ml-1",children:"â"})]})}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:e.jsxs("a",{href:`https://auth.bluelanternsecurity.io/passkeys/add?client_id=1eg0krtt4b3uem3hetq0pdpc29&redirect_uri=${encodeURIComponent("https://bluelanternsecurity.io/login-success")}`,className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-purple-500/10 border border-purple-500/20 text-purple-300 hover:bg-purple-500/20 transition-colors text-xs font-medium group",children:[e.jsx(Kt,{className:"w-3 h-3"}),"Add Passkey",e.jsx("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity ml-1",children:"â"})]})})]}),e.jsxs("div",{"data-tour":"credits-and-seats",className:"flex w-full flex-col gap-4 roun
1ded-2xl border border-slate-800/50 bg-slate-950/50 p-4 backdrop-blur-sm md:w-[340px]",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-slate-400 font-medium uppercase tracking-wider mb-1",children:"Plan"}),e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsx("span",{className:`text-2xl font-bold sm:text-3xl ${x?"text-emerald-300":"text-white"}`,children:x?"Seat License":"Free Tier"})}),!x&&e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:i?"30 free Scan Now runs per day. Monitoring, integrations, and API keys require a Seat License.":"Shared accounts run on seats only. Add seats to enable scans, monitoring, and API keys."})]}),e.jsxs("div",{className:"border-t border-slate-800/70 pt-4",children:[e.jsx("p",{className:"text-xs text-slate-400 font-medium uppercase tracking-wider mb-1",children:"Seat License"}),x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-semibold text-emerald-300",children:[e.jsx(he,{className:"w-4 h-4"}),"Active"]}),e.jsxs("p",{className:"mt-1 text-xs text-slate-500",children:["Covers monitoring, integrations, and API access for one person, up to 500 runs per day.",!K&&o?.current_period_end?` Renews ${new Date(o.current_period_end).toLocaleDateString()}.`:""]}),K?e.jsxs("p",{className:"mt-2 text-xs font-semibold text-amber-400",children:["Cancels on ",new Date(K).toLocaleDateString()," â active until then."]}):i&&(Ze?e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-slate-400",children:"Cancel your Seat License?"}),e.jsxs("button",{type:"button",onClick:tt,disabled:H,className:"inline-flex items-center gap-1 text-xs font-semibold text-red-400 transition-colors hover:text-red-300 disabled:opacity-50",children:[H&&e.jsx(B,{className:"w-3 h-3 animate-spin"}),H?"Schedulingâ¦":"Yes, cancel"]}),e.jsx("button",{type:"button",onClick:()=>ee(!1),disabled:H,className:"text-xs text-slate-500 transition-colors hover:text-slate-300",children:"Keep"})]}):e.jsx("button",{type:"button",onClick:()=>{T(""),ee(!0)},className:"mt-2 text-xs font-medium text-slate-500 transition-colors hover:text-red-400",children:"Cancel license"})),A&&e.jsx("p",{className:"mt-2 text-xs text-red-400",children:A})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-slate-400",children:"No active license."}),i?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:we,disabled:j,className:"mt-2 inline-flex w-full items-center justify-center gap-2 rounded-lg bg-emerald-600 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-50 sm:w-auto",children:[j?e.jsx(B,{className:"w-4 h-4 animate-spin"}):e.jsx(he,{className:"w-4 h-4"}),"Purchase Seat License · ",je]}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-slate-500",children:"A Seat License unlocks continuous monitoring, org integrations, and API keys, up to 500 runs per day."}),A&&e.jsx("p",{className:"mt-2 text-xs text-red-400",children:A})]}):e.jsx(V,{to:"/organization",className:"mt-2 inline-flex items-center gap-1.5 text-sm font-medium text-cyan-300 transition-colors hover:text-cyan-200",children:"Manage seats in Organization â"})]})]}),o?.plan==="seat"&&e.jsx("div",{className:"border-t border-slate-800/70 pt-4",children:e.jsxs("button",{type:"button",onClick:ye,disabled:G,className:"inline-flex items-center gap-2 text-xs font-medium text-slate-400 transition-colors hover:text-white disabled:opacity-50",children:[G?e.jsx(B,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(ze,{className:"w-3.5 h-3.5"}),"Manage billing & invoices"]})})]})]})]}),a&&e.jsxs("div",{className:`flex flex-col gap-3 rounded-2xl border p-5 sm:flex-row sm:items-center sm:justify-between ${a.ok?"border-emerald-500/20 bg-emerald-500/5":"border-amber-500/20 bg-amber-500/5"}`,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[a.ok?e.jsx(pe,{className:"mt-0.5 h-5 w-5 shrink-0 text-emerald-400"}):e.jsx(Z,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:a.ok?"Outlook.com mailbox connected":"Mailbox not connected"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:a.message})]})]}),e.jsx(V,{to:a.ok?"/monitoring-hub":"/integrations",className:"shrink-0 rounded-lg border border-slate-700 px-4 py-2 text-sm font-medium text-slate-200 transition-colors hover:border-slate-600 hover:text-white",children:a.ok?"Open Monitoring Hub":"Back to Integrations"})]}),!x&&i&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-cyan-500/20 bg-cyan-500/5 p-5 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-white",children:"You're on the Free Tier"}),e.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"30 Scan Now runs a day. Add a seat to turn on continuous monitoring, org integrations, and API keys."})]}),e.jsxs("button",{type:"button",onClick:we,disabled:j,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-lg bg-cyan-600 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-cyan-500 disabled:cursor-not-allowed disabled:opacity-50",children:[j?e.jsx(B,{className:"h-4 w-4 animate-spin"}):e.jsx(he,{className:"h-4 w-4"}),"Add a seat · ",je]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3 md:gap-6",children:[e.jsxs("div",{className:"group relative overflow-hidden rounded-2xl border border-slate-800 bg-slate-900 p-5 transition-colors hover:border-slate-700 sm:p-6",children:[e.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx(J,{className:"h-20 w-20 text-blue-400 sm:h-24 sm:w-24"})}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("p",{className:"text-slate-400 text-sm font-medium",children:"Scans (7 Days)"}),e.jsx("p",{className:"mt-2 text-2xl font-bold text-white sm:text-3xl",children:D.filter(t=>zt(t.rawDate)).length})]})]}),e.jsxs("div",{className:"group relative overflow-hidden rounded-2xl border border-slate-800 bg-slate-900 p-5 transition-colors hover:border-slate-700 sm:p-6",children:[e.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx(Jt,{className:"h-20 w-20 text-purple-400 sm:h-24 sm:w-24"})}),e.jsxs("div",{className:"relative z-10",children:[e.jsxs("p",{className:"text-slate-400 text-sm font-medium",children:["Scans Today",x?"":" (of 30 free)"]}),e.jsx("p",{className:"mt-2 text-2xl font-bold text-white sm:text-3xl",children:D.filter(t=>ds(t.rawDate)).length})]})]}),e.jsxs("div",{className:"group relative overflow-hidden rounded-2xl border border-slate-800 bg-slate-900 p-5 transition-colors hover:border-slate-700 sm:p-6",children:[e.jsx("div",{className:"absolute top-0 right-0 p-4 opacity-10 group-hover:opacity-20 transition-opacity",children:e.jsx(Ue,{className:"h-20 w-20 text-emerald-400 sm:h-24 sm:w-24"})}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("p",{className:"text-slate-400 text-sm font-medium",children:"Last Activity"}),e.jsx("p",{className:"mt-2 text-2xl font-bold text-white sm:text-3xl",children:wt})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3 lg:gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(We,{usageData:lt??[],loading:rt}),e.jsxs("div",{className:"bg-slate-900 border border-slate-800 rounded-2xl overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex flex-col gap-4 border-b border-slate-800 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-white flex items-center gap-2",children:"Scan Activity"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Showing scan activity from the last 7 days."})]}),e.jsx("div",{className:"flex gap-3",children:e.jsxs("button",{onClick:vt,className:"flex w-full items-center justify-center gap-2 rounded-lg px-3 py-2 text-sm text-slate-400 transition-colors hover:bg-slate-800 hover:text-white sm:w-auto
1sm:justify-start sm:py-1.5",children:[e.jsx(Qt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Download CSV"}),e.jsx("span",{className:"sm:hidden",children:"Export CSV"})]})})]}),e.jsxs("div",{className:"divide-y divide-slate-800/50 md:hidden",children:[X?e.jsx("div",{className:"p-8 text-center text-slate-500",children:"Loading..."}):Fe.map(t=>e.jsx("article",{className:"p-4 sm:p-5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"rounded-xl bg-blue-500/10 p-2.5 text-blue-400",children:e.jsx(J,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-white",children:t.toolName}),e.jsx("div",{className:"mt-1 text-xs text-slate-500",children:t.action})]}),e.jsxs("span",{className:`inline-flex w-fit items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium ${Oe(t.status)}`,children:[$e(t.status),t.status]})]}),e.jsxs("div",{className:"mt-4 rounded-xl border border-slate-800 bg-slate-950/40 p-3",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-slate-500",children:"Run Date"}),e.jsx("div",{className:"mt-1 text-sm text-slate-300",children:t.date})]})]})]})},t.id)),!X&&D.length===0&&e.jsx("div",{className:"p-8 text-center text-slate-500",children:"No activity found."})]}),e.jsx("div",{className:"hidden overflow-x-auto md:block",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{className:"bg-slate-950/50 text-slate-400 text-xs uppercase tracking-wider font-semibold border-b border-slate-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4 font-medium text-center",children:"Tool Name"}),e.jsx("th",{className:"px-6 py-4 font-medium text-center",children:"Date"}),e.jsx("th",{className:"px-6 py-4 font-medium text-center",children:"Status"})]})}),e.jsxs("tbody",{className:"divide-y divide-slate-800/50",children:[X?e.jsx("tr",{children:e.jsx("td",{colSpan:"3",className:"p-8 text-center text-slate-500",children:"Loading..."})}):Fe.map(t=>e.jsxs("tr",{className:"group hover:bg-slate-800/30 transition-colors",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-500/10 text-blue-400 group-hover:bg-blue-500/20 transition-colors",children:e.jsx(J,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-white",children:t.toolName}),e.jsx("div",{className:"text-xs text-slate-500 mt-0.5",children:t.action})]})]})}),e.jsx("td",{className:"px-6 py-4 text-sm text-slate-400 text-center",children:t.date}),e.jsx("td",{className:"px-6 py-4 text-center",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${Oe(t.status)}`,children:[$e(t.status),t.status]})})]},t.id)),!X&&D.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:"3",className:"p-12 text-center text-slate-500",children:"No activity found."})})]})]})}),D.length>5&&e.jsx("div",{className:"p-4 border-t border-slate-800 text-center",children:e.jsx("button",{onClick:()=>mt(!ae),className:"text-sm text-blue-400 hover:text-blue-300 font-medium transition-colors",children:ae?"Show Fewer":"View All Scans (7 Days)"})})]})]}),e.jsx("div",{className:"lg:col-span-1",children:e.jsxs("div",{className:"overflow-hidden rounded-2xl border border-slate-800 bg-slate-900 lg:sticky lg:top-24",children:[e.jsx("div",{className:"flex items-center justify-between border-b border-slate-800 p-5 sm:p-6",children:e.jsx("h2",{className:"text-lg font-bold text-white flex items-center gap-2",children:"Subscription"})}),e.jsxs("div",{className:"divide-y divide-slate-800/50",children:[e.jsxs("div",{className:"p-4 sm:p-5",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-slate-500",children:"Plan"}),e.jsx("p",{className:`mt-1 text-sm font-semibold ${x?"text-emerald-300":"text-white"}`,children:o?.plan==="seat"?"Seat License":i?"Free Tier":"No seat plan"}),o?.status&&e.jsx("p",{className:"mt-0.5 text-xs capitalize text-slate-500",children:o.status})]}),o?.plan==="seat"&&e.jsxs("div",{className:"p-4 sm:p-5",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider text-slate-500",children:"Seats"}),e.jsxs("p",{className:"mt-1 text-sm font-semibold text-white",children:[Number(o.seat_count??0).toLocaleStr
1ing(),Number.isFinite(Number(o.seats_used))&&e.jsxs("span",{className:"font-normal text-slate-500",children:[" · ",Number(o.seats_used).toLocaleString()," in use"]})]}),K?e.jsxs("p",{className:"mt-0.5 text-xs text-amber-400",children:["Cancels on ",new Date(K).toLocaleDateString()]}):o.current_period_end&&e.jsxs("p",{className:"mt-0.5 text-xs text-slate-500",children:["Renews ",new Date(o.current_period_end).toLocaleDateString()]})]}),p.length>0&&e.jsxs("div",{className:"p-4 sm:p-5",children:[e.jsx("p",{className:"mb-2 text-xs uppercase tracking-wider text-slate-500",children:"Purchase history"}),e.jsx("ul",{className:"divide-y divide-slate-800/50",children:p.map(t=>{const d={purchase:"Seat License purchased",renewal:"Renewal",seat_change:"Seat change"}[t.kind]||"Invoice",C=Number.isFinite(Number(t.amount_paid))?new Intl.NumberFormat(void 0,{style:"currency",currency:String(t.currency||"usd").toUpperCase()}).format(Number(t.amount_paid)/100):null,U=t.created_at?new Date(String(t.created_at).replace(" ","T")).toLocaleDateString():"",E=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-white",children:d}),C&&e.jsx("span",{className:"text-sm text-slate-300",children:C})]}),e.jsxs("div",{className:"mt-0.5 flex items-center justify-between gap-3 text-xs text-slate-500",children:[e.jsx("span",{children:Number.isFinite(Number(t.seat_count))?`${Number(t.seat_count).toLocaleString()} seat${Number(t.seat_count)===1?"":"s"}`:""}),e.jsx("span",{children:U})]})]});return e.jsx("li",{className:"py-2.5 first:pt-0 last:pb-0",children:t.hosted_invoice_url?e.jsx("a",{href:t.hosted_invoice_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-md transition-colors hover:text-cyan-200",title:"Open invoice in Stripe",children:E}):E},t.stripe_invoice_id)})})]}),e.jsx("div",{className:"p-4 sm:p-5",children:o?.plan==="seat"?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-slate-500",children:p.length>0?"Receipts and payment methods live in the Stripe billing portal.":"Invoices, receipts, and payment methods live in the Stripe billing portal."}),e.jsxs("button",{type:"button",onClick:ye,disabled:G,className:"mt-3 inline-flex items-center gap-2 text-sm font-medium text-cyan-300 transition-colors hover:text-cyan-200 disabled:opacity-50",children:[G?e.jsx(B,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(ze,{className:"w-3.5 h-3.5"}),"View invoices"]})]}):e.jsx("p",{className:"text-xs text-slate-500",children:i?"No subscription yet. Invoice history appears here once you add a seat.":"No subscription yet. Seats are managed on the Organization page."})})]})]})})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-800 bg-slate-900 p-5 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-400",children:"Product tour"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:"Walk through where everything lives: running a scan, monitor keys, agents, seats, and team setup."})]}),e.jsxs("button",{type:"button",onClick:F,className:"inline-flex w-full items-center justify-center gap-2 rounded-xl border border-slate-700 bg-slate-950/60 px-4 py-2.5 text-sm font-medium text-slate-300 transition-colors hover:border-slate-600 hover:text-white md:w-auto",children:[e.jsx(Ut,{className:"w-4 h-4"}),"Replay Tour"]})]}),e.jsx("div",{className:"my-5 h-px bg-slate-800"}),e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-400",children:"Terms of Service"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-medium ${M.termsAccepted?"border-emerald-500/20 bg-emerald-500/10 text-emerald-400":"border-amber-500/20 bg-amber-500/10 text-amber-400"}`,children:[M.termsAccepted?e.jsx(pe,{className:"w-3.5 h-3.5"}):e.jsx(Z,{className:"w-3.5 h-3.5"}),M.termsAccepted?"Accepted":"Pending acceptance"]}),e.jsx("span",{className:"text-sm text-slate-500",children:M.termsAccepted?`Accepted ${ms(M.lastTermsAcceptedTime)}`:"Acceptance is required for protected product access."})]})]}),e.jsx(V,{to:"/terms",className:"inline-flex w-full items-center justify-center gap-2 rounded-xl border border-slate-700 bg-slate-950/60 px-4 py-2.5 text-sm font-medium text-slate-300 transition-colors hover:border-slate-600 hover:text-white md:w-auto",children:"Review Terms"})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-5 h-px bg-slate-800"}),e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-red-400 flex items-center gap-2",children:[e.jsx(Be,{className:"w-4 h-4"}),"Delete Account"]}),e.jsx("p",{className:"mt-2 text-sm text-slate-400",children:"Permanently delete your login, your personal account, and any organization where you are the only member, with all of their data. This action cannot be undone."}),I&&e.jsx("p",{className:"mt-2 text-sm text-amber-400",children:"You must revoke all active API keys before account deleti
1on can be completed."})]}),e.jsxs("button",{onClick:ft,className:"inline-flex w-full items-center justify-center gap-2 rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-2.5 text-sm font-medium text-red-400 transition-colors hover:bg-red-500/20 hover:border-red-500/40 hover:text-red-300 md:w-auto",children:[e.jsx(_,{className:"w-4 h-4"}),"Delete Account"]})]})]}),g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"my-5 h-px bg-slate-800"}),e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-red-400 flex items-center gap-2",children:[e.jsx(_,{className:"w-4 h-4"}),"Delete Organization"]}),e.jsxs("p",{className:"mt-2 text-sm text-slate-400",children:["Permanently delete ",u?.name||"this organization"," and all of its data for every member. Your own login and personal account are not affected."]})]}),e.jsxs("button",{onClick:gt,className:"inline-flex w-full items-center justify-center gap-2 rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-2.5 text-sm font-medium text-red-400 transition-colors hover:bg-red-500/20 hover:border-red-500/40 hover:text-red-300 md:w-auto",children:[e.jsx(_,{className:"w-4 h-4"}),"Delete Organization"]})]})]})]})]}),e.jsx(fe,{isOpen:xt,onClose:()=>le(!1),apiKeys:P,loading:ke,onDelete:bt,createHref:"/request-api-key"}),ut&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-slate-900 border border-slate-800 rounded-2xl p-6 w-full max-w-md
1shadow-2xl relative animate-in fade-in zoom-in-95 duration-200",children:[e.jsx("button",{onClick:ue,className:"absolute top-4 right-4 text-slate-400 hover:text-white transition-colors",children:e.jsx(Q,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[e.jsx("div",{className:"p-3 bg-red-500/10 text-red-400 rounded-full",children:e.jsx(Z,{className:"w-8 h-8"})}),e.jsx("h3",{className:"text-xl font-bold text-white",children:"Revoke API Key?"}),e.jsxs("p",{className:"text-slate-400 text-sm leading-relaxed",children:["Are you sure you want to delete the API key",re?.attribution?.trim()?e.jsxs(e.Fragment,{children:[" ",e.jsxs("span",{className:"font-semibold text-white",children:["â",re.attribution.trim(),"â"]})]}):"","? Any applications currently using this key will immediately lose access. This action cannot be undone."]}),De&&e.jsx("div",{className:"w-full bg-red-500/10 border border-red-500/20 rounded-xl p-3 text-red-400 text-sm",children:De}),e.jsxs("div",{className:"flex w-full flex-col-reverse gap-3 pt-2 sm:flex-row",children:[e.jsx("button",{onClick:ue,className:"flex-1 px-4 py-2 bg-slate-800 hover:bg-slate-700 text-white rounded-xl font-medium transition-colors",disabled:ne,children:"Cancel"}),e.jsx("button",{onClick:yt,className:"flex-1 px-4 py-2 bg-red-600 hover:bg-red-500 text-white rounded-xl font-medium transition-colors flex items-center justify-center gap-2",disabled:ne,children:ne?e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"w-4 h-4"}),"Revoke Key"]})})]})]})]})}),ht&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-slate-900 border border-slate-800 rounded-2xl p-6 w-full max-w-md
1shadow-2xl relative animate-in fade-in zoom-in-95 duration-200",children:[e.jsx("button",{onClick:()=>{W(!1),k("")},className:"absolute top-4 right-4 text-slate-400 hover:text-white transition-colors",children:e.jsx(Q,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[e.jsx("div",{className:"p-3 bg-red-500/10 text-red-400 rounded-full",children:e.jsx(Be,{className:"w-8 h-8"})}),e.jsx("h3",{className:"text-xl font-bold text-white",children:I?"Revoke API Keys First":"Delete Your Account?"}),I?e.jsxs("div",{className:"w-full space-y-3",children:[e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-amber-400 mb-1",children:[e.jsx($,{className:"w-4 h-4"}),e.jsxs("span",{className:"text-sm font-semibold",children:[P.length," Active API Key",P.length===1?"":"s"," Detected"]})]}),e.jsxs("p",{className:"text-sm text-amber-100/80",children:["This account still has active API key",P.length===1?"":"s","."]})]}),e.jsx("p",{className:"text-slate-400 text-sm leading-relaxed",children:"To prevent orphaned credentials, you must revoke every API key before Blue Lantern can finalize account deletion. Use the API Keys section to revoke them, then return here."})]}):e.jsx("p",{className:"text-slate-400 text-sm leading-relaxed",children:"This will permanently delete your login, your personal account, and any organization where you are the only member, including all runs, reports, devices, integrations and alert rules. You will be removed from organizations you share with others. Purchase records are kept for billing. This action is irreversible."}),_e&&e.jsx("div",{className:"w-full bg-red-500/10 border border-red-500/20 rounded-xl p-3 text-red-400 text-sm",children:_e}),Le.length>0&&e.jsx("ul",{className:"w-full space-y-2 text-left",children:Le.map(t=>e.jsxs("li",{className:"rounded-xl border border-amber-500/20 bg-amber-500/10 p-3 text-sm",children:[e.jsx("span",{className:"font-semibold text-amber-300",children:t.name||"Account"}),e.jsx("span",{className:"block text-amber-100/80",children:t.reason})]},t.account_id))}),e.jsxs("div",{className:"flex w-full flex-col-reverse gap-3 pt-2 sm:flex-row",children:[e.jsx("button",{onClick:()=>{W(!1),k("")},className:"flex-1 px-4 py-2 bg-slate-800 hover:bg-slate-700 text-white rounded-xl font-medium transition-colors",disabled:oe,children:"Cancel"}),I?e.jsxs("button",{onClick:()=>{W(!1),k(""),le(!0)},className:"flex-1 px-4 py-2 bg-amber-600 hover:bg-amber-500 text-white rounded-xl font-medium transition-colors flex items-center justify-center gap-2",children:[e.jsx($,{className:"w-4 h-4"}),"Manage API Keys"]}):e.jsx("button",{onClick:jt,className:"flex-1 px-4 py-2 bg-red-600 hover:bg-red-500 text-white rounded-xl font-medium transition-colors flex items-center justify-center gap-2",disabled:oe,children:oe?e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"w-4 h-4"}),"Delete Account"]})})]})]})]})}),pt&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-slate-900 border border-slate-800 rounded-2xl p-6 w-full max-w-md
1shadow-2xl relative animate-in fade-in zoom-in-95 duration-200",children:[e.jsx("button",{onClick:Ie,className:"absolute top-4 right-4 text-slate-400 hover:text-white transition-colors",children:e.jsx(Q,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex flex-col items-center text-center space-y-4",children:[e.jsx("div",{className:"p-3 bg-red-500/10 text-red-400 rounded-full",children:e.jsx(_,{className:"w-8 h-8"})}),e.jsxs("h3",{className:"text-xl font-bold text-white",children:["Delete ",u?.name,"?"]}),e.jsx("p",{className:"text-slate-400 text-sm leading-relaxed",children:"This permanently deletes the organization for every member: all runs, reports, devices, integrations and their credentials, alert rules, API keys and memberships. Purchase records are kept for billing. Any seat subscription must be cancelled first. This action is irreversible."}),e.jsxs("label",{className:"w-full text-left text-sm text-slate-300",children:["Type ",e.jsx("span",{className:"font-semibold text-white",children:u?.name})," to confirm",e.jsx("input",{type:"text",value:xe,onChange:t=>Me(t.target.value),className:"mt-2 w-full rounded-xl border border-slate-700 bg-slate-950/60 px-3 py-2 text-white focus:border-red-500/50 focus:outline-none",autoComplete:"off"})]}),Pe&&e.jsx("div",{className:"w-full bg-red-500/10 border border-red-500/20 rounded-xl p-3 text-red-400 text-sm",children:Pe}),e.jsxs("div",{className:"flex w-full flex-col-reverse gap-3 pt-2 sm:flex-row",children:[e.jsx("button",{onClick:Ie,className:"flex-1 px-4 py-2 bg-slate-800 hover:bg-slate-700 text-white rounded-xl font-medium transition-colors",disabled:de,children:"Cancel"}),e.jsx("button",{onClick:Nt,className:"flex-1 px-4 py-2 bg-red-600 hover:bg-red-500 disabled:opacity-50 disabled:hover:bg-red-600 text-white rounded-xl font-medium transition-colors flex items-center justify-center gap-2",disabled:de||xe.trim()!==(u?.name||"").trim(),children:de?e.jsx("div",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"w-4 h-4"}),"Delete Organization"]})})]})]})]})})]})};export{Ss as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.