import{C as T}from"./Container-CuH2YNr5.js";import{I}from"./ItemsListing-BHlkb6-j.js";import{T as $}from"./Toolbar-iQxHKI_C.js";import{W as d}from"./WidgetRow-DQvw9AsK.js";import{d as A,i as v,ad as h,j as V,s as l,l as L,c as g,o as i,b as c,w,e as n,q as m,u as a,br as C,F as B,r as O,bs as R,M as o,bt as K,m as U}from"./index-LFx1jIjH.js";import{V as D}from"./VTextField-DyzwZgKh.js";import"./Button-SUce42c3.js";import"./VBtn-BYKkZzw0.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VContainer-or1Uze2V.js";/* empty css              */import"./ListItem-DhvO1M3C.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-B4veTxLS.js";import"./VInput-B3Z2GK8Z.js";import"./MediaItemThumb-cYqdWFcl.js";import"./PanelviewItemCompact-Bf82DAtE.js";import"./VSpacer-Cg-cZSyv.js";import"./VInfiniteScroll-DH2IK80_.js";import"./layout-C6GuZOkj.js";import"./VRow-cyJLSUM5.js";import"./VVirtualScroll-DYZmdOFl.js";import"./VAlert-Cyb25ra3.js";import"./VToolbar-Dc2WDt1C.js";const F={key:1},M={key:2},ue=A({__name:"Search",setup(P){const p=v(!1),t=v(),s=v(!1),f=v();h(()=>l.globalSearchTerm,()=>{clearTimeout(f.value),f.value=setTimeout(()=>{y(l.globalSearchTerm,l.globalSearchType)},1e3)},{immediate:!0}),h(()=>l.globalSearchType,()=>{y(l.globalSearchTerm,l.globalSearchType)});const y=async function(e,u){s.value=!0,localStorage.setItem("globalsearch",e||"");const r=l.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(!l.globalSearchTerm){const e=localStorage.getItem("globalsearch");e&&e!=="null"&&(l.globalSearchTerm=e)}});const b=function(e){e.ctrlKey||e.altKey||e.metaKey||(!p.value&&e.key=="Backspace"&&l.globalSearchTerm?l.globalSearchTerm=l.globalSearchTerm.slice(0,-1):!p.value&&e.key.length==1&&(l.globalSearchTerm+=e.key))};document.addEventListener("keyup",b),L(()=>{document.removeEventListener("keyup",b)});const S=function(e){return t.value?e==o.TRACK?t.value.tracks:e==o.ARTIST?t.value.artists:e==o.ALBUM?t.value.albums:e==o.PLAYLIST?t.value.playlists:e==o.PODCAST?t.value.podcasts:e==o.AUDIOBOOK?t.value.audiobooks:e==o.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:w(()=>[c(D,{id:"searchInput",modelValue:a(l).globalSearchTerm,"onUpdate:modelValue":u[0]||(u[0]=r=>a(l).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(l).globalSearchType,"onUpdate:modelValue":u[3]||(u[3]=r=>a(l).globalSearchType=r),style:{"margin-top":"10px","margin-left":"10px"}},{default:w(()=>[(i(!0),g(B,null,O([void 0,a(o).TRACK,a(o).ARTIST,a(o).ALBUM,a(o).PLAYLIST,a(o).PODCAST,a(o).AUDIOBOOK,a(o).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(l).globalSearchType?s.value?m("",!0):(i(),g("div",M,[c(I,{itemtype:`${a(l).globalSearchType}s`,"show-provider":!0,"show-favorites-only-filter":!1,"show-select-button":!1,"show-refresh-button":!1,"load-items":async r=>S(a(l).globalSearchType),title:e.$t(`${a(l).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}},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}},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}},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}},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}},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}},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}},null,8,["widget-row"])):m("",!0)]))]),_:1})]))}});export{ue as default};
