import{C as A}from"./Container-C7yRkeCv.js";import{I}from"./ItemsListing-Cnfrbqt8.js";import{T as L}from"./Toolbar-C66D0zTJ.js";import{W as d}from"./WidgetRow-BRke-iAc.js";import{u as V}from"./userPreferences-DWdlmlmR.js";import{az as C,J as p,L as y,a3 as B,b7 as a,a4 as O,aP as f,aG as i,o as m,aE as r,aH as b,aF as n,aK as c,c8 as P,c9 as R,ah as K,b5 as U,bd as o,ca as D,c7 as F,bc as E}from"./index-D2rF_80D.js";import{S as M}from"./search-Dxc3u4CV.js";import"./index-kQIztB-E.js";import"./Button-CrfR8Gdt.js";import"./ListItem-CU9QYmiw.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-cf4_7ViH.js";import"./MediaItemThumb-A-03axGx.js";import"./VCheckbox-DccbdgFZ.js";import"./VCheckboxBtn-Dik76WyM.js";import"./VSelectionControl-BHjDOTFl.js";import"./PanelviewItemCompact-BWonx8dk.js";import"./VInfiniteScroll-CfzetGUD.js";import"./VVirtualScroll-CG155sfU.js";import"./VToolbar-Db4qfa2C.js";import"./createLucideIcon-Bb8oGlVw.js";const G={key:1},H={key:2},ne=C({__name:"Search",setup(N){const v=p(!1),t=p(),s=p(!1),h=p(),{getPreference:S,setPreference:k}=V();y(()=>a.globalSearchTerm,()=>{clearTimeout(h.value),h.value=setTimeout(()=>{g(a.globalSearchTerm,a.globalSearchType)},1e3)},{immediate:!0}),y(()=>a.globalSearchType,()=>{g(a.globalSearchTerm,a.globalSearchType)});const g=async function(e,u){s.value=!0,k("globalSearch",e||"");const l=a.globalSearchType?50:8,$=u?[u]:void 0;e?t.value=await E.search(e,$,l):t.value=void 0,s.value=!1};B(()=>{if(!a.globalSearchTerm){const e=S("globalSearch").value;e&&e!=="null"&&(a.globalSearchTerm=e)}});const w=function(e){e.ctrlKey||e.altKey||e.metaKey||(!v.value&&e.key=="Backspace"&&a.globalSearchTerm?a.globalSearchTerm=a.globalSearchTerm.slice(0,-1):!v.value&&e.key.length==1&&(a.globalSearchTerm+=e.key))};document.addEventListener("keyup",w),O(()=>{document.removeEventListener("keyup",w)});const T=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(),f("section",null,[m(L,{icon:r(M),title:e.$t("global_search")},null,8,["icon","title"]),m(A,{variant:"default"},{default:b(()=>[m(P,{id:"searchInput",modelValue:r(a).globalSearchTerm,"onUpdate:modelValue":u[0]||(u[0]=l=>r(a).globalSearchTerm=l),clearable:"","prepend-inner-icon":"mdi-magnify",label:e.$t("type_to_search"),"hide-details":"",variant:"outlined",onFocus:u[1]||(u[1]=l=>v.value=!0),onBlur:u[2]||(u[2]=l=>v.value=!1)},null,8,["modelValue","label"]),m(R,{modelValue:r(a).globalSearchType,"onUpdate:modelValue":u[3]||(u[3]=l=>r(a).globalSearchType=l),style:{"margin-top":"10px","margin-left":"10px"}},{default:b(()=>[(i(!0),f(K,null,U([void 0,r(o).TRACK,r(o).ARTIST,r(o).ALBUM,r(o).PLAYLIST,r(o).PODCAST,r(o).AUDIOBOOK,r(o).RADIO],l=>(i(),n(F,{key:l,text:e.$t(l?l+"s":"searchtype_all"),value:l},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"}})):c("",!0),r(a).globalSearchType?s.value?c("",!0):(i(),f("div",H,[m(I,{itemtype:`${r(a).globalSearchType}s`,"show-provider":!0,"show-favorites-only-filter":!1,"show-select-button":!1,"show-refresh-button":!1,"load-items":async l=>T(r(a).globalSearchType),title:e.$t(`${r(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(),f("div",G,[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"])):c("",!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"])):c("",!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"])):c("",!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"])):c("",!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"])):c("",!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"])):c("",!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"])):c("",!0)]))]),_:1})]))}});export{ne as default};
