import{I as v}from"./ItemsListing-CrsWz3l1.js";import{I as g,_}from"./ProviderDetails.vue_vue_type_script_setup_true_lang-mdGZES1H.js";import{Q as A,x as f,w as V,o as h,a4 as s,aU as D,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-CjKqSS7W.js";import{M as U}from"./MediaItemImages-CFIzn1ny.js";import"./MediaItemThumb-Bya9ATIE.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./ListItem-BaIlglzD.js";import"./Button-DRhzEmCu.js";import"./VBtn-CIAN6k9R.js";import"./VCheckbox-CtuLMwoL.js";import"./VCheckboxBtn-Yw1fo7EH.js";import"./PanelviewItemCompact-BmWmXS-a.js";import"./VSpacer-DzR7cAEV.js";/* empty css              */import"./Container-CEsuepd5.js";import"./VContainer-Cjucexo-.js";import"./Toolbar-kbNl1QNN.js";import"./VToolbar-CtTowi2z.js";import"./VTextField-cwB3gAIj.js";import"./VInfiniteScroll-C31KzLAu.js";import"./layout-C1aoomOZ.js";import"./VRow-0YuWZVs6.js";import"./VVirtualScroll-LbHvdAV3.js";import"./VAlert-uW_UuQw8.js";import"./marquee_text_sync-CP58W-xc.js";import"./VDialog-OUDbMT8x.js";const ie=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}),h(()=>{const r=s.subscribe(D.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)},w=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-track-number":!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]=I=>e.value.metadata.images=I),w]},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{ie as default};
