1import{b as F,a as _,aB as N,P as Q,a6 as H,c as G,l as f,h as c,s as t,g as L,A as y,C as p,j as n,t as z,q as s,B as o,H as g,p as J}from"./BI8qgwQJ.js";import{F as K,d as v,C as O,W,i as l,a0 as X,a7 as Y,$ as I,M as R,P as Z,c5 as ee,A as x,dv as te}from"./app-BAclpbpz.js";import{M as A}from"./DmHmcQev.js";import{M as se}from"./CwP7oRtQ.js";import{_ as le}from"./eSadS_9Y.js";import{M as oe}from"./6RkKJGoN.js";import"./BTqQ_sdn.js";import"./AEl_Lkqw.js";import"./Cyjh9VK6.js";import"./BMGXAZ5W.js";import"./Broj9-SH.js";const ae={class:"_gaps"},ne={class:"_gaps"},re={class:"_gaps_m"},ue={key:0,value:"all"},ie={value:"local"},ce={key:1,value:"server"},pe={value:"user"},de={value:null},he={value:"image"},fe={value:"video"},ve={value:"audio"},me={value:"module"},_e={value:"flash"},Se={class:"_gaps"},ye={key:0},ge={style:{overflow:"hidden"}},Te=F({__name:"search.note",props:{query:{default:""},userId:{default:void 0},username:{default:void 0},host:{default:""}},async setup(P){let d,b;const h=P,B=K(),M=_(0),U=_(),q=_(N(h,"query").value),k=_(N(h,"host").value),w=_(!1),C=_(null),u=Q(null),V=v.noteSearchableScope??"local";let S=null;h.userId&&(S=([d,b]=H(()=>O("users/show",{userId:h.userId}).catch(()=>null)),d=await d,b(),d)),h.username&&S==null&&(S=([d,b]=H(()=>O("users/show",{username:h.username,...h.host?{host:h.host}:{}}).catch(()=>null)),d=await d,b(),d)),S!=null&&(V==="local"&&S.host!=null||(u.value=S));const m=_(u.value!=null?"user":V==="local"?"local":k.value?"server":"all"),T=a=>!a||a===Z?".":a,r=G(()=>{const a=q.value.trim();if(!a)return null;if(m.value==="user")return u.value==null?null:{query:a,host:T(u.value.host),userId:u.value.id};if(v.federation!=="none"&&m.value==="server"){let e=k.value?.trim();if(!e)return null;if(e.startsWith("https://")||e.startsWith("http://"))try{e=new URL(e).host}catch{}return{query:a,host:T(e)}}return v.federation==="none"||m.value==="local"?{query:a,host:"."}:{query:a}});function j(){ee({includeSelf:!0,localOnly:v.noteSearchableScope==="local"}).then(a=>{u.value=a})}function E(){u.value=I}function D(){u.value=null}async function $(){if(r.value!=null){if((r.value.query.startsWith("http://")||r.value.query.startsWith("https://"))&&!r.value.query.includes(" ")&&!(await x({type:"info",text:l.ts.lookupConfirm})).canceled){const e=await te(r.value.query);e.type==="User"?B.push(`/@${e.object.username}@${e.object.host}`):e.type==="Note"&&B.push(`/notes/${e.object.id}`);return}if(r.value.query.length>1&&!r.value.query.includes(" ")){if(r.value.query.startsWith("@")&&!(await x({type:"info",text:l.ts.lookupConfirm})).canceled){B.push(`/${r.value.query}`);return}if(r.value.query.startsWith("#")&&!(await x({type:"info",text:l.ts.openTagPageConfirm})).canceled){B.push(`/tags/${encodeURIComponent(r.value.query.substring(1))}`);return}}U.value={endpoint:"notes/search",limit:10,params:{...r.value,order:w.value?"desc":"asc",filetype:C.value}},M.value++}}return(a,e)=>(c(),f("div",ae,[t("div",ne,[p(W,{modelValue:q.value,"onUpdate:modelValue":e[0]||(e[0]=i=>q.value=i),large:"",autofocus:"",type:"search",onEnter:z($,["prevent"])},{prefix:n(()=>e[5]||(e[5]=[t("i",{class:"ph-magnifying-glass ph-bold ph-lg"},null,-1)])),_:1},8,["modelValue"]),p(A,{expanded:""},{header:n(()=>[g(o(s(l).ts.options),1)]),default:n(()=>[t("div",re,[p(le,{modelValue:m.value,"onUpdate:modelValue":e[1]||(e[1]=i=>m.value=i)},{default:n(()=>[s(v).federation!=="none"&&s(V)==="global"?(c(),f("option",ue,o(s(l).ts._search.searchScopeAll),1)):y("",!0),t("option",ie,o(s(v).federation==="none"?s(l).ts._search.searchScopeAll:s(l).ts._search.searchScopeLocal),1),s(v).federation!=="none"&&s(V)==="global"?(c(),f("option",ce,o(s(l).ts._search.searchScopeServer),1)):y("",!0),t("option",pe,o(s(l).ts._search.searchScopeUser),1)]),_:1},8,["modelValue"]),s(v).federation!=="none"&&m.value==="server"?(c(),f("div",{key:0,class:"pages-search-note-subOptionRoot-pgtz"},[p(W,{modelValue:k.value,"onUpdate:modelValue":e[2]||(e[2]=i=>k.value=i),placeholder:s(l).ts._search.serverHostPlaceholder,onEnter:z($,["prevent"])},{label:n(()=>[g(o(s(l).ts._search.pleaseEnterServerHost),1)]),prefix:n(()=>e[6]||(e[6]=[t("i",{class:"ph-hard-drives ph-bold ph-lg"},null,-1)])),_:1},8,["modelValue","placeholder"])],2)):y("",!0),p(X,{modelValue:w.value,"onUpdate:modelValue":e[3]||(e[3]=i=>w.value=i)},{default:n(()=>[g(o(s(l).ts._noteSearch.newestToOldest),1)]),_:1},8,["modelValue"]),p(Y,{modelValue:C.value,"onUpdate:modelValue":e[4]||(e[4]=i=>C.value=i),small:""},{label:n(()=>[g(o(s(l).ts._noteSearch.fileType),1)]),default:n(()=>[t("option",de,o(s(l).ts._noteSearch._fileType.none),1),t("option",he,o(s(l).ts._noteSearch._fileType.image),1),t("option",fe,o(s(l).ts._noteSearch._fileType.video),1),t("option",ve,o(s(l).ts._noteSearch._fileType.audio),1),t("option",me,o(s(l).ts._noteSearch._fileType.module),1),t("option",_e,o(s(l).ts._noteSearch._fileType.flash),1)]),_:1},8,["modelValue"]),m.value==="user"?(c(),f("div",{key:1,class:"pages-search-note-subOptionRoot-pgtz"},[t("div",{class:"pages-search-note-userSelectLabel-9I4U"},o(s(l).ts._search.pleaseSelectUser),3),t("div",Se,[u.value==null?(c(),f("div",{key:0,class:"pages-search-note-userSelectButtons-4VND"},[s(I)!=null?(c(),f("div",ye,[p(R,{transparent:"",class:"pages-search-note-userSelectButton-eH3r",onClick:E},{default:n(()=>
1[t("div",{class:"pages-search-note-userSelectButtonInner-l2Be"},[e[7]||(e[7]=t("span",null,[t("i",{class:"ph-plus ph-bold ph-lg"}),t("i",{class:"ph-user ph-bold ph-lg"})],-1)),t("span",null,o(s(l).ts.selectSelf),1)],2)]),_:1},8,["class"])])):y("",!0),t("div",{style:J(s(I)==null?"grid-column: span 2;":void 0)},[p(R,{transparent:"",class:"pages-search-note-userSelectButton-eH3r",onClick:j},{default:n(()=>[t("div",{class:"pages-search-note-userSelectButtonInner-l2Be"},[e[8]||(e[8]=t("span",null,[t("i",{class:"ph-plus ph-bold ph-lg"})],-1)),t("span",null,o(s(l).ts.selectUser),1)],2)]),_:1},8,["class"])],4)],2)):(c(),f("div",{key:1,class:"pages-search-note-userSelectedButtons-n3kz"},[t("div",ge,[p(oe,{user:u.value,withChart:!1,class:""},null,8,["user","class"])]),t("div",null,[t("button",{class:"_button pages-search-note-userSelectedRemoveButton-o0S4",onClick:D},e[9]||(e[9]=[t("i",{class:"ph-x ph-bold ph-lg"},null,-1)]),2)])],2))])],2)):y("",!0)])]),_:1}),t("div",null,[p(R,{large:"",primary:"",gradate:"",rounded:"",disabled:r.value==null,style:{margin:"0 auto"},onClick:$},{default:n(()=>[g(o(s(l).ts.search),1)]),_:1},8,["disabled"])])]),U.value?(c(),L(A,{key:0},{header:n(()=>[g(o(s(l).ts.searchResult),1)]),default:n(()=>[(c(),L(se,{key:`searchNotes:${M.value}`,pagination:U.value},null,8,["pagination"]))]),_:1})):y("",!0)]))}});export{Te 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.