import{x as M,aw as $,ax as C,r,w as b,y as D,z as A,A as m,H as I,n as t,B as y,S as g,J as c,M as U,I as v,ao as w}from"./index-CFvoaD7J.js";import{T as h}from"./Toolbar-DNen7a-V.js";import{V as N}from"./VDialog-CdvGeqlS.js";import{V as S}from"./VList-fGk9SRdf.js";import{V as f}from"./VTextField-DF4u_eMy.js";import{a as x,V as H}from"./VCard-DxLPF-Ra.js";import{V as L}from"./VSpacer-UYEiyhN7.js";import{v as T}from"./VListItem-CSPID7yq.js";const R={style:{padding:"15px"}},q=M({__name:"AddManualLink",props:$({type:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(p){const s=C(p,"modelValue"),B=p,u=r(""),n=r(""),d=r(""),i=r(!1),l=r();b(()=>s.value,e=>{e!=null&&(I.dialogActive=e),e==!1&&(u.value="",n.value="",d.value="",l.value=void 0)},{immediate:!0}),b(()=>l.value,e=>{if(e){n.value||(n.value=e.name);for(const a of e.metadata.images||[])if(a.type=="thumb"){d.value=a.path;break}}});const V=()=>{!u.value||!u.value.startsWith("http")||(i.value=!0,B.type==U.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}))},k=function(){V(),l.value&&(l.value.name=n.value||l.value.name,delete l.value.sort_name,d.value&&(l.value.metadata.images=[{type:w.THUMB,path:d.value,provider:"builtin",remotely_accessible:!0}]),v.addItemToLibrary(l.value,!0).then(()=>{s.value=!1}))};return(e,a)=>(D(),A(N,{modelValue:s.value,"onUpdate:modelValue":a[4]||(a[4]=o=>s.value=o),transition:"dialog-bottom-transition"},{default:m(()=>[t(H,null,{default:m(()=>[t(h,{icon:"mdi-playlist-plus",title:e.$t("add_url_item")},null,8,["title"]),t(S),a[5]||(a[5]=y("br",null,null,-1)),y("div",R,[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:n.value,"onUpdate:modelValue":a[1]||(a[1]=o=>n.value=o),variant:"outlined",label:e.$t("enter_name"),disabled:i.value},null,8,["modelValue","label","disabled"]),t(f,{modelValue:d.value,"onUpdate:modelValue":a[2]||(a[2]=o=>d.value=o),variant:"outlined",label:e.$t("image_url"),disabled:i.value},null,8,["modelValue","label","disabled"]),t(x,null,{default:m(()=>[t(L),t(T,{variant:"outlined",onClick:a[3]||(a[3]=o=>s.value=!1)},{default:m(()=>[g(c(e.$t("cancel")),1)]),_:1}),t(T,{variant:"flat",color:"primary",disabled:i.value,onClick:k},{default:m(()=>[g(c(e.$t("save")),1)]),_:1},8,["disabled"])]),_:1})])]),_:1})]),_:1},8,["modelValue"]))}});export{q as _};
