1import{j as e,r as p,u as et,e as st}from"./vendor-react-Dqm4a0k5.js";import{M as tt,j as fe,N as ts}from"./MobileTabGrid-D3o1zdIa.js";import{s as S,C as b,a as y,g as R,e as U,f as V,c as k,J as $,B as w,u as bs,h as Y,y as He,Y as as,z as Ye,ak as at}from"./index-BR-ShKyk.js";import{T as Ne,a as Pe,b as q,c as O,d as rt}from"./ComprehensiveEmailSystemTester-D2oSdOs7.js";import{u as se,a as lt,R as nt,b as it,c as Xe,d as ws,e as ot,f as ct,C as Le}from"./useReportAlternative-CJ-aTbIu.js";import{I as ee}from"./validation-DfDrtHjz.js";import{S as W,a as Q,b as X,c as J,d as I}from"./categories-DVobXU6A.js";import{a as ce,u as te,b as re}from"./vendor-query-BQV4-hhd.js";import{S as me,a as dt,u as mt}from"./licenseCodes-gVoUkkH-.js";import{ar as de,au as je,av as ys,e as xe,s as le,T as E,a6 as ks,D as _s,aP as Z,S as ae,bL as ut,bM as Cs,af as Ae,aE as Oe,O as ve,X as Je,r as Me,v as Be,p as ie,aT as xt,aU as ht,h as ft,bt as Fe,j as Ze,aq as pt,i as gt,a4 as jt,f as vt,A as Ss,b2 as Ts,ak as Nt,Q as be,E as Re,bN as ge,ae as Ds,R as bt,bO as rs,U as wt,V as ue,aj as ls,b as ns,m as We,M as ne,bP as As,ay as yt,bQ as kt,q as Ls,bR as Ee,L as _t,bS as Ct,l as St}from"./vendor-icons-Dv6Y7wXg.js";import{f as G,g as Tt,O as is,p as _e,Q as Ce,a as Ms}from"./vendor-utils-KLhAiGEE.js";import{R as Dt,a as At,E as Lt}from"./EditAvgCostDialog-SJgVhJsU.js";import{D as Fs,f as Mt,a as Rs,b as Es,c as Is,d as Ft,e as Rt}from"./useOwnedToolCount-wyv1Fa3v.js";import{T as ze}from"./placeholderStyles-DBHPcRYS.js";import{L as B,u as es}from"./useSupportTickets-CNr_YXIK.js";import{T as Et,l as It,m as Pt,n as Ot,a5 as zt,ae as qt,af as Ut,ag as Vt,j as $t,a as Kt,L as Gt}from"./FullShell-D8umUy0n.js";import{S as F}from"./shimmer-DpOdRRUj.js";import{A as Ht,a as Yt,b as Bt,c as Wt,d as Qt,e as Xt,f as Jt,g as Zt}from"./CategoryPicker-PGHuajy7.js";import{R as Se,P as ea,s as sa,q as os,T as Te,v as cs,r as ds,t as Ve,X as $e,Y as Ke,B as Ge,A as ta}from"./PieChart-NNT8RMQh.js";import{A as aa,u as ra}from"./AreaChart-QRCKVOOc.js";import{S as ms,U as la}from"./UpgradeModal-WfY9nN7b.js";import{u as na,b as ia,d as oa}from"./useNotificationPreferences-Dpqtbt_N.js";import{S as ca}from"./tapIntent-ChFounVY.js";import{u as Ps}from"./useTeamTools-CB7LIUeC.js";import{e as da,d as ma}from"./ConsoleKit-D6nSHYFq.js";import{M as ua,b as xa}from"./MobileOptimizedLayout-Bn6L9nW0.js";import{u as ha}from"./useDebounce-JJj-9H3L.js";import{A as fa,m as pa}from"./vendor-motion-uI1IlCbt.js";import{W as ga}from"./useWatchlistFlag-BdqMoolJ.js";import{u as ja}from"./use-toast-DL6cPnZQ.js";import{u as va}from"./toolIcon-CtXhzpJG.js";import{u as Na}from"./PageHeader-YF11zZ1Y.js";import{m as ba}from"./featureVisits-BSHlqVTm.js";import"./Breadcrumbs-DyKA5pqw.js";import"./radix-react-slot-CrO6XSQS.js";import"./radix-react-compose-refs-IIetlP92.js";import"./bulkCategorize-h2Op8naW.js";import"./vendor-radix-DFc8vCWX.js";import"./theme-logo-CvMov46y.js";import"./MobilePageTransitionAnimated-lpTtBr8f.js";import"./useEarnStack-5Of8e7D0.js";import"./CommandPalette-QTja5aVJ.js";import"./command-BihCDANY.js";import"./vendor-supabase-RijQlDjE.js";import"./PlanComparisonDrawer-CbPW99uT.js";import"./usePlanManagement-BuZFkxtl.js";import"./useDashboardMetrics-DizIeV6R.js";import"./useBugReports-DNNSx95G.js";import"./dropdown-menu-BeTST-1x.js";import"./useUnifiedToolsData-rJg8g7fP.js";import"./usePlanLimitedData-BmP7rsfl.js";import"./TrialEndedToast-tuQJxlUQ.js";function oe(s){return s.toLowerCase().trim().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ")}function Os(s,t){const r=s.length,l=t.length,a=[];for(let n=0;n<=r;n++)a[n]=[n];for(let n=0;n<=l;n++)a[0][n]=n;for(let n=1;n<=r;n++)for(let i=1;i<=l;i++){const d=s[n-1]===t[i-1]?0:1;a[n][i]=Math.min(a[n-1][i]+1,a[n][i-1]+1,a[n-1][i-1]+d)}return a[r][l]}const wa=4,ya=8,ka=10,_a=1,us=.8,Ca=.75,xs=s=>s.split(" ").filter(Boolean),Sa=[["lifetime","access","to"],["lifetime","deal","to"],["lifetime","subscription","to"],["lifetime","access"],["access","to"]];function Ta(s){for(const t of Sa){if(t.length>=s.length)continue;let r=!0;for(let l=0;l<t.length;l++)if(s[l]!==t[l]){r=!1;break}if(r)return t.length}return 0}function hs(s,t){if(t.length===0||t.length>s.length)return!1;for(const r of[0,Ta(s)]){if(r+t.length>s.length)continue;let l=!0;for(let a=0;a<t.length;a++)if(s[r+a]!==t[a]){l=!1;break}if(l)return!0}return!1}function Qe(s,t){const r=oe(s||""),l=oe(t||"");if(!r||!l)return 0;if(r===l)return _a;const a=xs(r),n=xs(l),i=r.length<=l.length?r:l,d=i.replace(/\s/g,"").length;if(d>=wa&&(hs(a,n)||hs(n,a)))return us;if(d>=ya){const m=(r.length>=l.length?a:n)[0]??"",o=i.replace(/\s/g,"");if(m!==o&&m.startsWith(o))return us}return Math.max(r.length,l.length)>=ka&&Os(r,l)<=1?Ca:0}function zs(s){return s>=.85?"high":s>=.65?"medium":"low"}function Da(s,t){const r=[];for(const a of s)for(const n of t){const i=Qe(a.name,n.product_name);i>=.6&&r.push({userToolId:a.id,userToolName:a.name,failedToolId:n.id,failedToolName:n.product_name,confidence:zs(i),similarityScore:i})}return r.sort((a,n)=>n.similarityScore-a.similarityScore)}const fs=.85,Aa=.6;function ps(s,t){const r=oe(s),l=oe(t);if(!r||!l)return 0;if(r===l)return 1;if(r.includes(l)||l.includes(r))return .85;const a=Math.max(r.length,l.length);return 1-Os(r,l)/a}function La(s,t){const r=ps(s,t);let l=0;const a=oe(t).split(" ").filter(n=>n.length>=2);for(const n of a){const i=ps(s,n);i>l&&(l=i)}return Math.max(r,l)}function Ma(s,t){const r=oe(s??"");if(r.length<2)return[];const l=[];for(const a of t){const n=La(r,a.name);n>=Aa&&l.push({name:a.name,normalized:a.normalized,confidence:zs(n),score:n,toolIds:a.toolIds})}return l.sort((a,n)=>n.score-a.score)}function Fa(s){const t=["Product","Marketplace","Closure Date","Founder(s) Name","Status"],r=s.map(a=>[a.product_name,a.marketplace,a.closure_date?new Date(a.closure_date).toLocaleDateString():"",a.founder_name||"",a.status]);return[t.join(","),...r.map(a=>a.map(n=>`"${n}"`).join(","))].join(` 2`)}function qs(s,t="failed-ltd-tools.csv"){const r=new Blob([s],{type:"text/csv;charset=utf-8;"}),l=document.createElement("a"),a=URL.createObjectURL(r);l.setAttribute("href",a),l.setAttribute("download",t),l.style.visibility="hidden",document.body.appendChild(l),l.click(),document.body.removeChild(l)}const qe=()=>{const{data:s=[]}=se();return ce({queryKey:["tool-matches",s.length],queryFn:async()=>{const{data:{user:t}}=await S.auth.getUser();if(!t)return[];if(s.length===0)return[];const{data:r}=await S.from("tools").select("id, title").eq("user_id",t.id),{data:l}=await S.from("appsumo_products").select("uuid, name").eq("user_id",t.id),a=[...(r||[]).map(i=>({id:i.id,name:i.title})),...(l||[]).map(i=>({id:i.uuid,name:i.name||""}))];return Da(a,s)},enabled:!0})},Ra=s=>{switch(s){case"Shut Down":return{color:"bg-red-500",icon:ks,variant:"destructive"};case"Revoked LTD":return{color:"bg-red-600",icon:E,variant:"destructive"};case"Diminished LTD":return{color:"bg-orange-500",icon:le,variant:"default"};case"Abandoned":return{color:"bg-orange-600",icon:E,variant:"default"};case"Open Source":return{color:"bg-gray-500",icon:de,variant:"secondary"};case"Unknown":return{color:"bg-yellow-500",icon:le,variant:"outline"};default:return{color:"bg-gray-500",icon:le,variant:"outline"}}};function Ie({tool:s,actions:t,showVerificationCount:r=!0}){const l=Ra(s.status),a=l.icon;return e.jsx(b,{className:"hover:shadow-md transition-shadow",children:e.jsx(y,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-semibold text-lg truncate",children:s.product_name}),e.jsxs(R,{variant:l.variant,className:"shrink-0",children:[e.jsx(a,{className:"w-3 h-3 mr-1"}),s.status]})]}),e.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{className:"w-4 h-4"}),e.jsx("span",{children:s.marketplace})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-4 h-4"}),e.jsxs("span",{children:["Closed: ",s.closure_date?G(new Date(s.closure_date),"MMM dd, yyyy"):e.jsx("span",{className:"text-muted-foreground italic",children:"Not reported"})]})]}),s.founder_name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ys,{className:"w-4 h-4"}),e.jsx("span",{children:s.founder_name})]}),r&&s.verification_count>0&&e.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[e.jsx(xe,{className:"w-4 h-4"}),e.jsxs("span",{children:[s.verification_count," verification",s.verification_count!==1?"s":""]})]})]})]}),t&&e.jsx("div",{className:"shrink-0",children:t})]})})})}function Ea({totalExposure:s,atRiskCount:t,archivedLoss:r,currency:l="USD"}){const a=d=>new Intl.NumberFormat("en-US",{style:"currency",currency:l,minimumFractionDigits:0,maximumFractionDigits:0}).format(d),n=s>500?"high":s>100?"medium":"low",i={high:"text-red-500 bg-red-500/10 border-red-500/30",medium:"text-amber-500 bg-amber-500/10 border-amber-500/30",low:"text-green-500 bg-green-500/10 border-green-500/30"};return e.jsxs(b,{className:"col-span-full lg:col-span-2",children:[e.jsx(U,{className:"pb-2",children:e.jsxs(V,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(_s,{className:"w-4 h-4 text-muted-foreground"}),"Financial Impact Overview"]})}),e.jsxs(y,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4",children:[e.jsxs("div",{className:k("min-w-0 p-3 sm:p-4 roun
2ded-lg border",i[n]),children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(E,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{className:"text-xs font-medium truncate",children:"At Risk"})]}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold break-words",children:a(s)}),e.jsxs("p",{className:"text-xs opacity-70 mt-1",children:[t," tool",t!==1?"s":""," at risk"]})]}),e.jsxs("div",{className:"min-w-0 p-3 sm:p-4 rounded-lg border bg-muted/50",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Z,{className:"w-4 h-4 shrink-0 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground truncate",children:"Archived Loss"})]}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold text-muted-foreground break-words",children:a(r)}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"From failed tools"})]}),e.jsxs("div",{className:"col-span-2 min-w-0 p-3 sm:col-span-1 sm:p-4 rounded-lg border bg-primary/5 border-primary/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ae,{className:"w-4 h-4 shrink-0 text-primary"}),e.jsx("span",{className:"text-xs font-medium text-primary truncate",children:"Protected"})]}),e.jsx("div",{className:"text-xl sm:text-2xl font-bold text-primary break-words",children:t>0?"Monitor":"Safe"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Active monitoring"})]})]}),s>0&&e.jsx("p",{className:"text-xs text-muted-foreground mt-4 pt-4 border-t",children:"Your at-risk exposure is calculated based on the estimated value of tools that match known failed LTDs. Consider archiving or finding alternatives for high-risk matches."})]})]})}function Ia(s){return ce({queryKey:["failed-tool-comments",s],queryFn:async()=>{if(!s)return[];const{data:t,error:r}=await S.from("failed_tool_comments").select("*").eq("failed_tool_id",s).order("created_at",{ascending:!0});if(r)throw r;const l=t?.map(g=>g.id)||[],{data:a}=await S.from("failed_tool_comment_votes").select("*").in("comment_id",l),{data:{user:n}}=await S.auth.getUser(),i=n?.id,d=[...new Set(t?.map(g=>g.user_id)||[])],{data:c}=d.length>0?await S.from("profiles").select("user_id, display_name").in("user_id",d):{data:[]},m=new Map((c||[]).map(g=>[g.user_id,g.display_name])),o=t?.map(g=>{const v=a?.filter(x=>x.comment_id===g.id)||[],T=v.filter(x=>x.vote_type==="up").length,j=v.filter(x=>x.vote_type==="down").length,_=v.find(x=>x.user_id===i)?.vote_type,u=g.display_name&&g.display_name.trim(),N=m.get(g.user_id),D=N&&N.trim();return{...g,vote_count:T-j,user_vote:_||null,display_name:u||D||"Anonymous"}})||[],h=o.filter(g=>!g.parent_id),f=o.filter(g=>g.parent_id);return h.map(g=>({...g,replies:f.filter(v=>v.parent_id===g.id)}))},enabled:!!s})}function Pa(){const s=te();return re({mutationFn:async({failedToolId:t,content:r,parentId:l})=>{const{data:{user:a}}=await S.auth.getUser();
2if(!a)throw new Error("Must be logged in to comment");const{data:n}=await S.from("profiles").select("display_name").eq("user_id",a.id).single(),i=n?.display_name&&n.display_name.trim()||a.email?.split("@")[0]||"Anonymous",{data:d,error:c}=await S.from("failed_tool_comments").insert({failed_tool_id:t,user_id:a.id,content:r,parent_id:l||null,display_name:i}).select().single();if(c)throw c;return d},onSuccess:(t,r)=>{s.invalidateQueries({queryKey:["failed-tool-comments",r.failedToolId]}),s.invalidateQueries({queryKey:["all-discussion-counts"]}),$.success("Comment added")},onError:t=>{$.error("Failed to add comment: "+t.message)}})}function Oa(){const s=te();return re({mutationFn:async({commentId:t,voteType:r,failedToolId:l})=>{const{data:{user:a}}=await S.auth.getUser();if(!a)throw new Error("Must be logged in to vote");const{data:n}=await S.from("failed_tool_comment_votes").select("*").eq("comment_id",t).eq("user_id",a.id).single();n?n.vote_type===r?await S.from("failed_tool_comment_votes").delete().eq("id",n.id):await S.from("failed_tool_comment_votes").update({vote_type:r}).eq("id",n.id):await S.from("failed_tool_comment_votes").insert({comment_id:t,user_id:a.id,vote_type:r})},onSuccess:(t,r)=>{s.invalidateQueries({queryKey:["failed-tool-comments",r.failedToolId]})},onError:t=>{$.error("Failed to vote: "+t.message)}})}function za(){const s=te();return re({mutationFn:async({commentId:t,failedToolId:r})=>{const{error:l}=await S.from("failed_tool_comments").delete().eq("id",t);if(l)throw l},onSuccess:(t,r)=>{s.invalidateQueries({queryKey:["failed-tool-comments",r.failedToolId]}),s.invalidateQueries({queryKey:["all-discussion-counts"]}),$.success("Comment deleted")},onError:t=>{$.error("Failed to delete comment: "+t.message)}})}function qa(){const s=te();return re({mutationFn:async({commentId:t,content:r,failedToolId:l})=>{const{error:a}=await S.from("failed_tool_comments").update({content:r,updated_at:new Date().toISOString()}).eq("id",t);if(a)throw a},onSuccess:(t,r)=>{s.invalidateQueries({queryKey:["failed-tool-comments",r.failedToolId]}),$.success("Comment updated")},onError:t=>{$.error("Failed to update comment: "+t.message)}})}function Ua(s){return ce({queryKey:["failed-tool-alternatives",s],queryFn:async()=>{if(!s)return[];const{data:t,error:r}=await S.from("failed_tool_alternatives").select("*").eq("failed_tool_id",s).order("upvotes",{ascending:!1});if(r)throw r;const{data:{user:l}}=await S.auth.getUser(),a=l?.id,n=[...new Set(t?.map(h=>h.user_id)||[])],{data:i}=n.length>0?await S.from("profiles").select("user_id, display_name").in("user_id",n):{data:[]},d=new Map((i||[]).map(h=>[h.user_id,h.display_name]));if(!a)return t?.map(h=>({...h,display_name:d.get(h.user_id)??null}));const c=t?.map(h=>h.id)||[],{data:m}=await S.from("failed_tool_alternative_votes").select("alternative_id").eq("user_id",a).in("alternative_id",c),o=new Set(m?.map(h=>h.alternative_id));return t?.map(h=>({...h,user_voted:o.has(h.id),display_name:d.get(h.user_id)??null}))},enabled:!!s})}function Va(){const s=te();return re({mutationFn:async({alternativeId:t,failedToolId:r})=>{const{error:l}=await S.from("failed_tool_alternatives").delete().eq("id",t);if(l)throw l},onSuccess:(t,r)=>{s.invalidateQueries({queryKey:["failed-tool-alternatives",r.failedToolId]}),$.success("Suggestion removed")},onError:t=>{$.error("Failed to remove suggestion: "+t.message)}})}function $a(){const s=te();return re({mutationFn:async({failedToolId:t,name:r,url:l,description:a})=>{const{data:{user:n}}=await S.auth.getUser();
2if(!n)throw new Error("Must be logged in to suggest alternatives");const{data:i,error:d}=await S.from("failed_tool_alternatives").insert({failed_tool_id:t,user_id:n.id,name:r,url:l||null,description:a||null}).select().single();if(d)throw d;return i},onSuccess:(t,r)=>{s.invalidateQueries({queryKey:["failed-tool-alternatives",r.failedToolId]}),$.success("Alternative suggestion added")},onError:t=>{$.error("Failed to add suggestion: "+t.message)}})}function Ka(){const s=te();return re({mutationFn:async({alternativeId:t,failedToolId:r})=>{const{data:{user:l}}=await S.auth.getUser();if(!l)throw new Error("Must be logged in to vote");const{data:a}=await S.from("failed_tool_alternative_votes").select("*").eq("alternative_id",t).eq("user_id",l.id).single();if(a){await S.from("failed_tool_alternative_votes").delete().eq("id",a.id);const{data:n}=await S.from("failed_tool_alternatives").select("upvotes").eq("id",t).single();await S.from("failed_tool_alternatives").update({upvotes:Math.max(0,(n?.upvotes||1)-1)}).eq("id",t)}else{await S.from("failed_tool_alternative_votes").insert({alternative_id:t,user_id:l.id});const{data:n}=await S.from("failed_tool_alternatives").select("upvotes").eq("id",t).single();await S.from("failed_tool_alternatives").update({upvotes:(n?.upvotes||0)+1}).eq("id",t)}},onSuccess:(t,r)=>{s.invalidateQueries({queryKey:["failed-tool-alternatives",r.failedToolId]})},onError:t=>{$.error("Failed to vote: "+t.message)}})}function Ga({alternativeId:s,alternativeName:t,failedToolName:r,disabled:l}){const[a,n]=p.useState(!1),[i,d]=p.useState("inaccurate"),[c,m]=p.useState(""),o=lt(),h=()=>{o.mutate({alternativeId:s,reason:i,details:c,alternativeName:t,failedToolName:r},{onSuccess:()=>{n(!1),d("inaccurate"),m("")}})};return e.jsxs(Fs,{open:a,onOpenChange:n,children:[e.jsx(Mt,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-destructive",disabled:l,title:l?"Already reported":"Report this suggestion",children:e.jsx(ut,{className:`h-3.5 w-3.5 ${l?"fill-muted-foreground/30":""}`})})}),e.jsxs(Rs,{className:"sm:max-w-md",children:[e.jsxs(Es,{children:[e.jsx(Is,{children:"Report Suggestion"}),e.jsxs(Ft,{children:['Report "',t,'" as inappropriate or inaccurate. Our team will review your report.']})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(B,{className:"text-sm font-medium",children:"Reason for reporting"}),e.jsx(Dt,{value:i,onValueChange:f=>d(f),children:nt.map(f=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(At,{value:f.value,id:f.value}),e.jsx(B,{htmlFor:f.value,className:"text-sm font-normal cursor-pointer",children:f.label})]},f.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"details",className:"text-sm font-medium",children:"Additional details (optional)"}),e.jsx(ze,{id:"details",placeholder:"Provide more context about the issue...",value:c,onChange:f=>m(f.target.value),className:"min-h-[80px] resize-none"})]})]}),e.jsxs(Rt,{children:[e.jsx(w,{variant:"outline",onClick:()=>n(!1),children:"Cancel"}),e.jsx(w,{onClick:h,disabled:o.isPending,variant:"destructive",children:o.isPending?"Submitting...":"Submit Report"})]})]})]})}function Ha({alternative:s,failedToolId:t,failedToolName:r,isReported:l=!1,currentUserId:a,isAdmin:n=!1}){const i=Ka(),d=Va(),c=()=>{i.mutate({alternativeId:s.id,failedToolId:t})},m=a===s.user_id,o=()=>{confirm("Are you sure you want to remove this suggestion?")&&d.mutate({alternativeId:s.id,failedToolId:t})};return e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border bg-card hover:bg-muted/30 transition-colors",children:[e.jsxs(w,{variant:s.user_voted?"default":"outline",size:"sm",className:"h-12 w-12 flex-shrink-0 flex-col gap-0.5",onClick:c,children:[e.jsx(Cs,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:s.upvotes})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:s.name}),s.url&&e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:e.jsx(Ae,{className:"h-3.5 w-3.5"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Suggested by ",s.display_name||"Anonymous"]}),s.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.description})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(m||n)&&e.jsx(w,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive",onClick:o,disabled:d.isPending,title:n&&!m?"Delete as admin":"Delete your suggestion",children:e.jsx(Oe,{className:"h-3.5 w-3.5"})}),e.jsx(Ga,{alternativeId:s.id,alternativeName:s.name,failedToolName:r,disabled:l})]})]})}function Ya({failedToolId:s,failedToolName:t,existingAlternatives:r=[]}){const[l,a]=p.useState(!1),[n,i]=p.useState(""),[d,c]=p.useState(""),[m,o]=p.useState(""),{user:h}=bs(),{isAdmin:f}=es(),{data:g=[],isLoading:v}=Ua(s),T=$a(),j=g.map(x=>x.id),{data:_=[]}=it(j),u=()=>{n.trim()&&T.mutate({failedToolId:s,name:n.trim(),url:d.trim()||void 0,description:m.trim()||void 0},{onSuccess:()=>{i(""),c(""),o(""),a(!1)}})},D=[...(r||[]).filter(x=>x&&x.trim()).map((x,L)=>({id:`existing-${L}`,name:x,isExisting:!0}))];return e.jsxs(b,{children:[e.jsx(U,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(V,{className:"text-base flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4"}),"Alternative Tools",g.length>0&&e.jsxs(R,{variant:"secondary",children:[g.length+D.length," suggestions"]})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>a(!l),children:[l?e.jsx(Je,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(Me,{className:"h-3.5 w-3.5 mr-1"}),l?"Cancel":"Suggest"]})]})}),e.jsxs(y,{className:"space-y-4",children:[l&&e.jsxs("div",{className:"space-y-3 p-4 rounded-lg border bg-muted/30",children:[e.jsx(ee,{placeholder:"Tool name *",value:n,onChange:x=>i(x.target.value)}),e.jsx(ee,{placeholder:"Website URL (optional)",value:d,onChange:x=>c(x.target.value)}),e.jsx(ze,{placeholder:"Why is this a good alternative? (optional)",value:m,onChange:x=>
2o(x.target.value),className:"min-h-[60px] resize-none"}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{size:"sm",onClick:u,disabled:!n.trim()||T.isPending,children:[e.jsx(Me,{className:"h-3.5 w-3.5 mr-1"}),"Add Suggestion"]})})]}),D.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Known Alternatives"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:D.map(x=>e.jsx(R,{variant:"secondary",className:"px-3 py-1",children:x.name},x.id))})]}),v?e.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm",children:"Loading suggestions..."}):g.length===0&&D.length===0?e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(ve,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No alternatives suggested yet."}),e.jsx("p",{className:"text-xs mt-1",children:"Know a good replacement? Suggest one!"})]}):g.length>0?e.jsxs("div",{className:"space-y-2",children:[D.length>0&&e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide mt-4",children:"Community Suggestions"}),e.jsx("div",{className:"space-y-2",children:g.map(x=>e.jsx(Ha,{alternative:x,failedToolId:s,failedToolName:t,isReported:_.includes(x.id),currentUserId:h?.id,isAdmin:f},x.id))})]}):null]})]})}const Ba=s=>{switch(s){case"Shut Down":return{color:"text-red-500 bg-red-500/10",icon:ks,variant:"destructive",description:"This tool is completely shut down and no longer operational."};case"Revoked LTD":return{color:"text-red-600 bg-red-600/10",icon:E,variant:"destructive",description:"Lifetime deal benefits have been revoked by the company."};case"Diminished LTD":return{color:"text-orange-500 bg-orange-500/10",icon:le,variant:"default",description:"LTD features have been reduced or limited compared to original offer."};case"Abandoned":return{color:"text-orange-600 bg-orange-600/10",icon:E,variant:"default",description:"The tool appears to be abandoned with no updates or support."};case"Open Source":return{color:"text-blue-500 bg-blue-500/10",icon:de,variant:"secondary",description:"The tool has been open-sourced for the community."};case"Unknown":return{color:"text-yellow-500 bg-yellow-500/10",icon:le,variant:"outline",description:"The current status is uncertain and needs verification."};default:return{color:"text-muted-foreground bg-muted",icon:le,variant:"outline",description:"Status information unavailable."}}};function Us({tool:s,open:t,onOpenChange:r}){const l=Xe();if(!s)return null;const a=Ba(s.status),n=a.icon,i=s;return e.jsx(Fs,{open:t,onOpenChange:r,children:e.jsxs(Rs,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Es,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(Is,{className:"text-2xl",children:s.product_name}),e.jsx("p",{className:"text-muted-foreground mt-1",children:s.marketplace})]}),e.jsxs(R,{variant:a.variant,className:"text-sm shrink-0",children:[e.jsx(n,{className:"w-4 h-4 mr-1"}),s.status]})]})}),e.jsxs(Ne,{defaultValue:"details",className:"w-full",children:[e.jsxs(Pe,{className:"grid w-full grid-cols-2",children:[e.jsxs(q,{value:"details",className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),"Details"]}),e.jsxs(q,{value:"alternatives",className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4"}),"Alternatives"]})]}),e.jsxs(O,{value:"details",className:"space-y-6 mt-4",children:[e.jsx(b,{className:a.color,children:e.jsxs(y,{className:"p-4 flex items-start gap-3",children:[e.jsx(n,{className:"w-5 h-5 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm",children:a.description})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.closure_date&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(je,{className:"w-5 h-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Closure Date"}),e.jsx("p",{className:"font-medium",children:G(new Date(s.closure_date),"MMM dd, yyyy")})]})]}),i.last_known_active_date&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(ie,{className:"w-5 h-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Last Active"}),e.jsx("p",{className:"font-medium",children:G(new Date(i.last_known_active_date),"MMM dd, yyyy")})]})]}),s.founder_name&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(ys,{className:"w-5 h-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Founder"}),e.jsx("p",{className:"font-medium",children:s.founder_name})]})]}),i.acquisition_status&&i.acquisition_status!=="Not Acquired"&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx(de,{className:"w-5 h-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Company Status"}),e.jsx("p",{className:"font-medium",children:i.acquisition_status})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ae,{className:"w-5 h-5 text-green-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Community Verification"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.verification_count," user",s.verification_count!==1?"s have":" has"," verified this report"]})]})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>l.mutate(s.id),disabled:l.isPending,children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Verify"]})]}),(i.website_url||i.twitter_handle||i.linkedin_url)&&e.jsxs(e.Fragment,{children:[e.jsx(me,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"Exter
2nal Links"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.website_url&&e.jsx(w,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:i.website_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(xt,{className:"w-4 h-4 mr-2"}),"Website",e.jsx(Ae,{className:"w-3 h-3 ml-1"})]})}),i.twitter_handle&&e.jsx(w,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:`https://twitter.com/${i.twitter_handle.replace("@","")}`,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ht,{className:"w-4 h-4 mr-2"}),i.twitter_handle,e.jsx(Ae,{className:"w-3 h-3 ml-1"})]})}),i.linkedin_url&&e.jsx(w,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:i.linkedin_url,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ft,{className:"w-4 h-4 mr-2"}),"LinkedIn",e.jsx(Ae,{className:"w-3 h-3 ml-1"})]})})]})]})]}),i.evidence_notes&&e.jsxs(e.Fragment,{children:[e.jsx(me,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"font-semibold text-sm flex items-center gap-2",children:[e.jsx(Be,{className:"w-4 h-4"}),"Evidence & Notes"]}),e.jsx(b,{children:e.jsx(y,{className:"p-4",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:i.evidence_notes})})})]})]}),e.jsx(me,{}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"font-semibold text-sm",children:"Timeline"}),e.jsxs("div",{className:"space-y-3",children:[s.created_at&&e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500"}),e.jsx("span",{className:"text-muted-foreground",children:"Reported:"}),e.jsx("span",{children:G(new Date(s.created_at),"MMM dd, yyyy")})]}),i.last_known_active_date&&e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-500"}),e.jsx("span",{className:"text-muted-foreground",children:"Last Active:"}),e.jsx("span",{children:G(new Date(i.last_known_active_date),"MMM dd, yyyy")})]}),s.closure_date&&e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500"}),e.jsx("span",{className:"text-muted-foreground",children:"Closed:"}),e.jsx("span",{children:G(new Date(s.closure_date),"MMM dd, yyyy")})]})]})]})]}),e.jsx(O,{value:"alternatives",className:"mt-4",children:e.jsx(Ya,{failedToolId:s.id,failedToolName:s.product_name,existingAlternatives:i.known_alternatives})})]})]})})}const Vs={high:{icon:Fe,label:"High Risk",color:"text-red-500",bgColor:"bg-red-500/10",borderColor:"border-red-500/30",description:"This tool has a strong match with a known failed LTD. Immediate action recommended.",gradient:"from-red-500 to-red-600"},medium:{icon:E,label:"Medium Risk",color:"text-amber-500",bgColor:"bg-amber-500/10",borderColor:"border-amber-500/30",description:"This tool has a moderate match. Review and monitor recommended.",gradient:"from-amber-500 to-amber-600"},low:{icon:le,label:"Low Risk",color:"text-blue-500",bgColor:"bg-blue-500/10",borderColor:"border-blue-500/30",description:"This tool has a weak match. May be a false positive, verify manually.",gradient:"from-blue-500 to-blue-600"}},Wa={sm:{icon:"w-4 h-4",container:"p-1.5",text:"text-xs",gap:"gap-1.5"},md:{icon:"w-5 h-5",container:"p-2",text:"text-sm",gap:"gap-2"},lg:{icon:"w-6 h-6",container:"p-3",text:"text-base",gap:"gap-3"}};function Qa({confidence:s,similarityScore:t,showLabel:r=!0,size:l="md"}){const a=Vs[s],n=Wa[l],i=a.icon,d=Math.round(t*100);return e.jsx(Et,{children:e.jsxs(It,{children:[e.jsx(Pt,{asChild:!0,children:e.jsxs("div",{className:k("inline-flex items-center rounded-lg border transition-all",a.bgColor,a.borderColor,n.container,n.gap,"hover:opacity-90 cursor-help"),children:[e.jsx(i,{className:k(n.icon,a.color)}),r&&e.jsxs("div",{className:k("flex flex-col",n.text),children:[e.jsx("span",{className:k("font-semibold",a.color),children:a.label}),e.jsxs("span",{className:"text-muted-foreground",children:[d,"% match"]})]})]})}),e.jsx(Ot,{side:"right",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i,{className:k("w-4 h-4",a.color)}),e.jsx("span",{className:"font-semibold",children:a.label})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),e.jsxs("div",{className:"pt-2 border-t",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{children:"Match Score"}),e.jsxs("span",{className:"font-mono",children:[d,"%"]})]}),e.jsx("div",{className:"mt-1 h-1.5 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:k("h-full rounded-full bg-gradient-to-r",a.gradient),style:{width:`${d}%`}})})]})]})})]})})}function Xa({matches:s}){const t={high:s.filter(l=>l.confidence==="high").length,medium:s.filter(l=>l.confidence==="medium").length,low:s.filter(l=>l.confidence==="low").length};return s.length===0?e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 border border-green-500/30 rounded-lg text-green-600",children:[e.jsx(xe,{className:"w-5 h-5"}),e.jsx("span",{className:"font-medium",children:"No risks detected"})]}):e.jsx("div",{className:"grid grid-cols-3 gap-3",children:["high","medium","low"].map(l=>{const a=Vs[l],n=a.icon,i=t[l];return e.jsxs("div",{className:k("flex items-center gap-2 p-3 rounded-lg border",a.bgColor,a.borderColor),children:[e.jsx(n,{className:k("w-5 h-5",a.color)}),e.jsxs("div",{children:[e.jsx("div",{className:k("text-2xl font-bold",a.color),children:i}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a.label})]})]},l)})})}const we={sm:"w-20 h-20",md:"w-28 h-28",lg:"w-32 h-32"},Ue={sm:"h-8 w-8",md:"h-10 w-10",lg:"h-12 w-12"};function Ja({className:s,size:t="md"}){return e.jsxs("div",{className:k("relative",we[t],s),children:[e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[e.jsx("div",{className:"absolute w-full h-full rounded-full bg-gradient-to-br from-purple-500/10 to-pink-500/10 animate-pulse"}),e.jsx("div",{className:"absolute w-3/4 h-3/4 rounded-full bg-gradient-to-br from-purple-500/20 to-pink-500/20 animate-[clay-bounce_3s_ease-in-out_infinite]"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-purple-500 to-pink-500 rounded-2xl blur-lg opacity-40 animate-pulse"}),e.jsx("div",{className:"relative bg-gradient-to-br from-purple-500 to-pink-600 p-4 rounded-2xl shadow-lg animate-[clay-bounce_2.5s_ease-in-out_infinite]",children:e.jsx(de,{className:k(Ue[t],"text-white")})})]})}),e.jsx("div",{className:"absolute top-2 right-4 w-3 h-3 bg-gradient-to-br from-amber-400 to-orange-500 rounded-full animate-ping"}),e.jsx("div",{className:"absolute bottom-6 left-2 w-2 h-2 bg-gradient-to-br from-blue-400 to-cyan-500 rounded-full animate-ping",style:{animationDelay:"0.5s"}}),e.jsx("div",{className:"absolute top-8 left-4 w-2 h-2 bg-gradient-to-br from-emerald-400 to-teal-500 rounded-full animate-ping",style:{animationDelay:"1s"}})]})}function Za({className:s,size:t="md"}){return e.jsxs("div",{className:k("relative",we[t],s),children:[e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[e.jsx("div",{className:"absolute w-full h-full rounded-full bg-gradient-to-br from-blue-500/10 to-cyan-500/10 animate-pulse"}),e.jsx("div",{className:"absolute w-3/4 h-3/4 rounded-full bg-gradient-to-br from-blue-500/20 to-cyan-500/20 animate-[clay-bounce_3s_ease-in-out_infinite]"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-500 to-cyan-500 rounded-2xl blur-lg opacity-40 animate-pulse"}),e.jsx("div",{className:"relative bg-gradient-to-br from-blue-500 to-cyan-600 p-4 rounded-2xl shadow-lg animate-[clay-bounce_2.5s_ease-in-out_infinite]",children:e.jsx(gt,{className:k(Ue[t],"text-white")})})]})}),e.jsx("div",{className:"absolute top-4 left-6 w-2 h-2 bg-gradient-to-br from-indigo-400 to-purple-500 rounded-full animate-ping"}),e.jsx("div",{className:"absolute bottom-4 right-6 w-3 h-3 bg-gradient-to-br from-sky-4
200 to-blue-500 rounded-full animate-ping",style:{animationDelay:"0.7s"}})]})}function er({className:s,size:t="md"}){return e.jsxs("div",{className:k("relative",we[t],s),children:[e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[e.jsx("div",{className:"absolute w-full h-full rounded-full bg-gradient-to-br from-emerald-500/10 to-teal-500/10 animate-pulse"}),e.jsx("div",{className:"absolute w-3/4 h-3/4 rounded-full bg-gradient-to-br from-emerald-500/20 to-teal-500/20 animate-[clay-bounce_3s_ease-in-out_infinite]"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-500 to-teal-500 rounded-2xl blur-lg opacity-40 animate-pulse"}),e.jsx("div",{className:"relative bg-gradient-to-br from-emerald-500 to-teal-600 p-4 rounded-2xl shadow-lg animate-[clay-bounce_2.5s_ease-in-out_infinite]",children:e.jsx(Ze,{className:k(Ue[t],"text-white")})})]})}),e.jsx("div",{className:"absolute top-2 right-6 w-2 h-2 bg-gradient-to-br from-green-400 to-emerald-500 rounded-full animate-ping"}),e.jsx("div",{className:"absolute bottom-8 left-4 w-3 h-3 bg-gradient-to-br from-teal-400 to-cyan-500 rounded-full animate-ping",style:{animationDelay:"0.5s"}})]})}function sr({className:s,size:t="md"}){return e.jsxs("div",{className:k("relative",we[t],s),children:[e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[e.jsx("div",{className:"absolute w-full h-full rounded-full bg-gradient-to-br from-amber-500/10 to-orange-500/10 animate-pulse"}),e.jsx("div",{className:"absolute w-3/4 h-3/4 rounded-full bg-gradient-to-br from-amber-500/20 to-orange-500/20 animate-[clay-bounce_3s_ease-in-out_infinite]"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-500 to-orange-500 rounded-2xl blur-lg opacity-40 animate-pulse"}),e.jsx("div",{className:"relative bg-gradient-to-br from-amber-500 to-orange-600 p-4 rounded-2xl shadow-lg animate-[clay-bounce_2.5s_ease-in-out_infinite]",children:e.jsx(pt,{className:k(Ue[t],"text-white")})})]})}),e.jsx("div",{className:"absolute top-4 right-4 w-2 h-2 bg-gradient-to-br from-yellow-400 to-amber-500 rounded-full animate-ping"}),e.jsx("div",{className:"absolute bottom-6 left-6 w-3 h-3 bg-gradient-to-br from-orange-400 to-red-500 rounded-full animate-ping",style:{animationDelay:"0.5s"}})]})}function tr({className:s,size:t="md",color:r="primary"}){const a={primary:{outer:"from-primary/10 to-success/10",inner:"from-primary/20 to-success/20",icon:"from-primary to-success",dots:["from-primary/80 to-primary","from-success to-primary"]},success:{outer:"from-success/10 to-success/5",inner:"from-success/20 to-success/10",icon:"from-success to-success/80",dots:["from-success/80 to-success","from-primary to-success"]},warning:{outer:"from-warning/10 to-warning/5",inner:"from-warning/20 to-warning/10",icon:"from-warning to-warning/80",dots:["from-warning/80 to-warning","from-warning to-destructive/50"]},info:{outer:"from-primary/10 to-primary/5",inner:"from-primary/20 to-primary/10",icon:"from-primary to-primary/80",dots:["from-primary/80 to-primary","from-primary to-success"]}}[r];return e.jsxs("div",{className:k("relative",we[t],s),children:[e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[e.jsx("div",{className:k("absolute w-full h-full rounded-full bg-gradient-to-br animate-pulse",a.outer)}),e.jsx("div",{className:k("absolute w-3/4 h-3/4 rounded-full bg-gradient-to-br",a.inner)}),e.jsx("div",{className:k("absolute w-1/2 h-1/2 rounded-full bg-gradient-to-br animate-[clay-bounce_2s_ease-in-out_infinite]",a.inner)})]}),e.jsx("div",{className:k("absolute top-2 right-4 w-2 h-2 rounded-full bg-gradient-to-br animate-ping",a.dots[0])}),e.jsx("div",{className:k("absolute bottom-4 left-2 w-1.5 h-1.5 rounded-full bg-gradient-to-br animate-ping",a.dots[1]),style:{animationDelay:"0.5s"}})]})}function $s({icon:s,gradient:t="from-purple-500 to-pink-600",size:r="md",className:l}){const a={sm:"w-14 h-14",md:"w-20 h-20",lg:"w-28 h-28"},n={sm:"h-6 w-6",md:"h-10 w-10",lg:"h-12 w-12"};return e.jsxs("div",{className:k("relative flex items-center justify-center",a[r],l),children:[e.jsx("div",{className:k("absolute inset-0 bg-gradient-to-br rounded-full blur-xl opacity-30 animate-pulse",t)}),e.jsx("div",{className:k("relative bg-gradient-to-br p-4 rounded-2xl shadow-lg",t),children:e.jsx(s,{className:k(n[r],"text-white")})})]})}const ar={tools:e.jsx(Ja,{size:"lg"}),stacks:e.jsx(Za,{size:"lg"}),bookmarks:e.jsx(sr,{size:"lg"}),analytics:e.jsx(er,{size:"lg"}),import:e.jsx(tr,{size:"lg",color:"primary"}),custom:null},rr={primary:"border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",success:"border-success/20 bg-gradient-to-br from-success/5 to-success/10",warning:"border-warning/20 bg-gradient-to-br from-warning/5 to-warning/10",info:"border-info/20 bg-gradient-to-br from-info/5 to-info/10"};
2function Ks({illustration:s,customIllustration:t,title:r,description:l,primaryAction:a,secondaryAction:n,tips:i,quickStart:d,accentColor:c="primary"}){return e.jsx(b,{className:k("border-dashed transition-all duration-300 hover:shadow-md overflow-hidden",rr[c]),children:e.jsx(y,{className:"py-8 px-6 sm:px-10",children:e.jsxs(dt,{staggerDelay:100,children:[e.jsx("div",{className:"mb-4 flex justify-center",children:s==="custom"?t:ar[s]}),e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:r}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto",children:l})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-3 mb-6",children:[a&&e.jsxs(w,{onClick:a.onClick,className:"gap-2 animate-glow-pulse",children:[a.icon||e.jsx(Me,{className:"h-4 w-4"}),a.label]}),n&&e.jsx(w,{variant:"outline",onClick:n.onClick,children:n.label})]}),d&&e.jsxs("div",{className:"bg-muted/50 rounded-xl p-4 mb-4 max-w-md mx-auto",children:[e.jsxs("h4",{className:"font-medium text-sm mb-3 flex items-center gap-2",children:[e.jsx(vt,{className:"h-4 w-4 text-primary"}),d.title]}),e.jsx("ol",{className:"space-y-2",children:d.steps.map((m,o)=>e.jsxs("li",{className:"flex items-start gap-3 text-sm text-muted-foreground",children:[e.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-primary/10 text-primary text-xs flex items-center justify-center font-medium",children:o+1}),m]},o))})]}),i&&i.length>0&&e.jsxs("div",{className:"border-t pt-6 mt-6",children:[e.jsxs("h4",{className:"text-sm font-medium text-center mb-4 flex items-center justify-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4 text-warning"}),"Pro Tips"]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 max-w-lg mx-auto",children:i.map((m,o)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground bg-muted/30 rounded-lg p-3",children:[m.icon||e.jsx(Ss,{className:"h-4 w-4 mt-0.5 text-primary flex-shrink-0"}),e.jsx("span",{children:m.text})]},o))})]})]})})})}function lr(){return e.jsx(Ks,{illustration:"custom",customIllustration:e.jsx($s,{icon:jt,gradient:"from-emerald-500 to-teal-600",size:"lg"}),title:"No risks detected",description:"Great news! None of your tools match known failed LTD tools in our community database.",accentColor:"success",tips:[{text:"We continuously check against our failed tools database"},{text:"Add more tools to increase coverage"}]})}function nr(){return e.jsx(Ks,{illustration:"custom",customIllustration:e.jsx($s,{icon:de,gradient:"from-slate-500 to-gray-600",size:"lg"}),title:"No archived tools",description:"Tools you archive from the risk assessment will appear here for your records.",tips:[{text:"Archive tools that have gone out of business"},{text:"Keep track of your LTD investments that didn't work out"}]})}function Gs(){return e.jsx(b,{children:e.jsx(y,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{width:"60%",height:"1.25rem"}),e.jsx(F,{width:"5rem",height:"1.25rem",rounded:"full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{width:"1rem",he
2ight:"1rem",rounded:"full"}),e.jsx(F,{width:"40%",height:"0.875rem"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{width:"1rem",height:"1rem",rounded:"full"}),e.jsx(F,{width:"50%",height:"0.875rem"})]})]})]}),e.jsx(F,{width:"5rem",height:"2rem",rounded:"md"})]})})})}function ir(){return e.jsxs("div",{className:"space-y-6",children:[e.jsx(F,{width:"100%",height:"3rem",rounded:"md"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsx(F,{width:"100%",height:"2.5rem",rounded:"md",className:"flex-1"}),e.jsx(F,{width:"11rem",height:"2.5rem",rounded:"md"})]}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{width:"40%",height:"1.25rem"}),e.jsx(F,{width:"6rem",height:"1.25rem",rounded:"full"}),e.jsx(F,{width:"4rem",height:"0.875rem"})]}),e.jsx(Gs,{})]},s))})]})}function or(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsx(F,{width:"100%",height:"2.5rem",rounded:"md",className:"flex-1"}),e.jsx(F,{width:"11rem",height:"2.5rem",rounded:"md"}),e.jsx(F,{width:"11rem",height:"2.5rem",rounded:"md"}),e.jsx(F,{width:"8rem",height:"2.5rem",rounded:"md"})]}),e.jsx(F,{width:"10rem",height:"0.875rem"}),e.jsx("div",{className:"grid gap-4",children:[1,2,3,4,5].map(s=>e.jsx(Gs,{},s))})]})}function cr(){return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex flex-col sm:flex-row gap-4",children:e.jsx(F,{width:"100%",height:"2.5rem",rounded:"md",className:"flex-1"})}),e.jsx("div",{className:"grid gap-4",children:[1,2,3].map(s=>e.jsx(b,{children:e.jsx(y,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0 space-y-3",children:[e.jsx(F,{width:"60%",height:"1.25rem"}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{width:"1rem",he
2ight:"1rem",rounded:"full"}),e.jsx(F,{width:"50%",height:"0.875rem"})]})}),e.jsx(F,{width:"100%",height:"4rem",rounded:"md"})]}),e.jsx(F,{width:"5rem",height:"2rem",rounded:"md"})]})})},s))})]})}const dr=[{value:"all",label:"All Time"},{value:"7",label:"Last 7 Days"},{value:"14",label:"Last 14 Days"},{value:"30",label:"Last 30 Days"}];function Hs(){const[s,t]=p.useState(""),[r,l]=p.useState("all"),[a,n]=p.useState("all"),[i,d]=p.useState(null),[c,m]=p.useState(!1),[o,h]=p.useState("your-risks"),[f,g]=p.useState(!1),{data:v=[],isLoading:T}=qe(),{data:j=[],isLoading:_}=se({newlyAdded:a}),{data:u=[]}=ws(),{customAvgCost:N,saveCustomAvgCost:D}=mt(),x=ot(),L=Xe(),z=N??59,K=N!=null,A=p.useMemo(()=>{const C=new Map;for(const P of v){const H=P.userToolName.toLowerCase().trim(),ke=C.get(H);ke?(ke.purchaseCount+=1,P.similarityScore>ke.similarityScore&&C.set(H,{...P,purchaseCount:ke.purchaseCount})):C.set(H,{...P,purchaseCount:1})}return Array.from(C.values())},[v]),ye=p.useMemo(()=>{const C=new Set(j.map(P=>P.id));return A.filter(P=>!(!C.has(P.failedToolId)||s&&!P.userToolName.toLowerCase().includes(s.toLowerCase())||r!=="all"&&P.confidence!==r))},[A,j,s,r]),he=p.useMemo(()=>s?j.filter(C=>C.product_name.toLowerCase().includes(s.toLowerCase())):j,[j,s]),Xs=A.length*z,Js=u.length*z,Zs=async C=>{const P=j.find(H=>H.id===C.failedToolId);P&&await x.mutateAsync({toolId:C.userToolId,toolType:"regular",failedLtdId:C.failedToolId,reason:`Matched with failed tool: ${P.product_name}`,originalData:{name:C.userToolName}})},ss=C=>{const P=j.find(H=>H.id===C);P&&(d(P),m(!0))};return T||_?e.jsx(ir,{}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Xa,{matches:A}),A.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ea,{totalExposure:Xs,atRiskCount:A.length,archivedLoss:Js}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground px-1",children:[e.jsxs("span",{children:["Estimated at ",e.jsxs("span",{className:"font-medium text-foreground",children:["$",z.toFixed(2)]}),"/tool",K?" (your custom average)":" (default estimate)","."]}),e.jsxs(w,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>g(!0),children:[e.jsx(Ts,{className:"h-3 w-3 mr-1"}),"Edit average"]})]})]}),e.jsx(Lt,{open:f,onOpenChange:g,currentAvgCost:z,onSave:C=>D(C)}),e.jsxs(Ne,{value:o,onValueChange:h,className:"w-full",children:[e.jsxs(Pe,{className:"grid w-full grid-cols-2 mb-4",children:[e.jsxs(q,{value:"your-risks",className:"flex items-center gap-2",children:[e.jsx(E,{className:"w-4 h-4"}),"Your At-Risk Tools",ye.length>0&&e.jsx(R,{variant:"destructive",className:"ml-1",children:ye.length})]}),e.jsxs(q,{value:"all-failed",className:"flex items-center gap-2",children:[e.jsx(Nt,{className:"w-4 h-4"}),"All Failed Tools",e.jsx(R,{variant:"secondary",className:"ml-1",children:he.length})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(be,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ee,{placeholder:o==="your-risks"?"Search your tools...":"Search failed tools...",value:s,onChange:C=>t(C.target.value),className:"pl-10"})]}),o==="your-risks"&&e.jsxs(W,{value:r,onValueChange:l,children:[e.jsx(Q,{className:"w-[180px]",children:e.jsx(X,{})}),e.jsxs(J,{children:[e.jsx(I,{value:"all",children:"All Matches"}),e.jsx(I,{value:"high",children:"High Risk"}),e.jsx(I,{value:"medium",children:"Medium Risk"}),e.jsx(I,{value:"low",children:"Low Risk"})]})]}),e.jsxs(W,{value:a,onValueChange:C=>n(C),children:[e.jsxs(Q,{className:"w-[160px]",children:[e.jsx(ie,{className:"w-4 h-4 mr-2 text-muted-foreground"}),e.jsx(X,{})]}),e.jsx(J,{children:dr.map(C=>e.jsx(I,{value:C.value,children:C.label},C.value))})]})]}),e.jsx(O,{value:"your-risks",className:"mt-0",children:ye.length===0?e.jsx(lr,{}):e.jsx("div",{className:"space-y-4",children:ye.map(C=>{const P=j.find(H=>H.id===C.failedToolId);return P?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-4",children:e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("h4",{className:"font-semibold",children:["Your Tool: ",C.userToolName]}),C.purchaseCount>1&&e.jsxs(R,{variant:"secondary",className:"text-xs",children:[C.purchaseCount," units purchased"]}),e.jsx(Qa,{confidence:C.confidence,similarityScore:C.similarityScore,size:"sm"})]})}),e.jsx(Ie,{tool:P,actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>ss(P.id),children:[e.jsx(Re,{className:"w-4 h-4 mr-2"}),"Details"]}
2),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>Zs(C),disabled:x.isPending,className:"text-destructive hover:text-destructive",children:[e.jsx(ge,{className:"w-4 h-4 mr-2"}),"Archive"]})]})})]},`${C.userToolId}-${C.failedToolId}`):null})})}),e.jsxs(O,{value:"all-failed",className:"mt-0",children:[e.jsxs("div",{className:"text-sm text-muted-foreground mb-4",children:["Showing ",he.length," failed tool",he.length!==1?"s":""," from the community database"]}),he.length===0?e.jsx("div",{className:"text-center py-12 bg-muted/20 rounded-lg border border-dashed",children:e.jsx("p",{className:"text-muted-foreground",children:"No failed tools found matching your criteria. Try adjusting your filters."})}):e.jsx("div",{className:"grid gap-4",children:he.map(C=>e.jsx(Ie,{tool:C,actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>ss(C.id),children:[e.jsx(Re,{className:"w-4 h-4 mr-2"}),"Details"]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>L.mutate(C.id),disabled:L.isPending,children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Verify"]})]})},C.id))})]})]}),e.jsx(Us,{tool:i,open:c,onOpenChange:m})]})}const mr=()=>{const s=te();return re({mutationFn:async t=>{const{error:r}=await S.from("failed_ltd_tools").delete().eq("id",t);if(r)throw r},onSuccess:()=>{s.invalidateQueries({queryKey:["failed-ltd-tools"]}),s.invalidateQueries({queryKey:["admin-tool-submissions"]}),s.invalidateQueries({queryKey:["tool-matching"]}),$.success("Tool deleted",{description:"The failed tool has been permanently removed from the database."})},onError:t=>{console.error("Error deleting failed tool:",t),$.error("Delete failed",{description:t.message||"Failed to delete the tool. Please try again."})}})};function ur({open:s,onOpenChange:t,toolName:r,onConfirm:l,isDeleting:a}){const[n,i]=p.useState(""),d=n==="DELETE",c=()=>{d&&(l(),i(""))},m=o=>{o||i(""),t(o)};return e.jsx(Ht,{open:s,onOpenChange:m,children:e.jsxs(Yt,{className:"max-w-md",children:[e.jsxs(Bt,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-destructive/10 rounded-full",children:e.jsx(E,{className:"h-5 w-5 text-destructive"})}),e.jsx(Wt,{children:"Delete Failed Tool"})]}),e.jsxs(Qt,{className:"space-y-3 pt-2",children:[e.jsxs("p",{children:["You are about to permanently delete"," ",e.jsxs("span",{className:"font-semibold text-foreground",children:['"',r,'"']})," ","from the community database."]}),e.jsx("p",{className:"text-destructive font-medium",children:"This action cannot be undone. All verification data, comments, and alternatives associated with this tool will also be deleted."})]})]}),e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsxs(B,{htmlFor:"confirm-delete",className:"text-sm font-medium",children:["Type ",e.jsx("span",{className:"font-mono bg-muted px-1.5 py-0.5 rounded",children:"DELETE"})," to confirm"]}),e.jsx(ee,{id:"confirm-delete",value:n,onChange:o=>i(o.target.value.toUpperCase()),placeholder:"Type DELETE",className:"font-mono",disabled:a})]}),e.jsxs(Xt,{children:[e.jsx(Jt,{disabled:a,children:"Cancel"}),e.jsx(Zt,{variant:"destructive",onClick:c,disabled:!d||a,children:a?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin mr-2"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Delete Tool"]})})]})]})})}const xr=["All","Shut Down","Revoked LTD","Diminished LTD","Abandoned","Unknown","Open Source"],hr=["All","AppSumo","Dealify","Private Deal","Saas Mantra","StackSocial","PitchGround","Other"],fr=[{value:"all",label:"All Time"},{value:"7",label:"Last 7 Days"},{value:"14",label:"Last 14 Days"},{value:"30",label:"Last 30 Days"}];function pr({initialNewlyAddedFilter:s="all"}){const[t,r]=p.useState(""),[l,a]=p.useState("All"),[n,i]=p.useState("All"),[d,c]=p.useState(s);p.useEffect(()=>{c(s)},[s]);const[m,o]=p.useState(null),[h,f]=p.useState(!1),[g,v]=p.useState(!1),[T,j]=p.useState(null),{isAdmin:_}=es(),{data:u=[],isLoading:N}=se({status:l!=="All"?l:void 0,marketplace:n!=="All"?n:void 0,search:t||void 0,newlyAdded:d}),D=Xe(),x=mr(),L=()=>{const A=Fa(u);qs(A)},M=A=>{o(A),f(!0)},z=A=>{j(A),v(!0)},K=()=>{T&&x.mutate(T.id,{onSuccess:()=>{v(!1),j(null)}})};return N?e.jsx(or,{}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(be,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ee,{placeholder:"Search failed tools...",value:t,onChange:A=>r(A.target.value),className:"pl-10"})]}),e.jsxs(W,{value:l,onValueChange:a,children:[e.jsx(Q,{className:"w-[180px]",children:e.jsx(X,{})}),e.jsx(J,{children:xr.map(A=>e.jsx(I,{value:A,children:A},A))})]}),e.jsxs(W,{value:n,onValueChange:i,children:[e.jsx(Q,{className:"w-[180px]",children:e.jsx(X,{})}),e.jsx(J,{children:hr.map(A=>e.jsx(I,{value:A,children:A},A))})]}),e.jsxs(W,{value:d,onValueChange:A=>c(A),children:[e.jsxs(Q,{className:"w-[160px]",children:[e.jsx(ie,{className:"w-4 h-4 mr-2 text-muted-foreground"}),e.jsx(X,{})]}),e.jsx(J,{children:fr.map(A=>e.jsx(I,{value:A.value,children:A.label},A.value))})]}),e.jsxs(w,{onClick:L,variant:"outline",children:[e.jsx(Ds,{className:"w-4 h-4 mr-2"}),"Export CSV"]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",u.length," failed tool",u.length!==1?"s":""]}),u.length===0?e.jsx("div",{className:"text-center py-12 bg-muted/20 rounded-lg border border-dashed",children:e.jsx("p",{className:"text-muted-foreground",children:"No failed tools found matching your criteria. Try adjusting your filters."})}):e.jsx("div",{className:"grid gap-4",children:u.map(A=>e.jsx(Ie,{tool:A,actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>M(A),children:[e.jsx(Re,{className:"w-4 h-4 mr-2"}),"Details"]}
2),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>D.mutate(A.id),disabled:D.isPending,children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Verify"]}),_&&e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>z(A),className:"text-destructive hover:text-destructive hover:bg-destructive/10 border-destructive/30",children:[e.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Delete"]})]})},A.id))}),e.jsx(Us,{tool:m,open:h,onOpenChange:f}),e.jsx(ur,{open:g,onOpenChange:v,toolName:T?.product_name||"",onConfirm:K,isDeleting:x.isPending})]})}function gr(){const[s,t]=p.useState(""),{data:r=[],isLoading:l}=ws(),a=ct(),n=r.filter(d=>{const c=d.original_tool_data;return String(c?.name||c?.title||"").toLowerCase().includes(s.toLowerCase())}),i=r.reduce((d,c)=>{const m=c.original_tool_data;return d+(Number(m?.price)||Number(m?.price_paid)||0)},0);return l?e.jsx(cr,{}):e.jsxs("div",{className:"space-y-6",children:[r.length>0&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(b,{className:"bg-muted/50",children:e.jsxs(y,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-full bg-destructive/10",children:e.jsx(Be,{className:"w-5 h-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:r.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Archived Tools"})]})]})}),e.jsx(b,{className:"bg-muted/50",children:e.jsxs(y,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-full bg-amber-500/10",children:e.jsx(_s,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["$",i.toFixed(0)]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Investment Lost"})]})]})})]}),e.jsx("div",{className:"flex flex-col sm:flex-row gap-4",children:e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(be,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ee,{placeholder:"Search archived tools...",value:s,onChange:d=>t(d.target.value),className:"pl-10"})]})}),n.length===0?e.jsx(nr,{}):e.jsx("div",{className:"grid gap-4",children:n.map(d=>{const c=d.original_tool_data,m=String(c?.name||c?.title||"Unknown Tool"),o=Number(c?.price)||Number(c?.price_paid)||0;return e.jsx(b,{className:"hover:shadow-md transition-shadow",children:e.jsx(y,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"font-semibold text-lg",children:m}),o>0&&e.jsxs(R,{variant:"outline",className:"text-destructive border-destructive/50",children:["-$",o]})]}),e.jsxs("div",{className:"space-y-3 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-4 h-4"}),e.jsxs("span",{children:["Archived: ",G(new Date(d.archived_at||""),"MMM dd, yyyy")]})]}),d.archive_reason&&e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"font-medium text-foreground mb-1",children:"Reason:"}),e.jsx("p",{children:d.archive_reason})]}),d.notes&&e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsx("p",{className:"font-medium text-foreground mb-1",children:"Notes:"}),e.jsx("p",{children:d.notes})]}),d.failed_ltd_tools&&e.jsx("div",{className:"pt-2",children:e.jsxs(R,{variant:"secondary",children:["Linked: ",d.failed_ltd_tools.product_name]})})]})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>a.mutate(d.id),disabled:a.isPending,children:[e.jsx(bt,{className:"w-4 h-4 mr-2"}),"Restore"]})]})})},d.id)})})]})}const gs={AppSumo:"hsl(var(--chart-1))","Private Deal":"hsl(var(--chart-2))",Dealify:"hsl(var(--chart-3))",StackSocial:"hsl(var(--chart-4))",PitchGround:"hsl(var(--chart-5))","Saas Mantra":"hsl(262, 80%, 50%)",GrabLTD:"hsl(200, 80%, 50%)",MightyDeals:"hsl(45, 90%, 50%)",DealMirror:"hsl(330, 80%, 50%)",Saaszilla:"hsl(180, 70%, 45%)",Other:"hsl(var(--muted-foreground))"},js={"Shut Down":"hsl(0, 70%, 50%)","Revoked LTD":"hsl(25, 95%, 53%)","Diminished LTD":"hsl(45, 93%, 47%)",Abandoned:"hsl(280, 70%, 50%)","Open Source":"hsl(142, 76%, 36%)",Unknown:"hsl(var(--muted-foreground))"};function jr(s){if(!s)return"Unknown";const t=s.toLowerCase().trim();if(t==="unknown"||t===""||t==="removed")return"Unknown";if(t.includes(".com/")||t.includes(".io/")||t.includes(".co/")||t.startsWith("http")){if(t.includes("appsumo"))return"AppSumo";if(t.includes("grabltd"))return"GrabLTD";if(t.includes("dealify"))return"Dealify";if(t.includes("pitchground"))return"PitchGround";if(t.includes("stacksocial"))return"StackSocial";if(t.includes("dealfuel"))return"DealFuel";if(t.includes("saasmantra")||t.includes("saas mantra"))return"Saas Mantra";const r=t.match(/(?:https?:\/\/)?(?:www\.)?([^./]+)/);return r?r[1].charAt(0).toUpperCase()+r[1].slice(1):"Other"}return t.includes("appsumo")?"AppSumo":t.includes("grabltd")?"GrabLTD":t.includes("dealify")?"Dealify":t.includes("pitchground")?"PitchGround":t.includes("stacksocial")?"StackSocial":t.includes("dealfuel")?"DealFuel":s.charAt(0).toUpperCase()+s.slice(1)}function vr(s){if(!s)return"Unknown";const t=s.toLowerCase().trim();return t==="unknown"||t===""?"Unknown":t==="removed"?"Removed":s.charAt(0).toUpperCase()+s.slice(1).toLowerCase()}const Nr=()=>{const{data:s=[],isLoading:t}=se(),r=p.useMemo(()=>{const c={};
2return s.forEach(m=>{const o=jr(m.marketplace);c[o]=(c[o]||0)+1}),Object.entries(c).map(([m,o])=>({name:m,value:o,color:gs[m]||gs.Other})).sort((m,o)=>o.value-m.value).slice(0,8)},[s]),l=p.useMemo(()=>{const c={};return s.forEach(m=>{const o=vr(m.status);c[o]=(c[o]||0)+1}),Object.entries(c).map(([m,o])=>({name:m,value:o,color:js[m]||js.Unknown})).sort((m,o)=>o.value-m.value)},[s]),a=p.useMemo(()=>{const c={},m=new Date;for(let o=23;o>=0;o--){const h=Tt(is(m,o)),f=G(h,"MMM yy");c[f]=0}return s.forEach(o=>{if(o.closure_date)try{const h=_e(o.closure_date);if(Ce(h)){const f=G(h,"MMM yy");c[f]!==void 0&&c[f]++}}catch{}}),Object.entries(c).map(([o,h])=>({month:o,failures:h}))},[s]),n=p.useMemo(()=>{const c={};return s.forEach(m=>{if(m.closure_date)try{const o=_e(m.closure_date);if(Ce(o)){const h=G(o,"yyyy");c[h]||(c[h]={total:0,shutDown:0,revoked:0}),c[h].total++,m.status==="Shut Down"&&c[h].shutDown++,m.status==="Revoked LTD"&&c[h].revoked++}}catch{}}),Object.entries(c).map(([m,o])=>({year:m,...o})).sort((m,o)=>m.year.localeCompare(o.year)).slice(-5)},[s]),i=p.useMemo(()=>r.slice(0,6).map(m=>({name:m.name.length>20?m.name.slice(0,18)+"...":m.name,fullName:m.name,count:m.value,percentage:Math.round(m.value/s.length*100)})),[r,s.length]),d=p.useMemo(()=>{const c=r[0],m=l[0],o=s.filter(f=>{if(!f.closure_date)return!1;const g=_e(f.closure_date);return Ce(g)&&g>is(new Date,3)}).length,h=s.filter(f=>{if(!f.closure_date)return!1;const g=_e(f.closure_date);return Ce(g)&&G(g,"yyyy")===G(new Date,"yyyy")}).length;return{topMarketplace:c,topStatus:m,recentFailures:o,thisYear:h}},[s,r,l]);return t?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3,4,5,6].map(c=>e.jsx(b,{children:e.jsx(y,{className:"p-6",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-1/3"}),e.jsx("div",{className:"h-32 bg-muted rounded"})]})})},c))}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(b,{className:"bg-gradient-to-br from-destructive/10 to-background border-destructive/20",children:e.jsx(y,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-destructive/20",children:e.jsx(Z,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This Year"}),e.jsx("p",{className:"text-2xl font-bold",children:d.thisYear})]})]})})}),e.jsx(b,{className:"bg-gradient-to-br from-warning/10 to-background border-warning/20",children:e.jsx(y,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-warning/20",children:e.jsx(je,{className:"h-5 w-5 text-warning"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last 3 Months"}),e.jsx("p",{className:"text-2xl font-bold",children:d.recentFailures})]})]})})}),e.jsx(b,{children:e.jsx(y,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/20",children:e.jsx(rs,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Top Marketplace"}),e.jsx("p",{className:"text-lg font-bold truncate",children:d.topMarketplace?.name})]})]})})}),e.jsx(b,{children:e.jsx(y,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-red-500/20",children:e.jsx(E,{className:"h-5 w-5 text-red-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Top Reason"}),e.jsx("p",{className:"text-lg font-bold truncate",children:d.topStatus?.name})]})]})})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(b,{children:[e.jsxs(U,{children:[e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(rs,{className:"h-5 w-5"}),"Failures by Marketplace"]}),e.jsx(Y,{children:"Distribution of failed tools across platforms"})]}),e.jsx(y,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(Se,{width:"100%",height:"100%",children:e.jsxs(ea,{children:[e.jsx(sa,{data:r,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:"value",isAnimationActive:!1,children:r.map((c,m)=>e.jsx(os,{fill:c.color},`cell-${m}`))}),e.jsx(Te,{formatter:c=>[`${c} tools`,"Count"],contentStyle:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx(cs,{formatter:c=>e.jsx("span",{className:"text-xs",children:c})})]})})})})]}),e.jsxs(b,{children:[e.jsxs(U,{children:[e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5"}),"Failure Types"]}),e.jsx(Y,{children:"How tools failed or changed"})]}),e.jsx(y,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(Se,{width:"100%",height:"100%",children:e.jsxs(ds,{data:l,layout:"vertical",children:[e.jsx(Ve,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx($e,{type:"number",stroke:"hsl(var(--muted-foreground))",fontSize:12}),e.jsx(Ke,{type:"category",dataKey:"name",stroke:"hsl(var(--muted-foreground))",fontSize:12,width:140,tick
2Formatter:c=>c.length>20?c.slice(0,18)+"...":c}),e.jsx(Te,{formatter:c=>[`${c} tools`,"Count"],contentStyle:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx(Ge,{dataKey:"value",radius:[0,4,4,0],children:l.map((c,m)=>e.jsx(os,{fill:c.color},`cell-${m}`))})]})})})})]})]}),e.jsxs(b,{children:[e.jsxs(U,{children:[e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-5 w-5"}),"Monthly Failure Trends"]}),e.jsx(Y,{children:"Number of tools that failed each month (last 24 months)"})]}),e.jsx(y,{children:e.jsx("div",{className:"h-[300px]",children:e.jsx(Se,{width:"100%",height:"100%",children:e.jsxs(aa,{data:a,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"failureGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--destructive))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--destructive))",stopOpacity:0})]})}),e.jsx(Ve,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx($e,{dataKey:"month",stroke:"hsl(var(--muted-foreground))",fontSize:11,tick:{fontSize:10},interval:"preserveStartEnd"}),e.jsx(Ke,{stroke:"hsl(var(--muted-foreground))",fontSize:12}),e.jsx(Te,{formatter:c=>[`${c} failures`,"Count"],contentStyle:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx(ta,{type:"monotone",dataKey:"failures",stroke:"hsl(var(--destructive))",strokeWidth:2,fill:"url(#failureGradient)"})]})})})})]}),e.jsxs(b,{children:[e.jsxs(U,{children:[e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-5 w-5"}),"Year-over-Year Comparison"]}),e.jsx(Y,{children:"Annual breakdown by failure type"})]}),e.jsx(y,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(Se,{width:"100%",height:"100%",children:e.jsxs(ds,{data:n,children:[e.jsx(Ve,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx($e,{dataKey:"year",stroke:"hsl(var(--muted-foreground))",fontSize:12}),e.jsx(Ke,{stroke:"hsl(var(--muted-foreground))",fontSize:12}),e.jsx(Te,{contentStyle:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx(cs,{}),e.jsx(Ge,{dataKey:"shutDown",name:"Shut Down",fill:"hsl(0, 70%, 50%)",radius:[4,4,0,0]}),e.jsx(Ge,{dataKey:"revoked",name:"Revoked LTD",fill:"hsl(25, 95%, 53%)",radius:[4,4,0,0]})]})})})})]}),e.jsxs(b,{children:[e.jsxs(U,{children:[e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(wt,{className:"h-5 w-5"}),"Marketplace Risk Rankings"]}),e.jsx(Y,{children:"Percentage of failed tools by marketplace"})]}),e.jsx(y,{children:e.jsx("div",{className:"space-y-4",children:i.map((c,m)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"font-medium",children:[m+1,". ",c.fullName]}),e.jsxs("span",{className:"text-muted-foreground",children:[c.count," tools (",c.percentage,"%)"]})]}),e.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-destructive/60 to-destructive",style:{width:`${c.percentage}%`}})})]},c.fullName))})})]})]})},Ys=()=>{const{data:s,isLoading:t,error:r}=zt(),l=qt(),a=Ut(),n=Vt(),i=s?.filter(o=>o.status==="pending")||[],d=s?.filter(o=>o.status==="acknowledged")||[],c=o=>o?o>=.85?"high":o>=.65?"medium":"low":"low",m=(o,h=!0)=>{const f=o.tool?.title||o.appsumo_product?.name||"Unknown Tool",g=o.tool?.price||o.appsumo_product?.price_paid,v=o.failed_tool,T=c(o.similarity_score);return e.jsx("div",{className:k("p-4 rounded-lg border transition-colors",T==="high"&&o.status==="pending"?"bg-destructive/5 border-destructive/30":"bg-card border-border"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:k("rounded-full p-2",T==="high"?"bg-destructive/20":T==="medium"?"bg-warning/20":"bg-blue-500/20"),children:e.jsx(E,{className:k("h-4 w-4",T==="high"?"text-destructive":T==="medium"?"text-warning":"text-blue-500")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-medium text-foreground",children:f}),e.jsxs(R,{variant:T==="high"?"destructive":T==="medium"?"secondary":"outline",children:[Math.round((o.similarity_score||0)*100),"% match"]}),o.status!=="pending"&&e.jsx(R,{variant:"outline",className:"capitalize",children:o.status})]}),v&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Matches ",e.jsx("span",{className:"font-medium",children:v.product_name}),v.marketplace&&` on ${v.marketplace}`]}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[v?.status&&e.jsx("span",{className:k("font-medium",v.status==="Shut Down"&&"text-destructive"),children:v.status}
2),g&&e.jsxs("span",{children:["$",g.toLocaleString()," at risk"]}),e.jsx("span",{children:Ms(new Date(o.created_at),{addSuffix:!0})})]}),h&&o.status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(w,{size:"sm",variant:"outline",onClick:()=>a.mutate(o.id),disabled:a.isPending,children:[e.jsx(ns,{className:"h-3.5 w-3.5 mr-1"}),"Acknowledge"]}),e.jsxs(w,{size:"sm",variant:"ghost",onClick:()=>l.mutate(o.id),disabled:l.isPending,children:[e.jsx(Je,{className:"h-3.5 w-3.5 mr-1"}),"Dismiss"]})]})]})]})},o.id)};return t?e.jsxs(b,{children:[e.jsx(U,{children:e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-5 w-5"}),"Risk Alerts"]})}),e.jsx(y,{children:e.jsx("div",{className:"animate-pulse space-y-4",children:[1,2,3].map(o=>e.jsx("div",{className:"h-24 bg-muted rounded-lg"},o))})})]}):e.jsxs(b,{children:[e.jsx(U,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-5 w-5"}),"Risk Alerts",i.length>0&&e.jsxs(R,{variant:"destructive",className:"ml-2",children:[i.length," pending"]})]}),e.jsx(Y,{children:"Automatic monitoring for failed or at-risk tools"})]}),e.jsxs(w,{variant:"outline",size:"sm",onClick:()=>n.mutate(),disabled:n.isPending,children:[e.jsx(ls,{className:k("h-4 w-4 mr-2",n.isPending&&"animate-spin")}),"Check Now"]})]})}),e.jsxs(y,{className:"space-y-6",children:[i.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[e.jsx(E,{className:"h-4 w-4 text-warning"}),"Pending Alerts (",i.length,")"]}),e.jsx("div",{className:"space-y-3",children:i.map(o=>m(o))})]}),d.length>0&&e.jsxs(e.Fragment,{children:[i.length>0&&e.jsx(me,{}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium text-muted-foreground mb-3 flex items-center gap-2",children:[e.jsx(ns,{className:"h-4 w-4 text-green-500"}),"Acknowledged (",d.length,")"]}),e.jsx("div",{className:"space-y-3",children:d.slice(0,3).map(o=>m(o,!1))})]})]}),s?.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(ue,{className:"h-12 w-12 text-muted-foreground/30 mx-auto mb-4"}),e.jsx("h3",{className:"font-medium text-foreground mb-1",children:"No Risk Alerts"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Your tools don't match any known failed products."}),e.jsxs(w,{variant:"outline",onClick:()=>n.mutate(),disabled:n.isPending,children:[e.jsx(ls,{className:k("h-4 w-4 mr-2",n.isPending&&"animate-spin")}),"Run Check"]})]})]})]})},br=()=>{const{data:s,isLoading:t}=na(),r=ia(),l=oa(),[a,n]=p.useState(!0),[i,d]=p.useState("immediate"),[c,m]=p.useState("medium"),[o,h]=p.useState(!0),[f,g]=p.useState(14),[v,T]=p.useState(!1);p.useEffect(()=>{if(s){const u=s;n(u.founder_track_alerts??!0),d(u.founder_track_alert_frequency??"immediate"),m(u.founder_track_severity_threshold??"medium"),h(u.watch_list_alerts??!0),g(u.watch_list_stale_days??14)}},[s]);const j=async()=>{const u={founder_track_alerts:a,founder_track_alert_frequency:i,founder_track_severity_threshold:c,watch_list_alerts:o,watch_list_stale_days:f};try{s?.id?await r.mutateAsync({id:s.id,...u}):await l.mutateAsync(u),T(!1)}catch(N){console.error("Error saving preferences:",N)}},_=(u,N)=>{u(N),T(!0)};return t?e.jsxs(b,{children:[e.jsx(U,{children:e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-5 w-5"}),"Alert Settings"]})}),e.jsx(y,{children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-10 bg-muted rounded"}),e.jsx("div",{className:"h-10 bg-muted rounded"}),e.jsx("div",{className:"h-10 bg-muted rounded"})]})})]}):e.jsxs(b,{children:[e.jsxs(U,{children:[e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-5 w-5"}),"Founder Track Alert Settings"]}),e.jsx(Y,{children:"Configure how you want to be notified about at-risk tools and watch list items"})]}),e.jsxs(y,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(B,{htmlFor:"founder-track-alerts",className:"text-base",children:"Enable Risk Alerts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Get notified when your tools match failed or at-risk products"})]}),e.jsx(ms,{id:"founder-track-alerts",checked:a,onCheckedChange:u=>_(n,u)})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4"}),"Alert Frequency"]}),e.jsxs(W,{value:i,onValueChange:u=>
2_(d,u),children:[e.jsx(Q,{children:e.jsx(X,{})}),e.jsxs(J,{children:[e.jsx(I,{value:"immediate",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"Immediate"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Get notified as soon as a match is found"})]})}),e.jsx(I,{value:"daily",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"Daily Digest"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Receive a daily summary of new alerts"})]})}),e.jsx(I,{value:"weekly",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"Weekly Digest"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Receive a weekly summary of alerts"})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"Minimum Confidence Level"]}),e.jsxs(W,{value:c,onValueChange:u=>_(m,u),children:[e.jsx(Q,{children:e.jsx(X,{})}),e.jsxs(J,{children:[e.jsx(I,{value:"low",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"Low (50%+ match)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"More alerts, including potential false positives"})]})}),e.jsx(I,{value:"medium",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"Medium (65%+ match)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Balanced - recommended"})]})}),e.jsx(I,{value:"high",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"High (85%+ match)"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Only high-confidence matches"})]})})]})]})]})]})]}),e.jsx(me,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(B,{htmlFor:"watch-list-alerts",className:"text-base flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Watch List Reminders"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Get reminded to check on tools in your watch list"})]}),e.jsx(ms,{id:"watch-list-alerts",checked:o,onCheckedChange:u=>_(h,u)})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(B,{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4"}),"Reminder After (Days)"]}),e.jsxs(W,{value:f.toString(),onValueChange:u=>_(g,parseInt(u)),children:[e.jsx(Q,{children:e.jsx(X,{})}),e.jsxs(J,{children:[e.jsx(I,{value:"7",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"7 days"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Weekly check-ins"})]})}),e.jsx(I,{value:"14",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"14 days"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Bi-weekly check-ins (recommended)"})]})}),e.jsx(I,{value:"30",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"30 days"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Monthly check-ins"})]})}),e.jsx(I,{value:"60",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:"60 days"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Less frequent reminders"})]})})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You'll receive an email reminder for watch list items not checked within this period"})]})]}),v&&e.jsx("div",{className:"flex justify-end pt-4 border-t",children:e.jsx(w,{onClick:j,disabled:r.isPending||l.isPending,children:r.isPending||l.isPending?"Saving...":"Save Settings"})})]})]})};function wr(){const[s,t]=p.useState(""),[r,l]=p.useState("all"),{data:a=[],isLoading:n}=se(),{data:i=[],isLoading:d}=$t(),{data:c=[],isLoading:m}=Kt(),{data:o=[]}=qe(),h=n||d||m,f=p.useMemo(()=>{if(a.length===0)return[];const u=[];return i.forEach(N=>{let D=null,x=0;a.forEach(M=>{const z=Qe(N.title,M.product_name);z>x&&(x=z,D={id:M.id,name:M.product_name,status:M.status,marketplace:M.marketplace,closureDate:M.closure_date})});const L=x>=.8?"high":x>=.6?"medium":x>=.4?"low":"safe";u.push({userToolId:N.id,userToolName:N.title,userToolSource:"tools",matchedF
2ailedTool:x>=.4?D:null,similarityScore:x,riskLevel:L})}),c.forEach(N=>{if(!N.name)return;let D=null,x=0;a.forEach(M=>{const z=Qe(N.name||"",M.product_name);z>x&&(x=z,D={id:M.id,name:M.product_name,status:M.status,marketplace:M.marketplace,closureDate:M.closure_date})});const L=x>=.8?"high":x>=.6?"medium":x>=.4?"low":"safe";u.push({userToolId:N.uuid,userToolName:N.name||"Unknown Product",userToolSource:"appsumo",matchedFailedTool:x>=.4?D:null,similarityScore:x,riskLevel:L})}),u.sort((N,D)=>D.similarityScore-N.similarityScore)},[i,c,a]),g=p.useMemo(()=>{let u=f;return s&&(u=u.filter(N=>N.userToolName.toLowerCase().includes(s.toLowerCase())||N.matchedFailedTool?.name.toLowerCase().includes(s.toLowerCase()))),r==="at-risk"?u=u.filter(N=>N.riskLevel!=="safe"):r==="safe"&&(u=u.filter(N=>N.riskLevel==="safe")),u},[f,s,r]),v=p.useMemo(()=>{const u=f.length,N=f.filter(K=>K.riskLevel!=="safe").length,D=f.filter(K=>K.riskLevel==="high").length,x=f.filter(K=>K.riskLevel==="medium").length,L=f.filter(K=>K.riskLevel==="low").length,M=f.filter(K=>K.riskLevel==="safe").length,z=u>0?Math.round(M/u*100):100;return{total:u,atRisk:N,highRisk:D,mediumRisk:x,lowRisk:L,safe:M,safePercentage:z}},[f]),T=()=>{const u=["Your Tool","Source","Risk Level","Match Score","Matched Failed Tool","Failed Tool Status","Failed Tool Marketplace"],N=g.map(x=>[x.userToolName,x.userToolSource==="appsumo"?"AppSumo":"Manual",x.riskLevel.toUpperCase(),`${Math.round(x.similarityScore*100)}%`,x.matchedFailedTool?.name||"N/A",x.matchedFailedTool?.status||"N/A",x.matchedFailedTool?.marketplace||"N/A"]),D=[u,...N].map(x=>x.map(L=>`"${String(L).replace(/"/g,'""')}"`).join(",")).join(` 3`);qs(D,"tool-comparison-report.csv")},j=u=>{switch(u){case"high":return e.jsx(Fe,{className:"w-5 h-5 text-destructive"});case"medium":return e.jsx(ae,{className:"w-5 h-5 text-amber-500"});case"low":return e.jsx(ae,{className:"w-5 h-5 text-blue-500"});case"safe":return e.jsx(We,{className:"w-5 h-5 text-emerald-500"})}},_=u=>{const N={high:"bg-destructive/10 text-destructive border-destructive/30",medium:"bg-amber-500/10 text-amber-600 border-amber-500/30",low:"bg-blue-500/10 text-blue-600 border-blue-500/30",safe:"bg-emerald-500/10 text-emerald-600 border-emerald-500/30"};return e.jsx(R,{variant:"outline",className:k("font-medium",N[u]),children:u==="safe"?"Safe":`${u.charAt(0).toUpperCase()+u.slice(1)} Risk`})};return h?e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[1,2,3,4].map(u=>e.jsx(b,{className:"animate-pulse",children:e.jsxs(y,{className:"p-4",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-16 mb-2"}),e.jsx("div",{className:"h-4 bg-muted rounded w-24"})]})},u))})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(b,{children:e.jsxs(y,{className:"p-4 flex items-center gap-3",children:[e.jsx(de,{className:"w-8 h-8 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:v.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Tools"})]})]})}),e.jsx(b,{className:"border-destructive/30 bg-destructive/5",children:e.jsxs(y,{className:"p-4 flex items-center gap-3",children:[e.jsx(Fe,{className:"w-8 h-8 text-destructive"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-destructive",children:v.highRisk}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"High Risk"})]})]})}),e.jsx(b,{className:"border-amber-500/30 bg-amber-500/5",children:e.jsxs(y,{className:"p-4 flex items-center gap-3",children:[e.jsx(E,{className:"w-8 h-8 text-amber-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-amber-600",children:v.mediumRisk}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Medium Risk"})]})]})}),e.jsx(b,{className:"border-blue-500/30 bg-blue-500/5",children:e.jsxs(y,{className:"p-4 flex items-center gap-3",children:[e.jsx(ae,{className:"w-8 h-8 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:v.lowRisk}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Low Risk"})]})]})}),e.jsx(b,{className:"border-emerald-500/30 bg-emerald-500/5",children:e.jsxs(y,{className:"p-4 flex items-center gap-3",children:[e.jsx(We,{className:"w-8 h-8 text-emerald-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:v.safe}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Safe"})]})]})})]}),e.jsxs(b,{children:[e.jsxs(U,{className:"pb-2",children:[e.jsxs(V,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ze,{className:"w-5 h-5"}),"Portfolio Health Score"]}),e.jsxs(Y,{children:["Based on comparison with ",a.length," known failed LTD tools"]})]}),e.jsxs(y,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Safety Score"}),e.jsxs("span",{className:"text-2xl font-bold text-emerald-600",children:[v.safePercentage,"%"]})]}),e.jsx(Gt,{value:v.safePercentage,className:"h-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v.atRisk>0?`${v.atRisk} of your ${v.total} tools match known failed LTD patterns. Review the at-risk tools below.`:"Excellent! None of your tools match known failed LTD patterns."})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[e.jsx("div",{className:"flex flex-1 gap-4 w-full sm:w-auto",children:e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(be,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(ee,{placeholder:"Search your tools or failed tools...",value:s,onChange:u=>t(u.target.value),className:"pl-10"})]})}),e.jsxs(w,{variant:"outline",onClick:T,children:[e.jsx(Ds,{className:"w-4 h-4 mr-2"}),"Export Report"]})]}),e.jsxs(Ne,{value:r,onValueChange:u=>l(u),children:[e.jsxs(Pe,{className:"grid w-full grid-cols-3 max-w-md",children:[e.jsxs(q,{value:"all",className:"gap-2",children:["All",e.jsx(R,{variant:"secondary",className:"ml-1",children:f.length})]}),e.jsxs(q,{value:"at-risk",className:"gap-2",children:["At Risk",e.jsx(R,{variant:"destructive",className:"ml-1",children:v.atRisk})]}),e.jsxs(q,{value:"safe",className:"gap-2",children:["Safe",e.jsx(R,{className:"ml-1 bg-emerald-500",children:v.safe})]})]}),e.jsx(O,{value:r,className:"mt-6",children:g.length===0?e.jsx(b,{className:"border-dashed",children:e.jsxs(y,{className:"p-12 text-center",children:[e.jsx(xe,{className:"w-12 h-12 text-emerald-500 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:r==="at-risk"?"No At-Risk Tools Found":r==="safe"?"No Safe Tools Found":"No Tools to Compare"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto",children:r==="at-risk"?"Great news! None of your tools match known failed LTD patterns.":"Add some tools to your portfolio to
3start comparing."})]})}):e.jsx(ca,{className:"h-[600px] pr-4",children:e.jsx("div",{className:"space-y-3",children:g.map(u=>e.jsx(b,{className:k("transition-all hover:shadow-md",u.riskLevel==="high"&&"border-destructive/40 bg-destructive/5",u.riskLevel==="medium"&&"border-amber-500/40 bg-amber-500/5",u.riskLevel==="low"&&"border-blue-500/40 bg-blue-500/5"),children:e.jsx(y,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex-shrink-0",children:j(u.riskLevel)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium truncate",children:u.userToolName}),e.jsx(R,{variant:"outline",className:"text-xs",children:u.userToolSource==="appsumo"?"AppSumo":"Manual"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Tool"})]}),u.matchedFailedTool&&e.jsxs(e.Fragment,{children:[e.jsx(Ss,{className:"w-5 h-5 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium truncate",children:u.matchedFailedTool.name}),e.jsx(R,{variant:"outline",className:"text-xs",children:u.matchedFailedTool.marketplace})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.matchedFailedTool.status," ⢠",Math.round(u.similarityScore*100),"% match"]})]})]}),!u.matchedFailedTool&&e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm text-emerald-600",children:"No matching failed tools found"})}),e.jsx("div",{className:"flex-shrink-0",children:_(u.riskLevel)})]})})},u.userToolId))})})})]})]})}function De({title:s,value:t,description:r,icon:l,targetTab:a,onNavigate:n,isActive:i=!1,tone:d}){const c=Ps(),m=p.useCallback(()=>{n(a)},[n,a]),o=p.useCallback(h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),n(a))},[n,a]);return c?e.jsx(da,{role:"button",tabIndex:0,"aria-label":`${s}: ${t}. ${r}. Click to view ${s.toLowerCase()} details.`,"aria-pressed":i,onClick:m,onKeyDown:o,value:t,label:s,tone:d,active:i,className:"cursor-pointer transition-colors hover:border-primary/50 focus:outline-none focus:ring-2 focus:ring-ring"}):e.jsx(b,{role:"button",tabIndex:0,"aria-label":`${s}: ${t}. ${r}. Click to view ${s.toLowerCase()} details.`,"aria-pressed":i,onClick:m,onKeyDown:o,className:k("cursor-pointer transition-all duration-200 p-3","hover:shadow-md hover:border-primary/50 hover:bg-accent/50","focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2","active:scale-[0.98]",i&&"border-primary bg-accent/30 shadow-md"),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground truncate",children:s}),e.jsx("p",{className:"text-xl font-bold",children:t}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r})]}),e.jsx(l,{className:k("h-4 w-4 shrink-0 ml-2",i?"text-primary":"text-muted-foreground"),"aria-hidden":"true"})]})})}const pe=2e3;function Bs({comment:s,failedToolId:t,onReply:r,currentUserId:l,isAdmin:a=!1}){const n=Oa(),i=za(),d=qa(),[c,m]=p.useState(!1),[o,h]=p.useState(s.content),f=j=>{n.mutate({commentId:s.id,voteType:j,failedToolId:t})},g=()=>{confirm("Are you sure you want to delete this comment?")&&i.mutate({commentId:s.id,failedToolId:t})},v=()=>{o.trim()&&d.mutate({commentId:s.id,content:o.trim(),failedToolId:t},{onSuccess:()=>m(!1)})},T=l===s.user_id;return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/30",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs font-medium",children:s.display_name&&s.display_name.trim()||"Anonymous"}),a&&T&&e.jsx(R,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 bg-primary/10 text-primary border-primary/30",children:"Admin"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Ms(new Date(s.created_at),{addSuffix:!0})}),s.updated_at&&s.updated_at!==s.created_at&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"(edited)"})]}),c?e.jsxs("div",{className:"space-y-2 w-full",children:[e.jsx(ze,{value:o,onChange:j=>
3h(j.target.value),className:"min-h-[60px] resize-none text-sm"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>m(!1),children:"Cancel"}),e.jsx(w,{size:"sm",onClick:v,disabled:!o.trim()||d.isPending,children:"Save"})]})]}):e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:s.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(w,{variant:"ghost",size:"sm",className:`h-7 px-2 ${s.user_vote==="up"?"text-green-500":""}`,onClick:()=>f("up"),children:[e.jsx(Cs,{className:"h-3.5 w-3.5 mr-1"}),e.jsx("span",{className:"text-xs",children:s.vote_count||0})]}),e.jsx(w,{variant:"ghost",size:"sm",className:`h-7 px-2 ${s.user_vote==="down"?"text-red-500":""}`,onClick:()=>f("down"),children:e.jsx(kt,{className:"h-3.5 w-3.5"})}),e.jsxs(w,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>r(s.id),children:[e.jsx(As,{className:"h-3.5 w-3.5 mr-1"}),e.jsx("span",{className:"text-xs",children:"Reply"})]}),T&&!c&&e.jsx(w,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:()=>{m(!0),h(s.content)},title:"Edit your comment",children:e.jsx(Ts,{className:"h-3.5 w-3.5"})}),(T||a)&&e.jsx(w,{variant:"ghost",size:"sm",className:"h-7 px-2 text-destructive hover:text-destructive",onClick:g,title:a&&!T?"Delete as admin":"Delete your comment",children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})]})]})}),s.replies&&s.replies.length>0&&e.jsx("div",{className:"ml-6 pl-4 border-l-2 border-muted space-y-2",children:s.replies.map(j=>e.jsx(Bs,{comment:j,failedToolId:t,onReply:r,currentUserId:l,isAdmin:a},j.id))})]})}function yr({failedToolId:s}){const[t,r]=p.useState(""),[l,a]=p.useState(null),[n,i]=p.useState("newest"),{data:d=[],isLoading:c}=Ia(s),m=Pa(),{isAdmin:o}=es(),{data:h}=ce({queryKey:["current-user"],queryFn:async()=>{const{data:{user:_}}=await S.auth.getUser();return _}}),f=d.length+d.reduce((_,u)=>_+(u.replies?.length||0),0),g=p.useMemo(()=>{const _=[...d];switch(n){case"newest":return _.sort((u,N)=>new Date(N.created_at).getTime()-new Date(u.created_at).getTime());case"oldest":return _.sort((u,N)=>new Date(u.created_at).getTime()-new Date(N.created_at).getTime());case"top":return _.sort((u,N)=>(N.vote_count||0)-(u.vote_count||0));default:return _}},[d,n]),v=()=>{!t.trim()||t.length>pe||m.mutate({failedToolId:s,content:t.trim(),parentId:l||void 0},{onSuccess:()=>{r(""),a(null)}})},T=_=>{a(_)},j=()=>{a(null)};return e.jsxs(b,{children:[e.jsx(U,{className:"pb-3",children:e.jsxs(V,{className:"text-base flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4"}),"Community Discussion",f>0&&e.jsxs(R,{variant:"secondary",className:"ml-auto",children:[f," ",f===1?"comment":"comments"]})]})}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[l&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(As,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Replying to a comment"}),e.jsx(w,{variant:"ghost",size:"sm",className:"h-6 px-2",onClick:j,children:"Cancel"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ze,{placeholder:"Share your experience or insights about this tool...",value:t,onChange:_=>r(_.target.value),className:"min-h-[80px] resize-none",maxLength:pe+100})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`text-xs ${t.length>pe?"text-destructive":"text-muted-foreground"}`,children:[t.length,"/",pe]}),e.jsxs(w,{size:"sm",onClick:v,disabled:!t.trim()||t.length>pe||m.isPending,children:[e.jsx(yt,{className:"h-3.5 w-3.5 mr-1"}),l?"Reply":"Comment"]})]})]}),e.jsx(me,{}),f>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[f," ",f===1?"comment":"comments"]}),e.jsxs(W,{value:n,onValueChange:_=>i(_),children:[e.jsx(Q,{className:"w-[140px] h-8 text-xs",children:e.jsx(X,{})}),e.jsxs(J,{children:[e.jsx(I,{value:"newest",children:"Newest first"}),e.jsx(I,{value:"oldest",children:"Oldest first"}),e.jsx(I,{value:"top",children:"Most liked"})]})]})]}),c?e.jsx("div",{className:"text-center py-4 text-muted-foreground text-sm",children:"Loading comments..."}):d.length===0?e.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[e.jsx(ne,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No comments yet. Be the first to share your experience!"})]}):e.jsx("div",{className:"space-y-3",children:g.map(_=>e.jsx(Bs,{comment:_,failedToolId:s,onReply:T,currentUserId:h?.id,isAdmin:o},_.id))})]})]})}function Ws(){const[s,t]=p.useState(""),[r,l]=p.useState(null),{data:a=[]}=se(),n=te(),{data:i={}}=ce({queryKey:["all-discussion-counts"],queryFn:async()=>{const{data:h}=await S.from("failed_tool_comments").select("failed_tool_id");if(!h)return{};const f={};return h.forEach(g=>{f[g.failed_tool_id]=(f[g.failed_tool_id]||0)+1}),f}}),d=p.useMemo(()=>a.filter(f=>s?f.product_name.toLowerCase().includes(s.toLowerCase()):!0).map(f=>({...f,commentCount:i[f.id]||0})).sort((f,g)=>g.commentCount-f.commentCount),[a,i,s]),c=a.find(h=>h.id===r),m=Object.values(i).filter(h=>h>0).length,o=Object.values(i).reduce((h,f)=>h+f,0);return r&&c?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>{l(null),n.invalidateQueries({queryKey:["all-discussion-counts"]})},className:"hover:bg-primary/10",children:e.jsx(Ls,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:c.product_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[c.marketplace," · ",c.status]})]})]}),e.jsx(yr,{failedToolId:r})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsx(b,{children:e.jsxs(y,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold",children:o}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Comments"})]})}),e.jsx(b,{children:e.jsxs(y,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold",children:m}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active Discussions"})]})}),e.jsx(b,{children:e.jsxs(y,{className:"p-4 text-center",children:[e.jsx("p",{className:"text-2xl font-bold",children:a.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tools in Database"})]})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(be,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}
3),e.jsx(ee,{placeholder:"Search tools to join a discussion...",value:s,onChange:h=>t(h.target.value),className:"pl-10"})]}),o===0&&!s&&e.jsx(b,{className:"border-dashed",children:e.jsxs(y,{className:"py-6 text-center",children:[e.jsx(ne,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No discussions yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Be the first to share your experience with a tool â click any tool below to start a conversation."})]})}),e.jsx("div",{className:"space-y-2",children:d.length===0?e.jsx(b,{children:e.jsxs(y,{className:"py-8 text-center text-muted-foreground",children:[e.jsx(ne,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No tools match your search."})]})}):d.map(h=>e.jsx(b,{className:"cursor-pointer hover:border-primary/50 transition-colors",onClick:()=>l(h.id),children:e.jsxs(y,{className:"p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ne,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:h.product_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[h.marketplace," · ",h.status]})]})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:h.commentCount>0?e.jsxs(R,{variant:"secondary",children:[h.commentCount," comment",h.commentCount!==1?"s":""]}):e.jsx(R,{variant:"outline",className:"text-muted-foreground",children:"Start discussion"})})]})},h.id))})]})}function kr(){const{data:s=[],isLoading:t,isError:r,refetch:l}=se();return{founders:p.useMemo(()=>{const n=new Map;for(const i of s){const d=i.founder_name?.trim();if(!d)continue;const c=oe(d);if(!c)continue;const m=n.get(c);m?(m.tools.push(i),m.toolIds.push(i.id)):n.set(c,{name:d,normalized:c,tools:[i],toolIds:[i.id]})}return Array.from(n.values())},[s]),isLoading:t,isError:r,refetch:l}}const vs=80,Ns=2,_r=6,Cr=5;function Qs(){const[s,t]=p.useState(""),{founders:r,isLoading:l,isError:a,refetch:n}=kr(),i=s.replace(/\s+/g," ").trimStart().slice(0,vs),d=ha(i.trim(),250),c=i.trim()!==d,m=p.useMemo(()=>Ma(d,r),[d,r]),o=p.useMemo(()=>{const j=new Map;for(const _ of r)j.set(_.normalized,_);return j},[r]),h=m.filter(j=>j.score>=fs),f=m.filter(j=>j.score<fs).slice(0,Cr),g=d.length>0,v=g&&d.length<Ns,T=g&&!v&&!c&&!l;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Ee,{className:"h-5 w-5 text-primary"}),"Founder Lookup"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter a founder's name to check whether they're linked to any failed, shut-down, or revoked LTD tools in the community database."})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ee,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground pointer-events-none"}),e.jsx(ee,{type:"text",inputMode:"text",autoComplete:"off",spellCheck:!1,maxLength:vs,"aria-label":"Founder name",placeholder:"e.g. Jane Doe",value:i,onChange:j=>t(j.target.value),className:"pl-10 pr-10"}),i.length>0&&e.jsx(w,{type:"button",variant:"ghost",size:"icon","aria-label":"Clear search",onClick:()=>t(""),className:"absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7 text-muted-foreground hover:text-foreground",children:e.jsx(Je,{className:"h-4 w-4"})})]}),e.jsxs("div",{"aria-live":"polite","aria-atomic":"true",className:"space-y-4",children:[a&&e.jsxs(He,{variant:"destructive",children:[e.jsx(E,{className:"h-4 w-4"}),e.jsx(as,{children:"Couldn't load the founder database"}),e.jsxs(Ye,{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"Something went wrong fetching the data."}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>n(),children:"Try again"})]})]}),!a&&!g&&e.jsx("p",{className:"text-sm text-muted-foreground",children:l?"Loading the founder databaseâ¦":`Start typing â ${r.length} founder${r.length===1?"":"s"} indexed from the failed-tools database.`}),!a&&v&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Keep typing â enter at least ",Ns," characters to search."]}),!a&&g&&!v&&(c||l)&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(_t,{className:"h-4 w-4 animate-spin"}),"Searchingâ¦"]}),!a&&T&&h.length>0&&h.map(j=>{const u=o.get(j.normalized)?.tools??[],N=u.slice(0,_r),D=u.length-N.length;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(He,{variant:"destructive",children:[e.jsx(Fe,{className:"h-4 w-4"}),e.jsxs(as,{className:"flex items-center gap-2",children:["Founder identified: ",j.name,e.jsxs(R,{variant:"destructive",className:"shrink-0",children:[Math.round(j.score*100),"% match"]})]}),e.jsxs(Ye,{children:["Heads up â this founder is linked to ",u.length," failed LTD"," ","tool",u.length===1?"":"s"," in the community database. Factor this in before buying their next deal."]})]}),e.jsx("div",{className:"space-y-3",children:N.map(x=>e.jsx(Ie,{tool:x},x.id))}),D>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["+ ",D," more tool",D===1?"":"s"," linked to this founder. See the Database tab for the full list."]})]},j.normalized)}),!a&&T&&h.length===0&&f.length>0&&e.jsx(b,{children:e.jsxs(y,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ve,{className:"h-4 w-4 text-amber-500"}),"No exact match for â",d,"â. Did you mean:"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(j=>e.jsxs(w,{type:"button",variant:"outline",size:"sm",onClick:()=>t(j.name),children:[j.name,e.jsxs(R,{variant:"secondary",className:"ml-2",children:[Math.round(j.score*100),"%"]})]},j.normalized))})]})}),!a&&T&&m.length===0&&e.jsx(b,{children:e.jsxs(y,{className:"p-6 text-center space-y-3",children:[e.jsx(We,{className:"h-10 w-10 text-green-600 mx-auto"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium",children:["No founder matching â",d,"â found"]}
3),e.jsx("p",{className:"text-sm text-muted-foreground",children:"That's a good sign â this name isn't linked to any failed tool we track. Double-check the spelling, or contribute it if you know of a tool they ran that shut down."})]}),e.jsx(Le,{})]})})]})]})}function Sr(){const[s,t]=p.useState("risks"),{data:r=[]}=se(),{data:l=[]}=qe(),{data:a=[]}=ce({queryKey:["user-archived-tools"],queryFn:async()=>{const{data:{user:i}}=await S.auth.getUser();if(!i)return[];const{data:d}=await S.from("user_archived_tools").select("*").eq("user_id",i.id);return d||[]}}),n=[{label:"Your Risks",value:l.length,icon:E,color:"text-amber-500",bgColor:"bg-amber-500/10",tab:"risks"},{label:"Archived",value:a.length,icon:ge,color:"text-purple-500",bgColor:"bg-purple-500/10",tab:"archive"},{label:"Database",value:r.length,icon:Z,color:"text-red-500",bgColor:"bg-red-500/10",tab:"database"}];return e.jsxs(ua,{headerContent:e.jsx(xa,{title:"Founder Track",subtitle:"Monitor your investment risks",rightActions:[e.jsx(Le,{children:e.jsxs(w,{size:"sm",className:"h-9 gap-1.5 px-3 text-xs","aria-label":"Report a failed tool",children:[e.jsx(Me,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),"Report"]})},"contribute")]}),children:[e.jsx("div",{className:"grid grid-cols-2 gap-3 mb-4",children:n.map(i=>{const d=i.icon,c=s===i.tab;return e.jsx(rt,{className:k("p-3 transition-all",c&&"ring-2 ring-primary ring-offset-2"),onClick:()=>t(i.tab),children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:k("w-10 h-10 rounded-lg flex items-center justify-center",i.bgColor),children:e.jsx(d,{className:k("h-5 w-5",i.color)})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:i.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.label})]})]})},i.tab)})}),l.length>0&&e.jsx(b,{className:"p-3 mb-4 bg-amber-500/10 border-amber-500/20",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ae,{className:"h-5 w-5 text-amber-500 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium",children:[l.length," tool",l.length!==1?"s":""," at risk"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Review your portfolio for potential issues"})]}),e.jsx(w,{variant:"ghost",size:"sm",className:"shrink-0",onClick:()=>t("risks"),children:"View"})]})}),e.jsxs(Ne,{value:s,onValueChange:t,className:"pb-4",children:[e.jsxs(tt,{columns:5,className:"mb-4",testId:"founder-track-tabs",children:[e.jsx(fe,{value:"risks",label:"Risks",icon:E}),e.jsx(fe,{value:"alerts",label:"Alerts",icon:ue}),e.jsx(fe,{value:"database",label:"DB",icon:Z}),e.jsx(fe,{value:"lookup",label:"Founder",icon:Ee}),e.jsx(fe,{value:"discussion",label:"Discuss",icon:ne})]}),e.jsx(fa,{mode:"wait",children:e.jsxs(pa.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:[e.jsx(O,{value:"risks",className:"mt-0 space-y-4",children:e.jsx(Hs,{})}),e.jsx(O,{value:"alerts",className:"mt-0 space-y-4",children:e.jsx(Ys,{})}),e.jsx(O,{value:"database",className:"mt-0",children:e.jsxs(b,{className:"p-6 text-center",children:[e.jsx(Z,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"Community Database"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[r.length," failed tools tracked"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"View full database on desktop for better experience"})]})}),e.jsx(O,{value:"lookup",className:"mt-0",children:e.jsx(Qs,{})}),e.jsx(O,{value:"discussion",className:"mt-0",children:e.jsx(Ws,{})})]},s)})]})]})}const Tr=["risks","compare","alerts","analytics","database","lookup","discussion","archive","settings"];function Sl(){const{goBack:s,navigateTo:t}=Na(),r=et(),[l]=st(),[a,n]=ra("risks");p.useEffect(()=>{const x=r.pathname.split("/"),L=x[x.length-1];if(L==="watchlist"||l.get("tab")==="watchlist"){t(ga,{replace:!0});return}Tr.includes(L)&&!l.has("tab")&&t(`/app/founder-track?tab=${L}`,{replace:!0})},[]);const{user:i}=bs();p.useEffect(()=>{ba("founder-track",i?.id)},[i?.id]);const[d,c]=p.useState(!1),[m,o]=p.useState("all"),h=ja(),{data:f=[]}=se(),{data:g=[]}=qe(),v=p.useMemo(()=>{const x=new Map;for(const L of g){const M=L.userToolName.toLowerCase().trim(),z=x.get(M);(!z||L.similarityScore>z.similarityScore)&&x.set(M,L)}return Array.from(x.values())},[g]),T=va(),{announceMessage:j}=at(),_=p.useRef(null),u=Ps(),{data:N=[]}=ce({queryKey:["user-archived-tools"],queryFn:async()=>{const{data:{user:x}}=await S.auth.getUser();if(!x)return[];const{data:L}=await S.from("user_archived_tools").select("*").eq("user_id",x.id);return L||[]}}),D=p.useCallback(x=>{n(x),j(`Navigated to ${{risks:"My Risks",compare:"Compare",alerts:"Alerts",analytics:"Analytics",database:"Database",lookup:"Founder Lookup",discu
3ssion:"Discussion",archive:"Archive",settings:"Settings"}[x]||x} tab`),setTimeout(()=>{_.current?.scrollIntoView({behavior:"smooth",block:"start"})},100)},[j]);return h&&T.canAccessFounderTrack?e.jsx(Sr,{}):T.canAccessFounderTrack?e.jsx(ts,{children:e.jsxs("section",{className:"w-full px-4 md:px-6 lg:px-8 space-y-4 pb-8 sm:pb-10",children:[u?e.jsx(ma,{title:"Founder Track",subtitle:"Track failed LTD tools and assess portfolio risk",actions:e.jsx(Le,{})}):e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:s,className:"hover:bg-primary/10","aria-label":"Go back",children:e.jsx(Ls,{className:"h-5 w-5"})}),e.jsx(E,{className:"h-5 w-5 text-destructive"}),e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-foreground",children:"Founder Track"})]}),e.jsx(Le,{})]}),e.jsxs("nav",{"aria-label":"Quick navigation to Founder Track sections",className:"grid gap-3 md:grid-cols-4",role:"navigation",children:[e.jsx(De,{title:"Total Failed Tools",value:f.length,description:"Community database",icon:Z,targetTab:"database",onNavigate:x=>{o("all"),D(x)},isActive:a==="database"}),e.jsx(De,{title:"Your Risks",value:v.length,description:"Tools at risk",icon:E,tone:v.length>0?"danger":void 0,targetTab:"risks",onNavigate:D,isActive:a==="risks"}),e.jsx(De,{title:"Archived",value:N.length,description:"Your archived tools",icon:ge,targetTab:"archive",onNavigate:D,isActive:a==="archive"}),e.jsx(De,{title:"Recent Activity",value:f.filter(x=>{const L=new Date(x.created_at||""),M=new Date(Date.now()-10080*60*1e3);return L>M}).length,description:"New DB entries (7 days)",icon:ie,targetTab:"database",onNavigate:x=>{o("7"),D(x)},isActive:a==="database"})]}),e.jsx("div",{ref:_,children:e.jsxs(Ne,{value:a,onValueChange:D,children:[e.jsxs(Pe,{className:"grid w-full grid-cols-10",children:[e.jsxs(q,{value:"risks",className:"flex items-center gap-1.5",children:[e.jsx(E,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"My Risks"})]}),e.jsxs(q,{value:"compare",className:"flex items-center gap-1.5",children:[e.jsx(Ct,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Compare"})]}),e.jsxs(q,{value:"alerts",className:"flex items-center gap-1.5",children:[e.jsx(ue,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Alerts"})]}),e.jsxs(q,{value:"analytics",className:"flex items-center gap-1.5",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Analytics"})]}),e.jsxs(q,{value:"database",className:"flex items-center gap-1.5",children:[e.jsx(Z,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Database"})]}),e.jsxs(q,{value:"lookup",className:"flex items-center gap-1.5",children:[e.jsx(Ee,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Founder Lookup"})]}),e.jsxs(q,{value:"discussion",className:"flex items-center gap-1.5",children:[e.jsx(ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Discussion"})]}),e.jsxs(q,{value:"archive",className:"flex items-center gap-1.5",children:[e.jsx(ge,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Archive"})]}),e.jsxs(q,{value:"settings",className:"flex items-center gap-1.5",children:[e.jsx(St,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]})]}),e.jsx(O,{value:"risks",className:"mt-4",children:e.jsx(Hs,{})}),e.jsx(O,{value:"compare",className:"mt-4",children:e.jsx(wr,{})}),e.jsx(O,{value:"alerts",className:"mt-4",children:e.jsx(Ys,{})}),e.jsx(O,{value:"analytics",className:"mt-4",children:e.jsx(Nr,{})}),e.jsx(O,{value:"database",className:"mt-4",children:e.jsx(pr,{initialNewlyAddedFilter:m})}),e.jsx(O,{value:"lookup",className:"mt-4",children:e.jsx(Qs,{})}),e.jsx(O,{value:"discussion",className:"mt-4",children:e.jsx(Ws,{})}),e.jsx(O,{value:"archive",className:"mt-4",children:e.jsx(gr,{})}),e.jsx(O,{value:"settings",className:"mt-4",children:e.jsx(br,{})})]})})]})}):e.jsx(ts,{children:e.jsxs("section",{className:"w-full px-4 md:px-6 lg:px-8 space-y-4 pb-8 sm:pb-10",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{className:"h-5 w-5 text-destructive"}),e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-foreground",children:"Founder Track"})]}),e.jsxs(He,{children:[e.jsx(E,{className:"h-4 w-4"}),e.jsxs(Ye,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Founder Track is available on Pro, Team, and Trial plans."}),e.jsx(w,{onClick:()=>c(!0),variant:"default",size:"sm",children:"Upgrade Now"})]})]}),e.jsxs(b,{children:[e.jsxs(U,{children:[e.jsx(V,{children:"What is Founder Track?"}),e.jsx(Y,{children:"Track failed LTD tools, assess investment risks, and make informed decisions about your software portfolio."})]}),e.jsx(y,{className:"space-y-4",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(E,{className:"h-4 w-4 text-amber-500"}),"Risk Assessment"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Identify which of your tools are at risk based on community data"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4 text-red-500"}),"Community Database"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Access a comprehensive database of failed LTD tools"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4 text-blue-500"}),"Personal Archive"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Keep track of your archived tools and lessons learned"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[e.jsx(ie,{className:"h-4 w-4 text-purple-500"}),"Early Warnings"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Get notified when tools show signs of potential failure"})]})]})})]}),e.jsx(la,{open:d,onOpenChange:c})]})})}export{Sl 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.