1import E from"./Clm1hox3.js";import z from"./BnMACNNt.js";import{_ as O}from"./CLShs8oA.js";import{k as W,l as j,T as G,B as J,a as Q,c as X,u as Y,z as l,K as R,A as P,ad as _,ao as x,ae as ee,g as h,o as i,aZ as oe,p as q,b1 as se,h as u,b0 as te,v as L,F as M,i as T,w as I}from"./CHWWsaLB.js";import{S as re}from"./DHy8eaPR.js";import{_ as ae}from"./DlAUqK2U.js";let m=!1;const ne=W({name:"HeaderSearch",components:{LoadingSvg:E},props:{mobile:{type:Boolean,default:!1}},setup(e){const{$afetch:s}=j(),c=G(),d=J(),t=Q(),F=X(),w=Y(),a=l(null),g=l(null),r=l({items:[]}),S=l("Search"),C=l(!1),b=l(!1),y=l(!1),$=l(!1),v=l(null),p=l(!1),B=async()=>{if(!(e.mobile||!m||c.path!=="/discover"||!t.searchInput)){if(await ee(),a.value){a.value.focus();const o=t.searchInput.length;a.value.setSelectionRange(o,o)}m=!1}},H=()=>{S.value="Start typing...",y.value=!0,(!t.searchInput||!t.searchInput.trim())&&(t.showElasticSearchFlyout=!0,p.value=!1)},N=()=>{t.searchInput||(S.value="Search",y.value=!1)},Z=()=>{const o=t.searchInput?t.searchInput.trim():"";o&&(t.showElasticSearchFlyout=!1),!e.mobile&&(o&&!p.value&&d.currentRoute.value.path!=="/discover"&&(m=document.activeElement===a.value,p.value=!0,d.replace({path:"/discover",query:{search:o}})),v.value&&clearTimeout(v.value),v.value=setTimeout(async()=>{if(o){p.value=!0;const n={...c.query};await d.replace({path:"/discover",query:{...n,search:o}})}else if(d.currentRoute.value.path==="/discover"){const n={...c.query};delete n.search,await d.replace({path:"/discover",query:n}),p.value=!1}},450))},D=async()=>{var k,f;m=!1;const o=((k=t.searchInput)==null?void 0:k.trim())||"";if(!o)return;F.track("Search for something",{"Search Term":o}),t.showElasticSearchFlyout=!1;const n={...c.query};if(await d.push({path:"/discover",query:{...n,search:o}}),w.isLoggedIn)try{await s(re.savePartialSearchHistory(o))}catch(V){console.error("Failed to save search history:",V)}(f=a.value)==null||f.blur(),t.dropdownResponsiveHeader=!1,x()},U=()=>{var o;m=!1,t.searchInput="",p.value=!1,t.showElasticSearchFlyout=!1,y.value=!1,S.value="Search",(o=a.value)==null||o.blur(),d.push({path:"/discover",query:{}})},A=()=>{C.value=!0,b.value=!0},K=()=>{C.value=!1,b.value=!1};return R(()=>c.query.search,o=>{o&&typeof o=="string"?t.searchInput=o:!o&&c.path==="/discover"&&(t.searchInput="")},{immediate:!0}),R(()=>c.path,(o,n)=>{const k=n==="/discover"||(n==null?void 0:n.startsWith("/discover/")),f=o==="/discover"||(o==null?void 0:o.startsWith("/discover/"));k&&!f&&(t.searchInput="",p.value=!1),f&&B()}),P(()=>{B()}),_(()=>{v.value&&clearTimeout(v.value)}),{mobile:e.mobile,searchInputRef:a,searchResponse:g,staffPicks:r,placeholder:S,showTooltipText:C,isHovered:b,isFocused:y,loading:$,handleFocus:H,handleBlur:N,partialSearch:Z,handleInput:D,clearSearch:U,showTooltip:A,hideTooltip:K,uiStore:t}}}),le=["placeholder"],ie={key:0,class:"discover-icon clear-search"},ue={class:"discover-icon"};function ce(e,s,c,d,t,F){const w=E,a=z,g=O;return i(),h("div",{class:L(["search-container",[{wide:!e.mobile&&(e.isFocused||e.uiStore.searchInput)},{disabled:e.loading},{mobile:e.mobile}]])},[oe(u("input",{ref:"searchInputRef","onUpdate:modelValue":s[0]||(s[0]=r=>e.uiStore.searchInput=r),class:L(["search-input",{wide:!e.mobile&&e.uiStore.searchInput}]),type:"text",placeholder:e.placeholder,onInput:s[1]||(s[1]=(...r)=>e.partialSearch&&e.partialSearch(...r)),onFocus:s[2]||(s[2]=(...r)=>e.handleFocus&&e.handleFocus(...r)),onBlur:s[3]||(s[3]=(...r)=>e.handleBlur&&e.handleBlur(...r)),onKeydown:s[4]||(s[4]=te((...r)=>e.handleInput&&e.handleInput(...r),["enter"]))},null,42,le),[[se,e.uiStore.searchInput]]),e.loading?(i(),q(w,{key:0,inverted:!0,narrow:!0})):(i(),h(M,{key:1},[s[10]||(s[10]=u("div",{class:"line"},null,-1)),e.mobile?(i(),h("div",{key:0,class:"discover-icon search-button",onClick:s[5]||(s[5]=(...r)=>e.handleInput&&e.handleInput(...r))},[T(a,{content:"Search",placement:"bottom",distance:20},{default:I(()=>s[7]||(s[7]=[u("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor"},[u("circle",{cx:"9",cy:"9",r:"6","stroke-width":"2"}),u("path",{d:"M14 14L18 18","stroke-width":"2","stroke-linecap":"round"})],-1)])),_:1})])):(i(),h(M,{key:1}
1,[e.uiStore.searchInput?(i(),h("div",ie,[T(a,{content:"Clear search",placement:"bottom",distance:20},{default:I(()=>[(i(),h("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",onClick:s[6]||(s[6]=(...r)=>e.clearSearch&&e.clearSearch(...r))},s[8]||(s[8]=[u("path",{d:"M15 5L5 15M5 5L15 15","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])))]),_:1})])):(i(),q(g,{key:1,to:"/discover"},{default:I(()=>[T(a,{content:"Discover",placement:"bottom",distance:20},{default:I(()=>[u("div",ue,[(i(),h("svg",{class:L({hovered:e.isHovered}),viewBox:"0 0 20 20",fill:"currentColor",stroke:"currentColor"},s[9]||(s[9]=[u("path",{d:"M11.8598 12.2561L11.8598 12.2561C12.0373 12.178 12.179 12.0363 12.2571 11.8589L12.2571 11.8589L14.6878 6.33461L14.6878 6.33459C14.8165 6.04206 14.7524 5.70049 14.5264 5.47448C14.3004 5.24844 13.9588 5.1844 13.6663 5.31312L8.14202 7.74377L8.14201 7.74378C7.96458 7.82186 7.82284 7.9636 7.74476 8.14103L7.74476 8.14103L5.31407 13.6653L5.31407 13.6653C5.18538 13.9578 5.24943 14.2994 5.47547 14.5254C5.70146 14.7514 6.04304 14.8155 6.33559 14.6868L6.27518 14.5495L6.33559 14.6868L11.8598 12.2561ZM9.04211 9.04113L12.4664 7.53443L10.9598 10.9588L7.53541 12.4655L9.04211 9.04113Z","stroke-width":"0.3"},null,-1),u("path",{d:"M10 0.475C4.7395 0.475 0.475 4.7395 0.475 10C0.475 15.2605 4.7395 19.525 10 19.525C15.2605 19.525 19.525 15.2605 19.525 10C19.525 4.7395 15.2605 0.475 10 0.475ZM2.025 10C2.025 5.59553 5.59553 2.025 10 2.025C14.4045 2.025 17.975 5.59553 17.975 10C17.975 14.4045 14.4045 17.975 10 17.975C5.59553 17.975 2.025 14.4045 2.025 10Z","stroke-width":"0.3"},null,-1)]),2))])]),_:1})]),_:1}))],64))],64))],2)}const Se=ae(ne,[["render",ce],["__scopeId","data-v-b07f3fd1"]]);export{Se 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.