%PDF- %PDF-
Direktori : /usr/share/transmission/public_html/ |
Current File : //usr/share/transmission/public_html/transmission-app.js |
(()=>{var zt=Object.create;var Ne=Object.defineProperty;var qt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Ht=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty;var Qt=n=>Ne(n,"__esModule",{value:!0});var Kt=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Gt=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of jt(e))!Wt.call(n,r)&&(t||r!=="default")&&Ne(n,r,{get:()=>e[r],enumerable:!(s=qt(e,r))||s.enumerable});return n},Vt=(n,e)=>Gt(Qt(Ne(n!=null?zt(Ht(n)):{},"default",!e&&n&&n.__esModule?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var Bt=Kt((ue,ne)=>{var Yt=200,Oe="__lodash_hash_undefined__",ye=1,st=2,nt=9007199254740991,we="[object Arguments]",$e="[object Array]",Xt="[object AsyncFunction]",rt="[object Boolean]",ot="[object Date]",it="[object Error]",at="[object Function]",Jt="[object GeneratorFunction]",Se="[object Map]",ct="[object Number]",Zt="[object Null]",te="[object Object]",lt="[object Promise]",es="[object Proxy]",dt="[object RegExp]",Ee="[object Set]",ut="[object String]",ts="[object Symbol]",ss="[object Undefined]",ze="[object WeakMap]",pt="[object ArrayBuffer]",ke="[object DataView]",ns="[object Float32Array]",rs="[object Float64Array]",os="[object Int8Array]",is="[object Int16Array]",as="[object Int32Array]",cs="[object Uint8Array]",ls="[object Uint8ClampedArray]",ds="[object Uint16Array]",us="[object Uint32Array]",ps=/[\\^$.*+?()[\]{}|]/g,hs=/^\[object .+?Constructor\]$/,ms=/^(?:0|[1-9]\d*)$/,L={};L[ns]=L[rs]=L[os]=L[is]=L[as]=L[cs]=L[ls]=L[ds]=L[us]=!0;L[we]=L[$e]=L[pt]=L[rt]=L[ke]=L[ot]=L[it]=L[at]=L[Se]=L[ct]=L[te]=L[dt]=L[Ee]=L[ut]=L[ze]=!1;var ht=typeof global=="object"&&global&&global.Object===Object&&global,fs=typeof self=="object"&&self&&self.Object===Object&&self,z=ht||fs||Function("return this")(),mt=typeof ue=="object"&&ue&&!ue.nodeType&&ue,ft=mt&&typeof ne=="object"&&ne&&!ne.nodeType&&ne,gt=ft&&ft.exports===mt,qe=gt&&ht.process,_t=function(){try{return qe&&qe.binding&&qe.binding("util")}catch{}}(),bt=_t&&_t.isTypedArray;function gs(n,e){for(var t=-1,s=n==null?0:n.length,r=0,o=[];++t<s;){var i=n[t];e(i,t,n)&&(o[r++]=i)}return o}function _s(n,e){for(var t=-1,s=e.length,r=n.length;++t<s;)n[r+t]=e[t];return n}function bs(n,e){for(var t=-1,s=n==null?0:n.length;++t<s;)if(e(n[t],t,n))return!0;return!1}function vs(n,e){for(var t=-1,s=Array(n);++t<n;)s[t]=e(t);return s}function ys(n){return function(e){return n(e)}}function ws(n,e){return n.has(e)}function Ss(n,e){return n==null?void 0:n[e]}function Es(n){var e=-1,t=Array(n.size);return n.forEach(function(s,r){t[++e]=[r,s]}),t}function ks(n,e){return function(t){return n(e(t))}}function Ts(n){var e=-1,t=Array(n.size);return n.forEach(function(s){t[++e]=s}),t}var Cs=Array.prototype,Ls=Function.prototype,Te=Object.prototype,je=z["__core-js_shared__"],vt=Ls.toString,$=Te.hasOwnProperty,yt=function(){var n=/[^.]+$/.exec(je&&je.keys&&je.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),wt=Te.toString,xs=RegExp("^"+vt.call($).replace(ps,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),St=gt?z.Buffer:void 0,Ce=z.Symbol,Et=z.Uint8Array,kt=Te.propertyIsEnumerable,As=Cs.splice,V=Ce?Ce.toStringTag:void 0,Tt=Object.getOwnPropertySymbols,Ds=St?St.isBuffer:void 0,Ps=ks(Object.keys,Object),He=se(z,"DataView"),ae=se(z,"Map"),We=se(z,"Promise"),Qe=se(z,"Set"),Ke=se(z,"WeakMap"),ce=se(Object,"create"),Rs=J(He),Fs=J(ae),Is=J(We),Us=J(Qe),Bs=J(Ke),Ct=Ce?Ce.prototype:void 0,Ge=Ct?Ct.valueOf:void 0;function Y(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var s=n[e];this.set(s[0],s[1])}}function Ms(){this.__data__=ce?ce(null):{},this.size=0}function Ns(n){var e=this.has(n)&&delete this.__data__[n];return this.size-=e?1:0,e}function Os(n){var e=this.__data__;if(ce){var t=e[n];return t===Oe?void 0:t}return $.call(e,n)?e[n]:void 0}function $s(n){var e=this.__data__;return ce?e[n]!==void 0:$.call(e,n)}function zs(n,e){var t=this.__data__;return this.size+=this.has(n)?0:1,t[n]=ce&&e===void 0?Oe:e,this}Y.prototype.clear=Ms;Y.prototype.delete=Ns;Y.prototype.get=Os;Y.prototype.has=$s;Y.prototype.set=zs;function q(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var s=n[e];this.set(s[0],s[1])}}function qs(){this.__data__=[],this.size=0}function js(n){var e=this.__data__,t=xe(e,n);if(t<0)return!1;var s=e.length-1;return t==s?e.pop():As.call(e,t,1),--this.size,!0}function Hs(n){var e=this.__data__,t=xe(e,n);return t<0?void 0:e[t][1]}function Ws(n){return xe(this.__data__,n)>-1}function Qs(n,e){var t=this.__data__,s=xe(t,n);return s<0?(++this.size,t.push([n,e])):t[s][1]=e,this}q.prototype.clear=qs;q.prototype.delete=js;q.prototype.get=Hs;q.prototype.has=Ws;q.prototype.set=Qs;function X(n){var e=-1,t=n==null?0:n.length;for(this.clear();++e<t;){var s=n[e];this.set(s[0],s[1])}}function Ks(){this.size=0,this.__data__={hash:new Y,map:new(ae||q),string:new Y}}function Gs(n){var e=Ae(this,n).delete(n);return this.size-=e?1:0,e}function Vs(n){return Ae(this,n).get(n)}function Ys(n){return Ae(this,n).has(n)}function Xs(n,e){var t=Ae(this,n),s=t.size;return t.set(n,e),this.size+=t.size==s?0:1,this}X.prototype.clear=Ks;X.prototype.delete=Gs;X.prototype.get=Vs;X.prototype.has=Ys;X.prototype.set=Xs;function Le(n){var e=-1,t=n==null?0:n.length;for(this.__data__=new X;++e<t;)this.add(n[e])}function Js(n){return this.__data__.set(n,Oe),this}function Zs(n){return this.__data__.has(n)}Le.prototype.add=Le.prototype.push=Js;Le.prototype.has=Zs;function W(n){var e=this.__data__=new q(n);this.size=e.size}function en(){this.__data__=new q,this.size=0}function tn(n){var e=this.__data__,t=e.delete(n);return this.size=e.size,t}function sn(n){return this.__data__.get(n)}function nn(n){return this.__data__.has(n)}function rn(n,e){var t=this.__data__;if(t instanceof q){var s=t.__data__;if(!ae||s.length<Yt-1)return s.push([n,e]),this.size=++t.size,this;t=this.__data__=new X(s)}return t.set(n,e),this.size=t.size,this}W.prototype.clear=en;W.prototype.delete=tn;W.prototype.get=sn;W.prototype.has=nn;W.prototype.set=rn;function on(n,e){var t=De(n),s=!t&&wn(n),r=!t&&!s&&Ve(n),o=!t&&!s&&!r&&Ut(n),i=t||s||r||o,a=i?vs(n.length,String):[],l=a.length;for(var c in n)(e||$.call(n,c))&&!(i&&(c=="length"||r&&(c=="offset"||c=="parent")||o&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||gn(c,l)))&&a.push(c);return a}function xe(n,e){for(var t=n.length;t--;)if(Pt(n[t][0],e))return t;return-1}function an(n,e,t){var s=e(n);return De(n)?s:_s(s,t(n))}function le(n){return n==null?n===void 0?ss:Zt:V&&V in Object(n)?mn(n):yn(n)}function Lt(n){return de(n)&&le(n)==we}function xt(n,e,t,s,r){return n===e?!0:n==null||e==null||!de(n)&&!de(e)?n!==n&&e!==e:cn(n,e,t,s,xt,r)}function cn(n,e,t,s,r,o){var i=De(n),a=De(e),l=i?$e:Q(n),c=a?$e:Q(e);l=l==we?te:l,c=c==we?te:c;var h=l==te,u=c==te,d=l==c;if(d&&Ve(n)){if(!Ve(e))return!1;i=!0,h=!1}if(d&&!h)return o||(o=new W),i||Ut(n)?At(n,e,t,s,r,o):pn(n,e,l,t,s,r,o);if(!(t&ye)){var p=h&&$.call(n,"__wrapped__"),g=u&&$.call(e,"__wrapped__");if(p||g){var b=p?n.value():n,v=g?e.value():e;return o||(o=new W),r(b,v,t,s,o)}}return d?(o||(o=new W),hn(n,e,t,s,r,o)):!1}function ln(n){if(!It(n)||bn(n))return!1;var e=Rt(n)?xs:hs;return e.test(J(n))}function dn(n){return de(n)&&Ft(n.length)&&!!L[le(n)]}function un(n){if(!vn(n))return Ps(n);var e=[];for(var t in Object(n))$.call(n,t)&&t!="constructor"&&e.push(t);return e}function At(n,e,t,s,r,o){var i=t&ye,a=n.length,l=e.length;if(a!=l&&!(i&&l>a))return!1;var c=o.get(n);if(c&&o.get(e))return c==e;var h=-1,u=!0,d=t&st?new Le:void 0;for(o.set(n,e),o.set(e,n);++h<a;){var p=n[h],g=e[h];if(s)var b=i?s(g,p,h,e,n,o):s(p,g,h,n,e,o);if(b!==void 0){if(b)continue;u=!1;break}if(d){if(!bs(e,function(v,C){if(!ws(d,C)&&(p===v||r(p,v,t,s,o)))return d.push(C)})){u=!1;break}}else if(!(p===g||r(p,g,t,s,o))){u=!1;break}}return o.delete(n),o.delete(e),u}function pn(n,e,t,s,r,o,i){switch(t){case ke:if(n.byteLength!=e.byteLength||n.byteOffset!=e.byteOffset)return!1;n=n.buffer,e=e.buffer;case pt:return!(n.byteLength!=e.byteLength||!o(new Et(n),new Et(e)));case rt:case ot:case ct:return Pt(+n,+e);case it:return n.name==e.name&&n.message==e.message;case dt:case ut:return n==e+"";case Se:var a=Es;case Ee:var l=s&ye;if(a||(a=Ts),n.size!=e.size&&!l)return!1;var c=i.get(n);if(c)return c==e;s|=st,i.set(n,e);var h=At(a(n),a(e),s,r,o,i);return i.delete(n),h;case ts:if(Ge)return Ge.call(n)==Ge.call(e)}return!1}function hn(n,e,t,s,r,o){var i=t&ye,a=Dt(n),l=a.length,c=Dt(e),h=c.length;if(l!=h&&!i)return!1;for(var u=l;u--;){var d=a[u];if(!(i?d in e:$.call(e,d)))return!1}var p=o.get(n);if(p&&o.get(e))return p==e;var g=!0;o.set(n,e),o.set(e,n);for(var b=i;++u<l;){d=a[u];var v=n[d],C=e[d];if(s)var k=i?s(C,v,d,e,n,o):s(v,C,d,n,e,o);if(!(k===void 0?v===C||r(v,C,t,s,o):k)){g=!1;break}b||(b=d=="constructor")}if(g&&!b){var S=n.constructor,F=e.constructor;S!=F&&"constructor"in n&&"constructor"in e&&!(typeof S=="function"&&S instanceof S&&typeof F=="function"&&F instanceof F)&&(g=!1)}return o.delete(n),o.delete(e),g}function Dt(n){return an(n,kn,fn)}function Ae(n,e){var t=n.__data__;return _n(e)?t[typeof e=="string"?"string":"hash"]:t.map}function se(n,e){var t=Ss(n,e);return ln(t)?t:void 0}function mn(n){var e=$.call(n,V),t=n[V];try{n[V]=void 0;var s=!0}catch{}var r=wt.call(n);return s&&(e?n[V]=t:delete n[V]),r}var fn=Tt?function(n){return n==null?[]:(n=Object(n),gs(Tt(n),function(e){return kt.call(n,e)}))}:Tn,Q=le;(He&&Q(new He(new ArrayBuffer(1)))!=ke||ae&&Q(new ae)!=Se||We&&Q(We.resolve())!=lt||Qe&&Q(new Qe)!=Ee||Ke&&Q(new Ke)!=ze)&&(Q=function(n){var e=le(n),t=e==te?n.constructor:void 0,s=t?J(t):"";if(s)switch(s){case Rs:return ke;case Fs:return Se;case Is:return lt;case Us:return Ee;case Bs:return ze}return e});function gn(n,e){return e=e??nt,!!e&&(typeof n=="number"||ms.test(n))&&n>-1&&n%1==0&&n<e}function _n(n){var e=typeof n;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?n!=="__proto__":n===null}function bn(n){return!!yt&&yt in n}function vn(n){var e=n&&n.constructor,t=typeof e=="function"&&e.prototype||Te;return n===t}function yn(n){return wt.call(n)}function J(n){if(n!=null){try{return vt.call(n)}catch{}try{return n+""}catch{}}return""}function Pt(n,e){return n===e||n!==n&&e!==e}var wn=Lt(function(){return arguments}())?Lt:function(n){return de(n)&&$.call(n,"callee")&&!kt.call(n,"callee")},De=Array.isArray;function Sn(n){return n!=null&&Ft(n.length)&&!Rt(n)}var Ve=Ds||Cn;function En(n,e){return xt(n,e)}function Rt(n){if(!It(n))return!1;var e=le(n);return e==at||e==Jt||e==Xt||e==es}function Ft(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=nt}function It(n){var e=typeof n;return n!=null&&(e=="object"||e=="function")}function de(n){return n!=null&&typeof n=="object"}var Ut=bt?ys(bt):dn;function kn(n){return Sn(n)?on(n):un(n)}function Tn(){return[]}function Cn(){return!1}ne.exports=En});var ie=class extends EventTarget{constructor(){super();this.actions=Object.seal({"deselect-all":{enabled:!1,shortcut:"Control+D",text:"Deselect all"},"move-bottom":{enabled:!1,text:"Move to the back of the queue"},"move-down":{enabled:!1,text:"Move down in the queue"},"move-top":{enabled:!1,text:"Move to the front of the queue"},"move-up":{enabled:!1,text:"Move up in the queue"},"open-torrent":{enabled:!0,shortcut:"Control+O",text:"Open torrent\u2026"},"pause-all-torrents":{enabled:!1,text:"Pause all"},"pause-selected-torrents":{enabled:!1,shortcut:"Control+U",text:"Pause"},"reannounce-selected-torrents":{enabled:!1,text:"Ask tracker for more peers"},"remove-selected-torrents":{enabled:!1,text:"Remove from list\u2026"},"resume-selected-torrents":{enabled:!1,shortcut:"Control+R",text:"Resume"},"resume-selected-torrents-now":{enabled:!1,text:"Resume now"},"select-all":{enabled:!1,shortcut:"Control+A",text:"Select all"},"show-about-dialog":{enabled:!0,text:"About"},"show-inspector":{enabled:!1,shortcut:"Control+I",text:"Torrent Inspector"},"show-labels-dialog":{enabled:!1,text:"Edit Labels\u2026"},"show-move-dialog":{enabled:!1,shortcut:"Control+L",text:"Set location\u2026"},"show-overflow-menu":{enabled:!0,text:"More options\u2026"},"show-preferences-dialog":{enabled:!0,shortcut:"Control+P",text:"Edit preferences"},"show-rename-dialog":{enabled:!1,shortcut:"Control+N",text:"Rename\u2026"},"show-shortcuts-dialog":{enabled:!0,text:"Keyboard shortcuts"},"show-statistics-dialog":{enabled:!0,shortcut:"Control+S",text:"Statistics"},"start-all-torrents":{enabled:!1,text:"Start all"},"toggle-compact-rows":{enabled:!0,text:"Compact rows"},"trash-selected-torrents":{enabled:!1,text:"Trash data and remove from list\u2026"},"verify-selected-torrents":{enabled:!1,shortcut:"Control+Shift+V",text:"Verify local data"}})}click(e){if(this.isEnabled(e)){let t=new Event("click");t.action=e,this.dispatchEvent(t)}}getActionForShortcut(e){for(let[t,s]of Object.entries(this.actions))if(e===s.shortcut)return t;return null}allShortcuts(){return new Map(Object.entries(this.actions).filter(([,e])=>e.shortcut).map(([e,t])=>[t.shortcut,e]))}isEnabled(e){return this._getAction(e).enabled}text(e){return this._getAction(e).text}keyshortcuts(e){return this._getAction(e).shortcut}update(e){let t=ie._recount(e.selected,e.nonselected);this._updateStates(t)}_getAction(e){let t=this.actions[e];if(!t)throw new Error(`no such action: ${e}`);return t}static _recount(e,t){let s=e.length+t.length,r=e.filter(u=>u.isStopped()).length,o=e.length-r,i=t.filter(u=>u.isStopped()).length,a=t.length-i,l=r+i,c=o+a,h=e.filter(u=>u.isQueued()).length;return{active:c,nonselected_active:a,nonselected_paused:i,paused:l,selected:e.length,selected_active:o,selected_paused:r,selected_queued:h,total:s}}_updateStates(e){let t=(s,r)=>{for(let o of r)this._updateActionState(o,s)};t(e.selected_paused>0,["resume-selected-torrents"]),t(e.paused>0,["start-all-torrents"]),t(e.active>0,["pause-all-torrents"]),t(e.selected_paused>0||e.selected_queued>0,["resume-selected-torrents-now"]),t(e.selected_active>0,["pause-selected-torrents","reannounce-selected-torrents"]),t(e.selected>0,["deselect-all","move-bottom","move-down","move-top","move-up","remove-selected-torrents","show-inspector","show-labels-dialog","show-move-dialog","trash-selected-torrents","verify-selected-torrents"]),t(e.selected===1,["show-rename-dialog"]),t(e.selected<e.total,["select-all"])}_updateActionState(e,t){let s=this.actions[e];if(!s)throw new Error(`no such action: ${e}`);if(s.enabled!==t){s.enabled=t;let r=new Event("change");r.action=e,r.enabled=t,this.dispatchEvent(r)}}};var Mt=Vt(Bt());var Z={ratio(n,e){let t=Math.floor(100*n/e)/100;return t===Number.POSITIVE_INFINITY||t===Number.NEGATIVE_INFINITY?t=-2:Number.isNaN(t)&&(t=-1),t},setInnerHTML(n,e){!n||n.currentHTML!==e&&(n.currentHTML=e,n.innerHTML=e)}};function Ln(n,e,t,s,r){for(let o of n.children)o.classList.toggle("selected",o===e);for(let o of t.children)o.classList.toggle("hidden",o!==s);r&&r(s)}function Pe(n,e,t){let s=document.createElement("div");s.id=n,s.classList.add("tabs-container");let r=document.createElement("div");r.classList.add("tabs-buttons"),s.append(r);let o=document.createElement("div");o.classList.add("tabs-pages"),s.append(o);let i=[];for(let[a,l,c]of e){let h=document.createElement("button");h.id=a,h.classList.add("tabs-button"),h.setAttribute("type","button"),h.textContent=c,r.append(h),i.push(h),l.classList.add("hidden","tabs-page"),o.append(l),h.addEventListener("click",()=>Ln(r,h,o,l,t))}return i[0].classList.add("selected"),o.children[0].classList.remove("hidden"),{buttons:i,root:s}}function P(n){let e=document.createElement("dialog");e.classList.add("dialog-container","popup",n),e.open=!0,e.setAttribute("role","dialog");let t=document.createElement("div");t.classList.add("dialog-window"),e.append(t);let s=document.createElement("div");s.classList.add("dialog-logo"),t.append(s);let r=document.createElement("div");r.classList.add("dialog-heading"),t.append(r);let o=document.createElement("div");o.classList.add("dialog-message"),t.append(o);let i=document.createElement("div");i.classList.add("dialog-workarea"),t.append(i);let a=document.createElement("div");a.classList.add("dialog-buttons"),t.append(a);let l=document.createElement("span");l.classList.add("dialog-buttons-begin"),a.append(l);let c=document.createElement("button");c.classList.add("dialog-dismiss-button"),c.textContent="Cancel",a.append(c);let h=document.createElement("button");h.textContent="OK",a.append(h);let u=document.createElement("span");return u.classList.add("dialog-buttons-end"),a.append(u),{confirm:h,dismiss:c,heading:r,message:o,root:e,workarea:i}}function D(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,n=>(n^crypto.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16))}function xn(n){let e=document.createElement("fieldset");e.classList.add("section");let t=document.createElement("legend");t.classList.add("title"),t.textContent=n,e.append(t);let s=document.createElement("div");return s.classList.add("content"),e.append(s),{content:s,root:e}}function Ye(n,e){let t=[],{root:s,content:r}=xn(n);for(let o of e){let i=document.createElement("label");i.textContent=o,r.append(i);let a=document.createElement("div");a.id=D(),r.append(a),i.setAttribute("for",a.id),t.push(a)}return{children:t,root:s}}function K(n,e=100){let t=null;return(...s)=>{t||(t=setTimeout(()=>{t=null,n(...s)},e))}}function Re(n,e){return(0,Mt.default)(n,e)}function An(n,e,t){t?n.setAttribute(e,!0):n.removeAttribute(e)}function N(n,e){An(n,"disabled",!e)}function Fe(n,e){n.classList.toggle("checked",e)}var ee=class extends EventTarget{constructor(e){super();this.listener=t=>{e.contains(t.target)||(this.dispatchEvent(new MouseEvent(t.type,t)),t.preventDefault())},Object.seal(this),this.start()}start(){setTimeout(()=>document.addEventListener("click",this.listener),0)}stop(){document.removeEventListener("click",this.listener)}};function _(n,e){n.textContent!==e&&(n.textContent=e)}var Xe=class{constructor(e){this._prefs=e,this._elements={toggle:document.querySelector("#toggle-notifications")}}_setEnabled(e){this.prefs.notifications_enabled=e,_(this._toggle,`${e?"Disable":"Enable"} Notifications`)}_requestPermission(){Notification.requestPermission().then(e=>this._setEnabled(e==="granted"))}toggle(){this._enabled?this._setEnabled(!1):Notification.permission==="granted"?this._setEnabled(!0):Notification.permission!=="denied"&&this._requestPermission()}};var m=class extends EventTarget{constructor(){super();this._cache={},this.dispatchPrefsChange=K((e,t,s)=>{let r=new Event("change");Object.assign(r,{key:e,old_value:t,value:s}),this.dispatchEvent(r)});for(let[e,t]of Object.entries(m._Defaults))this._set(e,m._getCookie(e,t)),Object.defineProperty(this,e.replaceAll("-","_"),{get:()=>this._get(e),set:s=>{this._set(e,s)}});Object.seal(this)}entries(){return Object.entries(this._cache)}keys(){return Object.keys(this._cache)}_get(e){let{_cache:t}=this;if(!Object.prototype.hasOwnProperty.call(t,e))throw new Error(e);return t[e]}_set(e,t){let{_cache:s}=this,r=s[e];r!==t&&(s[e]=t,m._setCookie(e,t),this.dispatchPrefsChange(e,r,t))}static _setCookie(e,t){let s=new Date;s.setFullYear(s.getFullYear()+1),document.cookie=`${e}=${t}; SameSite=Strict; expires=${s.toGMTString()}`}static _getCookie(e,t){let s=m._readCookie(e);return s===null?t:s==="true"?!0:s==="false"?!1:/^\d+$/.test(s)?Number.parseInt(s,10):s}static _readCookie(e){let s=`; ${document.cookie}`.split(`; ${e}=`);return s.length===2?s.pop().split(";").shift():null}};m.AltSpeedEnabled="alt-speed-enabled";m.DisplayCompact="compact";m.DisplayFull="full";m.DisplayMode="display-mode";m.FilterActive="active";m.FilterAll="all";m.FilterDownloading="downloading";m.FilterFinished="finished";m.FilterMode="filter-mode";m.FilterPaused="paused";m.FilterSeeding="seeding";m.NotificationsEnabled="notifications-enabled";m.RefreshRate="refresh-rate-sec";m.SortAscending="ascending";m.SortByActivity="activity";m.SortByAge="age";m.SortByName="name";m.SortByProgress="progress";m.SortByQueue="queue";m.SortByRatio="ratio";m.SortBySize="size";m.SortByState="state";m.SortDescending="descending";m.SortDirection="sort-direction";m.SortMode="sort-mode";m._Defaults={[m.AltSpeedEnabled]:!1,[m.DisplayMode]:m.DisplayFull,[m.FilterMode]:m.FilterAll,[m.NotificationsEnabled]:!1,[m.RefreshRate]:5,[m.SortDirection]:m.SortAscending,[m.SortMode]:m.SortByName};var pe=class extends EventTarget{constructor(e){super();this.elements=pe._create(e),this.elements.dismiss.addEventListener("click",()=>this._onDismiss()),document.body.append(this.elements.root),this.elements.dismiss.focus()}close(){this.elements.root.remove(),this.dispatchEvent(new Event("close")),delete this.elements}_onDismiss(){this.close()}static _create(e){let t=P("about-dialog");t.root.setAttribute("aria-label","About transmission"),t.heading.textContent="Transmission",t.dismiss.textContent="Close";let s=document.createElement("div");return s.classList.add("about-dialog-version-number"),s.textContent=e.version,t.heading.append(s),s=document.createElement("div"),s.classList.add("about-dialog-version-checksum"),s.textContent=e.checksum,t.heading.append(s),s=document.createElement("div"),s.textContent="A fast and easy bitTorrent client",t.workarea.append(s),s=document.createElement("div"),s.textContent="Copyright \xA9 The Transmission Project",t.workarea.append(s),t.confirm.remove(),delete t.confirm,t}};var Je=class extends EventTarget{constructor(e){super();this.action_listener=this._update.bind(this),this.action_manager=e,this.action_manager.addEventListener("change",this.action_listener),Object.assign(this,this._create()),this.show()}show(){for(let[e,t]of Object.entries(this.actions))N(t,this.action_manager.isEnabled(e));document.body.append(this.root)}close(){if(!this.closed){this.action_manager.removeEventListener("change",this.action_listener),this.root.remove(),this.dispatchEvent(new Event("close"));for(let e of Object.keys(this))delete this[e];this.closed=!0}}_update(e){let t=this.actions[e.action];t&&N(t,e.enabled)}_create(){let e=document.createElement("div");e.role="menu",e.classList.add("context-menu","popup");let t={},s=(o,i=!1)=>{let a=document.createElement("div"),l=this.action_manager.text(o);a.role="menuitem",i?a.classList.add("context-menuitem","warning"):a.classList.add("context-menuitem"),a.dataset.action=o,a.textContent=l;let c=this.action_manager.keyshortcuts(o);c&&a.setAttribute("aria-keyshortcuts",c),a.addEventListener("click",()=>{this.action_manager.click(o),this.close()}),t[o]=a,e.append(a)},r=()=>{let o=document.createElement("div");o.classList.add("context-menu-separator"),e.append(o)};return s("resume-selected-torrents"),s("resume-selected-torrents-now"),s("pause-selected-torrents"),r(),s("move-top"),s("move-up"),s("move-down"),s("move-bottom"),r(),s("remove-selected-torrents",!0),s("trash-selected-torrents",!0),r(),s("verify-selected-torrents"),s("show-move-dialog"),s("show-rename-dialog"),s("show-labels-dialog"),r(),s("reannounce-selected-torrents"),r(),s("select-all"),s("deselect-all"),{actions:t,root:e}}};var Nt=new Intl.PluralRules,j=Nt.resolvedOptions().locale,Dn=new Intl.NumberFormat(j),Ze=1e3,Pn=[new Intl.NumberFormat(j,{maximumFractionDigits:0,style:"unit",unit:"byte"}),new Intl.NumberFormat(j,{maximumFractionDigits:0,style:"unit",unit:"kilobyte"}),new Intl.NumberFormat(j,{maximumFractionDigits:0,style:"unit",unit:"megabyte"}),new Intl.NumberFormat(j,{maximumFractionDigits:2,style:"unit",unit:"gigabyte"}),new Intl.NumberFormat(j,{maximumFractionDigits:2,style:"unit",unit:"terabyte"}),new Intl.NumberFormat(j,{maximumFractionDigits:2,style:"unit",unit:"petabyte"})],Rn=new Intl.NumberFormat(j,{maximumFractionDigits:2,style:"unit",unit:"kilobyte-per-second"}),Fn=new Intl.NumberFormat(j,{maximumFractionDigits:2,style:"unit",unit:"megabyte-per-second"}),w={_toTruncFixed(n,e){return(Math.floor(n*10**e)/10**e).toFixed(e)},countString(n,e,t){return`${this.number(t)} ${this.ngettext(n,e,t)}`},mem(n){if(n<0)return"Unknown";if(n===0)return"None";let e=n;for(let t of Pn){if(e<Ze)return t.format(e);e/=Ze}return"E2BIG"},ngettext(n,e,t){return Nt.select(t)==="one"?n:e},number(n){return Dn.format(n)},percentString(n){let e=n<100?1:0;return this._toTruncFixed(n,e)},ratioString(n){return n===-1?"None":n===-2?"∞":this.percentString(n)},size(n){return this.mem(n)},speed(n){return n<999.95?Rn.format(n):Fn.format(n/1e3)},speedBps(n){return this.speed(this.toKBps(n))},stringSanitizer(n){return["E2BIG","NaN"].some(e=>n.includes(e))?"\u2026":n},timeInterval(n){let e=Math.floor(n/86400);if(e)return this.countString("day","days",e);let t=Math.floor(n%86400/3600);if(t)return this.countString("hour","hours",t);let s=Math.floor(n%3600/60);return s?this.countString("minute","minutes",s):(n=Math.floor(n%60),this.countString("second","seconds",n))},timestamp(n){if(!n)return"N/A";let e=new Date(n*1e3),t=new Date,s="",r="",o=t.getFullYear()===e.getFullYear(),i=t.getMonth()===e.getMonth(),a=t.getDate()-e.getDate();o&&i&&Math.abs(a)<=1?a===0?s="Today":a===1?s="Yesterday":s="Tomorrow":s=e.toDateString();let l=e.getHours(),c="AM";l>12&&(l=l-12,c="PM"),l===0&&(l=12),l<10&&(l=`0${l}`);let h=e.getMinutes();return h<10&&(h=`0${h}`),n=e.getSeconds(),n<10&&(n=`0${n}`),r=[l,h,n].join(":"),[s,r,c].join(" ")},toKBps(n){return Math.floor(n/Ze)}};var et=class extends EventTarget{isDone(){return this.fields.have>=this.fields.size}isEditable(){return this.fields.torrent.getFileCount()>1&&!this.isDone()}refreshWantedHTML(){let e=this.elements.root;e.classList.toggle("skip",!this.fields.isWanted),e.classList.toggle("complete",this.isDone()),N(e.checkbox,this.isEditable()),e.checkbox.checked=this.fields.isWanted}refreshProgressHTML(){let{size:e,have:t}=this.fields,s=100*(e?t/e:1),r=w,o=`${r.size(t)} of ${r.size(e)} (${r.percentString(s)}%)`;_(this.elements.progress,o)}refresh(){let e=0,t=!1,s=!1,r=!1,o=0,i=!1,a=this.fields.torrent.getFiles();for(let l of this.fields.indices){let c=a[l];switch(e+=c.bytesCompleted,o+=c.length,i|=c.wanted,c.priority.toString()){case"-1":s=!0;break;case"1":t=!0;break;default:r=!0;break}}Fe(this.elements.priority_low_button,s),Fe(this.elements.priority_normal_button,r),Fe(this.elements.priority_high_button,t),(this.fields.have!==e||this.fields.size!==o)&&(this.fields.have=e,this.fields.size=o,this.refreshProgressHTML()),this.fields.isWanted!==i&&(this.fields.isWanted=i,this.refreshWantedHTML())}fireWantedChanged(e){let t=new Event("wantedToggled");t.indices=[...this.fields.indices],t.wanted=e,this.dispatchEvent(t)}firePriorityChanged(e){let t=new Event("priorityToggled");t.indices=[...this.fields.indices],t.priority=e,this.dispatchEvent(t)}createRow(e,t,s,r){let o=document.createElement("li");o.classList.add("inspector-torrent-file-list-entry",r?"even":"odd"),this.elements.root=o;let i=document.createElement("input"),a=D();i.type="checkbox",i.className="file-wanted-control",i.title="Download file",i.id=a,i.addEventListener("change",h=>this.fireWantedChanged(h.target.checked)),o.checkbox=i,o.append(i),i=document.createElement("label"),i.className="inspector-torrent-file-list-entry-name",i.setAttribute("for",a),_(i,s),o.append(i),i=document.createElement("div"),i.className="inspector-torrent-file-list-entry-progress",o.append(i),this.elements.progress=i,i=document.createElement("div"),i.className="file-priority-radiobox";let l=i,c=h=>this.firePriorityChanged(h.target.value);i=document.createElement("input"),i.type="radio",i.value="-1",i.className="low",i.title="Low Priority",i.addEventListener("click",c),this.elements.priority_low_button=i,l.append(i),i=document.createElement("input"),i.type="radio",i.value="0",i.className="normal",i.title="Normal Priority",i.addEventListener("click",c),this.elements.priority_normal_button=i,l.append(i),i=document.createElement("input"),i.type="radio",i.value="1",i.title="High Priority",i.className="high",i.addEventListener("click",c),this.elements.priority_high_button=i,l.append(i),o.append(l),o.style.paddingLeft=`${t*20}px`,this.refresh()}getElement(){return this.elements.root}constructor(e,t,s,r,o){super();this.fields={have:0,indices:r,isWanted:!0,size:0,torrent:e},this.elements={priority_high_button:null,priority_low_button:null,priority_normal_button:null,progress:null,root:null},this.createRow(e,t,s,o)}};var f=class extends EventTarget{constructor(e){super();this.fieldObservers={},this.fields={},this.refresh(e)}notifyOnFieldChange(e,t){this.fieldObservers[e]=this.fieldObservers[e]||[],this.fieldObservers[e].push(t)}setField(e,t,s){let r=e[t];if(Re(r,s))return!1;let o=this.fieldObservers[t];if(e===this.fields&&o&&o.length>0)for(let i of o)i.call(this,s,r,t);return e[t]=s,!0}updateFiles(e){let t=!1,s=this.fields.files||[],r=["length","name","bytesCompleted","wanted","priority"];for(let[o,i]of e.entries()){let a=s[o]||{};for(let l of r)l in i&&(t|=this.setField(a,l,i[l]));s[o]=a}return this.fields.files=s,t}static collateTrackers(e){return e.map(t=>t.announce.toLowerCase()).join(" ")}refreshFields(e){let t=!1;for(let[s,r]of Object.entries(e))switch(s){case"files":case"fileStats":t|=this.updateFiles(r);break;case"trackerStats":t|=this.setField(this.fields,"trackers",r);break;case"trackers":s in this.fields||(t|=this.setField(this.fields,s,r));break;case"name":this.setField(this.fields,s,e[s])&&(this.fields.collatedName="",t=!0);break;default:t|=this.setField(this.fields,s,r)}return t}refresh(e){this.refreshFields(e)&&this.dispatchEvent(new Event("dataChanged"))}getComment(){return this.fields.comment}getCreator(){return this.fields.creator}getDateAdded(){return this.fields.addedDate}getDateCreated(){return this.fields.dateCreated}getDesiredAvailable(){return this.fields.desiredAvailable}getDownloadDir(){return this.fields.downloadDir}getDownloadSpeed(){return this.fields.rateDownload}getDownloadedEver(){return this.fields.downloadedEver}getError(){return this.fields.error}getErrorString(){return this.fields.errorString}getETA(){return this.fields.eta}getFailedEver(){return this.fields.corruptEver}getFiles(){return this.fields.files||[]}getFile(e){return this.fields.files[e]}getFileCount(){return this.fields["file-count"]}getHashString(){return this.fields.hashString}getHave(){return this.getHaveValid()+this.getHaveUnchecked()}getHaveUnchecked(){return this.fields.haveUnchecked}getHaveValid(){return this.fields.haveValid}getId(){return this.fields.id}getLabels(){return this.fields.labels.sort()}getLastActivity(){return this.fields.activityDate}getLeftUntilDone(){return this.fields.leftUntilDone}getMagnetLink(){return this.fields.magnetLink}getMetadataPercentComplete(){return this.fields.metadataPercentComplete}getName(){return this.fields.name||"Unknown"}getPeers(){return this.fields.peers||[]}getPeersConnected(){return this.fields.peersConnected}getPeersGettingFromUs(){return this.fields.peersGettingFromUs}getPeersSendingToUs(){return this.fields.peersSendingToUs}getPieceCount(){return this.fields.pieceCount}getPieceSize(){return this.fields.pieceSize}getPrimaryMimeType(){return this.fields["primary-mime-type"]||"application/octet-stream"}getPrivateFlag(){return this.fields.isPrivate}getQueuePosition(){return this.fields.queuePosition}getRecheckProgress(){return this.fields.recheckProgress}getSeedRatioLimit(){return this.fields.seedRatioLimit}getSeedRatioMode(){return this.fields.seedRatioMode}getSizeWhenDone(){return this.fields.sizeWhenDone}getStartDate(){return this.fields.startDate}getStatus(){return this.fields.status}getTotalSize(){return this.fields.totalSize}getTrackers(){return this.fields.trackers||[]}getUploadSpeed(){return this.fields.rateUpload}getUploadRatio(){return this.fields.uploadRatio}getUploadedEver(){return this.fields.uploadedEver}getWebseedsSendingToUs(){return this.fields.webseedsSendingToUs}isFinished(){return this.fields.isFinished}hasExtraInfo(){return"hashString"in this.fields}isSeeding(){return this.getStatus()===f._StatusSeed}isStopped(){return this.getStatus()===f._StatusStopped}isChecking(){return this.getStatus()===f._StatusCheck}isDownloading(){return this.getStatus()===f._StatusDownload}isQueued(){return this.getStatus()===f._StatusDownloadWait||this.getStatus()===f._StatusSeedWait}isDone(){return this.getLeftUntilDone()<1}needsMetaData(){return this.getMetadataPercentComplete()<1}getActivity(){return this.getDownloadSpeed()+this.getUploadSpeed()}getPercentDoneStr(){return w.percentString(100*this.getPercentDone())}getPercentDone(){return this.fields.percentDone}getStateString(){switch(this.getStatus()){case f._StatusStopped:return this.isFinished()?"Seeding complete":"Paused";case f._StatusCheckWait:return"Queued for verification";case f._StatusCheck:return"Verifying local data";case f._StatusDownloadWait:return"Queued for download";case f._StatusDownload:return"Downloading";case f._StatusSeedWait:return"Queued for seeding";case f._StatusSeed:return"Seeding";case null:return"Unknown";default:return"Error"}}seedRatioLimit(e){switch(this.getSeedRatioMode()){case f._RatioUseGlobal:return e.seedRatioLimit();case f._RatioUseLocal:return this.getSeedRatioLimit();default:return-1}}getErrorMessage(){let e=this.getErrorString();switch(this.getError()){case f._ErrTrackerWarning:return`Tracker returned a warning: ${e}`;case f._ErrTrackerError:return`Tracker returned an error: ${e}`;case f._ErrLocalError:return`Error: ${e}`;default:return null}}getCollatedName(){let e=this.fields;return!e.collatedName&&e.name&&(e.collatedName=e.name.toLowerCase()),e.collatedName||""}getCollatedTrackers(){let e=this.fields;return!e.collatedTrackers&&e.trackers&&(e.collatedTrackers=f.collateTrackers(e.trackers)),e.collatedTrackers||""}testState(e){let t=this.getStatus();switch(e){case m.FilterActive:return this.getPeersGettingFromUs()>0||this.getPeersSendingToUs()>0||this.getWebseedsSendingToUs()>0||this.isChecking();case m.FilterSeeding:return t===f._StatusSeed||t===f._StatusSeedWait;case m.FilterDownloading:return t===f._StatusDownload||t===f._StatusDownloadWait;case m.FilterPaused:return this.isStopped();case m.FilterFinished:return this.isFinished();default:return!0}}test(e,t,s,r){let o=this.testState(e);if(o&&s&&(o=this.getCollatedName().includes(s.toLowerCase())),o){let i=this.getLabels();r.length>0&&(o=r.some(a=>i.includes(a)))}return o&&t&&t.length>0&&(o=this.getCollatedTrackers().includes(t)),o}static compareById(e,t){return e.getId()-t.getId()}static compareByName(e,t){return e.getCollatedName().localeCompare(t.getCollatedName())||f.compareById(e,t)}static compareByQueue(e,t){return e.getQueuePosition()-t.getQueuePosition()}static compareByAge(e,t){let s=e.getDateAdded();return t.getDateAdded()-s||f.compareByQueue(e,t)}static compareByState(e,t){let s=e.getStatus();return t.getStatus()-s||f.compareByQueue(e,t)}static compareByActivity(e,t){let s=e.getActivity();return t.getActivity()-s||f.compareByState(e,t)}static compareByRatio(e,t){let s=e.getUploadRatio(),r=t.getUploadRatio();return s<r?1:s>r?-1:f.compareByState(e,t)}static compareByProgress(e,t){let s=e.getPercentDone(),r=t.getPercentDone();return s-r||f.compareByRatio(e,t)}static compareBySize(e,t){let s=e.getTotalSize(),r=t.getTotalSize();return s-r||f.compareByName(e,t)}static compareTorrents(e,t,s,r){let o=0;switch(s){case m.SortByActivity:o=f.compareByActivity(e,t);break;case m.SortByAge:o=f.compareByAge(e,t);break;case m.SortByQueue:o=f.compareByQueue(e,t);break;case m.SortByProgress:o=f.compareByProgress(e,t);break;case m.SortBySize:o=f.compareBySize(e,t);break;case m.SortByState:o=f.compareByState(e,t);break;case m.SortByRatio:o=f.compareByRatio(e,t);break;case m.SortByName:o=f.compareByName(e,t);break;default:console.log(`Unrecognized sort mode: ${s}`),o=f.compareByName(e,t);break}return r===m.SortDescending&&(o=-o),o}static sortTorrents(e,t,s){switch(t){case m.SortByActivity:e.sort(this.compareByActivity);break;case m.SortByAge:e.sort(this.compareByAge);break;case m.SortByName:e.sort(this.compareByName);break;case m.SortByProgress:e.sort(this.compareByProgress);break;case m.SortByQueue:e.sort(this.compareByQueue);break;case m.SortByRatio:e.sort(this.compareByRatio);break;case m.SortBySize:e.sort(this.compareBySize);break;case m.SortByState:e.sort(this.compareByState);break;default:console.log(`Unrecognized sort mode: ${t}`),e.sort(this.compareByName);break}return s===m.SortDescending&&e.reverse(),e}};f._StatusStopped=0;f._StatusCheckWait=1;f._StatusCheck=2;f._StatusDownloadWait=3;f._StatusDownload=4;f._StatusSeedWait=5;f._StatusSeed=6;f._RatioUseGlobal=0;f._RatioUseLocal=1;f._RatioUnlimited=2;f._ErrNone=0;f._ErrTrackerWarning=1;f._ErrTrackerError=2;f._ErrLocalError=3;f._TrackerInactive=0;f._TrackerWaiting=1;f._TrackerQueued=2;f._TrackerActive=3;f.Fields={};f.Fields.Metadata=["addedDate","file-count","name","primary-mime-type","totalSize"];f.Fields.Stats=["error","errorString","eta","isFinished","isStalled","labels","leftUntilDone","metadataPercentComplete","peersConnected","peersGettingFromUs","peersSendingToUs","percentDone","queuePosition","rateDownload","rateUpload","recheckProgress","seedRatioMode","seedRatioLimit","sizeWhenDone","status","trackers","downloadDir","uploadedEver","uploadRatio","webseedsSendingToUs"];f.Fields.InfoExtra=["comment","creator","dateCreated","files","hashString","isPrivate","magnetLink","pieceCount","pieceSize"];f.Fields.StatsExtra=["activityDate","corruptEver","desiredAvailable","downloadedEver","fileStats","haveUnchecked","haveValid","peers","startDate","trackerStats"];var Ot=["encryption","speed-up","speed-down","percent-done","status","peer-address","peer-app-name"],R=class extends EventTarget{constructor(e){super();this.closed=!1,this.controller=e,this.elements=this._create(),this.current_page=this.elements.info.root,this.interval=setInterval(this._refreshTorrents.bind(this),3e3),this.name="inspector",this.selection_listener=t=>this._setTorrents(t.selected),this.torrent_listener=()=>this._updateCurrentPage(),this.torrents=[],this.file_torrent=null,this.file_torrent_n=null,this.file_rows=null,this.outside=new ee(this.elements.root),this.outside.addEventListener("click",()=>this.close()),Object.seal(this),e.addEventListener("torrent-selection-changed",this.selection_listener),this._setTorrents(this.controller.getSelectedTorrents()),document.body.append(this.elements.root)}close(){if(!this.closed){this.outside.stop(),clearInterval(this.interval),this._setTorrents([]),this.elements.root.remove(),this.controller.removeEventListener("torrent-selection-changed",this.selection_listener),this.dispatchEvent(new Event("close"));for(let e of Object.keys(this))this[e]=null;this.closed=!0}}static _createInfoPage(){let e=document.createElement("div");e.classList.add("inspector-info-page");let t={root:e},s=i=>{let a=document.createElement("div");a.textContent=i,a.classList.add("section-label"),e.append(a)},r=i=>{let a=document.createElement("label");_(a,i),e.append(a);let l=document.createElement("span");return e.append(l),l};s("Activity");let o=[["have","Have:"],["availability","Availability:"],["uploaded","Uploaded:"],["downloaded","Downloaded:"],["state","State:"],["running_time","Running time:"],["remaining_time","Remaining:"],["last_activity","Last activity:"],["error","Error:"]];for(let[i,a]of o)t[i]=r(a);s("Details"),o=[["size","Size:"],["location","Location:"],["hash","Hash:"],["privacy","Privacy:"],["origin","Origin:"],["dateAdded","Date added:"],["magnetLink","Magnet:"],["comment","Comment:"],["labels","Labels:"]];for(let[i,a]of o)t[i]=r(a);return t}static _createListPage(e,t){let s=document.createElement("div"),r=document.createElement(e);return r.id=t,s.append(r),{list:r,root:s}}static _createTiersPage(){return R._createListPage("div","inspector-tiers-list")}static _createFilesPage(){return R._createListPage("ul","inspector-file-list")}static _createPeersPage(){let e=document.createElement("table");e.classList.add("peer-list");let t=document.createElement("thead"),s=document.createElement("tr"),r=["","Up","Down","Done","Status","Address","Client"];for(let[i,a]of r.entries()){let l=document.createElement("th"),c=Ot[i];c==="encryption"&&(l.dataset.encrypted=!0),l.classList.add(c),_(l,a),s.append(l)}let o=document.createElement("tbody");return t.append(s),e.append(t),e.append(o),{root:e,tbody:o}}_create(){let e={files:R._createFilesPage(),info:R._createInfoPage(),peers:R._createPeersPage(),tiers:R._createTiersPage()},t=r=>{this.current_page=r,this._updateCurrentPage()};return{...Pe("inspector",[["inspector-tab-info",e.info.root,"Info"],["inspector-tab-peers",e.peers.root,"Peers"],["inspector-tab-tiers",e.tiers.root,"Tiers"],["inspector-tab-files",e.files.root,"Files"]],t.bind(this)),...e}}_setTorrents(e){let t="dataChanged",s=this.torrent_listener;for(let r of this.torrents)r.removeEventListener(t,s);this.torrents=[...e];for(let r of this.torrents)r.addEventListener(t,s);this._refreshTorrents(),this._updateCurrentPage()}static _needsExtraInfo(e){return e.some(t=>!t.hasExtraInfo())}_refreshTorrents(){let{controller:e,torrents:t}=this,s=t.map(r=>r.getId());if(s&&s.length>0){let r=["id",...f.Fields.StatsExtra];R._needsExtraInfo(t)&&r.push(...f.Fields.InfoExtra),e.updateTorrents(s,r)}}_updateCurrentPage(){let{current_page:e,elements:t}=this;switch(e){case t.files.root:this._updateFiles();break;case t.info.root:this._updateInfo();break;case t.peers.root:this._updatePeers();break;case t.tiers.root:this._updateTiers();break;default:console.warn("unexpected page"),console.log(e)}}_updateInfo(){let e="None",t="Mixed",s="Unknown",r=w,o=Date.now(),{elements:i,torrents:a}=this,l=a.reduce((u,d)=>u+d.getSizeWhenDone(),0),c=null;if(a.length===0)c=e;else if(a.every(u=>u.isFinished()))c="Finished";else if(a.every(u=>u.isStopped()))c="Paused";else{let u=p=>p.getStateString(),d=u(a[0]);c=a.every(p=>u(p)===d)?d:t}_(i.info.state,c);let h=c;if(a.length===0)c=e;else{let u=a.reduce((b,v)=>b+v.getHaveValid(),0),d=a.reduce((b,v)=>b+v.getHaveUnchecked(),0),p=a.reduce((b,v)=>b+v.getLeftUntilDone(),0),g=100*(l?(l-p)/l:1);c=r.percentString(g),d?c=`${r.size(u)} of ${r.size(l)} (${c}%), ${r.size(d)} Unverified`:p?c=`${r.size(u)} of ${r.size(l)} (${c}%)`:c=`${r.size(u)} (100%)`}if(_(i.info.have,r.stringSanitizer(c)),a.length===0)c=e;else if(l===0)c=e;else{let u=a.reduce((d,p)=>p.getHave()+p.getDesiredAvailable(),0);c=`${r.percentString(100*u/l)}%`}if(_(i.info.availability,r.stringSanitizer(c)),a.length===0)c=e;else{let u=a.reduce((p,g)=>p+g.getDownloadedEver(),0),d=a.reduce((p,g)=>p+g.getFailedEver(),0);c=d?`${r.size(u)} (+${r.size(d)} discarded after failed checksum)`:r.size(u)}if(_(i.info.downloaded,r.stringSanitizer(c)),a.length===0)c=e;else{let u=a.reduce((p,g)=>p+g.getUploadedEver(),0),d=a.reduce((p,g)=>p+g.getSizeWhenDone(),0)||a.reduce((p,g)=>p+g.getHaveValid(),0);c=`${r.size(u)} (Ratio: ${r.ratioString(Z.ratio(u,d))})`}if(_(i.info.uploaded,c),a.length===0)c=e;else if(a.every(u=>u.isStopped()))c=h;else{let u=p=>p.getStartDate(),d=u(a[0]);c=a.every(p=>u(p)===d)?r.timeInterval(o/1e3-d):t}if(_(i.info.running_time,c),a.length===0)c=e;else{let u=p=>p.getETA(),d=u(a[0]);a.every(p=>u(p)===d)?d<0?c=s:c=r.timeInterval(d):c=t}if(_(i.info.remaining_time,c),a.length===0)c=e;else{let u=a.reduce((p,g)=>Math.max(p,g.getLastActivity()),-1),d=Math.floor(o/1e3);if(0<u&&u<=d){let p=d-u;c=p<5?"Active now":`${r.timeInterval(p)} ago`}else c=e}if(_(i.info.last_activity,c),a.length===0)c=e;else{let u=p=>p.getErrorString(),d=u(a[0]);c=a.every(p=>u(p)===d)?d:t}if(_(i.info.error,c||e),a.length===0)c=e;else{let u=a.reduce((d,p)=>d+p.getTotalSize(),0);if(u){let d=v=>v.getPieceSize(),p=a.reduce((v,C)=>v+C.getPieceCount(),0),g=r.number(p),b=d(a[0]);c=a.every(v=>d(v)===b)?`${r.size(u)} (${g} pieces @ ${r.mem(b)})`:`${r.size(u)} (${g} pieces)`}else c="None"}if(_(i.info.size,r.stringSanitizer(c)),a.length===0)c=e;else{let u=p=>p.getHashString(),d=u(a[0]);c=a.every(p=>u(p)===d)?d:t}if(_(i.info.hash,c),a.length===0)c=e;else{let u=p=>p.getPrivateFlag(),d=u(a[0]);a.every(p=>u(p)===d)?d?c="Private to this tracker -- DHT and PEX disabled":c="Public torrent":c=t}if(_(i.info.privacy,c),a.length===0)c=e;else{let u=p=>p.getComment(),d=u(a[0]);c=a.every(p=>u(p)===d)?d:t}if(c=c||e,c.startsWith("https://")||c.startsWith("http://")?(c=encodeURI(c),Z.setInnerHTML(i.info.comment,`<a href="${c}" target="_blank" >${c}</a>`)):_(i.info.comment,c),c=a.length===0?e:a[0].getLabels().join(", "),_(i.info.labels,c),a.length===0)c=e;else{let u=k=>k.getCreator(),d=u(a[0]),p=!a.every(k=>u(k)===d);u=k=>k.getDateCreated();let g=u(a[0]),b=!a.every(k=>u(k)===g),v=!d||d.length===0,C=!g;p||b?c=t:v&&C?c=s:C&&!v?c=`Created by ${d}`:v&&!C?c=`Created on ${new Date(g*1e3).toDateString()}`:c=`Created by ${d} on ${new Date(g*1e3).toDateString()}`}if(_(i.info.origin,c),a.length===0)c=e;else{let u=p=>p.getDownloadDir(),d=u(a[0]);c=a.every(p=>u(p)===d)?d:t}if(_(i.info.location,c),a.length===0)c=e;else{let u=p=>p.getDateAdded(),d=u(a[0]);c=a.every(p=>u(p)===d)?new Date(d*1e3).toDateString():t}if(_(i.info.dateAdded,c),a.length===0)_(i.info.magnetLink,e);else if(a.length>1)_(i.info.magnetLink,t);else{let u=a[0].getMagnetLink();Z.setInnerHTML(i.info.magnetLink,`<a class="inspector-info-magnet" href="${u}"><button></button></a>`)}}static _peerStatusTitle(e){let t=Object.seal({"?":"We unchoked this peer, but they're not interested",D:"Downloading from this peer",E:"Encrypted Connection",H:"Peer was discovered through Distributed Hash Table (DHT)",I:"Peer is an incoming connection",K:"Peer has unchoked us, but we're not interested",O:"Optimistic unchoke",T:"Peer is connected via uTP",U:"Uploading to peer",X:"Peer was discovered through Peer Exchange (PEX)",d:"We would download from this peer if they'd let us",u:"We would upload to this peer if they'd ask"});return[...e].filter(s=>t[s]).map(s=>`${s}: ${t[s]}`).join(` `)}_updatePeers(){let e=w,{elements:t,torrents:s}=this,{tbody:r}=t.peers,o=[(a,l)=>{l.dataset.encrypted=a.isEncrypted},(a,l)=>_(l,a.rateToPeer?e.speedBps(a.rateToPeer):""),(a,l)=>_(l,a.rateToClient?e.speedBps(a.rateToClient):""),(a,l)=>_(l,`${Math.floor(a.progress*100)}%`),(a,l)=>{_(l,a.flagStr),l.setAttribute("title",R._peerStatusTitle(a.flagStr))},(a,l)=>_(l,a.address),(a,l)=>_(l,a.clientName)],i=[];for(let a of s){let l=document.createElement("tr");l.classList.add("torrent-row");let c=document.createElement("td");c.setAttribute("colspan",o.length),_(c,a.getName()),l.append(c),i.push(l);for(let h of a.getPeers()){let u=document.createElement("tr");u.classList.add("peer-row");for(let[d,p]of o.entries()){let g=document.createElement("td");g.classList.add(Ot[d]),p(h,g),u.append(g)}i.push(u)}for(;r.firstChild;)r.firstChild.remove();r.append(...i)}}static getAnnounceState(e){switch(e.announceState){case f._TrackerActive:return"Announce in progress";case f._TrackerWaiting:{let t=Math.max(0,e.nextAnnounceTime-Date.now()/1e3);return`Next announce in ${w.timeInterval(t)}`}case f._TrackerQueued:return"Announce is queued";case f._TrackerInactive:return e.isBackup?"Tracker will be used as a backup":"Announce not scheduled";default:return`unknown announce state: ${e.announceState}`}}static lastAnnounceStatus(e){let t="Last Announce",s=["N/A"];if(e.hasAnnounced){let r=w.timestamp(e.lastAnnounceTime);e.lastAnnounceSucceeded?s=[r," (got ",w.countString("peer","peers",e.lastAnnouncePeerCount),")"]:(t="Announce error",s=[e.lastAnnounceResult?`${e.lastAnnounceResult} - `:"",r])}return{label:t,value:s.join("")}}static lastScrapeStatus(e){let t="Last Scrape",s="N/A";if(e.hasScraped){let r=w.timestamp(e.lastScrapeTime);e.lastScrapeSucceeded?s=r:(t="Scrape error",s=(e.lastScrapeResult?`${e.lastScrapeResult} - `:"")+r)}return{label:t,value:s}}static _getOrigin(e){try{let t="udp://";if(e.announce.startsWith(t)){let r="http://",o=e.announce.replace(t,r);return new URL(o).origin.replace(r,t)}return new URL(e.announce).origin}catch{return[e.sitename||e.host||e.announce]}}_updateTiers(){let e="N/A",{list:t}=this.elements.tiers,{torrents:s}=this,r=[];for(let o of s){let i=document.createElement("div");if(i.classList.add("inspector-group"),r.push(i),s.length>1){let a=document.createElement("div");a.classList.add("tier-list-torrent"),_(a,o.getName()),r.push(a)}for(let[a,l]of o.getTrackers().entries()){let c=R.getAnnounceState(l),h=R.lastAnnounceStatus(l),u=R.lastScrapeStatus(l),d=document.createElement("div");d.classList.add("tier-list-row",a%2?"odd":"even");let p=document.createElement("div"),g=R._getOrigin(l);p.classList.add("tier-list-tracker"),_(p,`${g} - tier ${l.tier+1}`),p.setAttribute("title",l.announce),d.append(p),p=document.createElement("div"),p.classList.add("tier-announce"),_(p,`${h.label}: ${h.value}`),d.append(p),p=document.createElement("div"),p.classList.add("tier-seeders"),_(p,`Seeders: ${l.seederCount>-1?l.seederCount:e}`),d.append(p),p=document.createElement("div"),p.classList.add("tier-state"),_(p,c),d.append(p),p=document.createElement("div"),p.classList.add("tier-leechers"),_(p,`Leechers: ${l.leecherCount>-1?l.leecherCount:e}`),d.append(p),p=document.createElement("div"),p.classList.add("tier-scrape"),_(p,`${u.label}: ${u.value}`),d.append(p),p=document.createElement("div"),p.classList.add("tier-downloads"),_(p,`Downloads: ${l.downloadCount>-1?l.downloadCount:e}`),d.append(p),r.push(d)}}for(;t.firstChild;)t.firstChild.remove();t.append(...r)}_changeFileCommand(e,t){let{controller:s,file_torrent:r}=this,o=r.getId();s.changeFileCommand(o,e,t)}_onFileWantedToggled(e){let{indices:t,wanted:s}=e;this._changeFileCommand(t,s?"files-wanted":"files-unwanted")}_onFilePriorityToggled(e){let{indices:t,priority:s}=e,r=null;switch(s.toString()){case"-1":r="priority-low";break;case"1":r="priority-high";break;default:r="priority-normal";break}this._changeFileCommand(t,r)}_clearFileList(){let{list:e}=this.elements.files;for(;e.firstChild;)e.firstChild.remove();this.file_torrent=null,this.file_torrent_n=null,this.file_rows=null}static createFileTreeModel(e){let t=[],s={children:{},file_indices:[]};for(let[r,o]of e.getFiles().entries()){let{name:i}=o,a=i.split("/"),l=s;for(let[c,h]of a.entries()){let u=l.children[h];u||(l.children[h]=u={children:{},depth:c,file_indices:[],name:h,parent:l}),l=u}l.file_index=r,delete l.children,t.push(l)}for(let r of t){let{file_index:o}=r,i=r;do i.file_indices.push(o),i=i.parent;while(i)}return s}addNodeToView(e,t,s,r){let o=new et(e,s.depth,s.name,s.file_indices,r%2);o.addEventListener("wantedToggled",this._onFileWantedToggled.bind(this)),o.addEventListener("priorityToggled",this._onFilePriorityToggled.bind(this)),this.file_rows.push(o),t.append(o.getElement())}addSubtreeToView(e,t,s,r){if(s.parent&&this.addNodeToView(e,t,s,r++),s.children)for(let o of Object.values(s.children))r=this.addSubtreeToView(e,t,o,r);return r}_updateFiles(){let{list:e}=this.elements.files,{file_rows:t,file_torrent:s,file_torrent_n:r,torrents:o}=this;if(o.length!==1){this._clearFileList();return}let[i]=o,a=i.getFiles().length;if(i!==s||a!==r){this._clearFileList(),this.file_torrent=i,this.file_torrent_n=a,this.file_rows=[];let l=document.createDocumentFragment(),c=R.createFileTreeModel(i);this.addSubtreeToView(i,l,c,0),e.append(l)}else for(let l of t)l.refresh()}};var Ie="",he=class extends EventTarget{constructor(e,t){super();this.controller=e,this.remote=t,this.elements={},this.torrents=[],this.show()}show(){let e=this.controller.getSelectedTorrents();e.length!==0&&(Ie=Ie||e[0].getDownloadDir(),this.torrents=e,this.elements=he._create(),this.elements.confirm.addEventListener("click",()=>this._onConfirm()),this.elements.dismiss.addEventListener("click",()=>this._onDismiss()),this.elements.entry.value=Ie,document.body.append(this.elements.root),this.elements.entry.focus())}close(){this.elements.root.remove(),this.dispatchEvent(new Event("close")),delete this.controller,delete this.remote,delete this.elements,delete this.torrents}_onDismiss(){this.close()}_onConfirm(){let e=this.torrents.map(s=>s.getId()),t=this.elements.entry.value.trim();Ie=t,this.remote.moveTorrents(e,t),this.close()}static _create(){let e=P("move-dialog");e.root.setAttribute("aria-label","Move Torrent"),e.heading.textContent="Set Torrent Location",confirm.textContent="Apply";let t=document.createElement("label");t.setAttribute("for","torrent-path"),t.textContent="Location:",e.workarea.append(t);let s=document.createElement("input");return s.setAttribute("type","text"),s.id="torrent-path",e.entry=s,e.workarea.append(s),e}};var G=class extends EventTarget{constructor(e){super();this.elements=G._create(e),this.elements.dismiss.addEventListener("click",()=>this._onDismiss()),this.options=e,document.body.append(this.elements.root),this.elements.dismiss.focus()}close(){if(!this.closed){this.elements.root.remove(),this.dispatchEvent(new Event("close"));for(let e of Object.keys(this))delete this[e];this.closed=!0}}_onDismiss(){this.close()}static _create(e){let{heading:t,message:s}=e,r=P("confirm-dialog");return r.confirm.remove(),delete r.confirm,r.heading.textContent=t,r.workarea.textContent=s,r}};var Ue=class extends EventTarget{constructor(e,t,s=""){super();this.controller=e,this.remote=t,this.elements=this._create(s),this.elements.dismiss.addEventListener("click",()=>this._onDismiss()),this.elements.confirm.addEventListener("click",()=>this._onConfirm()),this._updateFreeSpaceInAddDialog(),document.body.append(this.elements.root),this.elements.url_input.focus()}close(){if(!this.closed){clearInterval(this.interval),this.elements.root.remove(),this.dispatchEvent(new Event("close"));for(let e of Object.keys(this))delete this[e];this.closed=!0}}_onDismiss(){this.close()}_updateFreeSpaceInAddDialog(){let e=this.elements.folder_input.value;this.remote.getFreeSpace(e,(t,s)=>{if(!this.closed){let r=s>0?`${w.size(s)} Free`:"";this.elements.freespace.textContent=r}})}_onConfirm(){let{controller:e,elements:t,remote:s}=this,{file_input:r,folder_input:o,start_input:i,url_input:a}=t,l=!i.checked,c=o.value.trim();for(let u of r.files){let d=new FileReader;d.addEventListener("load",p=>{let g=p.target.result,b="base64,",v=g.indexOf(b);if(v===-1)return;let C={arguments:{"download-dir":c,metainfo:g.slice(Math.max(0,v+b.length)),paused:l},method:"torrent-add"};s.sendRequest(C,k=>{k.result!=="success"&&(alert(`Error adding "${u.name}": ${k.result}`),e.setCurrentPopup(new G({heading:`Error adding "${u.name}"`,message:k.result})))})}),d.readAsDataURL(u)}let h=a.value.trim();if(h.length>0){/^[\da-f]{40}$/i.test(h)&&(h=`magnet:?xt=urn:btih:${h}`);let u={arguments:{"download-dir":c,filename:h,paused:l},method:"torrent-add"};s.sendRequest(u,d=>{d.result!=="success"&&e.setCurrentPopup(new G({heading:`Error adding "${h}"`,message:d.result}))})}this._onDismiss()}_create(e){let t=P(),{confirm:s,root:r,heading:o,workarea:i}=t;r.classList.add("open-torrent"),o.textContent="Add Torrents",s.textContent="Add";let a=D(),l=document.createElement("label");l.setAttribute("for",a),l.textContent="Please select torrent files to add:",i.append(l);let c=document.createElement("input");c.type="file",c.name="torrent-files[]",c.id=a,c.multiple="multiple",i.append(c),t.file_input=c,a=D(),l=document.createElement("label"),l.setAttribute("for",a),l.textContent="Or enter a URL:",i.append(l),c=document.createElement("input"),c.type="url",c.id=a,c.value=e,i.append(c),t.url_input=c,c.addEventListener("keyup",({key:p})=>{p==="Enter"&&s.click()}),a=D(),l=document.createElement("label"),l.id="add-dialog-folder-label",l.for=a,l.textContent="Destination folder: ",i.append(l);let h=document.createElement("span");h.id="free-space-text",l.append(h),i.append(l),t.freespace=h,c=document.createElement("input"),c.type="text",c.id="add-dialog-folder-input",c.addEventListener("change",()=>this._updateFreeSpaceInAddDialog()),c.value=this.controller.session_properties["download-dir"],i.append(c),t.folder_input=c;let u=document.createElement("div");i.append(u);let d=document.createElement("input");return d.type="checkbox",d.id="auto-start-check",d.checked=this.controller.shouldAddedTorrentsStart(),u.append(d),t.start_input=d,l=document.createElement("label"),l.id="auto-start-label",l.setAttribute("for",d.id),l.textContent="Start when added",u.append(l),t}};var x={_DaemonVersion:"version",_DownSpeedLimit:"speed-limit-down",_DownSpeedLimited:"speed-limit-down-enabled",_QueueMoveBottom:"queue-move-bottom",_QueueMoveDown:"queue-move-down",_QueueMoveTop:"queue-move-top",_QueueMoveUp:"queue-move-up",_Root:"../rpc",_TurtleDownSpeedLimit:"alt-speed-down",_TurtleState:"alt-speed-enabled",_TurtleUpSpeedLimit:"alt-speed-up",_UpSpeedLimit:"speed-limit-up",_UpSpeedLimited:"speed-limit-up-enabled"},H=class{constructor(e){this._controller=e,this._error="",this._session_id=""}sendRequest(e,t,s){let r=new Headers;r.append("cache-control","no-cache"),r.append("content-type","application/json"),r.append("pragma","no-cache"),this._session_id&&r.append(H._SessionHeader,this._session_id);let o=null;fetch(x._Root,{body:JSON.stringify(e),headers:r,method:"POST"}).then(i=>{if(o=i,i.status===409){let a=new Error(H._SessionHeader);throw a.header=i.headers.get(H._SessionHeader),a}return i.json()}).then(i=>{t&&t.call(s,i,o)}).catch(i=>{if(i.message===H._SessionHeader){this._session_id=i.header,this.sendRequest(e,t,s);return}console.trace(i),this._controller.togglePeriodicSessionRefresh(!1),this._controller.setCurrentPopup(new G({heading:"Connection failed",message:"Could not connect to the server. You may need to reload the page to reconnect."}))})}loadDaemonPrefs(e,t){let s={method:"session-get"};this.sendRequest(s,e,t)}checkPort(e,t){let s={method:"port-test"};this.sendRequest(s,e,t)}renameTorrent(e,t,s,r,o){let i={arguments:{ids:e,name:s,path:t},method:"torrent-rename-path"};this.sendRequest(i,r,o)}setLabels(e,t,s){let r={ids:e,labels:t};this.sendRequest({arguments:r,method:"torrent-set"},s)}loadDaemonStats(e,t){let s={method:"session-stats"};this.sendRequest(s,e,t)}updateTorrents(e,t,s,r){let o={arguments:{fields:t,format:"table"},method:"torrent-get"};e&&(o.arguments.ids=e),this.sendRequest(o,i=>{let a=i.arguments;s.call(r,a.torrents,a.removed)})}getFreeSpace(e,t,s){let r={arguments:{path:e},method:"free-space"};this.sendRequest(r,o=>{let i=o.arguments;t.call(s,i.path,i["size-bytes"])})}changeFileCommand(e,t,s){let r={ids:[e]};r[s]=t,this.sendRequest({arguments:r,method:"torrent-set"},()=>{this._controller.refreshTorrents([e])})}sendTorrentSetRequests(e,t,s,r,o){s||(s={}),s.ids=t;let i={arguments:s,method:e};this.sendRequest(i,r,o)}sendTorrentActionRequests(e,t,s,r){this.sendTorrentSetRequests(e,t,null,s,r)}startTorrents(e,t,s,r){let o=t?"torrent-start-now":"torrent-start";this.sendTorrentActionRequests(o,e,s,r)}stopTorrents(e,t,s){this.sendTorrentActionRequests("torrent-stop",e,t,s)}moveTorrents(e,t,s,r){this.sendTorrentSetRequests("torrent-set-location",e,{location:t,move:!0},s,r)}removeTorrents(e,t){let s={arguments:{"delete-local-data":t,ids:[]},method:"torrent-remove"};if(e)for(let r=0,o=e.length;r<o;++r)s.arguments.ids.push(e[r].getId());this.sendRequest(s,()=>{this._controller.refreshTorrents()})}verifyTorrents(e,t,s){this.sendTorrentActionRequests("torrent-verify",e,t,s)}reannounceTorrents(e,t,s){this.sendTorrentActionRequests("torrent-reannounce",e,t,s)}addTorrentByUrl(e,t){/^[\da-f]{40}$/i.test(e)&&(e=`magnet:?xt=urn:btih:${e}`);let s={arguments:{filename:e,paused:t.paused},method:"torrent-add"};this.sendRequest(s,()=>{this._controller.refreshTorrents()})}savePrefs(e){let t={arguments:e,method:"session-set"};this.sendRequest(t,()=>{this._controller.loadDaemonPrefs()})}updateBlocklist(){let e={method:"blocklist-update"};this.sendRequest(e,()=>{this._controller.loadDaemonPrefs()})}moveTorrentsToTop(e,t,s){this.sendTorrentActionRequests(x._QueueMoveTop,e,t,s)}moveTorrentsToBottom(e,t,s){this.sendTorrentActionRequests(x._QueueMoveBottom,e,t,s)}moveTorrentsUp(e,t,s){this.sendTorrentActionRequests(x._QueueMoveUp,e,t,s)}moveTorrentsDown(e,t,s){this.sendTorrentActionRequests(x._QueueMoveDown,e,t,s)}};H._SessionHeader="X-Transmission-Session-Id";function me(n,e){let t=document.createElement("fieldset");t.classList.add("section",n);let s=document.createElement("legend");return s.classList.add("title"),s.textContent=e,t.append(s),t}function $t(n,e,t,s){let r=document.createElement("button");return r.textContent=e,r.addEventListener("click",s),n.append(r),r.dataset.action=t,r}var Be=class extends EventTarget{constructor(e,t,s,r){super();this.action_listener=this._onActionChange.bind(this),this.action_manager=r,this.action_manager.addEventListener("change",this.action_listener),this.prefs_listener=this._onPrefsChange.bind(this),this.prefs=t,this.prefs.addEventListener("change",this.prefs_listener),this.closed=!1,this.remote=s,this.name="overflow-menu",this.session_listener=this._onSessionChange.bind(this),this.session_manager=e,this.session_manager.addEventListener("session-change",this.session_listener);let{session_properties:o}=e;Object.assign(this,this._create(o)),this.outside=new ee(this.root),this.outside.addEventListener("click",()=>this.close()),Object.seal(this),this.show()}show(){document.body.append(this.root)}close(){if(!this.closed){this.outside.stop(),this.session_manager.removeEventListener("session-change",this.session_listener),this.action_manager.removeEventListener("change",this.action_listener),this.prefs.removeEventListener("change",this.prefs_listener),this.root.remove(),this.dispatchEvent(new Event("close"));for(let e of Object.keys(this))this[e]=null;this.closed=!0}}_onSessionChange(e){let{alt_speed_check:t}=this.elements,{session_properties:s}=e;t.checked=s[x._TurtleState]}_onPrefsChange(e){switch(e.key){case m.SortDirection:case m.SortMode:this.root.querySelector(`[data-pref="${e.key}"]`).value=e.value;break;default:break}}_onActionChange(e){let t=this.actions[e.action];t&&this._updateElement(t)}_updateElement(e){if(e.dataset.action){let{action:t}=e.dataset,s=this.action_manager.keyshortcuts(t);s&&e.setAttribute("aria-keyshortcuts",s),N(e,this.action_manager.isEnabled(t))}}_onClick(e){let{action:t,pref:s}=e.target.dataset;if(t){this.action_manager.click(t);return}if(s){this.prefs[s]=e.target.value;return}console.log("unhandled"),console.log(e),console.trace()}_create(e){let t={},s={},r=this._onClick.bind(this),o=document.createElement("div");o.classList.add("overflow-menu","popup");let i=me("display","Display");o.append(i);let a=document.createElement("div");a.id="display-options",i.append(a);let l=document.createElement("div");l.classList.add("table-row"),a.append(l);let c=document.createElement("label");c.id="display-sort-mode-label",c.textContent="Sort by",l.append(c);let h=document.createElement("select");h.id="display-sort-mode-select",h.dataset.pref=m.SortMode,l.append(h);let u=[[m.SortByActivity,"Activity"],[m.SortByAge,"Age"],[m.SortByName,"Name"],[m.SortByProgress,"Progress"],[m.SortByQueue,"Queue order"],[m.SortByRatio,"Ratio"],[m.SortBySize,"Size"],[m.SortByState,"State"]];for(let[E,T]of u){let O=document.createElement("option");O.value=E,O.textContent=T,h.append(O)}c.setAttribute("for",h.id),h.value=this.prefs.sort_mode,h.addEventListener("change",E=>{this.prefs.sort_mode=E.target.value}),l=document.createElement("div"),l.classList.add("table-row"),a.append(l);let d=document.createElement("input");d.id="display-sort-reverse-check",d.dataset.pref=m.SortDirection,d.type="checkbox",l.append(d),c=document.createElement("label"),c.id="display-sort-reverse-label",c.setAttribute("for",d.id),c.textContent="Reverse sort",l.append(c),d.checked=this.prefs.sort_direction!==m.SortAscending,d.addEventListener("input",E=>{this.prefs.sort_direction=E.target.checked?m.SortDescending:m.SortAscending}),l=document.createElement("div"),l.classList.add("table-row"),a.append(l);let p="toggle-compact-rows";d=document.createElement("input"),d.id="display-compact-check",d.dataset.action=p,d.type="checkbox",l.append(d),c=document.createElement("label"),c.id="display-compact-label",c.for=d.id,c.setAttribute("for",d.id),c.textContent=this.action_manager.text(p),l.append(c),d.checked=this.prefs.display_mode===m.DisplayCompact,d.addEventListener("input",E=>{let{checked:T}=E.target;this.prefs.display_mode=T?m.DisplayCompact:m.DisplayFull}),l=document.createElement("div"),l.classList.add("table-row","display-fullscreen-row"),a.append(l),d=document.createElement("input"),d.id="display-fullscreen-check",d.type="checkbox";let g=()=>document.fullscreenElement!==null;d.checked=g(),d.addEventListener("input",()=>{g()?document.exitFullscreen():document.body.requestFullscreen()}),document.addEventListener("fullscreenchange",()=>{d.checked=g()}),l.append(d),c=document.createElement("label"),c.id="display-fullscreen-label",c.for=d.id,c.setAttribute("for",d.id),c.textContent="Fullscreen",l.append(c),i=me("speed","Speed Limit"),o.append(i),a=document.createElement("div"),a.id="speed-options",i.append(a),l=document.createElement("div"),l.classList.add("speed-up"),a.append(l),c=document.createElement("label"),c.id="speed-up-label",c.textContent="Upload:",l.append(c);let b="Unlimited";h=document.createElement("select"),h.id="speed-up-select",l.append(h);let v=["50","100","250","500","1000","2500","5000","10000",b];for(let E of[...new Set(v).add(`${e[x._UpSpeedLimit]}`).values()].sort((T,O)=>T-O)){let T=document.createElement("option");T.value=E,T.textContent=E===b?b:w.speed(E),h.append(T)}c.setAttribute("for",h.id),h.value=e[x._UpSpeedLimited]?`${e[x._UpSpeedLimit]}`:b,h.addEventListener("change",E=>{let{value:T}=E.target;console.log(E),T===b?this.remote.savePrefs({[x._UpSpeedLimited]:!1}):this.remote.savePrefs({[x._UpSpeedLimited]:!0,[x._UpSpeedLimit]:Number.parseInt(T,10)})}),l=document.createElement("div"),l.classList.add("speed-down"),a.append(l),c=document.createElement("label"),c.id="speed-down-label",c.textContent="Download:",l.append(c),h=document.createElement("select"),h.id="speed-down-select",l.append(h);for(let E of[...new Set(v).add(`${e[x._DownSpeedLimit]}`).values()].sort((T,O)=>T-O)){let T=document.createElement("option");T.value=E,T.textContent=E===b?b:w.speed(E),h.append(T)}c.setAttribute("for",h.id),h.value=e[x._DownSpeedLimited]?`${e[x._DownSpeedLimit]}`:b,h.addEventListener("change",E=>{let{value:T}=E.target;console.log(E),T===b?this.remote.savePrefs({[x._DownSpeedLimited]:!1}):this.remote.savePrefs({[x._DownSpeedLimited]:!0,[x._DownSpeedLimit]:Number.parseInt(T,10)})}),l=document.createElement("div"),l.classList.add("alt-speed"),a.append(l),d=document.createElement("input"),d.id="alt-speed-check",d.type="checkbox",d.checked=e[x._TurtleState],d.addEventListener("change",E=>{this.remote.savePrefs({[x._TurtleState]:E.target.checked})}),l.append(d),s.alt_speed_check=d,c=document.createElement("label"),c.id="alt-speed-image",c.setAttribute("for",d.id),l.append(c),c=document.createElement("label"),c.id="alt-speed-label",c.setAttribute("for",d.id),c.textContent="Use Temp limits",l.append(c),c=document.createElement("label"),c.id="alt-speed-values-label",c.setAttribute("for",d.id);let C=w.speed(e[x._TurtleUpSpeedLimit]),k=w.speed(e[x._TurtleDownSpeedLimit]);c.textContent=`(${C} up, ${k} down)`,l.append(c),i=me("actions","Actions"),o.append(i);for(let E of["show-preferences-dialog","pause-all-torrents","start-all-torrents"]){let T=this.action_manager.text(E);t[E]=$t(i,T,E,r)}i=me("info","Info"),o.append(i),a=document.createElement("div"),i.append(a);for(let E of["show-about-dialog","show-shortcuts-dialog","show-statistics-dialog"]){let T=this.action_manager.text(E);t[E]=$t(a,T,E,r)}i=me("links","Links"),o.append(i),a=document.createElement("ul"),i.append(a);let S=document.createElement("a");S.href="https://transmissionbt.com/",S.tabindex="0",S.textContent="Homepage";let F=document.createElement("li");return F.append(S),a.append(F),S=document.createElement("a"),S.href="https://transmissionbt.com/donate/",S.tabindex="0",S.textContent="Tip Jar",F=document.createElement("li"),F.append(S),a.append(F),S=document.createElement("a"),S.href="https://github.com/transmission/transmission/",S.tabindex="0",S.textContent="Source Code",F=document.createElement("li"),F.append(S),a.append(F),this._updateElement=this._updateElement.bind(this),{actions:t,elements:s,root:o}}};var y=class extends EventTarget{static _initTimeDropDown(e){for(let t=0;t<24*4;++t){let s=Number.parseInt(t/4,10),r=t%4*15,o=t*15,i=`${s}:${r||"00"}`;e.options[t]=new Option(i,o)}}static _initDayDropDown(e){let t=[["Everyday","127"],["Weekdays","62"],["Weekends","65"],["Sunday","1"],["Monday","2"],["Tuesday","4"],["Wednesday","8"],["Thursday","16"],["Friday","32"],["Saturday","64"]];for(let s=0;t[s];++s){let[r,o]=t[s];e.options[s]=new Option(r,o)}}_checkPort(){let e=this.elements.network.port_status_label;delete e.dataset.open,_(e,"Checking..."),this.remote.checkPort(this._onPortChecked,this)}_onPortChecked(e){let t=this.elements.network.port_status_label,s=e.arguments["port-is-open"];t.dataset.open=s,_(t,s?"Open":"Closed")}_setBlocklistButtonEnabled(e){let t=this.elements.peers.blocklist_update_button;N(t,e),t.value=e?"Update":"Updating..."}static _getValue(e){if(e.tagName==="TEXTAREA")return e.value;switch(e.type){case"checkbox":case"radio":return e.checked;case"number":case"select-one":case"text":case"url":{let t=e.value;return Number.parseInt(t,10).toString()===t?Number.parseInt(t,10):Number.parseFloat(t).toString()===t?Number.parseFloat(t):t}default:return null}}_onControlChanged(e){let{key:t}=e.target.dataset;this.remote.savePrefs({[t]:y._getValue(e.target)}),(t==="peer-port"||t==="port-forwarding-enabled")&&this._checkPort()}_onDialogClosed(){this.dispatchEvent(new Event("closed"))}_update(e){if(!!e){this._setBlocklistButtonEnabled(!0);for(let[t,s]of Object.entries(e))for(let r of this.elements.root.querySelectorAll(`[data-key="${t}"]`))if(t==="blocklist-size"){let o=w.number(s);r.innerHTML=`Blocklist has <span class="blocklist-size-number">${o}</span> rules`,_(this.elements.peers.blocklist_update_button,"Update")}else switch(r.type){case"checkbox":case"radio":r.checked!==s&&(r.checked=s,r.dispatchEvent(new Event("change")));break;case"text":case"textarea":case"url":case"email":case"number":case"search":r.value!=s&&r!==document.activeElement&&(r.value=s,r.dispatchEvent(new Event("change")));break;case"select-one":r.value!==s&&(r.value=s,r.dispatchEvent(new Event("change")));break;default:console.log(r.type);break}}}shouldAddedTorrentsStart(){return this.data.elements.root.find("#start-added-torrents")[0].checked}static _createCheckAndLabel(e,t){let s=document.createElement("div");s.id=e;let r=document.createElement("input");r.id=D(),r.type="checkbox",s.append(r);let o=document.createElement("label");return o.textContent=t,o.setAttribute("for",r.id),s.append(o),{check:r,label:o,root:s}}static _enableIfChecked(e,t){let s=()=>{e.tagName==="INPUT"?N(e,t.checked):e.classList.toggle("disabled",!t.checked)};t.addEventListener("change",s),s()}static _getProtocolHandlerRegistered(){return localStorage.getItem("protocol-handler-registered")==="true"}static _updateProtocolHandlerButton(e){e.removeAttribute("disabled"),e.removeAttribute("title"),y._getProtocolHandlerRegistered()?(e.textContent="Remove Browser Handler","unregisterProtocolHandler"in navigator||e.setAttribute("title","Your browser does not support removing protocol handlers. This button only allows you to re-register a handler.")):(e.textContent="Add Browser Handler",e.removeAttribute("title"),"registerProtocolHandler"in navigator||(e.setAttribute("disabled",!0),e.setAttribute("title","Your browser does not support protocol handlers")))}static _toggleProtocolHandler(e){let t=new URL(window.location.href);t.search="addtorrent=%s",this._getProtocolHandlerRegistered()?(navigator.unregisterProtocolHandler?.("magnet",t.toString()),localStorage.removeItem("protocol-handler-registered"),y._updateProtocolHandlerButton(e)):(navigator.registerProtocolHandler("magnet",t.toString(),"Transmission Web"),localStorage.setItem("protocol-handler-registered","true"),y._updateProtocolHandlerButton(e))}static _createTorrentsPage(){let e=document.createElement("div");e.classList.add("prefs-torrents-page");let t=document.createElement("div");t.textContent="Downloading",t.classList.add("section-label"),e.append(t),t=document.createElement("label"),t.textContent="Download to:",e.append(t);let s=document.createElement("input");s.type="text",s.id=D(),s.dataset.key="download-dir",t.setAttribute("for",s.id),e.append(s);let r=s,o=y._createCheckAndLabel("incomplete-dir-div","Use temporary folder:");o.check.title="Separate folder to temporarily store downloads until they are complete.",o.check.dataset.key="incomplete-dir-enabled",o.label.title=o.check.title,e.append(o.root);let i=o.check;s=document.createElement("input"),s.type="text",s.dataset.key="incomplete-dir",e.append(s),y._enableIfChecked(s,o.check);let a=s;o=y._createCheckAndLabel("autostart-div","Start when added"),o.check.dataset.key="start-added-torrents",e.append(o.root);let l=o.check;o=y._createCheckAndLabel("suffix-div",`Append "part" to incomplete files' names`),o.check.dataset.key="rename-partial-files",e.append(o.root);let c=o.check;o=y._createCheckAndLabel("download-queue-div","Download queue size:"),o.check.dataset.key="download-queue-enabled",e.append(o.root);let h=o.check;s=document.createElement("input"),s.type="number",s.dataset.key="download-queue-size",e.append(s),y._enableIfChecked(s,o.check);let u=s;t=document.createElement("div"),t.textContent="Seeding",t.classList.add("section-label"),e.append(t),o=y._createCheckAndLabel("stop-ratio-div","Stop seeding at ratio:"),o.check.dataset.key="seedRatioLimited",e.append(o.root);let d=o.check;s=document.createElement("input"),s.type="number",s.min="0.1",s.step="any",s.dataset.key="seedRatioLimit",e.append(s),y._enableIfChecked(s,o.check);let p=s;o=y._createCheckAndLabel("stop-idle-div","Stop seeding if idle for N mins:"),o.check.dataset.key="idle-seeding-limit-enabled",e.append(o.root);let g=o.check;s=document.createElement("input"),s.type="number",s.min="0.1",s.step="any",s.dataset.key="idle-seeding-limit",e.append(s),y._enableIfChecked(s,o.check);let b=s;t=document.createElement("div"),t.textContent="Magnet Protocol Handler",t.classList.add("section-label"),e.append(t);let v=document.createElement("button");return v.classList.add("register-handler-button"),y._updateProtocolHandlerButton(v),e.append(v),{autostart_check:l,download_dir:r,download_queue_check:h,download_queue_input:u,incomplete_dir_check:i,incomplete_dir_input:a,register_handler_button:v,root:e,stop_idle_check:g,stop_idle_input:b,stop_ratio_check:d,stop_ratio_input:p,suffix_check:c}}static _createSpeedPage(){let e=document.createElement("div");e.classList.add("prefs-speed-page");let t=document.createElement("div");t.textContent="Speed Limits",t.classList.add("section-label"),e.append(t);let s=y._createCheckAndLabel("upload-speed-div","Upload (kB/s):");s.check.dataset.key="speed-limit-up-enabled",e.append(s.root);let r=s.check,o=document.createElement("input");o.type="number",o.dataset.key="speed-limit-up",e.append(o),y._enableIfChecked(o,s.check);let i=o;s=y._createCheckAndLabel("download-speed-div","Download (kB/s):"),s.check.dataset.key="speed-limit-down-enabled",e.append(s.root);let a=s.check;o=document.createElement("input"),o.type="number",o.dataset.key="speed-limit-down",e.append(o),y._enableIfChecked(o,s.check);let l=o;t=document.createElement("div"),t.textContent="Alternative Speed Limits",t.classList.add("section-label","alt-speed-section-label"),e.append(t),t=document.createElement("div"),t.textContent="Override normal speed limits manually or at scheduled times",t.classList.add("alt-speed-label"),e.append(t),t=document.createElement("label"),t.textContent="Upload (kB/s):",e.append(t),o=document.createElement("input"),o.type="number",o.dataset.key="alt-speed-up",o.id=D(),t.setAttribute("for",o.id),e.append(o);let c=o;t=document.createElement("label"),t.textContent="Download (kB/s):",e.append(t),o=document.createElement("input"),o.type="number",o.dataset.key="alt-speed-down",o.id=D(),t.setAttribute("for",o.id),e.append(o);let h=o;s=y._createCheckAndLabel("alt-times-div","Scheduled times"),s.check.dataset.key="alt-speed-time-enabled",e.append(s.root);let u=s.check;t=document.createElement("label"),t.textContent="From:",y._enableIfChecked(t,s.check),e.append(t);let d=document.createElement("select");d.id=D(),d.dataset.key="alt-speed-time-begin",y._initTimeDropDown(d),t.setAttribute("for",d.id),e.append(d),y._enableIfChecked(d,s.check);let p=d;t=document.createElement("label"),t.textContent="To:",y._enableIfChecked(t,s.check),e.append(t),d=document.createElement("select"),d.id=D(),d.dataset.key="alt-speed-time-end",y._initTimeDropDown(d),t.setAttribute("for",d.id),e.append(d),y._enableIfChecked(d,s.check);let g=d;return t=document.createElement("label"),t.textContent="On days:",y._enableIfChecked(t,s.check),e.append(t),d=document.createElement("select"),d.id=D(),d.dataset.key="alt-speed-time-day",y._initDayDropDown(d),t.setAttribute("for",d.id),e.append(d),y._enableIfChecked(d,s.check),{alt_days_select:d,alt_download_speed_input:h,alt_from_select:p,alt_times_check:u,alt_to_select:g,alt_upload_speed_input:c,download_speed_check:a,download_speed_input:l,root:e,upload_speed_check:r,upload_speed_input:i}}static _createPeersPage(){let e=document.createElement("div");e.classList.add("prefs-peers-page");let t=document.createElement("div");t.textContent="Connections",t.classList.add("section-label"),e.append(t),t=document.createElement("label"),t.textContent="Max peers per torrent:",e.append(t);let s=document.createElement("input");s.type="number",s.dataset.key="peer-limit-per-torrent",s.id=D(),t.setAttribute("for",s.id),e.append(s);let r=s;t=document.createElement("label"),t.textContent="Max peers overall:",e.append(t),s=document.createElement("input"),s.type="number",s.dataset.key="peer-limit-global",s.id=D(),t.setAttribute("for",s.id),e.append(s);let o=s;t=document.createElement("div"),t.textContent="Options",t.classList.add("section-label"),e.append(t),t=document.createElement("label"),t.textContent="Encryption mode:",e.append(t);let i=document.createElement("select");i.id=D(),i.dataset.key="encryption",i.options[0]=new Option("Prefer encryption","preferred"),i.options[1]=new Option("Allow encryption","tolerated"),i.options[2]=new Option("Require encryption","required"),e.append(i);let a=i,l=y._createCheckAndLabel("use-pex-div","Use PEX to find more peers");l.check.title="PEX is a tool for exchanging peer lists with the peers you're connected to.",l.check.dataset.key="pex-enabled",l.label.title=l.check.title,e.append(l.root);let c=l.check;l=y._createCheckAndLabel("use-dht-div","Use DHT to find more peers"),l.check.title="DHT is a tool for finding peers without a tracker.",l.check.dataset.key="dht-enabled",l.label.title=l.check.title,e.append(l.root);let h=l.check;l=y._createCheckAndLabel("use-lpd-div","Use LPD to find more peers"),l.check.title="LPD is a tool for finding peers on your local network.",l.check.dataset.key="lpd-enabled",l.label.title=l.check.title,e.append(l.root);let u=l.check;t=document.createElement("div"),t.textContent="Blocklist",t.classList.add("section-label"),e.append(t),l=y._createCheckAndLabel("blocklist-enabled-div","Enable blocklist:"),l.check.dataset.key="blocklist-enabled",e.append(l.root);let d=l.check;s=document.createElement("input"),s.type="url",s.value="http://www.example.com/blocklist",s.dataset.key="blocklist-url",e.append(s),y._enableIfChecked(s,l.check);let p=s;t=document.createElement("label"),t.textContent="Blocklist has {n} rules",t.dataset.key="blocklist-size",t.classList.add("blocklist-size-label"),y._enableIfChecked(t,l.check),e.append(t);let g=document.createElement("button");return g.classList.add("blocklist-update-button"),g.textContent="Update",e.append(g),y._enableIfChecked(g,l.check),{blocklist_enabled_check:d,blocklist_update_button:g,blocklist_url_input:p,dht_check:h,encryption_select:a,lpd_check:u,max_peers_overall_input:o,max_peers_per_torrent_input:r,pex_check:c,root:e}}static _createNetworkPage(){let e=document.createElement("div");e.classList.add("prefs-network-page");let t=document.createElement("div");t.textContent="Listening Port",t.classList.add("section-label"),e.append(t),t=document.createElement("label"),t.textContent="Peer listening port:",e.append(t);let s=document.createElement("input");s.type="number",s.dataset.key="peer-port",s.id=D(),t.setAttribute("for",s.id),e.append(s);let r=s,o=document.createElement("div");o.classList.add("port-status"),t=document.createElement("label"),t.textContent="Port is",o.append(t);let i=document.createElement("label");i.textContent="?",i.classList.add("port-status-label"),o.append(i),e.append(o);let a=y._createCheckAndLabel("randomize-port","Randomize port on launch");a.check.dataset.key="peer-port-random-on-start",e.append(a.root);let l=a.check;a=y._createCheckAndLabel("port-forwarding","Use port forwarding from my router"),a.check.dataset.key="port-forwarding-enabled",e.append(a.root);let c=a.check;t=document.createElement("div"),t.textContent="Options",t.classList.add("section-label"),e.append(t),a=y._createCheckAndLabel("utp-enabled","Enable uTP for peer communication"),a.check.dataset.key="utp-enabled",e.append(a.root);let h=a.check;t=document.createElement("div"),t.textContent="Default Public Trackers",t.classList.add("section-label"),e.append(t);let u=["Trackers to use on all public torrents.","To add a backup URL, add it on the next line after a primary URL.","To add a new primary URL, add it after a blank line."];for(let g of u)t=document.createElement("label"),t.classList.add("default-trackers-label"),t.textContent=g,t.setAttribute("for","default-trackers"),e.append(t);let d=document.createElement("textarea");return d.dataset.key="default-trackers",d.id="default-trackers",e.append(d),{default_trackers_textarea:d,port_forwarding_check:c,port_input:r,port_status_label:i,random_port_check:l,root:e,utp_check:h}}static _create(){let e={network:y._createNetworkPage(),peers:y._createPeersPage(),speed:y._createSpeedPage(),torrents:y._createTorrentsPage()};return{...Pe("prefs-dialog",[["prefs-tab-torrent",e.torrents.root,"Torrents"],["prefs-tab-speed",e.speed.root,"Speed"],["prefs-tab-peers",e.peers.root,"Peers"],["prefs-tab-network",e.network.root,"Network"]]),...e}}constructor(e,t){super();this.closed=!1,this.session_manager=e,this.remote=t,this.update_soon=()=>this._update(this.session_manager.session_properties),this.elements=y._create(),this.elements.peers.blocklist_update_button.addEventListener("click",o=>{_(o.target,"Updating blocklist..."),this.remote.updateBlocklist(),this._setBlocklistButtonEnabled(!1)}),this.elements.torrents.register_handler_button.addEventListener("click",o=>{y._toggleProtocolHandler(o.currentTarget)}),this.outside=new ee(this.elements.root),this.outside.addEventListener("click",()=>this.close()),Object.seal(this);let s=this._onControlChanged.bind(this),r=o=>{for(let i of Object.values(o))if(i.tagName==="INPUT")switch(i.type){case"checkbox":case"radio":case"number":case"text":case"url":i.addEventListener("change",s);break;default:console.trace(`unhandled input: ${i.type}`);break}else(i.tagName==="TEXTAREA"||i.tagName==="SELECT")&&i.addEventListener("change",s)};r(this.elements.network),r(this.elements.peers),r(this.elements.speed),r(this.elements.torrents),this.session_manager.addEventListener("session-change",this.update_soon),this.update_soon(),document.body.append(this.elements.root)}close(){if(!this.closed){this.outside.stop(),this.session_manager.removeEventListener("session-change",this.update_soon),this.elements.root.remove(),dispatchEvent(new Event("close"));for(let e of Object.keys(this))this[e]=null;this.closed=!0}}};var re=class extends EventTarget{constructor(e){super();this.options=e,this.elements=re._create(e),this.elements.dismiss.addEventListener("click",()=>this._onDismiss()),this.elements.confirm.addEventListener("click",()=>this._onConfirm()),document.body.append(this.elements.root),this.elements.dismiss.focus()}close(){if(!this.closed){this.elements.root.remove(),this.dispatchEvent(new Event("close"));for(let e of Object.keys(this))delete this[e];this.closed=!0}}_onDismiss(){this.close()}_onConfirm(){let{remote:e,torrents:t,trash:s}=this.options;t.length>0&&e.removeTorrents(t,s),this.close()}static _create(e){let{trash:t}=e,{heading:s,message:r}=re._createMessage(e),o=P("remove-dialog");return o.heading.textContent=s,o.message.textContent=r,o.confirm.textContent=t?"Trash":"Remove",o}static _createMessage(e){let t=null,s=null,{torrents:r,trash:o}=e,[i]=r;return o&&r.length===1?(t=`Remove ${i.getName()} and delete data?`,s="All data downloaded for this torrent will be deleted. Are you sure you want to remove it?"):o?(t=`Remove ${r.length} transfers and delete data?`,s="All data downloaded for these torrents will be deleted. Are you sure you want to remove them?"):r.length===1?(t=`Remove ${i.getName()}?`,s="Once removed, continuing the transfer will require the torrent file. Are you sure you want to remove it?"):(t=`Remove ${r.length} transfers?`,s="Once removed, continuing the transfers will require the torrent files. Are you sure you want to remove them?"),{heading:t,message:s}}};var fe=class extends EventTarget{constructor(e,t){super();this.controller=e,this.remote=t,this.elements={},this.torrents=[],this.show()}show(){let e=this.controller.getSelectedTorrents();if(e.length!==1){console.trace();return}this.torrents=e,this.elements=fe._create(),this.elements.dismiss.addEventListener("click",()=>this._onDismiss()),this.elements.confirm.addEventListener("click",()=>this._onConfirm()),this.elements.entry.value=e[0].getName(),document.body.append(this.elements.root),this.elements.entry.focus()}close(){this.elements.root.remove(),this.dispatchEvent(new Event("close")),delete this.controller,delete this.remote,delete this.elements,delete this.torrents}_onDismiss(){this.close()}_onConfirm(){let[e]=this.torrents,t=e.getName(),s=this.elements.entry.value;this.remote.renameTorrent([e.getId()],t,s,r=>{r.result==="success"&&e.refresh(r.arguments)}),this.close()}static _create(){let e=P("rename-dialog");e.root.setAttribute("aria-label","Rename Torrent"),e.heading.textContent="Enter new name:",e.confirm.textContent="Rename";let t=document.createElement("label");t.setAttribute("for","torrent-rename-name"),t.textContent="Enter new name:",e.workarea.append(t);let s=document.createElement("input");return s.setAttribute("type","text"),s.id="torrent-rename-name",e.entry=s,e.workarea.append(s),e}};var ge=class extends EventTarget{constructor(e,t){super();this.controller=e,this.remote=t,this.elements={},this.torrents=[],this.show()}show(){let e=this.controller.getSelectedTorrents();if(e.length===0){console.error("At least one selected torrent expected.");return}let[t]=e;this.torrents=e,this.elements=ge._create(),this.elements.dismiss.addEventListener("click",()=>this._onDismiss()),this.elements.confirm.addEventListener("click",()=>this._onConfirm()),this.elements.entry.value=t.getLabels().join(", "),document.body.append(this.elements.root),this.elements.entry.focus()}close(){this.elements.root.remove(),this.dispatchEvent(new Event("close")),delete this.elements,delete this.torrents}_onDismiss(){this.close()}_onConfirm(){let{torrents:e}=this,{remote:t}=this,s=e.map(l=>l.getId()),{elements:r}=this,{entry:o}=r,{value:i}=o,a=i.split(/ *, */).filter(l=>l.length>0);t.setLabels(s,a,l=>{if(l.result==="success")for(let c of e)c.refresh({labels:a})}),this.close()}static _create(){let e=P("labels-dialog");e.root.setAttribute("aria-label","Edit Labels"),e.heading.textContent="Edit Labels:",e.confirm.textContent="Save";let t=document.createElement("label");t.setAttribute("for","torrent-labels"),t.textContent="Labels:",e.workarea.append(t);let s=document.createElement("input");return s.setAttribute("type","text"),s.id="torrent-labels",e.entry=s,e.workarea.append(s),e}};var _e=class extends EventTarget{constructor(e){super();this.elements=_e._create(e),this.elements.dismiss.addEventListener("click",()=>this._onDismiss()),document.body.append(this.elements.root),this.elements.dismiss.focus()}close(){this.elements.root.remove(),this.dispatchEvent(new Event("close")),delete this.elements}_onDismiss(){this.close()}static _create(e){let t=P("shortcuts-dialog");t.root.setAttribute("aria-label","Keyboard Shortcuts");let s=document.createElement("table"),r=document.createElement("thead");s.append(r);let o=document.createElement("tr");r.append(o);let i=document.createElement("th");i.textContent="Key",o.append(i),i=document.createElement("th"),i.textContent="Action",o.append(i);let a=document.createElement("tbody");s.append(a);let l={};for(let[c,h]of e.allShortcuts().entries()){let u=c.split("+"),d=[u.pop(),...u].join("+");l[d]={name:h,shortcut:c}}for(let[,c]of Object.entries(l).sort()){let{name:h,shortcut:u}=c;o=document.createElement("tr"),a.append(o);let d=document.createElement("td");d.textContent=u.replaceAll("+"," + "),o.append(d),d=document.createElement("td"),d.textContent=e.text(h),o.append(d)}return t.heading.textContent="Transmission",t.dismiss.textContent="Close",t.heading.textContent="Keyboard shortcuts",t.message.append(s),t.confirm.remove(),delete t.confirm,t}};var be=class extends EventTarget{constructor(e){super();this.remote=e;let t=()=>this.remote.loadDaemonStats(r=>this._update(r.arguments)),s=5e3;this.interval=setInterval(t,s),t(),this.elements=be._create(),this.elements.dismiss.addEventListener("click",()=>this._onDismiss()),document.body.append(this.elements.root),this.elements.dismiss.focus()}close(){if(!this.closed){clearInterval(this.interval),this.elements.root.remove();for(let e of Object.keys(this))delete this[e];this.closed=!0}}_onDismiss(){this.close()}_update(e){console.log(e);let t=w,s=e["current-stats"],r=Z.ratio(s.uploadedBytes,s.downloadedBytes);_(this.elements.session.up,t.size(s.uploadedBytes)),_(this.elements.session.down,t.size(s.downloadedBytes)),_(this.elements.session.ratio,t.ratioString(r)),_(this.elements.session.time,t.timeInterval(s.secondsActive)),s=e["cumulative-stats"],r=Z.ratio(s.uploadedBytes,s.downloadedBytes),_(this.elements.total.up,t.size(s.uploadedBytes)),_(this.elements.total.down,t.size(s.downloadedBytes)),_(this.elements.total.ratio,t.ratioString(r)),_(this.elements.total.time,t.timeInterval(s.secondsActive))}static _create(){let e=P("statistics-dialog"),{confirm:t,dismiss:s,heading:r,root:o,workarea:i}=e;t.remove(),s.textContent="Close",delete e.confirm;let a="Statistics";o.setAttribute("aria-label",a),r.textContent=a;let l=["Uploaded:","Downloaded:","Ratio:","Running time:"],c=Ye("Current session",l),[h,u,d,p]=c.children,g=e.session={};g.up=h,g.down=u,g.ratio=d,g.time=p,i.append(c.root),c=Ye("Total",l);let[b,v,C,k]=c.children,S=e.total={};return S.up=b,S.down=v,S.ratio=C,S.time=k,i.append(c.root),e}};var I={formatDL:n=>`\u25BC${w.speedBps(n.getDownloadSpeed())}`,formatETA:n=>{let e=n.getETA();return e<0||e>=999*60*60?"":`ETA: ${w.timeInterval(e)}`},formatLabels:n=>n.getLabels().length>0?`\u{1F3F7} ${n.getLabels().join(", ")}`:"",formatUL:n=>`\u25B2${w.speedBps(n.getUploadSpeed())}`,getProgressInfo:(n,e)=>{let t=e.getStatus(),s=["torrent-progress-bar"],r=null;if(t===f._StatusStopped&&s.push("paused"),e.needsMetaData())s.push("magnet"),r=Math.round(e.getMetadataPercentComplete()*100);else if(t===f._StatusCheck)s.push("verify"),r=Math.round(e.getRecheckProgress()*100);else if(e.getLeftUntilDone()>0)s.push("leech"),r=Math.round(e.getPercentDone()*100);else{s.push("seed");let o=e.seedRatioLimit(n);r=o>0?e.getUploadRatio()*100/o:100}return e.isQueued()&&s.push("queued"),{classList:s,percent:r}},renderProgressbar:(n,e,t)=>{let s=I.getProgressInfo(n,e);t.className=s.classList.join(" "),t.style.setProperty("--progress",`${s.percent.toFixed(2)}%`)}},oe=class{static getPeerDetails(e){let t=w,s=e.getErrorMessage();if(s)return s;if(e.isDownloading()){let r=e.getPeersConnected(),o=e.getWebseedsSendingToUs();return o&&r?["Downloading from",e.getPeersSendingToUs(),"of",t.countString("peer","peers",r),"and",t.countString("web seed","web seeds",o),"\u2013",I.formatDL(e),I.formatUL(e)].join(" "):o?["Downloading from",t.countString("web seed","web seeds",o),"\u2013",I.formatDL(e),I.formatUL(e)].join(" "):["Downloading from",e.getPeersSendingToUs(),"of",t.countString("peer","peers",r),"\u2013",I.formatDL(e),I.formatUL(e)].join(" ")}return e.isSeeding()?["Seeding to",e.getPeersGettingFromUs(),"of",t.countString("peer","peers",e.getPeersConnected()),"-",I.formatUL(e)].join(" "):e.isChecking()?["Verifying local data (",w.percentString(100*e.getRecheckProgress()),"% tested)"].join(""):e.getStateString()}static getProgressDetails(e,t){if(t.needsMetaData()){let a="retrieving";t.isStopped()&&(a="needs");let l=100*t.getMetadataPercentComplete();return[`Magnetized transfer - ${a} metadata (`,w.percentString(l),"%)"].join("")}let s=t.getSizeWhenDone(),r=t.getTotalSize(),o=t.isDone()||t.isSeeding(),i=[];if(o?(r===s?i.push(w.size(r)):i.push(w.size(s)," of ",w.size(t.getTotalSize())," (",t.getPercentDoneStr(),"%)"),i.push(", uploaded ",w.size(t.getUploadedEver())," (Ratio ",w.ratioString(t.getUploadRatio()),")")):i.push(w.size(s-t.getLeftUntilDone())," of ",w.size(s)," (",t.getPercentDoneStr(),"%)"),!t.isStopped()&&(!o||t.seedRatioLimit(e)>0)){i.push(" - ");let a=t.getETA();a<0||a>=999*60*60?i.push("remaining time unknown"):i.push(w.timeInterval(t.getETA())," remaining")}return i.join("")}render(e,t,s){let r=t.isStopped(),o=s._name_container;_(o,t.getName()),o.classList.toggle("paused",r),o=s._labels_container,_(o,I.formatLabels(t)),I.renderProgressbar(e,t,s._progressbar),s._progressbar.classList.add("full");let i=t.getError()!==f._ErrNone;o=s._peer_details_container,o.classList.toggle("error",i),_(o,oe.getPeerDetails(t)),o=s._progress_details_container,_(o,oe.getProgressDetails(e,t)),o=s._toggle_running_button,o.alt=r?"Resume":"Pause",o.dataset.action=r?"resume":"pause"}createRow(e){let t=document.createElement("li");t.className="torrent";let s=document.createElement("div");s.classList.add("icon"),s.dataset.iconMimeType=e.getPrimaryMimeType().split("/",1).pop(),s.dataset.iconMultifile=e.getFileCount()>1?"true":"false";let r=document.createElement("div");r.className="torrent-name";let o=document.createElement("div");o.className="torrent-labels";let i=document.createElement("div");i.className="torrent-peer-details";let a=document.createElement("div");a.classList.add("torrent-progress");let l=document.createElement("div");l.classList.add("torrent-progress-bar","full"),a.append(l);let c=document.createElement("a");c.className="torrent-pauseresume-button",a.append(c);let h=document.createElement("div");return h.className="torrent-progress-details",t.append(s),t.append(r),t.append(o),t.append(i),t.append(a),t.append(h),t._icon=s,t._name_container=r,t._labels_container=o,t._peer_details_container=i,t._progress_details_container=h,t._progressbar=l,t._toggle_running_button=c,t}},ve=class{static getPeerDetails(e){let t=e.getErrorMessage();if(t)return t;if(e.isDownloading()){let s=e.getDownloadSpeed()>0,r=e.getUploadSpeed()>0;if(!r&&!s)return"Idle";let o=[`${I.formatETA(e)} `];return s&&o.push(I.formatDL(e)),r&&o.push(I.formatUL(e)),o.join(" ")}return e.isSeeding()?`Ratio: ${w.ratioString(e.getUploadRatio())}, ${I.formatUL(e)}`:e.getStateString()}render(e,t,s){let r=s._name_container;r.classList.toggle("paused",t.isStopped()),_(r,t.getName()),r=s._labels_container,_(r,I.formatLabels(t));let o=t.getError()!==f._ErrNone;r=s._details_container,r.classList.toggle("error",o),_(r,ve.getPeerDetails(t)),I.renderProgressbar(e,t,s._progressbar),s._progressbar.classList.add("compact")}createRow(e){let t=document.createElement("div");t.classList.add("torrent-progress-bar","compact");let s=document.createElement("div");s.classList.add("icon"),s.dataset.iconMimeType=e.getPrimaryMimeType().split("/",1).pop(),s.dataset.iconMultifile=e.getFileCount()>1?"true":"false";let r=document.createElement("div");r.className="torrent-peer-details compact";let o=document.createElement("div");o.className="torrent-labels compact";let i=document.createElement("div");i.className="torrent-name compact";let a=document.createElement("li");return a.append(t),a.append(r),a.append(o),a.append(i),a.append(s),a.className="torrent compact",a._progressbar=t,a._details_container=r,a._labels_container=o,a._name_container=i,a}},tt=class{constructor(e,t,s){this._view=e,this._torrent=s,this._element=e.createRow(s);let r=()=>this.render(t);this._torrent.addEventListener("dataChanged",r),r()}getElement(){return this._element}render(e){let t=this.getTorrent();t&&this._view.render(e,t,this.getElement())}isSelected(){return this.getElement().classList.contains("selected")}getTorrent(){return this._torrent}getTorrentId(){return this.getTorrent().getId()}};var M=class extends EventTarget{constructor(e,t,s){super();this.action_manager=e,this.notifications=t,this.prefs=s,this.remote=new H(this),this.addEventListener("torrent-selection-changed",o=>this.action_manager.update(o)),this.filterText="",this._torrents={},this._rows=[],this.dirtyTorrents=new Set,this.refilterSoon=K(()=>this._refilter(!1)),this.refilterAllSoon=K(()=>this._refilter(!0)),this.boundPopupCloseListener=this.popupCloseListener.bind(this),this.dispatchSelectionChangedSoon=K(()=>this._dispatchSelectionChanged(),200);for(let o of document.querySelectorAll("button[data-action]")){let{action:i}=o.dataset;N(o,this.action_manager.isEnabled(i)),o.addEventListener("click",()=>{this.action_manager.click(i)})}document.querySelector("#filter-tracker").addEventListener("change",o=>{this.setFilterTracker(o.target.value==="all"?null:o.target.value)}),this.action_manager.addEventListener("change",o=>{for(let i of document.querySelectorAll(`[data-action="${o.action}"]`))N(i,o.enabled)}),this.action_manager.addEventListener("click",o=>{switch(o.action){case"deselect-all":this._deselectAll();break;case"move-bottom":this._moveBottom();break;case"move-down":this._moveDown();break;case"move-top":this._moveTop();break;case"move-up":this._moveUp();break;case"open-torrent":this.setCurrentPopup(new Ue(this,this.remote));break;case"pause-all-torrents":this._stopTorrents(this._getAllTorrents());break;case"pause-selected-torrents":this._stopTorrents(this.getSelectedTorrents());break;case"reannounce-selected-torrents":this._reannounceTorrents(this.getSelectedTorrents());break;case"remove-selected-torrents":this._removeSelectedTorrents(!1);break;case"resume-selected-torrents":this._startSelectedTorrents(!1);break;case"resume-selected-torrents-now":this._startSelectedTorrents(!0);break;case"select-all":this._selectAll();break;case"show-about-dialog":this.setCurrentPopup(new pe(this.version_info));break;case"show-inspector":this.setCurrentPopup(new R(this));break;case"show-move-dialog":this.setCurrentPopup(new he(this,this.remote));break;case"show-overflow-menu":this.popup instanceof Be?this.setCurrentPopup(null):this.setCurrentPopup(new Be(this,this.prefs,this.remote,this.action_manager));break;case"show-preferences-dialog":this.setCurrentPopup(new y(this,this.remote));break;case"show-shortcuts-dialog":this.setCurrentPopup(new _e(this.action_manager));break;case"show-statistics-dialog":this.setCurrentPopup(new be(this.remote));break;case"show-rename-dialog":this.setCurrentPopup(new fe(this,this.remote));break;case"show-labels-dialog":this.setCurrentPopup(new ge(this,this.remote));break;case"start-all-torrents":this._startTorrents(this._getAllTorrents());break;case"toggle-compact-rows":this.prefs.display_mode=this.prefs.display_mode===m.DisplayCompact?m.DisplayFull:m.DisplayCompact;break;case"trash-selected-torrents":this._removeSelectedTorrents(!0);break;case"verify-selected-torrents":this._verifyTorrents(this.getSelectedTorrents());break;default:console.warn(`unhandled action: ${o.action}`)}});let r=document.querySelector("#filter-mode");r.value=this.prefs.filter_mode,r.addEventListener("change",o=>{this.prefs.filter_mode=o.target.value,this.refilterAllSoon()}),document.addEventListener("keydown",this._keyDown.bind(this)),document.addEventListener("keyup",this._keyUp.bind(this)),r=document.querySelector("#torrent-container"),r.addEventListener("click",()=>{this.popup&&this.popup.name!=="inspector"?this.setCurrentPopup(null):this._deselectAll()}),r.addEventListener("dragenter",M._dragenter),r.addEventListener("dragover",M._dragenter),r.addEventListener("drop",this._drop.bind(this)),this._setupSearchBox(),this.elements={torrent_list:document.querySelector("#torrent-list")},this.elements.torrent_list.addEventListener("contextmenu",o=>{let i=event.target;for(;i&&!i.classList.contains("torrent");)i=i.parentNode;let a=this._rows.find(p=>p.getElement()===i);a&&!a.isSelected()&&this._setSelectedRow(a);let l=new Je(this.action_manager);this.setCurrentPopup(l);let h=document.querySelector("#torrent-container").getBoundingClientRect(),u=Math.min(o.x,h.x+h.width-l.root.clientWidth),d=Math.min(o.y,h.y+h.height-l.root.clientHeight);l.root.style.left=`${u>0?u:0}px`,l.root.style.top=`${d>0?d:0}px`,o.preventDefault()}),this.loadDaemonPrefs(),this._initializeTorrents(),this.refreshTorrents(),this.togglePeriodicSessionRefresh(!0),this.prefs.addEventListener("change",({key:o,value:i})=>this._onPrefChanged(o,i));for(let[o,i]of this.prefs.entries())this._onPrefChanged(o,i)}_openTorrentFromUrl(){setTimeout(()=>{let e=new URLSearchParams(window.location.search).get("addtorrent");if(e){this.setCurrentPopup(new Ue(this,this.remote,e));let t=new URL(window.location);t.search="",window.history.pushState("","",t.toString())}},0)}loadDaemonPrefs(){this.remote.loadDaemonPrefs(e=>{this.session_properties=e.arguments,this._openTorrentFromUrl()})}get session_properties(){return this._session_properties}set session_properties(e){if(Re(this._session_properties,e))return;this._session_properties=Object.seal(e);let t=new Event("session-change");t.session_properties=e,this.dispatchEvent(t),this._updateGuiFromSession(e)}_setupSearchBox(){let e=document.querySelector("#torrent-search"),t="blur";e.classList.add(t),e.addEventListener("blur",()=>e.classList.add(t)),e.addEventListener("focus",()=>e.classList.remove(t)),e.addEventListener("keyup",()=>this._setFilterText(e.value))}_onPrefChanged(e,t){switch(e){case m.DisplayMode:{this.torrentRenderer=t==="compact"?new ve:new oe,this.refilterAllSoon();break}case m.FilterMode:case m.SortDirection:case m.SortMode:this.refilterAllSoon();break;case m.RefreshRate:{clearInterval(this.refreshTorrentsInterval);let s=this.refreshTorrents.bind(this),r=Math.max(2,this.prefs.refresh_rate_sec)*1e3;this.refreshTorrentsInterval=setInterval(s,r);break}default:break}}_getAllTorrents(){return Object.values(this._torrents)}static _getTorrentIds(e){return e.map(t=>t.getId())}seedRatioLimit(){let e=this.session_properties;return e&&e.seedRatioLimited?e.seedRatioLimit:-1}_getSelectedRows(){return this._rows.filter(e=>e.isSelected())}getSelectedTorrents(){return this._getSelectedRows().map(e=>e.getTorrent())}_getSelectedTorrentIds(){return M._getTorrentIds(this.getSelectedTorrents())}_setSelectedRow(e){let t=e?e.getElement():null;for(let s of this.elements.torrent_list.children)s.classList.toggle("selected",s===t);this.dispatchSelectionChangedSoon()}_selectRow(e){e.getElement().classList.add("selected"),this.dispatchSelectionChangedSoon()}_deselectRow(e){e.getElement().classList.remove("selected"),this.dispatchSelectionChangedSoon()}_selectAll(){for(let e of this.elements.torrent_list.children)e.classList.add("selected");this.dispatchSelectionChangedSoon()}_deselectAll(){for(let e of this.elements.torrent_list.children)e.classList.remove("selected");this.dispatchSelectionChangedSoon(),delete this._last_torrent_clicked}_indexOfLastTorrent(){return this._rows.findIndex(e=>e.getTorrentId()===this._last_torrent_clicked)}_selectRange(e){let t=this._indexOfLastTorrent();if(t===-1)this._selectRow(e);else{let s=this._rows.indexOf(e),r=Math.min(t,s),o=Math.max(t,s);for(let i=r;i<=o;++i)this._selectRow(this._rows[i])}this.dispatchSelectionChangedSoon()}_dispatchSelectionChanged(){let e=[],t=[];for(let r of this._rows)(r.isSelected()?t:e).push(r.getTorrent());let s=new Event("torrent-selection-changed");s.nonselected=e,s.selected=t,this.dispatchEvent(s)}static _createKeyShortcutFromKeyboardEvent(e){let t=[];return e.ctrlKey&&t.push("Control"),e.altKey&&t.push("Alt"),e.metaKey&&t.push("Meta"),e.shitKey&&t.push("Shift"),t.push(e.key.length===1?e.key.toUpperCase():e.key),t.join("+")}_keyDown(e){let{ctrlKey:t,keyCode:s,metaKey:r,shiftKey:o,target:i}=e,a=i.matches("input");if(!a){let u=M._createKeyShortcutFromKeyboardEvent(e),d=this.action_manager.getActionForShortcut(u);if(d){e.preventDefault(),this.action_manager.click(d);return}}if(s===27&&this.popup){this.setCurrentPopup(null),e.preventDefault();return}let c=document.querySelector(".popup:not(.hidden)"),h=this._rows;if(!a&&!c&&!r&&!t){let u=s===16,d=s===38,p=s===40;if((d||p)&&h.length>0){let g=this._indexOfLastTorrent(),b=this._shift_index,v=0,C=h.length-1,k=g;p&&k+1<=C?++k:d&&k-1>=v&&--k;let S=h[k];b>=0?b<=g&&g<k||b>=g&&g>k?this._selectRow(S):(b>=g&&k>g||b<=g&&g>k)&&this._deselectRow(h[g]):o?this._selectRange(S):this._setSelectedRow(S),S&&(this._last_torrent_clicked=S.getTorrentId(),S.getElement().scrollIntoView(),e.preventDefault())}else u&&(this._shift_index=this._indexOfLastTorrent())}}_keyUp(e){e.keyCode===16&&delete this._shift_index}static _dragenter(e){if(e.dataTransfer&&e.dataTransfer.types){let t=new Set(["text/uri-list","text/plain"]);if(e.dataTransfer.types.some(s=>t.has(s)))return e.stopPropagation(),e.preventDefault(),e.dataTransfer.dropEffect="copy",!1}else e.dataTransfer&&(e.dataTransfer.dropEffect="none");return!0}static _isValidURL(e){try{return!!new URL(e)}catch{return!1}}shouldAddedTorrentsStart(){return this.session_properties["start-added-torrents"]}_drop(e){let t=!this.shouldAddedTorrentsStart();if(!e.dataTransfer||!e.dataTransfer.types)return!0;let s=e.data.Transfer.types.filter(r=>["text/uri-list","text/plain"].contains(r)).pop();for(let r of e.dataTransfer.getData(s).split(` `).map(o=>o.trim()).filter(o=>M._isValidURL(o)))this.remote.addTorrentByUrl(r,t);return e.preventDefault(),!1}togglePeriodicSessionRefresh(e){if(!e&&this.sessionInterval&&(clearInterval(this.sessionInterval),delete this.sessionInterval),e&&(this.loadDaemonPrefs(),!this.sessionInterval)){let t=8e3;this.sessionInterval=setInterval(this.loadDaemonPrefs.bind(this),t)}}_setFilterText(e){this.filterText=e?e.trim():null,this.refilterAllSoon()}_onTorrentChanged(e){let t=e.currentTarget;this.dirtyTorrents.add(t.getId()),this.refilterSoon()}updateTorrents(e,t){this.remote.updateTorrents(e,t,(s,r)=>{let o=[],i=s.shift(),a={};for(let l of s){for(let[u,d]of i.entries())a[d]=l[u];let{id:c}=a,h=this._torrents[c];if(h){let u=h.needsMetaData();h.refresh(a),u&&!h.needsMetaData()&&o.push(c)}else h=this._torrents[c]=new f(a),h.addEventListener("dataChanged",this._onTorrentChanged.bind(this)),this.dirtyTorrents.add(c),(!("name"in h.fields)||!("status"in h.fields))&&o.push(c)}if(o.length>0){let l=["id",...f.Fields.Metadata,...f.Fields.Stats];this.updateTorrents(o,l),this.refilterSoon()}r&&(this._deleteTorrents(r),this.refilterSoon())})}refreshTorrents(){let e=["id",...f.Fields.Stats];this.updateTorrents("recently-active",e)}_initializeTorrents(){let e=["id",...f.Fields.Metadata,...f.Fields.Stats];this.updateTorrents(null,e)}_onRowClicked(e){let t=e.metaKey||e.ctrlKey,{row:s}=e.currentTarget;if(this.popup&&this.popup.name!=="inspector"){this.setCurrentPopup(null);return}if(e.target.classList.contains("torrent-pauseresume-button"))switch(e.target.dataset.action){case"pause":this._stopTorrents([s.getTorrent()]);break;case"resume":this._startTorrents([s.getTorrent()]);break;default:break}e.stopPropagation(),e.shiftKey?(this._selectRange(s),window.focus()):!s.isSelected()&&t?this._selectRow(s):s.isSelected()?s.isSelected()&&t?this._deselectRow(s):s.isSelected()&&this._setSelectedRow(s):this._setSelectedRow(s),this._last_torrent_clicked=s.getTorrentId()}_deleteTorrents(e){if(e&&e.length>0){for(let t of e)this.dirtyTorrents.add(t),delete this._torrents[t];this.refilterSoon()}}_removeSelectedTorrents(e){let t=this.getSelectedTorrents();t.length>0&&this.setCurrentPopup(new re({remote:this.remote,torrents:t,trash:e}))}_startSelectedTorrents(e){this._startTorrents(this.getSelectedTorrents(),e)}_startTorrents(e,t){this.remote.startTorrents(M._getTorrentIds(e),t,this.refreshTorrents,this)}_verifyTorrents(e){this.remote.verifyTorrents(M._getTorrentIds(e),this.refreshTorrents,this)}_reannounceTorrents(e){this.remote.reannounceTorrents(M._getTorrentIds(e),this.refreshTorrents,this)}_stopTorrents(e){this.remote.stopTorrents(M._getTorrentIds(e),this.refreshTorrents,this)}changeFileCommand(e,t,s){this.remote.changeFileCommand(e,t,s)}_moveTop(){this.remote.moveTorrentsToTop(this._getSelectedTorrentIds(),this.refreshTorrents,this)}_moveUp(){this.remote.moveTorrentsUp(this._getSelectedTorrentIds(),this.refreshTorrents,this)}_moveDown(){this.remote.moveTorrentsDown(this._getSelectedTorrentIds(),this.refreshTorrents,this)}_moveBottom(){this.remote.moveTorrentsToBottom(this._getSelectedTorrentIds(),this.refreshTorrents,this)}_updateGuiFromSession(e){let[,t,s]=e.version.match(/(.*)\s\(([\da-f]+)\)/);this.version_info={checksum:s,version:t},document.querySelector("#toolbar-overflow").classList.toggle("alt-speed-enabled",e[x._TurtleState])}_updateStatusbar(){let e=w,t=this._getAllTorrents(),s=t.reduce((i,a)=>i+a.getUploadSpeed(),0),r=t.reduce((i,a)=>i+a.getDownloadSpeed(),0),o=e.countString("Transfer","Transfers",this._rows.length);_(document.querySelector("#speed-up-label"),e.speedBps(s)),_(document.querySelector("#speed-dn-label"),e.speedBps(r)),_(document.querySelector("#filter-count"),o)}static _displayName(e){let t=e;return t.length>0&&(t=t.charAt(0).toUpperCase()+t.slice(1)),t}_updateFilterSelect(){let e=this._getTrackerCounts(),t=Object.keys(e).sort(),s="";s+=this.filterTracker?'<option value="all">All</option>':'<option value="all" selected="selected">All</option>';for(let r of t)s+=`<option value="${r}"`,r===this.filterTracker&&(s+=' selected="selected"'),s+=`>${M._displayName(r)}</option>`;(!this.filterTrackersStr||this.filterTrackersStr!==s)&&(this.filterTrackersStr=s,document.querySelector("#filter-tracker").innerHTML=s)}sortRows(e){let t=e.map(r=>r.getTorrent()),s=e.reduce((r,o)=>(r[o.getTorrent().getId()]=o,r),{});f.sortTorrents(t,this.prefs.sort_mode,this.prefs.sort_direction);for(let[r,o]of t.entries())e[r]=s[o.getId()]}_refilter(e){let{sort_mode:t,sort_direction:s,filter_mode:r}=this.prefs,o=this.filterTracker,i=this.torrentRenderer,a=this.elements.torrent_list,l=null,c=null,h=/^labels:([\w,-\s]*)(.*)$/.exec(this.filterText);h?(l=h[2].trim(),c=h[1].split(",")):(l=this.filterText,c=[]);let u=()=>[...a.children].length,d=()=>[...a.children].reduce((A,U)=>A+U.classList.contains("selected")?1:0,0),p=u(),g=d();if(this._updateFilterSelect(),clearTimeout(this.refilterTimer),delete this.refilterTimer,e){for(;a.firstChild;)a.firstChild.remove();this._rows=[],this.dirtyTorrents=new Set(Object.keys(this._torrents))}let b=[],v=[];for(let A of this._rows)this.dirtyTorrents.has(A.getTorrentId())?v.push(A):b.push(A);for(let A of v)A.getElement().remove();let C=[];for(let A of v){let U=A.getTorrentId(),B=this._torrents[U];B&&B.test(r,o,l,c)&&C.push(A),this.dirtyTorrents.delete(U)}v=C;for(let A of this.dirtyTorrents.values()){let U=this._torrents[A];if(U&&U.test(r,o,l,c)){let B=new tt(i,this,U),Me=B.getElement();Me.row=B,v.push(B),Me.addEventListener("click",this._onRowClicked.bind(this)),Me.addEventListener("dblclick",()=>this.action_manager.click("show-inspector"))}}this.sortRows(v);let k=[],S=b.length,F=v.length,E=document.createDocumentFragment(),T=0,O=0;for(;T!==S||O!==F;){let A=null;if(T===S?A=!1:O===F?A=!0:A=f.compareTorrents(b[T].getTorrent(),v[O].getTorrent(),t,s)<0,A)k.push(b[T++]);else{let U=v[O++],B=U.getElement();T===S?E.append(B):a.insertBefore(B,b[T].getElement()),k.push(U)}}a.append(E),this._rows=k,this.dirtyTorrents.clear();for(let[A,U]of k.map(B=>B.getElement()).entries()){let B=A%2===0;U.classList.toggle("even",B),U.classList.toggle("odd",!B)}this._updateStatusbar(),(g!==d()||p!==u())&&this.dispatchSelectionChangedSoon()}setFilterTracker(e){let t=document.querySelector("#filter-tracker");t.value=e,this.filterTracker=e,this.refilterAllSoon()}_getTrackerCounts(){let e={};for(let t of this._getAllTorrents())for(let s of t.getTrackers()){let{sitename:r}=s;e[r]=(e[r]||0)+1}return e}popupCloseListener(e){if(e.target!==this.popup)throw new Error(e);this.popup.removeEventListener("close",this.boundPopupCloseListener),delete this.popup}setCurrentPopup(e){this.popup&&this.popup.close(),this.popup=e,this.popup&&this.popup.addEventListener("close",this.boundPopupCloseListener)}};function In(){let n=new ie,e=new m,t=new Xe(e),s=new M(n,t,e),r=K(()=>s.elements.torrent_list.scrollTo(0,1));window.addEventListener("load",r),window.addEventListener("orientationchange",r)}document.addEventListener("DOMContentLoaded",In);})();