1import{u as z,j as t}from"./vendor-query-Cuv1FQk6.js";import{r as R,u as F,L as y}from"./vendor-react-qWEbcnl5.js";import{S as W}from"./SEO-C_Dunz7h.js";import{I}from"./InstitutionalHeader-BRkCmmwU.js";import{I as D}from"./InstitutionalFooter-BM7wowF9.js";import{s as j,I as E,B as S}from"./index-zfWpKczA.js";import{u as P}from"./useSiteDirectory-BZkryxqs.js";import{a6 as _,a5 as H}from"./vendor-icons-CQPDGG0w.js";import"./vendor-helmet-OKLD9pxQ.js";import"./vendor-radix-C88Ak59v.js";import"./vendor-supabase-C_eKbu-8.js";import"./vendor-recharts-D60XYxEx.js";const w=r=>r;function O(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}const Q=new Set(["de","da","do","das","dos","e","a","o","as","os","em","para","com","por","no","na","nos","nas","um","uma","que"]);function C(r){return O(r).split(" ").filter(e=>e.length>2&&!Q.has(e)).slice(0,5)}function A(r){return r.replace(/[,()*]/g," ").trim()}function K(r){const e=C(r),a=e.length>0;return z({queryKey:["site-search",e.join("+")],enabled:a,staleTime:60*1e3,queryFn:async()=>{const l=[],m=await Promise.all(e.map(async u=>{const o=A(u);if(!o)return{articles:[],vacancies:[]};const n=`%${o}%`,h=j.from("articles").select(w("slug, title, category, excerpt")).eq("status","published").or(`title.ilike.${n},excerpt.ilike.${n},meta_description.ilike.${n},slug.ilike.${n}`).order("published_at",{ascending:!1}).limit(40).returns(),p=j.from("vacancies").select(w("slug, title")).eq("status","published").or(`title.ilike.${n},description.ilike.${n},slug.ilike.${n}`).limit(20).returns(),[f,d]=await Promise.all([h,p]);return{articles:f.data??[],vacancies:d.data??[]}})),c=new Set,i=new Map;for(const u of m){for(const o of u.articles){const h=`/artigos/${(o.category||"geral").toLowerCase().trim()}/${o.slug}`;i.set(h,(i.get(h)||0)+1),!c.has(h)&&(c.add(h),l.push({label:o.title,href:h,snippet:o.excerpt,source:"artigo"}))}for(const o of u.vacancies){const n=`/vagas/${o.slug}`;i.set(n,(i.get(n)||0)+1),!c.has(n)&&(c.add(n),l.push({label:o.title,href:n,snippet:null,source:"vaga"}))}}return l.sort((u,o)=>(i.get(o.href)||0)-(i.get(u.href)||0)).slice(0,60)}})}const $=r=>r;function M(r){return`/artigos/${(r.category||"geral").toLowerCase().trim()}/${r.slug}`}function U(r,e){const a=C(r);return z({queryKey:["search-recommendations",a.join("+")],enabled:e,staleTime:5*60*1e3,queryFn:async()=>{const l=[],m=new Set,c=(i,u)=>{for(const o of i){const n=M(o);m.has(n)||(m.add(n),l.push({label:o.title,href:n,reason:u}))}};if(a.length>0){const{data:i}=await j.from("articles").select($("slug, title, category, tags")).eq("status","published").overlaps("tags",a).order("published_at",{ascending:!1}).limit(8).returns();c(i??[],"Tag relacionada")}if(l.length<8&&a.length>0)for(const i of a){if(l.length>=8)break;const{data:u}=await j.from("articles").select($("slug, title, category, tags")).eq("status","published").ilike("category",`%${i.replace(/[,()*%]/g,"")}%`).order("published_at",{ascending:!1}).limit(6).returns();c(u??[],"Categoria relacionada")}if(l.length===0){const{data:i}=await j.from("articles").select($("slug, title, category, tags")).eq("status","published").order("published_at",{ascending:!1}).limit(8).returns();c(i??[],"Conteúdo recente")}return l.slice(0,8)}})}function L(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function k(r){let e=r;return e=e.replace(/(coes|oes|aes)$/,"ao"),e=e.replace(/(is|ns|res|zes|ses)$/,""),e=e.replace(/s$/,""),e=e.replace(/(mente|cao|ismo|ista|ico|ica)$/,""),e.length>=3?e:r}function V(r,e){const a=L(r);if(!a)return!1;const l=k(a);return e.some(m=>{if(!m)return!1;const c=k(m);return a===m||a.startsWith(m)||m.startsWith(a)||l===c||l.startsWith(c)||c.startsWith(l)})}const b=R.memo(function({text:e,tokens:a,className:l=""}){if(!e||a.length===0)return t.jsx("span",{className:l,children:e});const m=a.map(L).filter(Boolean);if(m.length===0)return t.jsx("span",{className:l,children:e});const c=e.split(/([^a-zA-Z0-9\u00C0-\u024F\u1E00-\u1EFF_]+)/);return t.jsx("span",{className:l,children:c.map((i,u)=>V(i,m)?t.jsx("mark",{className:"bg-primary/20 text-foreground rounded px-0.5 font-semibold",children:i},u):t.jsx("span",{children:i},u))})});function T(r){const e=[];for(const a of r)e.push({label:a.label,href:a.href}),a.children&&e.push(...T(a.children));return e}function v(r){return r.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}const G=new Set(["de","da","do","das","dos","e","a","o","as","os","em","para","com","por","no","na","nos","nas","um","uma","que"]);function q(r){let e=r;return e=e.replace(/(coes|oes|aes)$/,"ao"),e=e.replace(/(is|ns|res|zes|ses)$/,""),e=e.replace(/s$/,""),e=e.replace(/(mente|cao|ismo|ista|ico|ica)$/,""),e.length>=3?e:r}function Z(r,e,a){const l=v(r.label),m=v(r.href),c=`${l} ${m}
1`,i=c.split(" ").filter(Boolean),u=i.map(q);let o=0,n=0;a&&c.includes(a)&&(o+=120);for(const p of e){const f=q(p);let d=0;i.includes(p)?d=20:u.includes(f)?d=16:i.some(g=>g.startsWith(p)||p.startsWith(g))?d=12:u.some(g=>g.startsWith(f)||f.startsWith(g))?d=10:c.includes(p)?d=8:f.length>=4&&c.includes(f)&&(d=6),d>0&&(n+=1,o+=l.includes(f)||l.includes(p)?d*1.5:d)}if(n===0)return e.length===0&&o>0?o:0;const h=n/Math.max(e.length,1);return o+=h*40,n>1&&(o+=(n-1)*8),o}function ce(){const[r]=F(),e=r.get("q")||"",[a,l]=R.useState(e),{tree:m,isLoading:c}=P(),{data:i=[],isLoading:u}=K(e),o=T(m),n=v(e),h=n.split(" ").filter(s=>s.length>1&&!G.has(s)),p=new Set,d=(e?o.map(s=>({page:s,score:Z(s,h,n)})).filter(s=>s.score>0).sort((s,x)=>x.score-s.score||s.page.label.length-x.page.label.length).filter(s=>p.has(s.page.href)?!1:(p.add(s.page.href),!0)).slice(0,100).map(s=>s.page):[]).map(s=>({...s,source:"página"}));for(const s of i)p.has(s.href)||(p.add(s.href),d.push({label:s.label,href:s.href,snippet:s.snippet,source:s.source}));const{data:g=[],isLoading:B}=U(e,!!e&&!u&&!c&&d.length===0),N=()=>{a.trim()&&(window.location.href=`/busca?q=${encodeURIComponent(a.trim())}`)};return t.jsxs(t.Fragment,{children:[t.jsx(W,{title:e?`Busca interna: ${e}`:"Busca interna",description:e?`Resultados da busca interna por "${e}" no site Eunerd.`:"Use a busca interna para navegar pelo conteúdo público da Eunerd.",noindex:!0}),t.jsx(I,{}),t.jsx("main",{className:"min-h-dvh bg-background pt-20",children:t.jsxs("div",{className:"container max-w-4xl mx-auto px-4 py-8 sm:py-12",children:[t.jsxs(y,{to:"/sitemap",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors mb-6",children:[t.jsx(_,{className:"h-4 w-4"}),"Voltar ao Mapa do Site"]}),t.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-foreground mb-6",children:e?`Resultados para "${e}"`:"Busca no Site"}),t.jsxs("div",{className:"flex gap-2 mb-8",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(H,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),t.jsx(E,{placeholder:"Buscar...",value:a,onChange:s=>l(s.target.value),onKeyDown:s=>s.key==="Enter"&&N(),className:"pl-10"})]}),t.jsx(S,{onClick:N,children:"Buscar"})]}),t.jsx("h2",{className:"sr-only",children:"Resultados da busca"}),c||u?t.jsx("div",{className:"space-y-3",children:Array.from({length:6}).map((s,x)=>t.jsx("div",{className:"h-16 bg-muted rounded-lg animate-pulse"},x))}):e?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:[d.length," resultado",d.length!==1?"s":""," encontrado",d.length!==1?"s":""]}),d.length>0?t.jsx("div",{className:"space-y-2",children:d.map((s,x)=>t.jsxs(y,{to:s.href,className:"block p-4 border border-border rounded-lg hover:border-primary/30 hover:bg-muted/50 transition-colors",children:[t.jsxs("p",{className:"font-medium text-foreground text-sm",children:[t.jsx(b,{text:s.label,tokens:h}),s.source&&s.source!=="página"&&t.jsx("span",{className:"ml-2 inline-flex items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:s.source})]}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["encontreumnerd.com.br",t.jsx(b,{text:s.href,tokens:h})]}),s.snippet?t.jsx("p",{className:"text-xs text-muted-foreground mt-2 line-clamp-2",children:t.jsx(b,{text:s.snippet,tokens:h})}):null]},`${s.href}-${x}`))}):t.jsxs("div",{className:"py-8",children:[t.jsxs("p",{className:"text-muted-foreground mb-6 text-center",children:['Não encontramos correspondência exata para "',e,'". Veja conteúdos relacionados:']}),B?t.jsx("div",{className:"space-y-2",children:[1,2,3].map(s=>t.jsx("div",{className:"h-16 bg-muted rounded-lg animate-pulse"},s))}):g.length>0?t.jsx("div",{className:"space-y-2",children:g.map((s,x)=>t.jsxs(y,{to:s.href,className:"block p-4 border border-border rounded-lg hover:border-primary/30 hover:bg-muted/50 transition-colors",children:[t.jsx("p",{className:"font-medium text-foreground text-sm",children:t.jsx(b,{text:s.label,tokens:h})}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.jsx(b,{text:s.reason,tokens:h})})]},`${s.href}-${x}`))}):null,t.jsx("div",{className:"text-center mt-6",children:t.jsx(S,{variant:"outline",asChild:!0,children:t.jsx("a",{href:`https://www.google.com/search?q=site:encontreumnerd.com.br+${encodeURIComponent(e)}`,target:"_blank",rel:"noopener noreferrer",children:"Buscar no Google"})})})]})]}):t.jsx("p",{className:"text-muted-foreground text-center py-12",children:"Digite um termo para buscar no site."})]})}),t.jsx(D,{})]})}
1export{ce 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.