import{At as e,B as t,Bt as n,Dt as r,G as i,L as a,Mt as o,N as s,P as c,Q as l,R as u,T as d,Tt as f,Ut as p,bt as m,j as h,ot as g,qt as _,w as v,y}from"./vue-3bs2-dMU.js";import{C as b,K as x,U as S}from"./stores-DmetsdTd.js";import{t as C}from"./HistoryKey-C5zPCBlq.js";import{C as w,D as T,G as E,K as D,S as O,T as k,ht as A,w as j,y as M}from"./vuetify-gGrfRH2I.js";import{t as N}from"./HistoryField-BFlc9nis.js";i(),f(),p(),y();var P=t({__name:`MoveTorrentDialog`,props:{guid:{},hashes:{},mode:{}},setup(t){let i=t,{isOpened:f}=S(i.guid),{t:p}=x(),y=b(),P=o(),F=o(),I=o(!1),L=e({newPath:``}),R=[e=>!!e||p(`dialogs.moveTorrent.required`)],z=h(()=>i.hashes.map(y.getTorrentByHash)),B=h(()=>{switch(i.mode){case`dl`:return z.value[0]?.download_path;default:return z.value[0]?.savePath}});async function V(){await P.value?.validate(),I.value&&(await y.toggleAutoTmm(i.hashes,!1),await y.moveTorrents(i.mode,i.hashes,L.newPath),F.value?.saveValueToHistory(),H())}function H(){f.value=!1}return l(()=>{L.newPath=B.value||``}),(e,i)=>(g(),s(O,{modelValue:n(f),"onUpdate:modelValue":i[3]||=e=>r(f)?f.value=e:null},{default:m(()=>[u(w,null,{default:m(()=>[u(k,null,{default:m(()=>[a(_(e.$t(`dialogs.moveTorrent.${t.mode}.title`)),1)]),_:1}),u(j,null,{default:m(()=>[u(n(M),{ref_key:`form`,ref:P,modelValue:I.value,"onUpdate:modelValue":i[1]||=e=>I.value=e,onSubmit:i[2]||=d(()=>{},[`prevent`])},{default:m(()=>[B.value?(g(),s(E,{key:0,"model-value":B.value,disabled:``,label:e.$t(`dialogs.moveTorrent.oldPath`)},null,8,[`model-value`,`label`])):c(``,!0),u(N,{ref_key:`field`,ref:F,modelValue:L.newPath,"onUpdate:modelValue":i[0]||=e=>L.newPath=e,"history-key":n(C).TORRENT_PATH,rules:R,autofocus:``,label:e.$t(`dialogs.moveTorrent.newPath`),onKeydown:v(V,[`enter`])},null,8,[`modelValue`,`history-key`,`label`])]),_:1},8,[`modelValue`])]),_:1}),u(T,null,{default:m(()=>[u(A),u(D,{color:`error`,onClick:H},{default:m(()=>[a(_(e.$t(`common.cancel`)),1)]),_:1}),u(D,{color:`accent`,disabled:!I.value,onClick:V},{default:m(()=>[a(_(e.$t(`common.save`)),1)]),_:1},8,[`disabled`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]))}});export{P as default};