import{C as T}from"./Container-CEbFgC5b.js";import{I}from"./ItemsListing-XUXN-Um6.js";import{T as $}from"./Toolbar-Ba4dAxS1.js";import{W as d}from"./WidgetRow-QNz25d2y.js";import{d as A,r as v,ae as y,m as V,s as o,q as L,c as g,b as c,w as b,o as i,h as n,e as m,u as a,bs as C,F as B,g as O,bt as R,M as l,bu as K,v as U}from"./index-Bn2Tzsay.js";import{V as D}from"./VTextField-fPA0WAHx.js";import"./index-CBho6rsP.js";import"./VContainer-CRIwFZfO.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./Button-r9Wpw3CQ.js";import"./VBtn-BQk37KYJ.js";import"./ListItem-BNbxxrdg.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-DCLVCnPO.js";import"./VInput-C_1AW61Q.js";import"./MediaItemThumb-B7hfZSf2.js";import"./PanelviewItemCompact-By5cXXTW.js";import"./VSpacer-ygjaGObn.js";import"./VInfiniteScroll-DvbiA0kw.js";import"./layout-kFqKNtL6.js";import"./VRow-CNVApy9v.js";import"./VVirtualScroll-B56qZ1Y0.js";import"./VAlert-Bj5fXNhB.js";import"./VToolbar-Z0nE2qFc.js";const F={key:1},M={key:2},ne=A({__name:"Search",setup(P){const p=v(!1),t=v(),s=v(!1),h=v();y(()=>o.globalSearchTerm,()=>{clearTimeout(h.value),h.value=setTimeout(()=>{f(o.globalSearchTerm,o.globalSearchType)},1e3)},{immediate:!0}),y(()=>o.globalSearchType,()=>{f(o.globalSearchTerm,o.globalSearchType)});const f=async function(e,u){s.value=!0,localStorage.setItem("globalsearch",e||"");const r=o.globalSearchType?50:8,k=u?[u]:void 0;e?t.value=await U.search(e,k,r):t.value=void 0,s.value=!1};V(()=>{if(!o.globalSearchTerm){const e=localStorage.getItem("globalsearch");e&&e!=="null"&&(o.globalSearchTerm=e)}});const w=function(e){e.ctrlKey||e.altKey||e.metaKey||(!p.value&&e.key=="Backspace"&&o.globalSearchTerm?o.globalSearchTerm=o.globalSearchTerm.slice(0,-1):!p.value&&e.key.length==1&&(o.globalSearchTerm+=e.key))};document.addEventListener("keyup",w),L(()=>{document.removeEventListener("keyup",w)});const S=function(e){return t.value?e==l.TRACK?t.value.tracks:e==l.ARTIST?t.value.artists:e==l.ALBUM?t.value.albums:e==l.PLAYLIST?t.value.playlists:e==l.PODCAST?t.value.podcasts:e==l.AUDIOBOOK?t.value.audiobooks:e==l.RADIO?t.value.radio:[]:[]};return(e,u)=>(i(),g("section",null,[c($,{icon:"mdi-magnify",title:e.$t("global_search")},null,8,["title"]),c(T,{variant:"default"},{default:b(()=>[c(D,{id:"searchInput",modelValue:a(o).globalSearchTerm,"onUpdate:modelValue":u[0]||(u[0]=r=>a(o).globalSearchTerm=r),clearable:"","prepend-inner-icon":"mdi-magnify",label:e.$t("type_to_search"),"hide-details":"",variant:"outlined",onFocus:u[1]||(u[1]=r=>p.value=!0),onBlur:u[2]||(u[2]=r=>p.value=!1)},null,8,["modelValue","label"]),c(C,{modelValue:a(o).globalSearchType,"onUpdate:modelValue":u[3]||(u[3]=r=>a(o).globalSearchType=r),style:{"margin-top":"10px","margin-left":"10px"}},{default:b(()=>[(i(!0),g(B,null,O([void 0,a(l).TRACK,a(l).ARTIST,a(l).ALBUM,a(l).PLAYLIST,a(l).PODCAST,a(l).AUDIOBOOK,a(l).RADIO],r=>(i(),n(R,{key:r,text:e.$t(r?r+"s":"searchtype_all"),value:r},null,8,["text","value"]))),128))]),_:1},8,["modelValue"]),s.value?(i(),n(K,{key:0,color:"accent",height:"4",indeterminate:"",rounded:"",style:{"margin-top":"15px"}})):m("",!0),a(o).globalSearchType?s.value?m("",!0):(i(),g("div",M,[c(I,{itemtype:`${a(o).globalSearchType}s`,"show-provider":!0,"show-favorites-only-filter":!1,"show-select-button":!1,"show-refresh-button":!1,"load-items":async r=>S(a(o).globalSearchType),title:e.$t(`${a(o).globalSearchType}s`),"allow-key-hooks":!1,"show-search-button":!1,"infinite-scroll":!0,"sort-keys":[],style:{padding:"0"}},null,8,["itemtype","load-items","title"])])):(i(),g("div",F,[t.value&&!s.value?(i(),n(d,{key:0,"widget-row":{title:e.$t("tracks"),icon:"mdi-file-music",items:t.value.tracks},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:1,"widget-row":{title:e.$t("artists"),icon:"mdi-account-music",items:t.value.artists},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:2,"widget-row":{title:e.$t("albums"),icon:"mdi-album",items:t.value.albums},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:3,"widget-row":{title:e.$t("playlists"),icon:"mdi-playlist-music",items:t.value.playlists},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:4,"widget-row":{title:e.$t("podcasts"),icon:"mdi-podcast",items:t.value.podcasts},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:5,"widget-row":{title:e.$t("audiobooks"),icon:"mdi-book-play-outline",items:t.value.audiobooks},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:6,"widget-row":{title:e.$t("radios"),icon:"mdi-radio",items:t.value.radio},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0)]))]),_:1})]))}});export{ne as default};
