import{B as e,Bt as t,Dt as n,G as r,L as i,M 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,E as x,K as S,R as C,U as w,c as T}from"./stores-DmetsdTd.js";import{C as E,D,G as O,K as k,L as A,N as j,S as M,_t as N,a as P,gt as F,ht as I,i as L,w as ee,y as te}from"./vuetify-gGrfRH2I.js";r(),f(),y(),p();var R=-2,z=-1,B=e({__name:`ShareLimitDialog`,props:{guid:{},hashes:{}},setup(e){let r=e,{isOpened:f}=w(r.guid),{t:p}=S(),y=T(),B=b(),V=x(),H=o(!1),U=o(`global`),W=o(!1),G=o(0),K=o(!1),q=o(0),J=o(!1),Y=o(0),X=o(C.DEFAULT),Z=h(()=>U.value!==`enabled`),ne=h(()=>[{title:p(`common.useGlobalSettings`),value:C.DEFAULT},{title:p(`constants.shareLimitAction.stopTorrent`),value:C.STOP_TORRENT},{title:p(`constants.shareLimitAction.removeTorrent`),value:C.REMOVE_TORRENT},{title:p(`constants.shareLimitAction.removeTorrentAndFiles`),value:C.REMOVE_TORRENT_AND_FILES},{title:p(`constants.shareLimitAction.torrentSuperseeding`),value:C.ENABLE_SUPERSEEDING}]);function Q(){f.value=!1}async function $(){switch(U.value){case`global`:await y.setShareLimit(r.hashes,R,R,R,C.DEFAULT);break;case`disabled`:await y.setShareLimit(r.hashes,z,z,z,C.DEFAULT);break;case`enabled`:await y.setShareLimit(r.hashes,W.value?G.value:z,K.value?q.value:z,J.value?Y.value:z,X.value)}Q()}return l(()=>{let e=B.getTorrentByHash(r.hashes[0]);if(!e)return Q();let t=e.ratio_limit,n=e.seeding_time_limit,i=e.inactive_seeding_time_limit;X.value=e.share_limit_action??C.DEFAULT,t===R&&n===R&&i===R?U.value=`global`:t===z&&n===z&&i===z?U.value=`disabled`:(U.value=`enabled`,W.value=t>=0,G.value=W.value?t:0,K.value=n>=0,q.value=K.value?n:0,J.value=i>=0,Y.value=J.value?i:0)}),(e,r)=>(g(),s(M,{modelValue:t(f),"onUpdate:modelValue":r[10]||=e=>n(f)?f.value=e:null,"max-width":`500`},{default:m(()=>[u(E,{title:e.$t(`dialogs.share_limit.title`)},{default:m(()=>[u(ee,null,{default:m(()=>[u(te,{modelValue:H.value,"onUpdate:modelValue":r[8]||=e=>H.value=e,onSubmit:r[9]||=d(()=>{},[`prevent`]),onKeydown:v(d($,[`prevent`]),[`enter`])},{default:m(()=>[u(L,{modelValue:U.value,"onUpdate:modelValue":r[0]||=e=>U.value=e},{default:m(()=>[u(P,{label:e.$t(`dialogs.share_limit.global`),value:`global`},null,8,[`label`]),u(P,{label:e.$t(`dialogs.share_limit.disabled`),value:`disabled`},null,8,[`label`]),u(P,{label:e.$t(`dialogs.share_limit.enabled`),value:`enabled`},null,8,[`label`])]),_:1},8,[`modelValue`]),u(F,null,{default:m(()=>[u(N,{cols:`12`,class:`d-flex align-center`},{default:m(()=>[a(`span`,null,[u(A,{modelValue:W.value,"onUpdate:modelValue":r[1]||=e=>W.value=e,disabled:Z.value},null,8,[`modelValue`,`disabled`])]),u(O,{modelValue:G.value,"onUpdate:modelValue":r[2]||=e=>G.value=e,disabled:Z.value||!W.value,density:`compact`,"hide-details":``,label:e.$t(`dialogs.share_limit.ratio_limit`)},null,8,[`modelValue`,`disabled`,`label`])]),_:1}),u(N,{cols:`12`,class:`d-flex align-center`},{default:m(()=>[a(`span`,null,[u(A,{modelValue:K.value,"onUpdate:modelValue":r[3]||=e=>K.value=e,disabled:Z.value},null,8,[`modelValue`,`disabled`])]),u(O,{modelValue:q.value,"onUpdate:modelValue":r[4]||=e=>q.value=e,disabled:Z.value||!K.value,density:`compact`,"hide-details":``,label:e.$t(`dialogs.share_limit.seeding_time_limit`)},null,8,[`modelValue`,`disabled`,`label`])]),_:1}),u(N,{cols:`12`,class:`d-flex align-center`},{default:m(()=>[a(`span`,null,[u(A,{modelValue:J.value,"onUpdate:modelValue":r[5]||=e=>J.value=e,disabled:Z.value},null,8,[`modelValue`,`disabled`])]),u(O,{modelValue:Y.value,"onUpdate:modelValue":r[6]||=e=>Y.value=e,disabled:Z.value||!J.value,density:`compact`,"hide-details":``,label:e.$t(`dialogs.share_limit.inactive_seeding_time_limit`)},null,8,[`modelValue`,`disabled`,`label`])]),_:1}),t(V).isFeatureAvailable(`5.2.0`)?(g(),s(N,{key:0,cols:`12`},{default:m(()=>[u(j,{modelValue:X.value,"onUpdate:modelValue":r[7]||=e=>X.value=e,items:ne.value,"item-title":`title`,"item-value":`value`,disabled:Z.value,density:`compact`,"hide-details":``,label:e.$t(`settings.bittorrent.seedLimits.then`)},null,8,[`modelValue`,`items`,`disabled`,`label`])]),_:1})):c(``,!0)]),_:1})]),_:1},8,[`modelValue`,`onKeydown`])]),_:1}),u(D,null,{default:m(()=>[u(I),u(k,{color:`error`,onClick:Q},{default:m(()=>[i(_(e.$t(`common.cancel`)),1)]),_:1}),u(k,{color:`accent`,disabled:!H.value,onClick:$},{default:m(()=>[i(_(e.$t(`common.save`)),1)]),_:1},8,[`disabled`])]),_:1})]),_:1},8,[`title`])]),_:1},8,[`modelValue`]))}});export{B as default};