import{C as T}from"./Container-DVyc_Yt_.js";import{I}from"./ItemsListing-6VW59A0B.js";import{T as $}from"./Toolbar-CLPRlZ-4.js";import{W as d}from"./WidgetRow-DgM_bx7i.js";import{av as A,H as v,J as y,a3 as C,au as a,a4 as L,aw as g,x as c,aB as b,ax as i,aD as n,ay as m,az as l,bB as V,ag as B,aC as O,bC as R,aM as o,bD as D,aL as K}from"./index-C-Ivu3jU.js";import{V as U}from"./VTextField-Bkx949P5.js";import"./index-kQIztB-E.js";import"./VContainer-CNNJtZg6.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./Button-FtStaD9_.js";import"./ListItem-BLmrgznL.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-B5IzKSW4.js";import"./VCheckboxBtn-BmKOjEU4.js";import"./VInput-CnrZS6Kh.js";import"./MediaItemThumb-BsXB7IV6.js";import"./PanelviewItemCompact-5_ppRL3T.js";import"./VSnackbar-C_PtJN1U.js";import"./layout-D2NB7OTD.js";import"./VRow-DOG0WeJD.js";import"./VVirtualScroll-C_Lzj3jv.js";import"./VAlert-B3qbTkCR.js";import"./VToolbar-DTucOBiF.js";const M={key:1},P={key:2},se=A({__name:"Search",setup(F){const p=v(!1),t=v(),s=v(!1),h=v();y(()=>a.globalSearchTerm,()=>{clearTimeout(h.value),h.value=setTimeout(()=>{f(a.globalSearchTerm,a.globalSearchType)},1e3)},{immediate:!0}),y(()=>a.globalSearchType,()=>{f(a.globalSearchTerm,a.globalSearchType)});const f=async function(e,u){s.value=!0,localStorage.setItem("globalsearch",e||"");const r=a.globalSearchType?50:8,k=u?[u]:void 0;e?t.value=await K.search(e,k,r):t.value=void 0,s.value=!1};C(()=>{if(!a.globalSearchTerm){const e=localStorage.getItem("globalsearch");e&&e!=="null"&&(a.globalSearchTerm=e)}});const w=function(e){e.ctrlKey||e.altKey||e.metaKey||(!p.value&&e.key=="Backspace"&&a.globalSearchTerm?a.globalSearchTerm=a.globalSearchTerm.slice(0,-1):!p.value&&e.key.length==1&&(a.globalSearchTerm+=e.key))};document.addEventListener("keyup",w),L(()=>{document.removeEventListener("keyup",w)});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:b(()=>[c(U,{id:"searchInput",modelValue:l(a).globalSearchTerm,"onUpdate:modelValue":u[0]||(u[0]=r=>l(a).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(V,{modelValue:l(a).globalSearchType,"onUpdate:modelValue":u[3]||(u[3]=r=>l(a).globalSearchType=r),style:{"margin-top":"10px","margin-left":"10px"}},{default:b(()=>[(i(!0),g(B,null,O([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(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(D,{key:0,color:"accent",height:"4",indeterminate:"",rounded:"",style:{"margin-top":"15px"}})):m("",!0),l(a).globalSearchType?s.value?m("",!0):(i(),g("div",P,[c(I,{itemtype:`${l(a).globalSearchType}s`,"show-provider":!0,"show-favorites-only-filter":!1,"show-select-button":!1,"show-refresh-button":!1,"load-items":async r=>S(l(a).globalSearchType),title:e.$t(`${l(a).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",M,[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{se as default};
