1import{j as e,bL as B,bM as ae,bN as ne,co as re,bQ as oe,bR as ce,bS as ie,B as K,bm as Q,t as le,aM as $,al as me,r as u,bW as de,ci as F,z,_ as V,cp as ue,ay as xe,aP as he,a3 as pe,cq as je,P as fe,I as ge,a as O,T as U,ap as be,U as Ce,J as L,K as m,c as ve,V as Se,C as o,bK as ye,be as Ne,bo as ke,f as q,R as Pe,Y as we,a9 as Ie,X as He,h as Ee,n as _,Z as Me,aa as Re,ab as Te,ac as Ae,ag as Be}from"./index-DGomepWC.js";import{P as Fe,a as ze,b as Ve}from"./post-DsRXleM8.js";import{C as Oe}from"./community-sidebar-DtDR1A9p.js";import{P as Ue}from"./page-title-BNX8VxUJ.js";import{P as Le}from"./person-avatar-Du35AwtW.js";import{u as f,S as _e}from"./search-bar-TRXcUReb.js";import{u as De,C as Ke,a as Qe}from"./post-comment-DdAFeZic.js";import{S as $e}from"./sticky-filter-bar-B2TvT5SZ.js";import"./index-BjBZgwZU.js";import"./progressive-image-B2oSGI7T.js";import"./nsfw-revealed-posts-DsvRbQpW.js";import"./hooks-Btm-G8gV.js";import"./post-buttons-CffSRobK.js";import"./index-lj7FE3e9.js";import"./use-reduced-motion-BYZIowLO.js";import"./remove-md-_dnXZpEl.js";import"./EasterEggBox-D5kmZdE_.js";function v({children:n}){return e.jsx("kbd",{className:"max-md:hidden bg-background text-muted-foreground pointer-events-none flex h-4 items-center justify-center gap-1 rounded border px-1 font-sans text-[0.7rem] font-medium select-none [&_svg:not([class*='size-'])]:size-3",children:n})}function qe({onSelect:n}){const a=B(t=>t.recentSearchesExpanded),c=B(t=>t.setRecentSearchesExpanded),d=f(t=>t.searchHistory),x=f(t=>t.removeSearch);return e.jsx(ae,{children:e.jsx(ne,{children:e.jsxs(re,{className:"p-4",open:a,onOpenChange:c,children:[e.jsxs(oe,{className:"uppercase text-xs font-medium text-muted-foreground flex items-center justify-between w-full",children:[e.jsx("span",{children:"RECENT SEARCHES"}),e.jsx(ce,{className:"h-4 w-4"})]}),e.jsx(ie,{className:"flex flex-col gap-1 pt-3",children:d.map(t=>e.jsxs("div",{className:"flex flex-row items-center",children:[e.jsx("button",{className:"text-start flex-1 overflow-hidden text-ellipsis text-nowrap",onClick:()=>n(t),children:t}),e.jsx(K,{size:"icon",variant:"ghost","aria-label":"remove from search",className:"-mr-2",onClick:()=>x(t),children:e.jsx(Q,{})})]},t))})]})})})}const S=[],D="NO_ITEMS";function Ge({search:n,onSelect:a}){const c=f(d=>d.removeSearch);return e.jsx(o,{className:"py md:hidden",children:e.jsxs("div",{className:"flex flex-row border-t items-center",children:[e.jsx("button",{className:"text-start py-2 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",onClick:a,children:n}),e.jsx(K,{size:"icon",variant:"ghost","aria-label":"remove from search",onClick:()=>c(n),className:"-mr-2",children:e.jsx(Q,{})})]})})}const Ye=u.memo(n=>e.jsxs(o,{className:"max-md:px-0",children:[e.jsx(Ve,{...n,featuredContext:"search"}),e.jsx(e.Fragment,{})]}));function Xe({commentPath:n}){const[a]=Pe([n]),c=$(),d=De({commentView:a});return a?e.jsxs(o,{noMobilePadding:!0,children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:q("flex mt-2.5 mb-1 gap-3 items-start",o.mobilePadding),children:[e.jsx(we,{icon:e.jsx(Ie,{className:"h-full w-full text-muted-foreground"}),children:e.jsx(Le,{actorId:a.creatorApId,size:"sm"})}),e.jsxs("div",{className:"flex-1 text-sm leading-6 block min-w-0",children:[e.jsxs(He,{to:"".concat(c.root,"posts/:post/comments/:comment"),params:{post:_(a.postApId),comment:_(a.apId)},children:[e.jsx("div",{className:"flex flex-row flex-wrap",children:e.jsxs("span",{children:[e.jsx("span",{className:"font-bold",children:a.creatorHandle}),e.jsx("span",{children:" commented in "}),e.jsx("span",{className:"font-bold",children:a.postTitle})]})}),e.jsx(Ee,{markdown:a.body,className:"pb-1",disableLinks:!0})]}),e.jsxs(Ke,{children:[e.jsx(Me,{time:a.createdAt}),e.jsx("div",{className:"flex-1"}),Re(a)&&e.jsx(Te,{className:"text-lg text-brand mr-2"}),e.jsx(Ae,{actions:d,"aria-label":"Comment actions"}),e.jsx(Qe,{commentView:a,fixRightAlignment:!0})]})]})]}),e.jsx(Be,{})]}),e.jsx(e.Fragment,{})]}):null}function hs({scope:n="global",defaultType:a="posts"}){var I;const c=le(),d=$(),{communityHandle:x}=me("".concat(d.root,"c/:communityHandle/s")),t=u.useMemo(()=>x?de(x):void 0,[x]),i=F("q","",z.string()),[y,G]=u.useState(i.value),P=u.useMemo(()=>V.debounce(s=>{G(s)},500),[]),N=(s,b)=>{i.set(s),P(s),b&&P.flush()},g=F("type",a,z.enum(["posts","communities","users","comments"])),r=g.value,h=g.set;ue(u.useCallback(s=>{if(!(s.target instanceof HTMLInputElement))switch(s.key){case"1":h("posts");break;case"2":h("comments");break;case"3":h("communities");break;case"4":h("users");break}},[h]));const{postSort:Y}=xe();he({name:t});const k=pe(t);let p;switch(r){case"posts":p="Posts";break;case"communities":p="Communities";break;case"users":p="Users";break;case"comments":p="Comments";break}const l=je({q:y!=null?y:"",sort:r==="communities"?"TopAll":Y,communityHandle:n==="community"||r==="posts"?t:void 0,type:p}),{hasNextPage:X,fetchNextPage:J,isFetchingNextPage:W,refetch:Z}=l,w=u.useMemo(()=>{var s,b,H,E,M,R,T,A;return r==="users"?(b=(s=l.data)==null?void 0:s.pages.map(j=>j.users).flat())!=null?b:S:r==="comments"?(E=(H=l.data)==null?void 0:H.pages.map(j=>j.comments).flat())!=null?E:S:r==="communities"?(R=(M=l.data)==null?void 0:M.pages.map(j=>j.communities).flat())!=null?R:S:(A=(T=l.data)==null?void 0:T.pages.flatMap(C=>C.posts))!=null?A:S},[(I=l.data)==null?void 0:I.pages,r]),ee=f(s=>s.saveSearch),se=f(s=>s.searchHistory),te=i.value.length===0?se:w.length===0&&!l.isRefetching&&!l.isPending?[D]:w;return e.jsxs(fe,{children:[e.jsx(Ue,{children:t?"Search ".concat(t):"Search"}),e.jsxs(ge,{children:[e.jsxs(O,{"data-tauri-drag-region":!0,children:[e.jsx(U,{side:"left",children:e.jsx(be,{})}),e.jsx(_e,{value:i.value,onValueChange:s=>N(s),placeholder:t&&r==="posts"?"Search ".concat(t):void 0,preventOpen:!0,className:"w-auto max-md:mx-3",autoFocus:c.maxMd&&i.value.length===0,"data-testid":"search-page-input"}),e.jsx(U,{side:"right",children:e.jsx(Ce,{})})]}),c.maxMd&&e.jsx(O,{children:e.jsxs(L,{slot:"start",type:"single",variant:"outline",size:"sm",value:r,onValueChange:s=>s&&g.set(s),children:[e.jsx(m,{value:"posts",children:"Posts"}),e.jsx(m,{value:"comments",children:"Comments"}),n==="global"&&e.jsx(m,{value:"communities",children:"Communities"}),n==="global"&&e.jsx(m,{value:"users",children:"Users"})]})})]}),e.jsxs(ve,{scrollY:!1,fullscreen:c.maxMd,children:[e.jsx(Fe,{children:e.jsx(Se,{scrollHost:!0,fullscreen:!0,data:te,header:[e.jsx($e,{className:"max-md:hidden",children:e.jsxs(L,{type:"single",variant:"outline",size:"sm",value:r,onValueChange:s=>s&&g.set(s),children:[e.jsxs(m,{value:"posts",children:["Posts",e.jsx(v,{children:"1"})]}),e.jsxs(m,{value:"comments",children:["Comments",e.jsx(v,{children:"2"})]}),n==="global"&&e.jsxs(m,{value:"communities",children:["Communities",e.jsx(v,{children:"3"})]}),n==="global"&&e.jsxs(m,{value:"users",children:["Users",e.jsx(v,{children:"4"})]})]})},"header-type-toggle"),e.jsx(o,{className:q("md:hidden",i.value.length>0&&"hidden"),children:e.jsx("span",{className:"py-2.5 text-sm text-muted-foreground",children:"RECENT SEARCHES"})},"recent-searches")],renderItem:({item:s})=>i.value.length===0&&V.isString(s)?e.jsx(Ge,{search:s,onSelect:()=>N(s,!0)}):s===D?e.jsxs(o,{children:[e.jsx("div",{className:"flex-1 italic text-muted-foreground p-6 text-center",children:e.jsx("span",{children:"Nothing to see here"})}),e.jsx(e.Fragment,{})]}):r==="comments"?e.jsx(Xe,{commentPath:s}):r==="posts"?e.jsx(Ye,{apId:s}):r==="users"?e.jsx(o,{children:e.jsx(Ne,{actorId:s,disableHover:!0,showCounts:!0,className:"pt-3.5"})}):e.jsxs(o,{children:[e.jsx(ke,{communityHandle:s,className:"pt-3.5"}),e.jsx(e.Fragment,{})]}),onEndReached:()=>{X&&!W&&J()},estimatedItemSize:r==="posts"?475:52,refresh:Z,placeholder:i.value.length>0&&e.jsxs(o,{className:r!=="communities"?"px-0":void 0,children:[r==="communities"?e.jsx(ye,{className:"flex-1"}):e.jsx(ze,{}),e.jsx(e.Fragment,{})]}),stickyIndicies:[0]})}),e.jsxs(o,{className:"max-md:hidden absolute top-0 right-0 left-0 z-10",children:[e.jsx("div",{className:"flex-1"}),t?e.jsx(Oe,{communityHandle:t,actorId:k==null?void 0:k.communityView.apId}):e.jsx(qe,{onSelect:s=>{N(s,!0),ee(s)}})]})]})]})}export{hs 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.