PageSourceSearch

https://sufiyanpro-omniroute.hf.space/_next/static/chunks/77657.4e3c65204b6f30cb.js

js sufiyanpro-omniroute.hf.space collected 2026-10-03 17:25:51 UTC 8,885 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[77657],{77657:(e,r,t)=>{t.r(r),t.d(r,{default:()=>o});var s=t(95155),a=t(12115),l=t(50910),i=t(98500),d=t.n(i);function n(e,r=!1){return 0===e.length?-1:r?e.indexOf(Math.max(...e)):e.indexOf(Math.min(...e))}function o({providers:e,onMetrics:r}){(0,l.c)("search");let t=e.filter(e=>"search"===e.kind&&"configured"===e.status),[i,c]=(0,a.useState)(""),[x,p]=(0,a.useState)([]),[m,u]=(0,a.useState)([]),[h,b]=(0,a.useState)(!1),[f,v]=(0,a.useState)(!1),g=(0,a.useCallback)(e=>{p(r=>r.includes(e)?r.filter(r=>r!==e):[...r,e])},[]),y=(0,a.useCallback)(()=>{p(t.map(e=>e.id))},[t]),j=(0,a.useCallback)(()=>{p([])},[]),N=(0,a.useCallback)(async()=>{if(!i.trim()||0===x.length)return;b(!0),v(!0),u([]);let e=(await Promise.allSettled(x.map(async e=>{let r=Date.now();try{let t=await fetch("/api/v1/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:i,provider:e,max_results:10})}),s=await t.json(),a=Date.now()-r;if(!t.ok)return{provider:e,latency:a,cost:0,resultCount:0,responseSize:0,urls:[],results:[],error:s?.error?.message??`Error ${t.status}`};let l=JSON.stringify(s),d=Array.isArray(s.results)?s.results:[];return{provider:e,latency:s.metrics?.response_time_ms??a,cost:s.usage?.search_cost_usd??0,resultCount:d.length,responseSize:l.length,urls:d.map(e=>e.url),results:d.map(e=>({title:e.title??e.url??"",url:e.url??"",snippet:e.snippet??e.description??""}))}}catch(t){return{provider:e,latency:Date.now()-r,cost:0,resultCount:0,responseSize:0,urls:[],results:[],error:t instanceof Error?t.message:"Failed"}}}))).map(e=>"fulfilled"===e.status?e.value:{provider:"unknown",latency:0,cost:0,resultCount:0,responseSize:0,urls:[],results:[],error:"Request failed"});u(e),b(!1);let t=e.filter(e=>!e.error);if(t.length>0){let e=Math.min(...t.map(e=>e.latency)),s=t.reduce((e,r)=>e+r.cost,0);r?.(e,s)}},[i,x,r]),w=m.filter(e=>!e.error),k=w.map(e=>e.latency),C=w.map(e=>e.cost),S=w[n(k,!1)]?.provider,_=w[n(C,!1)]?.provider,$=function(e){let r=new Map;for(let t of e)for(let e of t.results)e.url&&r.set(e.url,(r.get(e.url)??0)+1);return r}(m);return 0===t.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1 py-16 text-center","data-testid":"compare-no-providers",children:[(0,s.jsx)("span",{className:"text-3xl mb-3","aria-hidden":"true",children:"⚖"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-2",children:"No active search provider. Configure one in Providers."}),(0,s.jsx)(d(),{href:"/dashboard/providers",className:"text-accent text-sm hover:underline",children:"Configure providers"})]}):(0,s.jsxs)("div",{className:"flex flex-col h-full p-4 space-y-4","data-testid":"compare-tab",children:[(0,s.jsxs)("div",{className:"bg-surface border border-border rounded-lg p-4 space-y-3",children:[(0,s.jsx)("label",{htmlFor:"compare-query",className:"block text-[10px] font-semibold text-text-muted uppercase tracking-wider",children:"Query para comparar"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{id:"compare-query",type:"text",value:i,onChange:e=>c(e.target.value),placeholder:"artificial intelligence trends 2026",className:"flex-1 bg-bg-alt border border-border rounded-lg px-3 py-2 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/30",onKeyDown:e=>{"Enter"===e.key&&N()},"data-testid":"compare-query-input"}),(0,s.jsx)("button",{className:"px-4 py-2 rounded-lg bg-primary text-white text-sm font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:()=>void N(),disabled:h||0===x.length||!i.trim(),"data-testid":"run-compare-button",children:h?"Comparando...":"Comparar"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("p",{className:"text-[10px] text-text-muted",children:["Providers (",x.length," selected):"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{className:"text-[10px] px-2 py-0.5 rounded border border-border text-text-muted hover:text-text-main hover:border-primary/30 transition-colors",onClick:y,"data-testid":"select-all-providers",children:"Select all"}),(0,s.jsx)("button",{className:"text-[10px] px-2 py-0.5 rounded border border-border text-text-muted hover:text-text-main hover:border-primary/30 transition-colors",onClick:j,"data-testid":"clear-providers",children:"Clear"})]})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:t.map(e=>{let r=x.includes(e.id);return(0,s.jsx)("button",{className:["px-2.5 py-1 rounded-md text-xs font-medium transition-colors border",r?"bg-primary/15 text-primary border-primary/30":"text-text-muted border-border hover:text-text-main hover:border-primary/30"].join(" "),onClick:()=>g(e.id),"data-testid":`provider-toggle-${e.id}`,"aria-pressed":r,children:e.name},e.id)})})]})]}),h&&(0,s.jsx)("div",{className:"flex items-center justify-center py-10","data-testid":"compare-loading",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[28px] text-primary animate-spin","aria-hidden":"true",children:"progress_activity"})}),f&&!h&&m.length>0&&(0,s.jsxs)("div",{className:"bg-surface border border-border rounded-lg overflow-hidden","data-testid":"compare-results",children:[(0,s.jsx)("div",{className:"px-4 py-2.5 bg-bg-alt border-b border-border",children:(0,s.jsxs)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:["Results — “",i,"”"]}
1)}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsx)("div",{className:"flex gap-3 p-3",style:{minWidth:`${296*m.length}px`},children:m.map(e=>{var r;let t=!e.error&&e.provider===S,a=!e.error&&e.provider===_;return(0,s.jsxs)("div",{className:"min-w-[280px] w-[280px] shrink-0 flex flex-col rounded-lg border border-border bg-surface overflow-hidden","data-testid":`compare-col-${e.provider}`,children:[(0,s.jsxs)("div",{className:"px-3 py-2 bg-bg-alt border-b border-border",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-text-main truncate mb-1",children:e.provider.replace("-search","")}),e.error?(0,s.jsx)("p",{className:"text-[10px] text-red-400 truncate",children:e.error}):(0,s.jsxs)("div",{className:"flex flex-wrap gap-x-2 gap-y-0.5 text-[10px] text-text-muted",children:[(0,s.jsxs)("span",{className:t?"text-emerald-400 font-medium":"",children:[e.latency,"ms"]}),(0,s.jsxs)("span",{className:a?"text-emerald-400 font-medium":"",children:["$",e.cost.toFixed(4)]}),(0,s.jsxs)("span",{children:[e.resultCount," results"]}),(0,s.jsx)("span",{children:(r=e.responseSize)<1024?`${r} B`:`${(r/1024).toFixed(1)} KB`})]})]}),(0,s.jsx)("div",{className:"flex flex-col divide-y divide-border overflow-y-auto max-h-[600px]",children:e.error?(0,s.jsx)("div",{className:"p-3",children:(0,s.jsx)("p",{className:"text-xs text-red-400",children:e.error})}):0===e.results.length?(0,s.jsx)("div",{className:"p-3",children:(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"No results"})}):e.results.map((e,r)=>{let t=($.get(e.url)??0)>1;return(0,s.jsxs)("div",{className:"p-3 space-y-0.5",children:[(0,s.jsxs)("div",{className:"flex items-start gap-1",children:[t&&(0,s.jsx)("span",{className:"text-emerald-400 text-[11px] mt-0.5 shrink-0",title:"in common with another provider","aria-label":"in common",children:"⭐"}),(0,s.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-sm text-text-main hover:text-primary leading-snug",children:e.title||e.url})]}),e.snippet&&(0,s.jsx)("p",{className:"text-xs text-text-muted line-clamp-2 leading-relaxed",children:e.snippet}),(0,s.jsx)("p",{className:"text-[10px] text-text-muted truncate",children:e.url})]},r)})})]},e.provider)})})}),m.length>=2&&(0,s.jsx)("div",{className:"px-4 py-2 bg-bg-alt border-t border-border",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-3 text-[10px] text-text-muted",children:m.slice(1).map(e=>{var r;let t,a,l=m[0]?.urls??[];return(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-medium text-text-main",children:m[0]?.provider.replace("-search","")})," vs ",(0,s.jsx)("span",{className:"font-medium text-text-main",children:e.provider.replace("-search","")}),": ",e.error?"—":(r=e.urls,t=new Set(l),a=r.filter(e=>t.has(e)).length,`${a}/${r.length}`)," in common"]},e.provider)})})})]}),!f&&!h&&(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1 py-12 text-center","data-testid":"compare-empty-state",children:[(0,s.jsx)("span",{className:"text-3xl mb-3","aria-hidden":"true",children:"⚖"}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Select providers and enter a query to compare"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Results will be shown side by side with latency, cost, and URL overlap"})]})]})}}}]);

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.