PageSourceSearch

https://viberank.dev/assets/AiToolFinderWidget-C4RAVrWm.js

js viberank.dev collected 2026-10-07 11:11:58 UTC 15,707 bytes, 1 lines download raw bytes

1import{r as l,j as e}from"./chunk-LFPYN7LY-0V9Ouenh.js";import{s as k}from"./createLucideIcon-DydsfW6r.js";import{a as j}from"./root-CiEsOx67.js";import{X as T}from"./x-TALoS3bc.js";import{L as D}from"./loader-2-CVgBrUD8.js";import{S as M}from"./send-B_oRGAWA.js";import{C as V}from"./chevron-up-saOR8yxj.js";import{C as Q}from"./chevron-down-YvvwCGMw.js";import"./index-B-WUrmPz.js";import"./index-DTVyCUS5.js";import"./AuthContext-DvDJYzs8.js";import"./ModalContext-DXEQhrtl.js";import"./xPixel-Dw5GTEdl.js";import"./credit-card-DRsAZGP6.js";import"./users-Cjr0jlYC.js";import"./shield-Bk2RJbgs.js";import"./file-text-BdWJGzM1.js";import"./mail-Bpzu1ozM.js";import"./zap-CaCOulTc.js";import"./message-square-BjyX8d_g.js";import"./thumbs-up-DZ1rrSMn.js";import"./thumbs-down-Dy5CCAe9.js";import"./upload-Cu2Q8pqm.js";import"./index-DuC5hf20.js";import"./iconBase-Bvdjejg3.js";const ve=({user:$,initialOpen:P=!1})=>{const[B,N]=l.useState(P),[n,_]=l.useState(!1),[c,p]=l.useState(""),[m,A]=l.useState(!1),[g,F]=l.useState([]),[u,o]=l.useState(null),[C,h]=l.useState(!1),x=l.useRef(null);l.useEffect(()=>{x.current&&(x.current.style.height="auto",x.current.style.height=`${Math.min(x.current.scrollHeight,120)}px`)},[c]);const H=async r=>{try{const{data:a,error:f}=await k.functions.invoke("analyze-url",{body:{url:r}});if(f)throw console.error("Error analyzing URL:",f),new Error(f.message||"Failed to analyze URL");if(!a||!a.summary)throw new Error("No summary received from URL analysis");return a.summary}catch(a){throw console.error("URL analysis error:",a),new Error(a.message||"Failed to analyze URL")}},y=async()=>{if(!$){o("Please sign in to use AI Tool Finder");return}A(!0),o(null),h(!1);try{const r=c.trim();if(!r){o("Please tell us what you need");return}let a="";if(r.includes("http")||r.includes("www.")||r.includes(".com")||r.includes(".org")||r.includes(".net")||r.includes(".io")||r.includes(".dev"))try{a=await H(r)}catch(i){o(i.message||"Failed to analyze the provided URL");return}else a=r;const{data:I,error:d}=await k.functions.invoke("process-apps-with-ai",{body:{user_query:a}});if(d){console.error("Supabase function invoke error:",d);let i="Failed to get AI recommendations.";throw d.context&&typeof d.context.error_message=="string"?i=d.context.error_message:typeof d.message=="string"&&(i=d.message),new Error(i)}if(!I)throw new Error("Received empty response from AI recommendations function.");const K=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,b=I.ai_recommendations;if(b&&b.top_apps){let i=[];Array.isArray(b.top_apps)&&(i=b.top_apps);const z=i.filter(t=>t.app_id&&typeof t.app_id=="string"&&K.test(t.app_id)),v=z.map(t=>t.app_id),R=new Map;if(z.forEach(t=>{R.set(t.app_id,t.relevance_explanation||"")}),v.length===0){o("No recommendations found for your query.");return}const{data:w,error:U}=await k.from("apps").select("*").in("id",v);if(U)throw console.error("Supabase DB error:",U),new Error("Failed to fetch app details.");if(w&&w.length>0){const t=v.map(L=>{const s=w.find(q=>q.id===L);return s?{id:s.id,name:s.name,tagline:s.tagline,url:s.url,logo:s.logo,upvotes:s.upvotes,downvotes:s.downvotes,category:s.category,relevance_explanation:R.get(L),current_rank_all_time:s.current_rank_all_time}:null}).filter(Boolean);F(t),h(!0)}else o("Could not load details for the recommended applications.")}else o("No recommendations found for your query.")}catch(r){console.error("Error fetching AI recommendations:",r),o(r.message||"Failed to fetch AI recommendations. Please try again.")}finally{A(!1)}},E=r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),y())},O=()=>{p(""),o(null),F([]),h(!1)},S=()=>{N(!1),_(!1),O()},W=()=>{_(!n)};return B?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"md:hidden fixed inset-0 bg-black/60 backdrop-blur-sm z-40 p-4 flex flex-col justify-center items-center",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl shadow-2xl border border-gray-200/20 dark:border-gray-700/30 flex flex-col h-[60vh] max-h-[60vh] overflow-hidden w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-100 dark:border-gray-800 bg-gradient-to-br from-teal-50/80 via-emerald-50/60 to-cyan-50/40 dark:from-gray-900 dark:via-gray-800 dark:to-gray-900 rounded-t-2xl",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-7 h-7 bg-gradient-to-br from-teal-500 via-emerald-500 to-cyan-500 rounded-full flex items-center justify-center shadow-lg",children:e.jsx(j,{className:"w-3.5 h-3.5 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold bg-gradient-to-r from-gray-900 to-gray-700 dark:from-white dark:to-gray-200 bg-clip-text text-transparent",children:"AI Tool Finder"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Find the perfect tools for your needs"})]})]}),e.jsx("button",{onClick:S,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-2 rounded-lg hover:bg-white/60 dark:hover:bg-gray-800/60 touch-manipulation","aria-label":"Close AI Tool Finder",children:e.jsx(T,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 pb-safe",children:C?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-lg font-bold text-gray-900 dark:text-white",children:["Found ",g.length," tools"]}),e.jsx("button",{onClick:()=>
1h(!1),className:"text-sm text-teal-600 dark:text-teal-400 hover:text-teal-700 dark:hover:text-teal-300 font-medium px-3 py-2 rounded-lg hover:bg-teal-50 dark:hover:bg-teal-900/20 touch-manipulation",children:"New Search"})]}),e.jsx("div",{className:"space-y-4",children:g.map(r=>e.jsx("div",{className:"flex flex-col sm:flex-row gap-4 p-4 border border-gray-200/60 dark:border-gray-700/60 rounded-xl hover:border-teal-300 dark:hover:border-teal-500 transition-all duration-200 bg-gradient-to-br from-gray-50/30 to-white dark:from-gray-800/30 dark:to-gray-900",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("img",{src:r.logo,alt:`${r.name} logo`,className:"w-12 h-12 rounded-lg object-cover shadow-sm border border-gray-200/60 dark:border-gray-700/60 flex-shrink-0",onError:a=>{a.target.src=`https://via.placeholder.com/48x48?text=${r.name.charAt(0).toUpperCase()}`}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white text-base",children:r.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1 leading-tight",style:{display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden"},children:r.tagline})]}),e.jsx("div",{className:"flex items-center gap-2 ml-3",children:e.jsxs("span",{className:"text-xs text-teal-600 dark:text-teal-400 font-medium px-2 py-1 bg-teal-50 dark:bg-teal-900/30 rounded-full",children:["#",r.current_rank_all_time||"?"]})})]}),r.category&&e.jsx("span",{className:"inline-block mb-3 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-full",children:r.category}),r.relevance_explanation&&e.jsx("div",{className:"mb-3 p-3 bg-teal-50 dark:bg-teal-900/20 rounded-lg border border-teal-200 dark:border-teal-800",children:e.jsx("p",{className:"text-sm text-teal-700 dark:text-teal-300",children:r.relevance_explanation})}),e.jsx("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm bg-gradient-to-r from-teal-500 to-emerald-500 text-white px-4 py-2 rounded-lg hover:from-teal-600 hover:to-emerald-600 transition-all duration-200 font-medium touch-manipulation",children:"Visit App"})]})]})},r.id))})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Drop a link or describe what you're looking for..."}),u&&e.jsx("div",{className:"p-4 bg-red-50/80 dark:bg-red-900/20 border border-red-200/60 dark:border-red-800/60 rounded-xl",children:e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:u})})]})}),e.jsx("div",{className:"border-t border-gray-100 dark:border-gray-800 p-4 bg-white dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1",children:e.jsx("textarea",{ref:x,value:c,onChange:r=>p(r.target.value),onKeyPress:E,className:"w-full p-3 sm:p-4 border border-gray-200 dark:border-gray-700 rounded-xl focus:ring-2 focus:ring-teal-500/20 focus:border-teal-500 dark:bg-gray-800 dark:text-white resize-none text-sm sm:text-base transition-all duration-200 overflow-y-hidden",rows:1,style:{minHeight:"44px",maxHeight:"120px"},disabled:m})}),e.jsx("button",{onClick:y,disabled:m||!c.trim(),className:"bg-gradient-to-r from-teal-500 to-emerald-500 text-white p-3 sm:p-4 rounded-xl hover:from-teal-600 hover:to-emerald-600 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 shadow-lg hover:shadow-xl active:scale-95 touch-manipulation","aria-label":"Submit search",children:m?e.jsx(D,{className:"w-4 h-4 sm:w-5 sm:h-5 animate-spin"}):e.jsx(M,{className:"w-4 h-4 sm:w-5 sm:h-5"})})]})})]})}),e.jsx("div",{className:"hidden md:block fixed bottom-6 right-6 z-40",children:e.jsxs("div",{className:`bg-white dark:bg-gray-900 rounded-2xl shadow-2xl border border-gray-200/20 dark:border-gray-700/30 transition-all duration-300 ${n?"w-80 h-16":"w-96 h-[600px]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-100 dark:border-gray-800 bg-gradient-to-br from-teal-50/80 via-emerald-50/60 to-cyan-50/40 dark:from-gray-900 dark:via-gray-800 dark:to-gray-900 rounded-t-2xl",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-teal-500 via-emerald-500 to-cyan-500 rounded-full flex items-center justify-center shadow-lg",children:e.jsx(j,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold bg-gradient-to-r from-gray-900 to-gray-700 dark:from-white dark:to-gray-200 bg-clip-text text-transparent",children:"AI Tool Finder"}),!n&&e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Find the perfect tools for your needs"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:W,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1 rounded-lg hover:bg-white/60 dark:hover:bg-gray-800/60","aria-label":n?"Expand":"Minimize",children:n?e.jsx(V,{className:"w-4 h-4"}):e.jsx(Q,{className:"w-4 h-4"})}),e.jsx("button",{onClick:S,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors p-1 rounded-lg hover:bg-white/60 dark:hover:bg-gray-800/60","aria-label":"Close AI Tool Finder",children:e.jsx(T,{className:"w-4 h-4"})})]})]}),!n&&e.jsxs("div",{className:"flex flex-col h-[calc(600px-80px)]",children:[e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:C?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-lg font-bold text-gray-900 dark:text-white",children:["Found ",g.length," tools"]}),e.jsx("button",{onClick:()=>
1h(!1),className:"text-sm text-teal-600 dark:text-teal-400 hover:text-teal-700 dark:hover:text-teal-300 font-medium",children:"New Search"})]}),e.jsx("div",{className:"space-y-4",children:g.map(r=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border border-gray-200/60 dark:border-gray-700/60 rounded-xl hover:border-teal-300 dark:hover:border-teal-500 transition-all duration-200 bg-gradient-to-br from-gray-50/30 to-white dark:from-gray-800/30 dark:to-gray-900",children:[e.jsx("img",{src:r.logo,alt:`${r.name} logo`,className:"w-10 h-10 rounded-lg object-cover shadow-sm border border-gray-200/60 dark:border-gray-700/60",onError:a=>{a.target.src=`https://via.placeholder.com/40x40?text=${r.name.charAt(0).toUpperCase()}`}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white text-sm truncate",children:r.name}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1 leading-tight",style:{display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden"},children:r.tagline}),r.category&&e.jsx("span",{className:"inline-block mt-2 px-2 py-0.5 text-xs bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded-full",children:r.category})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.jsxs("span",{className:"text-xs text-teal-600 dark:text-teal-400 font-medium",children:["#",r.current_rank_all_time||"?"]}),e.jsx("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs bg-gradient-to-r from-teal-500 to-emerald-500 text-white px-2 py-1 rounded-lg hover:from-teal-600 hover:to-emerald-600 transition-all duration-200 font-medium",children:"Visit"})]})]}),r.relevance_explanation&&e.jsx("div",{className:"mt-2 p-2 bg-teal-50 dark:bg-teal-900/20 rounded-lg border border-teal-200 dark:border-teal-800",children:e.jsx("p",{className:"text-xs text-teal-700 dark:text-teal-300",children:r.relevance_explanation})})]})]},r.id))})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Drop a link or describe what you're looking for..."}),u&&e.jsx("div",{className:"p-3 bg-red-50/80 dark:bg-red-900/20 border border-red-200/60 dark:border-red-800/60 rounded-xl",children:e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:u})})]})}),e.jsx("div",{className:"border-t border-gray-100 dark:border-gray-800 p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx("textarea",{ref:x,value:c,onChange:r=>p(r.target.value),onKeyPress:E,placeholder:"Describe what you're looking for...",className:"w-full p-3 border border-gray-200 dark:border-gray-700 rounded-xl focus:ring-2 focus:ring-teal-500/20 focus:border-teal-500 dark:bg-gray-800 dark:text-white resize-none text-sm placeholder:text-gray-400 dark:placeholder:text-gray-500 transition-all duration-200",rows:1,style:{minHeight:"44px",maxHeight:"120px"},disabled:m})}),e.jsx("button",{onClick:y,disabled:m||!c.trim(),className:"bg-gradient-to-r from-teal-500 to-emerald-500 text-white p-3 sm:p-4 rounded-xl hover:from-teal-600 hover:to-emerald-600 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 shadow-lg hover:shadow-xl","aria-label":"Submit search",children:m?e.jsx(D,{className:"w-4 h-4 animate-spin"}):e.jsx(M,{className:"w-4 h-4"})})]})})]})]})})]}):e.jsx("div",{className:"fixed bottom-8 right-4 sm:bottom-6 sm:right-6 z-40",children:e.jsx("button",{onClick:()=>N(!0),className:"bg-gradient-to-r from-teal-500 via-emerald-500 to-cyan-500 text-white px-6 py-4 sm:px-6 sm:py-4 rounded-full shadow-lg hover:shadow-xl transition-all duration-300 transform hover:scale-105 active:scale-95 group touch-manipulation flex items-center justify-center","aria-label":"Open AI Tool Finder",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{className:"w-5 h-5 sm:w-7 sm:h-6"}),e.jsx("span",{className:"text-sm sm:text-base font-medium whitespace-nowrap",children:"AI Tool Finder"})]})})})};export{ve 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.