import{I as v}from"./ItemsListing-DWt-TOzI.js";import{I as g,_}from"./ProviderDetails.vue_vue_type_script_setup_true_lang-DK0OvcPJ.js";import{Q as A,x as f,w as V,o as D,a4 as s,aZ as h,b as B,Z as M,B as E,R as n,a9 as p,W as d,a0 as T,S as u}from"./index-CW9q7Ug9.js";import{M as U}from"./MediaItemImages-DxHgQozY.js";import"./MediaItemThumb-CL9fz0xp.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./ListItem-7Usxgk-m.js";import"./VBtn-BG_l-jMN.js";import"./VCheckbox-iOyX9dtq.js";import"./VCheckboxBtn-VcTG8xE4.js";import"./PanelviewItemCompact-DWTozcIF.js";import"./VSpacer-Cfs--T9C.js";/* empty css              */import"./Container-EEkubRcn.js";import"./VContainer-DzQ369Qf.js";import"./Toolbar-C4zmMwWE.js";import"./VToolbar-C3R4TUTJ.js";import"./VTextField-Dh0rJNQB.js";import"./VInfiniteScroll-rtn8HdwT.js";import"./layout-BUE-Vdg2.js";import"./VRow-DLxHB18w.js";import"./VVirtualScroll-BDWbQaCz.js";import"./VAlert-QmZazhWy.js";import"./marquee_text_sync-B5G6DNi6.js";import"./VDialog-hpeVNzwd.js";const ae=A({__name:"AlbumDetails",props:{itemId:{},provider:{}},setup(b){const i=b,e=f(),o=f(!1),y=async function(){o.value=!0,e.value=await s.getAlbum(i.itemId,i.provider),o.value=!1};V(()=>i.itemId,r=>{r&&y()},{immediate:!0}),D(()=>{const r=s.subscribe(h.MEDIA_ITEM_UPDATED,t=>{var m;const a=t.data;if(((m=e.value)==null?void 0:m.uri)==a.uri)o.value=!0,e.value=a,o.value=!1;else if("provider_mappings"in a){for(const l of a.provider_mappings)if(l.item_id==i.itemId&&[l.provider_instance,l.provider_domain].includes(i.provider)){o.value=!0,e.value=a,o.value=!1;break}}});B(r)});const c=async function(r){return await s.getAlbumTracks(i.itemId,i.provider,r.libraryOnly)},k=async function(r){return await s.getAlbumVersions(e.value.item_id,e.value.provider)},I=async function(){e.value&&(e.value=await s.sendCommand("music/albums/update",{item_id:e.value.item_id,update:e.value,overwrite:!0}))};return(r,t)=>{var a,m,l;return u(),M("section",null,[E(g,{item:e.value,"active-provider":r.provider},null,8,["item","active-provider"]),e.value?(u(),n(v,{key:0,itemtype:"albumtracks","parent-item":e.value,"show-provider":!0,"show-favorites-only-filter":!0,"show-library-only-filter":e.value.provider=="library"&&T(s).hasStreamingProviders.value,"show-refresh-button":!1,"allow-key-hooks":!0,"load-items":c,"sort-keys":["track_number","name","sort_name","duration","duration_desc"],title:r.$t("tracks")},null,8,["parent-item","show-library-only-filter","title"])):p("",!0),t[1]||(t[1]=d("br",null,null,-1)),e.value?(u(),n(v,{key:1,itemtype:"albumversions","parent-item":e.value,"show-provider":!0,"show-favorites-only-filter":!1,"show-refresh-button":!1,"load-items":k,"sort-keys":["provider","name","year"],title:r.$t("other_versions"),"hide-on-empty":!0},null,8,["parent-item","title"])):p("",!0),t[2]||(t[2]=d("br",null,null,-1)),((a=e.value)==null?void 0:a.provider)=="library"&&((l=(m=e.value)==null?void 0:m.metadata)!=null&&l.images)?(u(),n(U,{key:2,modelValue:e.value.metadata.images,"onUpdate:modelValue":[t[0]||(t[0]=w=>e.value.metadata.images=w),I]},null,8,["modelValue"])):p("",!0),t[3]||(t[3]=d("br",null,null,-1)),e.value?(u(),n(_,{key:3,"item-details":e.value},null,8,["item-details"])):p("",!0),t[4]||(t[4]=d("br",null,null,-1))])}}});export{ae as default};
