import{d as M,al as $,am as h,r,N as b,c as C,e as D,w as m,f as t,i as T,Y as c,t as g,s as U,M as _,b as v,ac as A}from"./index-e34071c2.js";import{T as I}from"./Toolbar-bbf3d11a.js";import{V as N}from"./VList-5a526902.js";import{V as f}from"./VTextField-df721147.js";import{b as w,V as L}from"./VCard-0f63f60c.js";import{V as R}from"./VSpacer-b7ae4876.js";import{s as y}from"./VListItem-6fb16d04.js";import{V as S}from"./VDialog-57dacf99.js";const F=T("br",null,null,-1),H={style:{padding:"15px"}},E=M({__name:"AddManualLink",props:$({type:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(p){const d=h(p,"modelValue"),k=p,u=r(""),s=r(""),n=r(""),i=r(!1),l=r();b(()=>d.value,e=>{e!=null&&(U.dialogActive=e),e==!1&&(u.value="",s.value="",n.value="",l.value=void 0)},{immediate:!0}),b(()=>l.value,e=>{if(e){s.value||(s.value=e.name);for(const a of e.metadata.images||[])if(a.type=="thumb"){n.value=a.path;break}}});const V=()=>{!u.value||!u.value.startsWith("http")||(i.value=!0,k.type==_.RADIO?v.getRadio(u.value,"builtin").then(e=>{l.value=e}).catch(e=>{console.error(e),l.value=void 0}).finally(()=>{i.value=!1}):v.getTrack(u.value,"builtin").then(e=>{l.value=e}).catch(e=>{console.error(e),l.value=void 0}).finally(()=>{i.value=!1}))},B=function(){V(),l.value&&(l.value.name=s.value||l.value.name,delete l.value.sort_name,n.value&&(l.value.metadata.images=[{type:A.THUMB,path:n.value,provider:"builtin",remotely_accessible:!0}]),v.addItemToLibrary(l.value,!0).then(()=>{d.value=!1}))};return(e,a)=>(C(),D(S,{modelValue:d.value,"onUpdate:modelValue":a[4]||(a[4]=o=>d.value=o),transition:"dialog-bottom-transition"},{default:m(()=>[t(L,null,{default:m(()=>[t(I,{icon:"mdi-playlist-plus",title:e.$t("add_url_item")},null,8,["title"]),t(N),F,T("div",H,[t(f,{modelValue:u.value,"onUpdate:modelValue":a[0]||(a[0]=o=>u.value=o),variant:"outlined",label:e.$t("enter_url"),disabled:i.value,onBlur:V},null,8,["modelValue","label","disabled"]),t(f,{modelValue:s.value,"onUpdate:modelValue":a[1]||(a[1]=o=>s.value=o),variant:"outlined",label:e.$t("enter_name"),disabled:i.value},null,8,["modelValue","label","disabled"]),t(f,{modelValue:n.value,"onUpdate:modelValue":a[2]||(a[2]=o=>n.value=o),variant:"outlined",label:e.$t("image_url"),disabled:i.value},null,8,["modelValue","label","disabled"]),t(w,null,{default:m(()=>[t(R),t(y,{variant:"outlined",onClick:a[3]||(a[3]=o=>d.value=!1)},{default:m(()=>[c(g(e.$t("cancel")),1)]),_:1}),t(y,{variant:"flat",color:"primary",disabled:i.value,onClick:B},{default:m(()=>[c(g(e.$t("save")),1)]),_:1},8,["disabled"])]),_:1})])]),_:1})]),_:1},8,["modelValue"]))}});export{E as _};
