import{C as T}from"./Container-iGBsqgnx.js";import{I}from"./ItemsListing-CHZs9N6z.js";import{T as $}from"./Toolbar-DambSy-S.js";import{W as m}from"./WidgetRow-BoNKZ8D3.js";import{a7 as A,F as p,M as y,L,a6 as t,N as V,a8 as g,a9 as i,o as c,ae as b,ai as n,aa as d,bj as C,ac as l,bk as B,a0 as O,af as R,aq as o,bl as K,bm as U,ap as D}from"./index-CFcIX8RO.js";import"./index-kQIztB-E.js";import"./Button-IxLZkOI0.js";import"./ListItem-CWPLlf7K.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-CGTv89Z9.js";import"./VCheckboxBtn-Dy9mjR59.js";import"./MediaItemThumb-oOnMmU-2.js";import"./PanelviewItemCompact-YHP34gKS.js";import"./VInfiniteScroll-DY-7nfIB.js";import"./VVirtualScroll-BRrQ8Y7O.js";import"./VAlert-DZurr_D6.js";import"./VToolbar-B_3_MVxk.js";const F={key:1},M={key:2},ae=A({__name:"Search",setup(P){const v=p(!1),a=p(),s=p(!1),h=p();y(()=>t.globalSearchTerm,()=>{clearTimeout(h.value),h.value=setTimeout(()=>{f(t.globalSearchTerm,t.globalSearchType)},1e3)},{immediate:!0}),y(()=>t.globalSearchType,()=>{f(t.globalSearchTerm,t.globalSearchType)});const f=async function(e,u){s.value=!0,localStorage.setItem("globalsearch",e||"");const r=t.globalSearchType?50:8,S=u?[u]:void 0;e?a.value=await D.search(e,S,r):a.value=void 0,s.value=!1};L(()=>{if(!t.globalSearchTerm){const e=localStorage.getItem("globalsearch");e&&e!=="null"&&(t.globalSearchTerm=e)}});const w=function(e){e.ctrlKey||e.altKey||e.metaKey||(!v.value&&e.key=="Backspace"&&t.globalSearchTerm?t.globalSearchTerm=t.globalSearchTerm.slice(0,-1):!v.value&&e.key.length==1&&(t.globalSearchTerm+=e.key))};document.addEventListener("keyup",w),V(()=>{document.removeEventListener("keyup",w)});const k=function(e){return a.value?e==o.TRACK?a.value.tracks:e==o.ARTIST?a.value.artists:e==o.ALBUM?a.value.albums:e==o.PLAYLIST?a.value.playlists:e==o.PODCAST?a.value.podcasts:e==o.AUDIOBOOK?a.value.audiobooks:e==o.RADIO?a.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(C,{id:"searchInput",modelValue:l(t).globalSearchTerm,"onUpdate:modelValue":u[0]||(u[0]=r=>l(t).globalSearchTerm=r),clearable:"","prepend-inner-icon":"mdi-magnify",label:e.$t("type_to_search"),"hide-details":"",variant:"outlined",onFocus:u[1]||(u[1]=r=>v.value=!0),onBlur:u[2]||(u[2]=r=>v.value=!1)},null,8,["modelValue","label"]),c(B,{modelValue:l(t).globalSearchType,"onUpdate:modelValue":u[3]||(u[3]=r=>l(t).globalSearchType=r),style:{"margin-top":"10px","margin-left":"10px"}},{default:b(()=>[(i(!0),g(O,null,R([void 0,l(o).TRACK,l(o).ARTIST,l(o).ALBUM,l(o).PLAYLIST,l(o).PODCAST,l(o).AUDIOBOOK,l(o).RADIO],r=>(i(),n(U,{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"}})):d("",!0),l(t).globalSearchType?s.value?d("",!0):(i(),g("div",M,[c(I,{itemtype:`${l(t).globalSearchType}s`,"show-provider":!0,"show-favorites-only-filter":!1,"show-select-button":!1,"show-refresh-button":!1,"load-items":async r=>k(l(t).globalSearchType),title:e.$t(`${l(t).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,[a.value&&!s.value?(i(),n(m,{key:0,"widget-row":{title:e.$t("tracks"),icon:"mdi-file-music",items:a.value.tracks},"show-provider-on-cover":!0},null,8,["widget-row"])):d("",!0),a.value&&!s.value?(i(),n(m,{key:1,"widget-row":{title:e.$t("artists"),icon:"mdi-account-music",items:a.value.artists},"show-provider-on-cover":!0},null,8,["widget-row"])):d("",!0),a.value&&!s.value?(i(),n(m,{key:2,"widget-row":{title:e.$t("albums"),icon:"mdi-album",items:a.value.albums},"show-provider-on-cover":!0},null,8,["widget-row"])):d("",!0),a.value&&!s.value?(i(),n(m,{key:3,"widget-row":{title:e.$t("playlists"),icon:"mdi-playlist-music",items:a.value.playlists},"show-provider-on-cover":!0},null,8,["widget-row"])):d("",!0),a.value&&!s.value?(i(),n(m,{key:4,"widget-row":{title:e.$t("podcasts"),icon:"mdi-podcast",items:a.value.podcasts},"show-provider-on-cover":!0},null,8,["widget-row"])):d("",!0),a.value&&!s.value?(i(),n(m,{key:5,"widget-row":{title:e.$t("audiobooks"),icon:"mdi-book-play-outline",items:a.value.audiobooks},"show-provider-on-cover":!0},null,8,["widget-row"])):d("",!0),a.value&&!s.value?(i(),n(m,{key:6,"widget-row":{title:e.$t("radios"),icon:"mdi-radio",items:a.value.radio},"show-provider-on-cover":!0},null,8,["widget-row"])):d("",!0)]))]),_:1})]))}});export{ae as default};
