PageSourceSearch

https://vece.ai/assets/SearchPageRoute-DCSK0OmZ.js

js vece.ai collected 2026-10-05 14:37:17 UTC 16,337 bytes, 1 lines download raw bytes

1import{r,a8 as O,j as s,a as ke,av as ms,h as fs,bn as gs,bo as ps,bp as Te,bq as xs,a9 as bs,br as Ne,u as ys,aa as Pe,bs as ae,af as Ce,e as F,bt as ws,bu as Ss,bv as Ee,bw as M,bx as ie,I as vs,J as js,K as Ns,by as Ps,ap as Cs,D as Es,bz as _s,bA as As,bB as Rs,bC as ks,bD as Ts,bE as Hs,bF as _e,m as Ms,bG as qs}from"./index-DhS0IPMw.js";import{D as Qs,Q as Is}from"./GuestCardViewBar-Cwg4ZC3S.js";import{I as Ls}from"./guestDigestGeo-CWBVgtZQ.js";import{A as Us,a as Ds,b as Fs,g as Os,Q as Bs}from"./DemographicStatsContent-Cl7W7tqn.js";import{m as Gs,a as Vs}from"./ProfileVisibleMetaLine-D3snNX14.js";import{c as Ws}from"./ProfileComparisonTimeFilter-b4xvkoE0.js";import"./index-EiZC051d.js";function Ks(){const[a,c]=r.useState([]),[h,y]=r.useState([]),[B,S]=r.useState([]),[C,l]=r.useState(!1),[b,d]=r.useState(null),f=r.useRef(0),v=r.useCallback(()=>{f.current+=1,c([]),y([]),S([]),l(!1),d(null)},[]),E=r.useCallback(w=>{c(m=>m.map(u=>u.id===w.id?w:u))},[]),_=r.useCallback(async w=>{const m=w.trim();if(!m||m.length<2){v();return}const u=++f.current;l(!0),d(null);try{const o=await O.search(m,"all",36);if(u!==f.current)return;c(o.questions||[]),y(o.users||[]),S(o.hashtags||[])}catch(o){if(u!==f.current)return;const g=o instanceof Error?o:new Error("Search failed");d(g),console.error("Search error:",g.message,g)}finally{u===f.current&&l(!1)}},[v]),p=r.useCallback(async w=>{const m=w.trim();if(!m||m.length<2){c([]),l(!1);return}const u=++f.current;l(!0),d(null);try{const o=await O.search(m,"questions",20);if(u!==f.current)return;c(o.questions||[])}catch(o){if(u!==f.current)return;const g=o instanceof Error?o:new Error("Question search failed");d(g),console.error("Question search error:",g.message,g)}finally{u===f.current&&l(!1)}},[]),q=r.useCallback(async w=>{const m=w.trim();if(!m||m.length<2){y([]),l(!1);return}const u=++f.current;l(!0),d(null);try{const o=await O.search(m,"users",20);if(u!==f.current)return;y(o.users||[])}catch(o){if(u!==f.current)return;const g=o instanceof Error?o:new Error("User search failed");d(g),console.error("User search error:",g.message,g)}finally{u===f.current&&l(!1)}},[]),Q=r.useCallback(async w=>{const m=w.trim();if(!m||m.length<2){S([]),l(!1);return}const u=++f.current;l(!0),d(null);try{const o=await O.search(m,"hashtags",20);if(u!==f.current)return;S(o.hashtags||[])}catch(o){if(u!==f.current)return;const g=o instanceof Error?o:new Error("Hashtag search failed");d(g),console.error("Hashtag search error:",g.message,g)}finally{u===f.current&&l(!1)}},[]);return{questions:a,users:h,hashtags:B,isLoading:C,error:b,clearResults:v,searchAll:_,searchQuestions:p,searchUsers:q,searchHashtags:Q,patchQuestion:E}}const He="vece-search-history-v3",Me=20;function Js(a){return{id:a.id,username:a.username,full_name:a.full_name,profile_picture:a.profile_picture,avatar_url:a.avatar_url,is_subscribed:a.is_subscribed}}function oe(){return{users:[],hashtags:[],questions:[]}}function ce(){try{const a=localStorage.getItem(He);if(!a)return oe();const c=JSON.parse(a);if(!c||typeof c!="object")return oe();const h=c;return{users:Array.isArray(h.users)?h.users:[],hashtags:Array.isArray(h.hashtags)?h.hashtags:[],questions:Array.isArray(h.questions)?h.questions:[]}}catch{return oe()}}function qe(a){try{localStorage.setItem(He,JSON.stringify(a))}catch{}}function Ys(a){const c=ce();c.users=[Js(a),...c.users.filter(h=>h.id!==a.id)].slice(0,Me),qe(c)}function Ae(a){const c=ce(),h=a;c.questions=[h,...c.questions.filter(y=>y.id!==h.id)].slice(0,Me),qe(c)}function $s(){return ce()}const zs="h-11 rounded-lg border-0 bg-muted/30 pl-10 shadow-none placeholder:text-muted-foreground/30 focus-visible:border-0 focus-visible:ring-0 focus-visible:ring-offset-0";function Re(a){Ts(a),Hs()}function Xs({onHashtagClick:a,followedHashtags:c=[],onProfileClick:h,onHashtagToggle:y,initialSearchQuery:B="",hideSearchInput:S=!1}){const C=ke(),l=ms(),{user:b}=fs(),[d,f]=gs("q"),v=10,E=18,_=10,[p,q]=r.useState({profiles:v,hashtags:E,questions:_}),Q=r.useRef(null),{users:w,hashtags:m,questions:u,isLoading:o,error:g,searchAll:le,clearResults:ue,patchQuestion:he}=Ks(),de=ps(),me=r.useRef(le),fe=r.useRef(ue);me.current=le,fe.current=ue;const[Qe,K]=r.useState(0),[Ie,Le]=r.useState(()=>typeof window<"u"&&window.matchMedia("(hover: none)").matches),{subscriptions:ge,isLoading:Ue,subscribeToHashtag:De,unsubscribeFromHashtag:Fe,subscribeToUser:Oe,unsubscribeFromUser:Be}=Te(),[Ge,G]=r.useState(()=>new Set),[Ve,V]=r.useState(()=>new Set),pe=r.useCallback((e,t)=>{e(n=>new Set(n).add(t))},[]),R=r.useCallback((e,t)=>{e(n=>{const x=new Set(n);return x.delete(t),x})},[]),We=r.useCallback(e=>{S||e.target.closest("input")||Re(Q.current)},[S]);r.useEffect(()=>{if(S||l.pathname!=="/search"||!xs(l.state))return;const e=window.setTimeout(()=>{Re(Q.current),C({pathname:l.pathname,search:l.search},{replace:!0,state:null})},60);return()=>window.clearTimeout(e)}
1,[S,l.pathname,l.search,l.state,C]),r.useEffect(()=>{const e=window.matchMedia("(hover: none)"),t=()=>Le(e.matches);return t(),e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),r.useEffect(()=>{q({profiles:v,hashtags:E,questions:_})},[d]),r.useEffect(()=>{const e=d.trim(),t=setTimeout(()=>{e.length>=2?(me.current(e),bs("search_performed",{query_length:e.length})):fe.current()},300);return()=>clearTimeout(t)},[d]);const J=w.map(e=>({id:e.id,name:Ne({name:e.name,surname:e.surname,full_name:e.full_name,username:e.username}),username:`@${e.username}`,followers:0,is_subscribed:e.is_subscribed,profilePicture:e.profile_picture||e.avatar_url,galleryCount:e.profile_gallery?.length})),{t:i,language:W}=ys(),Y=r.useMemo(()=>m.map(e=>({id:e.id,name:Pe(e,W)})),[m,W]),$=r.useMemo(()=>u.map(e=>ae(e)),[u]),k=r.useMemo(()=>$s(),[Qe]),A=d.trim(),I=A.length===0,Ke=A.length===1,T=o&&A.length>=2,z=r.useRef(de?.setIsSearching);z.current=de?.setIsSearching,r.useEffect(()=>(z.current?.(T),()=>{z.current?.(!1)}),[T]);const X=r.useMemo(()=>k.users.map(e=>({id:e.id,name:Ne({full_name:e.full_name,username:e.username}),username:`@${e.username}`,followers:0,is_subscribed:e.is_subscribed,profilePicture:e.profile_picture||e.avatar_url,galleryCount:void 0})),[k.users]),Z=r.useMemo(()=>k.hashtags.map(e=>({id:e.id,name:Pe({name:e.name},W)})),[k.hashtags,W]),ee=r.useMemo(()=>k.questions.map(e=>ae(e)),[k.questions]),xe=X.length>0||Z.length>0||ee.length>0,H=I?X:J,L=I?Z:Y,j=I?ee:$,[be,Je]=r.useState({}),se=r.useRef(new Set);r.useEffect(()=>{for(const e of j){const t=e.batchId;!t||se.current.has(t)||(se.current.add(t),O.getQuestionBatch(t).then(n=>Je(x=>({...x,[t]:n.map(P=>ae(P))}))).catch(()=>se.current.delete(t)))}},[j]);const Ye=r.useMemo(()=>{const e=new Set(j.map(x=>x.id)),t=new Set,n=[];for(const x of j.slice(0,p.questions)){const P=x.batchId?be[x.batchId]:void 0;if(!x.batchId||!P||P.length<2){n.push({row:x,hit:!0,continues:!1});continue}t.has(x.batchId)||(t.add(x.batchId),P.forEach((je,ds)=>n.push({row:je,hit:e.has(je.id),continues:ds>0})))}return n},[j,be,p.questions]),ye=e=>e==="hashtags"?E:e==="questions"?_:v,te=e=>{q(t=>({...t,[e]:t[e]+ye(e)}))},re=e=>{q(t=>({...t,[e]:ye(e)}))},$e=e=>e==="profiles"?H.length:e==="hashtags"?L.length:e==="questions"?j.length:0,ne=e=>Math.max(0,$e(e)-p[e]),we=e=>Ve.has(e)?!1:Ge.has(e)||ge.hashtags.some(t=>t.hashtag.id===e)?!0:c.some(t=>t.id===e),Se=e=>{const t=w.find(n=>n.id===e.id);t&&(Ys(t),K(n=>n+1)),h?.({name:e.name,username:e.username,interest:75,attitude:60,userId:e.id})},ze=e=>{const t=u.find(n=>n.id===e);t&&(Ae(t),K(n=>n+1))},Xe=r.useCallback(e=>{e?.question&&(he(e.question),Ae(e.question),K(t=>t+1))},[he]),Ze=(e,t)=>{if(_e("light"),we(e)){pe(V,e),R(G,e),Fe(e).finally(()=>R(V,e)).catch(()=>{R(V,e)});return}pe(G,e),R(V,e),De(e,!1,t).finally(()=>R(G,e)).catch(()=>{R(G,e)})},es=(e,t)=>ge.users.some(n=>(n.user?.id??n.id)===e)?!0:Ue?t??!1:!1,ss=(e,t,n)=>{n.preventDefault(),n.stopPropagation(),_e("light"),t?Be(e):Oe(e)},N=(b?.billing_plan??"free")==="plus",ts=J.length>0||Y.length>0||$.length>0,ve=H.length>0||L.length>0||j.length>0,rs=A.length>=2&&!o&&!g&&!ts&&N,U=I&&xe,ns=I&&!xe,as=Ke,D=A.length>=2&&!g&&(ve||!N||T),is=T&&A.length>=2&&!ve&&N,os=U&&X.length>0||D&&(N?J.length>0:!0),cs=U&&Z.length>0||D&&Y.length>0,ls=U&&ee.length>0||D&&$.length>0,us=U||D,hs=A.length>=2&&!o&&!!g;return s.jsx(Ws,{delayDuration:Ie?500:200,skipDelayDuration:0,children:s.jsxs("div",{className:"flex w-full flex-col",children:[!S&&s.jsx("div",{className:"mobile-search-sticky sticky z-10 bg-background pb-3 lg:hidden",onPointerDown:We,children:s.jsxs("div",{className:"relative",children:[s.jsx(Ce,{className:"pointer-events-none absolute left-3 top-1/2 h-5 w-5 -translate-y-1/2 text-muted-foreground"}),s.jsx(Ls,{ref:Q,id:"mobile-search-input",type:"search",enterKeyHint:"search",inputMode:"search",autoComplete:"off",placeholder:N?i.search.searchPlaceholderPlus:i.search.searchPlaceholder,value:d,onChange:e=>f(ws(e.target.value)),className:F(zs,T&&"pr-10",!N&&!d&&"mobile-search-with-chip")}),!N&&!d?s.jsxs("button",{type:"button",onClick:()=>C("/plans"),className:"header-search-plus mobile-search-plus","aria-label":i.search.searchUsersWithVecePlus,children:[s.jsx(Ss,{className:"h-3 w-3",strokeWidth:1.75,"aria-hidden":!0}),s.jsx("span",{children:i.search.plusChip})]}):null,T?s.jsx("span",{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2",children:s.jsx(Ee,{label:i.search.searching})}):null]})}),s.jsx("div",{className:"pb-24 space-y-4",children:s.jsxs("div",{className:"lg:max-w-[600px]",children:[s.jsx(M,{open:ns,children:s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[s.jsx(Ce,{className:"w-12 h-12 text-muted-foreground
1/30 mb-4"}),s.jsx("p",{className:"text-muted-foreground text-[14px]",children:i.search.emptyStateTitle}),s.jsx("p",{className:"text-[12px] text-muted-foreground/70 mt-1",children:i.search.emptyStateSubtitle})]})}),s.jsx(M,{open:as,children:s.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:s.jsx("p",{className:"text-muted-foreground text-[14px]",children:i.search.minCharsHint})})}),s.jsx(M,{open:hs,children:s.jsx("div",{className:"flex flex-col items-center justify-center px-4 py-16 text-center",children:s.jsx("p",{className:"text-muted-foreground text-[14px]",children:i.search.searchError})})}),s.jsx(M,{open:is,children:s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(Ee,{label:i.search.searching}),s.jsx("p",{className:"mt-3 text-muted-foreground text-[14px]",children:i.search.searching})]})}),s.jsx(M,{open:rs,children:s.jsx("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:s.jsxs("p",{className:"text-muted-foreground text-[14px]",children:[i.search.noResultsFor,' "',d,'"']})})}),s.jsxs(M,{open:us,innerClassName:"space-y-5",children:[os&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(ie,{variant:"search",className:"mb-4 px-1",children:i.search.profiles}),H.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"space-y-3",children:H.slice(0,p.profiles).map(e=>{const t=es(e.id,e.is_subscribed);return s.jsxs("div",{className:"flex w-full items-center gap-1",children:[s.jsxs("button",{type:"button",onClick:()=>Se({id:e.id,name:e.name,username:e.username}),className:"flex min-w-0 flex-1 items-center gap-3 text-left hover:opacity-70 transition-opacity",children:[s.jsxs(Us,{className:F("h-10 w-10 shrink-0 rounded-full",Vs),children:[e.profilePicture&&s.jsx(Ds,{src:e.profilePicture,alt:e.name}),s.jsx(Fs,{className:F("text-[13px] text-white",Gs),style:Os(e.id??e.username),children:vs(e.name)}),s.jsx(js,{remaining:(e.galleryCount??0)-1})]}),s.jsxs("div",{className:"min-w-0 text-left",children:[s.jsx("div",{className:F(Ns,"truncate text-[15px] leading-tight text-foreground"),children:e.name}),s.jsx("div",{className:"truncate text-[12px] text-muted-foreground",children:e.username})]})]}),N&&s.jsxs("button",{type:"button",onClick:n=>ss(e.id,t,n),"aria-pressed":t,className:F(Es,"justify-between gap-1"),children:[s.jsx("span",{className:"truncate",children:t?i.preferences.unfollow:i.preferences.follow}),t?s.jsx(Ps,{className:"h-3 w-3 shrink-0 opacity-70",strokeWidth:2,"aria-hidden":!0}):s.jsx(Cs,{className:"h-3 w-3 shrink-0 opacity-70",strokeWidth:2,"aria-hidden":!0})]})]},e.id)})}),(H.length>v||p.profiles>v)&&s.jsxs("div",{className:"flex items-center justify-end gap-3",children:[p.profiles>v&&s.jsx("button",{type:"button",onClick:()=>re("profiles"),className:"py-2 text-[13px] italic text-foreground hover:text-muted-foreground",children:i.search.showLess}),p.profiles<H.length&&s.jsx("button",{type:"button",onClick:()=>te("profiles"),className:"py-2 text-[13px] italic text-foreground hover:text-muted-foreground",children:i.search.showMoreRemaining.replace("{{count}}",String(ne("profiles")))})]})]}):!N&&(D||U)&&s.jsx("div",{className:"flex justify-center pt-1",children:s.jsx(_s,{label:i.search.searchUsersWithVecePlus,onClick:()=>As(C,"search_users_upsell")})})]}),cs&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(ie,{variant:"search",className:"mb-4 px-1",children:i.search.themes}),s.jsx(Rs,{rows:L.slice(0,p.hashtags).map(e=>({id:e.id,displayName:e.name,isSubscribed:we(e.id)})),onToggle:e=>Ze(e.id,e.displayName),pendingIds:new Set,emptyLabel:"",toggleAriaLabel:e=>e.isSubscribed?i.preferences.unfollowThemeAria(e.displayName):i.preferences.followThemeAria(e.displayName)}),(L.length>E||p.hashtags>E)&&s.jsxs("div",{className:"flex items-center justify-end gap-3",children:[p.hashtags>E&&s.jsx("button",{type:"button",onClick:()=>re("hashtags"),className:"py-2 text-[13px] italic text-foreground hover:text-muted-foreground",children:i.search.showLess}),p.hashtags<L.length&&s.jsx("button",{type:"button",onClick:()=>te("hashtags"),className:"py-2 text-[13px] italic text-foreground hover:text-muted-foreground",children:i.search.showMoreRemaining.replace("{{count}}",String(ne("hashtags")))})]})]}),ls&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(ie,{variant:"search",className:"mb-4 px-1",children:i.search.questions}),s.jsx("div",{className:"space-y-2",children:Ye.map(({row:e,hit:t,continues:n})=>s.jsx(Bs,{className:t?void 0:"opacity-70",questionText:e.question,answered:e.hasAnswered,author:n?null:e.author,createdAt:e.createdAt,facts:{answers:e.voteCount,options:e.options.length,custom:e.allowUserOptions},onExpand:()=>ze(e.id),children:x=>s.jsx(Is,{questionId:e.id,teamName:e.teamName,hashtags:e.hashtags,question:e.question,questionTextHidden:e.questionTextHidden,continuesBatch:n,maxAnswers:e.maxAnswers,options:e.options,endTime:e.endTime,voteCount:e.voteCount,createdAt:e.createdAt,onHashtagClick:a,followedHashtags:c,onAvatarClick:P=>Se({id:P.id,name:P.name,username:P.username}),onAnswerSubmitted:Xe,initialSelectedOptions:e.selectedOptions,showResults:e.hasAnswered,author:e.author,allowUserOptions:e.allowUserOptions,gender:e.gender,country_id:e.country_id,age_range:e.age_range,onCollapse:x,...ks(e)})},e.id))}),(j.length>_||p.questions>_)&&s.jsxs("div",{className:"flex items-center justify-end gap-3",children:[p.questions>_&&s.jsx("button",{type:"button",onClick:()=>re("questions"),className:"py-2 text-[13px] italic text-foreground hover:text-muted-foreground",children:i.search.showLess}),p.questions<j.length&&s.jsx("button",{type:"button",onClick:()=>te("questions"),className:"py-2 text-[13px] italic text-foreground hover:text-muted-foreground",children:i.search.showMoreRemaining.replace("{{count}}",String(ne("questions")))})]})]})]})]})})]})})}function Zs(a){return s.jsx(Qs,{children:s.jsx(Xs,{...a})})}function et(){const[a,c]=r.useState(()=>typeof window<"u"&&window.matchMedia("(min-width: 1024px)").matches);return r.useEffect(()=>{const h=window.matchMedia("(min-width: 1024px)"),y=()=>c(h.matches);return y(),h.addEventListener("change",y),()=>h.removeEventListener("change",y)},[]),a}function ct(){const a=ke(),[c]=Ms(),h=et(),{subscriptions:y}=Te(),B=y.hashtags.map(b=>{const d=b.hashtag.name.startsWith("#")?b.hashtag.name:`#${b.hashtag.name}`;return{id:b.hashtag.id||b.id,tag:d,followedAt:new Date,isFavorite:b.favourite}}),S=b=>{b.userId&&qs(a,b.userId,"/search")},C=b=>{},l=c.get("q")||"";return s.jsx(Zs,{followedHashtags:B,onHashtagClick:C,onProfileClick:S,initialSearchQuery:l,hideSearchInput:h})}export{ct 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.