From 380f0971357be0c7455dad6d5a024b07cb30d47d Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Sun, 3 Dec 2023 10:30:35 +0000 Subject: [PATCH] Rebuild webui --- crates/librqbit/webui/dist/assets/index.js | 2 +- crates/librqbit/webui/dist/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/librqbit/webui/dist/assets/index.js b/crates/librqbit/webui/dist/assets/index.js index 1d41eaf..fd9b77a 100644 --- a/crates/librqbit/webui/dist/assets/index.js +++ b/crates/librqbit/webui/dist/assets/index.js @@ -41,4 +41,4 @@ Error generating stack: `+o.message+` Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r=[],l=0;l=0)&&(n[l]=e[l]);return n}function ia(e){return"default"+e.charAt(0).toUpperCase()+e.substr(1)}function mh(e){var t=hh(e,"string");return typeof t=="symbol"?t:String(t)}function hh(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function vh(e,t,n){var r=y.useRef(e!==void 0),l=y.useState(t),o=l[0],i=l[1],u=e!==void 0,s=r.current;return r.current=u,!u&&s&&o!==t&&i(t),[u?e:o,y.useCallback(function(a){for(var m=arguments.length,h=new Array(m>1?m-1:0),f=1;f{o.target===e&&(l(),t(o))},n+r)}function Uh(e){e.offsetHeight}const aa=e=>!e||typeof e=="function"?e:t=>{e.current=t};function Bh(e,t){const n=aa(e),r=aa(t);return l=>{n&&n(l),r&&r(l)}}function mo(e,t){return y.useMemo(()=>Bh(e,t),[e,t])}function Hh(e){return e&&"setState"in e?Tn.findDOMNode(e):e??null}const Wh=Wt.forwardRef(({onEnter:e,onEntering:t,onEntered:n,onExit:r,onExiting:l,onExited:o,addEndListener:i,children:u,childRef:s,...a},m)=>{const h=y.useRef(null),f=mo(h,s),w=E=>{f(Hh(E))},g=E=>N=>{E&&h.current&&E(h.current,N)},x=y.useCallback(g(e),[e]),R=y.useCallback(g(t),[t]),p=y.useCallback(g(n),[n]),c=y.useCallback(g(r),[r]),v=y.useCallback(g(l),[l]),S=y.useCallback(g(o),[o]),T=y.useCallback(g(i),[i]);return d.jsx(zh,{ref:m,...a,onEnter:x,onEntered:p,onEntering:R,onExit:c,onExited:S,onExiting:v,addEndListener:T,nodeRef:h,children:typeof u=="function"?(E,N)=>u(E,{...N,ref:w}):Wt.cloneElement(u,{ref:w})})}),Vh=Wh;function Qh(e){const t=y.useRef(e);return y.useEffect(()=>{t.current=e},[e]),t}function Me(e){const t=Qh(e);return y.useCallback(function(...n){return t.current&&t.current(...n)},[t])}const Qf=e=>y.forwardRef((t,n)=>d.jsx("div",{...t,ref:n,className:M(t.className,e)})),Kf=Qf("h4");Kf.displayName="DivStyledAsH4";const Gf=y.forwardRef(({className:e,bsPrefix:t,as:n=Kf,...r},l)=>(t=H(t,"alert-heading"),d.jsx(n,{ref:l,className:M(e,t),...r})));Gf.displayName="AlertHeading";const Kh=Gf;function Gh(){return y.useState(null)}function Yh(){const e=y.useRef(!0),t=y.useRef(()=>e.current);return y.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function Xh(e){const t=y.useRef(null);return y.useEffect(()=>{t.current=e}),t.current}const Zh=typeof global<"u"&&global.navigator&&global.navigator.product==="ReactNative",Jh=typeof document<"u",ca=Jh||Zh?y.useLayoutEffect:y.useEffect,qh=["as","disabled"];function bh(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function ev(e){return!e||e.trim()==="#"}function Hu({tagName:e,disabled:t,href:n,target:r,rel:l,role:o,onClick:i,tabIndex:u=0,type:s}){e||(n!=null||r!=null||l!=null?e="a":e="button");const a={tagName:e};if(e==="button")return[{type:s||"button",disabled:t},a];const m=f=>{if((t||e==="a"&&ev(n))&&f.preventDefault(),t){f.stopPropagation();return}i==null||i(f)},h=f=>{f.key===" "&&(f.preventDefault(),m(f))};return e==="a"&&(n||(n="#"),t&&(n=void 0)),[{role:o??"button",disabled:void 0,tabIndex:t?void 0:u,href:n,target:e==="a"?r:void 0,"aria-disabled":t||void 0,rel:e==="a"?l:void 0,onClick:m,onKeyDown:h},a]}const tv=y.forwardRef((e,t)=>{let{as:n,disabled:r}=e,l=bh(e,qh);const[o,{tagName:i}]=Hu(Object.assign({tagName:n,disabled:r},l));return d.jsx(i,Object.assign({},l,o,{ref:t}))});tv.displayName="Button";const nv=["onKeyDown"];function rv(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function lv(e){return!e||e.trim()==="#"}const Yf=y.forwardRef((e,t)=>{let{onKeyDown:n}=e,r=rv(e,nv);const[l]=Hu(Object.assign({tagName:"a"},r)),o=Me(i=>{l.onKeyDown(i),n==null||n(i)});return lv(r.href)||r.role==="button"?d.jsx("a",Object.assign({ref:t},r,l,{onKeyDown:o})):d.jsx("a",Object.assign({ref:t},r,{onKeyDown:n}))});Yf.displayName="Anchor";const ov=Yf,Xf=y.forwardRef(({className:e,bsPrefix:t,as:n=ov,...r},l)=>(t=H(t,"alert-link"),d.jsx(n,{ref:l,className:M(e,t),...r})));Xf.displayName="AlertLink";const iv=Xf,uv={[St]:"show",[Ht]:"show"},Zf=y.forwardRef(({className:e,children:t,transitionClasses:n={},onEnter:r,...l},o)=>{const i={in:!1,timeout:300,mountOnEnter:!1,unmountOnExit:!1,appear:!1,...l},u=y.useCallback((s,a)=>{Uh(s),r==null||r(s,a)},[r]);return d.jsx(Vh,{ref:o,addEndListener:Ah,...i,onEnter:u,childRef:t.ref,children:(s,a)=>y.cloneElement(t,{...a,className:M("fade",e,t.props.className,uv[s],n[s])})})});Zf.displayName="Fade";const Kl=Zf,sv={"aria-label":it.string,onClick:it.func,variant:it.oneOf(["white"])},Wu=y.forwardRef(({className:e,variant:t,"aria-label":n="Close",...r},l)=>d.jsx("button",{ref:l,type:"button",className:M("btn-close",t&&`btn-close-${t}`,e),"aria-label":n,...r}));Wu.displayName="CloseButton";Wu.propTypes=sv;const Jf=Wu,qf=y.forwardRef((e,t)=>{const{bsPrefix:n,show:r=!0,closeLabel:l="Close alert",closeVariant:o,className:i,children:u,variant:s="primary",onClose:a,dismissible:m,transition:h=Kl,...f}=yh(e,{show:"onClose"}),w=H(n,"alert"),g=Me(p=>{a&&a(!1,p)}),x=h===!0?Kl:h,R=d.jsxs("div",{role:"alert",...x?void 0:f,ref:t,className:M(i,w,s&&`${w}-${s}`,m&&`${w}-dismissible`),children:[m&&d.jsx(Jf,{onClick:g,"aria-label":l,variant:o}),u]});return x?d.jsx(x,{unmountOnExit:!0,...f,ref:void 0,in:r,children:R}):r?R:null});qf.displayName="Alert";const fa=Object.assign(qf,{Link:iv,Heading:Kh}),bf=y.forwardRef(({as:e,bsPrefix:t,variant:n="primary",size:r,active:l=!1,disabled:o=!1,className:i,...u},s)=>{const a=H(t,"btn"),[m,{tagName:h}]=Hu({tagName:e,disabled:o,...u}),f=h;return d.jsx(f,{...m,...u,ref:s,disabled:o,className:M(i,a,l&&"active",n&&`${a}-${n}`,r&&`${a}-${r}`,u.href&&o&&"disabled")})});bf.displayName="Button";const tn=bf;function av(e){const t=y.useRef(e);return t.current=e,t}function ed(e){const t=av(e);y.useEffect(()=>()=>t.current(),[])}function cv(e,t){let n=0;return y.Children.map(e,r=>y.isValidElement(r)?t(r,n++):r)}function fv(e,t){return y.Children.toArray(e).some(n=>y.isValidElement(n)&&n.type===t)}function dv({as:e,bsPrefix:t,className:n,...r}){t=H(t,"col");const l=Df(),o=If(),i=[],u=[];return l.forEach(s=>{const a=r[s];delete r[s];let m,h,f;typeof a=="object"&&a!=null?{span:m,offset:h,order:f}=a:m=a;const w=s!==o?`-${s}`:"";m&&i.push(m===!0?`${t}${w}`:`${t}${w}-${m}`),f!=null&&u.push(`order${w}-${f}`),h!=null&&u.push(`offset${w}-${h}`)}),[{...r,className:M(n,...i,...u)},{as:e,bsPrefix:t,spans:i}]}const td=y.forwardRef((e,t)=>{const[{className:n,...r},{as:l="div",bsPrefix:o,spans:i}]=dv(e);return d.jsx(l,{...r,ref:t,className:M(n,!i.length&&o)})});td.displayName="Col";const Vu=td,nd=y.forwardRef(({bsPrefix:e,fluid:t=!1,as:n="div",className:r,...l},o)=>{const i=H(e,"container"),u=typeof t=="string"?`-${t}`:"-fluid";return d.jsx(n,{ref:o,...l,className:M(r,t?`${i}${u}`:i)})});nd.displayName="Container";const pv=nd;var mv=Function.prototype.bind.call(Function.prototype.call,[].slice);function dn(e,t){return mv(e.querySelectorAll(t))}function da(e,t){if(e.contains)return e.contains(t);if(e.compareDocumentPosition)return e===t||!!(e.compareDocumentPosition(t)&16)}const hv="data-rr-ui-";function vv(e){return`${hv}${e}`}const rd=y.createContext(Vn?window:void 0);rd.Provider;function Qu(){return y.useContext(rd)}const yv={type:it.string,tooltip:it.bool,as:it.elementType},Ku=y.forwardRef(({as:e="div",className:t,type:n="valid",tooltip:r=!1,...l},o)=>d.jsx(e,{...l,ref:o,className:M(t,`${n}-${r?"tooltip":"feedback"}`)}));Ku.displayName="Feedback";Ku.propTypes=yv;const ld=Ku,gv=y.createContext({}),ft=gv,od=y.forwardRef(({id:e,bsPrefix:t,className:n,type:r="checkbox",isValid:l=!1,isInvalid:o=!1,as:i="input",...u},s)=>{const{controlId:a}=y.useContext(ft);return t=H(t,"form-check-input"),d.jsx(i,{...u,ref:s,type:r,id:e||a,className:M(n,t,l&&"is-valid",o&&"is-invalid")})});od.displayName="FormCheckInput";const id=od,ud=y.forwardRef(({bsPrefix:e,className:t,htmlFor:n,...r},l)=>{const{controlId:o}=y.useContext(ft);return e=H(e,"form-check-label"),d.jsx("label",{...r,ref:l,htmlFor:n||o,className:M(t,e)})});ud.displayName="FormCheckLabel";const Gi=ud,sd=y.forwardRef(({id:e,bsPrefix:t,bsSwitchPrefix:n,inline:r=!1,reverse:l=!1,disabled:o=!1,isValid:i=!1,isInvalid:u=!1,feedbackTooltip:s=!1,feedback:a,feedbackType:m,className:h,style:f,title:w="",type:g="checkbox",label:x,children:R,as:p="input",...c},v)=>{t=H(t,"form-check"),n=H(n,"form-switch");const{controlId:S}=y.useContext(ft),T=y.useMemo(()=>({controlId:e||S}),[S,e]),E=!R&&x!=null&&x!==!1||fv(R,Gi),N=d.jsx(id,{...c,type:g==="switch"?"checkbox":g,ref:v,isValid:i,isInvalid:u,disabled:o,as:p});return d.jsx(ft.Provider,{value:T,children:d.jsx("div",{style:f,className:M(h,E&&t,r&&`${t}-inline`,l&&`${t}-reverse`,g==="switch"&&n),children:R||d.jsxs(d.Fragment,{children:[N,E&&d.jsx(Gi,{title:w,children:x}),a&&d.jsx(ld,{type:m,tooltip:s,children:a})]})})})});sd.displayName="FormCheck";const Gl=Object.assign(sd,{Input:id,Label:Gi}),ad=y.forwardRef(({bsPrefix:e,type:t,size:n,htmlSize:r,id:l,className:o,isValid:i=!1,isInvalid:u=!1,plaintext:s,readOnly:a,as:m="input",...h},f)=>{const{controlId:w}=y.useContext(ft);return e=H(e,"form-control"),d.jsx(m,{...h,type:t,size:r,ref:f,readOnly:a,id:l||w,className:M(o,s?`${e}-plaintext`:e,n&&`${e}-${n}`,t==="color"&&`${e}-color`,i&&"is-valid",u&&"is-invalid")})});ad.displayName="FormControl";const wv=Object.assign(ad,{Feedback:ld}),cd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"form-floating"),d.jsx(n,{ref:l,className:M(e,t),...r})));cd.displayName="FormFloating";const Sv=cd,fd=y.forwardRef(({controlId:e,as:t="div",...n},r)=>{const l=y.useMemo(()=>({controlId:e}),[e]);return d.jsx(ft.Provider,{value:l,children:d.jsx(t,{...n,ref:r})})});fd.displayName="FormGroup";const dd=fd,pd=y.forwardRef(({as:e="label",bsPrefix:t,column:n=!1,visuallyHidden:r=!1,className:l,htmlFor:o,...i},u)=>{const{controlId:s}=y.useContext(ft);t=H(t,"form-label");let a="col-form-label";typeof n=="string"&&(a=`${a} ${a}-${n}`);const m=M(l,t,r&&"visually-hidden",n&&a);return o=o||s,n?d.jsx(Vu,{ref:u,as:"label",className:m,htmlFor:o,...i}):d.jsx(e,{ref:u,className:m,htmlFor:o,...i})});pd.displayName="FormLabel";const xv=pd,md=y.forwardRef(({bsPrefix:e,className:t,id:n,...r},l)=>{const{controlId:o}=y.useContext(ft);return e=H(e,"form-range"),d.jsx("input",{...r,type:"range",ref:l,className:M(t,e),id:n||o})});md.displayName="FormRange";const kv=md,hd=y.forwardRef(({bsPrefix:e,size:t,htmlSize:n,className:r,isValid:l=!1,isInvalid:o=!1,id:i,...u},s)=>{const{controlId:a}=y.useContext(ft);return e=H(e,"form-select"),d.jsx("select",{...u,size:n,ref:s,className:M(r,e,t&&`${e}-${t}`,l&&"is-valid",o&&"is-invalid"),id:i||a})});hd.displayName="FormSelect";const Ev=hd,vd=y.forwardRef(({bsPrefix:e,className:t,as:n="small",muted:r,...l},o)=>(e=H(e,"form-text"),d.jsx(n,{...l,ref:o,className:M(t,e,r&&"text-muted")})));vd.displayName="FormText";const Cv=vd,yd=y.forwardRef((e,t)=>d.jsx(Gl,{...e,ref:t,type:"switch"}));yd.displayName="Switch";const Nv=Object.assign(yd,{Input:Gl.Input,Label:Gl.Label}),gd=y.forwardRef(({bsPrefix:e,className:t,children:n,controlId:r,label:l,...o},i)=>(e=H(e,"form-floating"),d.jsxs(dd,{ref:i,className:M(t,e),controlId:r,...o,children:[n,d.jsx("label",{htmlFor:r,children:l})]})));gd.displayName="FloatingLabel";const Tv=gd,_v={_ref:it.any,validated:it.bool,as:it.elementType},Gu=y.forwardRef(({className:e,validated:t,as:n="form",...r},l)=>d.jsx(n,{...r,ref:l,className:M(e,t&&"was-validated")}));Gu.displayName="Form";Gu.propTypes=_v;const pe=Object.assign(Gu,{Group:dd,Control:wv,Floating:Sv,Check:Gl,Switch:Nv,Label:xv,Text:Cv,Range:kv,Select:Ev,FloatingLabel:Tv});var ul;function pa(e){if((!ul&&ul!==0||e)&&Vn){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),ul=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return ul}function Wo(e){e===void 0&&(e=po());try{var t=e.activeElement;return!t||!t.nodeName?null:t}catch{return e.body}}function jv(e=document){const t=e.defaultView;return Math.abs(t.innerWidth-e.documentElement.clientWidth)}const ma=vv("modal-open");class Rv{constructor({ownerDocument:t,handleContainerOverflow:n=!0,isRTL:r=!1}={}){this.handleContainerOverflow=n,this.isRTL=r,this.modals=[],this.ownerDocument=t}getScrollbarWidth(){return jv(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(t){}removeModalAttributes(t){}setContainerStyle(t){const n={overflow:"hidden"},r=this.isRTL?"paddingLeft":"paddingRight",l=this.getElement();t.style={overflow:l.style.overflow,[r]:l.style[r]},t.scrollBarWidth&&(n[r]=`${parseInt(Xt(l,r)||"0",10)+t.scrollBarWidth}px`),l.setAttribute(ma,""),Xt(l,n)}reset(){[...this.modals].forEach(t=>this.remove(t))}removeContainerStyle(t){const n=this.getElement();n.removeAttribute(ma),Object.assign(n.style,t.style)}add(t){let n=this.modals.indexOf(t);return n!==-1||(n=this.modals.length,this.modals.push(t),this.setModalAttributes(t),n!==0)||(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state)),n}remove(t){const n=this.modals.indexOf(t);n!==-1&&(this.modals.splice(n,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(t))}isTopModal(t){return!!this.modals.length&&this.modals[this.modals.length-1]===t}}const Yu=Rv,Vo=(e,t)=>Vn?e==null?(t||po()).body:(typeof e=="function"&&(e=e()),e&&"current"in e&&(e=e.current),e&&("nodeType"in e||e.getBoundingClientRect)?e:null):null;function Lv(e,t){const n=Qu(),[r,l]=y.useState(()=>Vo(e,n==null?void 0:n.document));if(!r){const o=Vo(e);o&&l(o)}return y.useEffect(()=>{t&&r&&t(r)},[t,r]),y.useEffect(()=>{const o=Vo(e);o!==r&&l(o)},[e,r]),r}function Ov({children:e,in:t,onExited:n,mountOnEnter:r,unmountOnExit:l}){const o=y.useRef(null),i=y.useRef(t),u=Me(n);y.useEffect(()=>{t?i.current=!0:u(o.current)},[t,u]);const s=mo(o,e.ref),a=y.cloneElement(e,{ref:s});return t?a:l||!i.current&&r?null:a}function Pv({in:e,onTransition:t}){const n=y.useRef(null),r=y.useRef(!0),l=Me(t);return ca(()=>{if(!n.current)return;let o=!1;return l({in:e,element:n.current,initial:r.current,isStale:()=>o}),()=>{o=!0}},[e,l]),ca(()=>(r.current=!1,()=>{r.current=!0}),[]),n}function Fv({children:e,in:t,onExited:n,onEntered:r,transition:l}){const[o,i]=y.useState(!t);t&&o&&i(!1);const u=Pv({in:!!t,onTransition:a=>{const m=()=>{a.isStale()||(a.in?r==null||r(a.element,a.initial):(i(!0),n==null||n(a.element)))};Promise.resolve(l(a)).then(m,h=>{throw a.in||i(!0),h})}}),s=mo(u,e.ref);return o&&!t?null:y.cloneElement(e,{ref:s})}function ha(e,t,n){return e?d.jsx(e,Object.assign({},n)):t?d.jsx(Fv,Object.assign({},n,{transition:t})):d.jsx(Ov,Object.assign({},n))}function Mv(e){return e.code==="Escape"||e.keyCode===27}const zv=["show","role","className","style","children","backdrop","keyboard","onBackdropClick","onEscapeKeyDown","transition","runTransition","backdropTransition","runBackdropTransition","autoFocus","enforceFocus","restoreFocus","restoreFocusOptions","renderDialog","renderBackdrop","manager","container","onShow","onHide","onExit","onExited","onExiting","onEnter","onEntering","onEntered"];function $v(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}let Qo;function Dv(e){return Qo||(Qo=new Yu({ownerDocument:e==null?void 0:e.document})),Qo}function Iv(e){const t=Qu(),n=e||Dv(t),r=y.useRef({dialog:null,backdrop:null});return Object.assign(r.current,{add:()=>n.add(r.current),remove:()=>n.remove(r.current),isTopModal:()=>n.isTopModal(r.current),setDialogRef:y.useCallback(l=>{r.current.dialog=l},[]),setBackdropRef:y.useCallback(l=>{r.current.backdrop=l},[])})}const wd=y.forwardRef((e,t)=>{let{show:n=!1,role:r="dialog",className:l,style:o,children:i,backdrop:u=!0,keyboard:s=!0,onBackdropClick:a,onEscapeKeyDown:m,transition:h,runTransition:f,backdropTransition:w,runBackdropTransition:g,autoFocus:x=!0,enforceFocus:R=!0,restoreFocus:p=!0,restoreFocusOptions:c,renderDialog:v,renderBackdrop:S=K=>d.jsx("div",Object.assign({},K)),manager:T,container:E,onShow:N,onHide:j=()=>{},onExit:U,onExited:P,onExiting:ie,onEnter:Ke,onEntering:Ge,onEntered:on}=e,Qn=$v(e,zv);const Re=Qu(),Ye=Lv(E),C=Iv(T),L=Yh(),O=Xh(n),[D,A]=y.useState(!n),fe=y.useRef(null);y.useImperativeHandle(t,()=>C,[C]),Vn&&!O&&n&&(fe.current=Wo(Re==null?void 0:Re.document)),n&&D&&A(!1);const Le=Me(()=>{if(C.add(),sn.current=Ql(document,"keydown",ho),un.current=Ql(document,"focus",()=>setTimeout(Oe),!0),N&&N(),x){var K,Hr;const Yn=Wo((K=(Hr=C.dialog)==null?void 0:Hr.ownerDocument)!=null?K:Re==null?void 0:Re.document);C.dialog&&Yn&&!da(C.dialog,Yn)&&(fe.current=Yn,C.dialog.focus())}}),et=Me(()=>{if(C.remove(),sn.current==null||sn.current(),un.current==null||un.current(),p){var K;(K=fe.current)==null||K.focus==null||K.focus(c),fe.current=null}});y.useEffect(()=>{!n||!Ye||Le()},[n,Ye,Le]),y.useEffect(()=>{D&&et()},[D,et]),ed(()=>{et()});const Oe=Me(()=>{if(!R||!L()||!C.isTopModal())return;const K=Wo(Re==null?void 0:Re.document);C.dialog&&K&&!da(C.dialog,K)&&C.dialog.focus()}),mt=Me(K=>{K.target===K.currentTarget&&(a==null||a(K),u===!0&&j())}),ho=Me(K=>{s&&Mv(K)&&C.isTopModal()&&(m==null||m(K),K.defaultPrevented||j())}),un=y.useRef(),sn=y.useRef(),Kn=(...K)=>{A(!0),P==null||P(...K)};if(!Ye)return null;const Br=Object.assign({role:r,ref:C.setDialogRef,"aria-modal":r==="dialog"?!0:void 0},Qn,{style:o,className:l,tabIndex:-1});let Gn=v?v(Br):d.jsx("div",Object.assign({},Br,{children:y.cloneElement(i,{role:"document"})}));Gn=ha(h,f,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:U,onExiting:ie,onExited:Kn,onEnter:Ke,onEntering:Ge,onEntered:on,children:Gn});let It=null;return u&&(It=S({ref:C.setBackdropRef,onClick:mt}),It=ha(w,g,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:It})),d.jsx(d.Fragment,{children:Tn.createPortal(d.jsxs(d.Fragment,{children:[It,Gn]}),Ye)})});wd.displayName="Modal";const Av=Object.assign(wd,{Manager:Yu});function Uv(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function Bv(e,t){e.classList?e.classList.add(t):Uv(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function va(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Hv(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=va(e.className,t):e.setAttribute("class",va(e.className&&e.className.baseVal||"",t))}const pn={FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"};class Wv extends Yu{adjustAndStore(t,n,r){const l=n.style[t];n.dataset[t]=l,Xt(n,{[t]:`${parseFloat(Xt(n,t))+r}px`})}restore(t,n){const r=n.dataset[t];r!==void 0&&(delete n.dataset[t],Xt(n,{[t]:r}))}setContainerStyle(t){super.setContainerStyle(t);const n=this.getElement();if(Bv(n,"modal-open"),!t.scrollBarWidth)return;const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";dn(n,pn.FIXED_CONTENT).forEach(o=>this.adjustAndStore(r,o,t.scrollBarWidth)),dn(n,pn.STICKY_CONTENT).forEach(o=>this.adjustAndStore(l,o,-t.scrollBarWidth)),dn(n,pn.NAVBAR_TOGGLER).forEach(o=>this.adjustAndStore(l,o,t.scrollBarWidth))}removeContainerStyle(t){super.removeContainerStyle(t);const n=this.getElement();Hv(n,"modal-open");const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";dn(n,pn.FIXED_CONTENT).forEach(o=>this.restore(r,o)),dn(n,pn.STICKY_CONTENT).forEach(o=>this.restore(l,o)),dn(n,pn.NAVBAR_TOGGLER).forEach(o=>this.restore(l,o))}}let Ko;function Vv(e){return Ko||(Ko=new Wv(e)),Ko}const Sd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-body"),d.jsx(n,{ref:l,className:M(e,t),...r})));Sd.displayName="ModalBody";const Qv=Sd,Kv=y.createContext({onHide(){}}),xd=Kv,kd=y.forwardRef(({bsPrefix:e,className:t,contentClassName:n,centered:r,size:l,fullscreen:o,children:i,scrollable:u,...s},a)=>{e=H(e,"modal");const m=`${e}-dialog`,h=typeof o=="string"?`${e}-fullscreen-${o}`:`${e}-fullscreen`;return d.jsx("div",{...s,ref:a,className:M(m,t,l&&`${e}-${l}`,r&&`${m}-centered`,u&&`${m}-scrollable`,o&&h),children:d.jsx("div",{className:M(`${e}-content`,n),children:i})})});kd.displayName="ModalDialog";const Ed=kd,Cd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-footer"),d.jsx(n,{ref:l,className:M(e,t),...r})));Cd.displayName="ModalFooter";const Gv=Cd,Yv=y.forwardRef(({closeLabel:e="Close",closeVariant:t,closeButton:n=!1,onHide:r,children:l,...o},i)=>{const u=y.useContext(xd),s=Me(()=>{u==null||u.onHide(),r==null||r()});return d.jsxs("div",{ref:i,...o,children:[l,n&&d.jsx(Jf,{"aria-label":e,variant:t,onClick:s})]})}),Xv=Yv,Nd=y.forwardRef(({bsPrefix:e,className:t,closeLabel:n="Close",closeButton:r=!1,...l},o)=>(e=H(e,"modal-header"),d.jsx(Xv,{ref:o,...l,className:M(t,e),closeLabel:n,closeButton:r})));Nd.displayName="ModalHeader";const Zv=Nd,Jv=Qf("h4"),Td=y.forwardRef(({className:e,bsPrefix:t,as:n=Jv,...r},l)=>(t=H(t,"modal-title"),d.jsx(n,{ref:l,className:M(e,t),...r})));Td.displayName="ModalTitle";const qv=Td;function bv(e){return d.jsx(Kl,{...e,timeout:null})}function ey(e){return d.jsx(Kl,{...e,timeout:null})}const _d=y.forwardRef(({bsPrefix:e,className:t,style:n,dialogClassName:r,contentClassName:l,children:o,dialogAs:i=Ed,"aria-labelledby":u,"aria-describedby":s,"aria-label":a,show:m=!1,animation:h=!0,backdrop:f=!0,keyboard:w=!0,onEscapeKeyDown:g,onShow:x,onHide:R,container:p,autoFocus:c=!0,enforceFocus:v=!0,restoreFocus:S=!0,restoreFocusOptions:T,onEntered:E,onExit:N,onExiting:j,onEnter:U,onEntering:P,onExited:ie,backdropClassName:Ke,manager:Ge,...on},Qn)=>{const[Re,Ye]=y.useState({}),[C,L]=y.useState(!1),O=y.useRef(!1),D=y.useRef(!1),A=y.useRef(null),[fe,Le]=Gh(),et=mo(Qn,Le),Oe=Me(R),mt=xh();e=H(e,"modal");const ho=y.useMemo(()=>({onHide:Oe}),[Oe]);function un(){return Ge||Vv({isRTL:mt})}function sn($){if(!Vn)return;const an=un().getScrollbarWidth()>0,Zu=$.scrollHeight>po($).documentElement.clientHeight;Ye({paddingRight:an&&!Zu?pa():void 0,paddingLeft:!an&&Zu?pa():void 0})}const Kn=Me(()=>{fe&&sn(fe.dialog)});ed(()=>{Ki(window,"resize",Kn),A.current==null||A.current()});const Br=()=>{O.current=!0},Gn=$=>{O.current&&fe&&$.target===fe.dialog&&(D.current=!0),O.current=!1},It=()=>{L(!0),A.current=Vf(fe.dialog,()=>{L(!1)})},K=$=>{$.target===$.currentTarget&&It()},Hr=$=>{if(f==="static"){K($);return}if(D.current||$.target!==$.currentTarget){D.current=!1;return}R==null||R()},Yn=$=>{w?g==null||g($):($.preventDefault(),f==="static"&&It())},Dd=($,an)=>{$&&sn($),U==null||U($,an)},Id=$=>{A.current==null||A.current(),N==null||N($)},Ad=($,an)=>{P==null||P($,an),Wf(window,"resize",Kn)},Ud=$=>{$&&($.style.display=""),ie==null||ie($),Ki(window,"resize",Kn)},Bd=y.useCallback($=>d.jsx("div",{...$,className:M(`${e}-backdrop`,Ke,!h&&"show")}),[h,Ke,e]),Xu={...n,...Re};Xu.display="block";const Hd=$=>d.jsx("div",{role:"dialog",...$,style:Xu,className:M(t,e,C&&`${e}-static`,!h&&"show"),onClick:f?Hr:void 0,onMouseUp:Gn,"aria-label":a,"aria-labelledby":u,"aria-describedby":s,children:d.jsx(i,{...on,onMouseDown:Br,className:r,contentClassName:l,children:o})});return d.jsx(xd.Provider,{value:ho,children:d.jsx(Av,{show:m,ref:et,backdrop:f,container:p,keyboard:!0,autoFocus:c,enforceFocus:v,restoreFocus:S,restoreFocusOptions:T,onEscapeKeyDown:Yn,onShow:x,onHide:R,onEnter:Dd,onEntering:Ad,onEntered:E,onExit:Id,onExiting:j,onExited:Ud,manager:un(),transition:h?bv:void 0,backdropTransition:h?ey:void 0,renderBackdrop:Bd,renderDialog:Hd})})});_d.displayName="Modal";const ge=Object.assign(_d,{Body:Qv,Header:Zv,Title:qv,Footer:Gv,Dialog:Ed,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150}),ya=1e3;function ty(e,t,n){const r=(e-t)/(n-t)*100;return Math.round(r*ya)/ya}function ga({min:e,now:t,max:n,label:r,visuallyHidden:l,striped:o,animated:i,className:u,style:s,variant:a,bsPrefix:m,...h},f){return d.jsx("div",{ref:f,...h,role:"progressbar",className:M(u,`${m}-bar`,{[`bg-${a}`]:a,[`${m}-bar-animated`]:i,[`${m}-bar-striped`]:i||o}),style:{width:`${ty(t,e,n)}%`,...s},"aria-valuenow":t,"aria-valuemin":e,"aria-valuemax":n,children:l?d.jsx("span",{className:"visually-hidden",children:r}):r})}const jd=y.forwardRef(({isChild:e=!1,...t},n)=>{const r={min:0,max:100,animated:!1,visuallyHidden:!1,striped:!1,...t};if(r.bsPrefix=H(r.bsPrefix,"progress"),e)return ga(r,n);const{min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:f,className:w,children:g,...x}=r;return d.jsx("div",{ref:n,...x,className:M(w,h),children:g?cv(g,R=>y.cloneElement(R,{isChild:!0})):ga({min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:f},n)})});jd.displayName="ProgressBar";const ny=jd,Rd=y.forwardRef(({bsPrefix:e,className:t,as:n="div",...r},l)=>{const o=H(e,"row"),i=Df(),u=If(),s=`${o}-cols`,a=[];return i.forEach(m=>{const h=r[m];delete r[m];let f;h!=null&&typeof h=="object"?{cols:f}=h:f=h;const w=m!==u?`-${m}`:"";f!=null&&a.push(`${s}${w}-${f}`)}),d.jsx(n,{ref:l,...r,className:M(t,o,...a)})});Rd.displayName="Row";const Ld=Rd,Od=y.forwardRef(({bsPrefix:e,variant:t,animation:n="border",size:r,as:l="div",className:o,...i},u)=>{e=H(e,"spinner");const s=`${e}-${n}`;return d.jsx(l,{ref:u,...i,className:M(o,s,r&&`${s}-${r}`,t&&`text-${t}`)})});Od.displayName="Spinner";const Un=Od,Sl="initializing",wa="paused",Pd="live",ry="error",ln=y.createContext({listTorrents:()=>{throw new Error("Function not implemented.")},getTorrentDetails:()=>{throw new Error("Function not implemented.")},getTorrentStats:()=>{throw new Error("Function not implemented.")},uploadTorrent:()=>{throw new Error("Function not implemented.")},pause:()=>{throw new Error("Function not implemented.")},start:()=>{throw new Error("Function not implemented.")},forget:()=>{throw new Error("Function not implemented.")},delete:()=>{throw new Error("Function not implemented.")}}),Ur=y.createContext({setCloseableError:e=>{},refreshTorrents:()=>{}}),Fd=y.createContext({refresh:()=>{}}),Go=({className:e,onClick:t,disabled:n,color:r})=>{const l=o=>{o.stopPropagation(),!n&&t()};return d.jsx("a",{className:`bi ${e} p-1`,onClick:l,href:"#"})},ly=({id:e,show:t,onHide:n})=>{if(!t)return null;const[r,l]=y.useState(!1),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(Ur),m=y.useContext(ln),h=()=>{l(!1),i(null),s(!1),n()},f=()=>{s(!0),(r?m.delete:m.forget)(e).then(()=>{a.refreshTorrents(),h()}).catch(g=>{i({text:`Error deleting torrent id=${e}`,details:g}),s(!1)})};return d.jsxs(ge,{show:t,onHide:h,children:[d.jsx(ge.Header,{closeButton:!0,children:"Delete torrent"}),d.jsxs(ge.Body,{children:[d.jsx(pe,{children:d.jsx(pe.Group,{controlId:"delete-torrent",children:d.jsx(pe.Check,{type:"checkbox",label:"Also delete files",checked:r,onChange:()=>l(!r)})})}),o&&d.jsx(Mr,{error:o})]}),d.jsxs(ge.Footer,{children:[u&&d.jsx(Un,{}),d.jsx(tn,{variant:"primary",onClick:f,disabled:u,children:"OK"}),d.jsx(tn,{variant:"secondary",onClick:h,children:"Cancel"})]})]})},oy=({id:e,statsResponse:t})=>{let n=t.state,[r,l]=y.useState(!1),[o,i]=y.useState(!1),u=y.useContext(Fd);const s=n=="live",a=n=="paused"||n=="error",m=y.useContext(Ur),h=y.useContext(ln),f=()=>{l(!0),h.start(e).then(()=>{u.refresh()},R=>{m.setCloseableError({text:`Error starting torrent id=${e}`,details:R})}).finally(()=>l(!1))},w=()=>{l(!0),h.pause(e).then(()=>{u.refresh()},R=>{m.setCloseableError({text:`Error pausing torrent id=${e}`,details:R})}).finally(()=>l(!1))},g=()=>{l(!0),i(!0)},x=()=>{l(!1),i(!1)};return d.jsx(Ld,{children:d.jsxs(Vu,{children:[a&&d.jsx(Go,{className:"bi-play-circle",onClick:f,disabled:r,color:"success"}),s&&d.jsx(Go,{className:"bi-pause-circle",onClick:w,disabled:r}),d.jsx(Go,{className:"bi-x-circle",onClick:g,disabled:r,color:"danger"}),d.jsx(ly,{id:e,show:o,onHide:x})]})})},iy=({id:e,detailsResponse:t,statsResponse:n})=>{const r=(n==null?void 0:n.state)??"",l=n==null?void 0:n.error,o=(n==null?void 0:n.total_bytes)??1,i=(n==null?void 0:n.progress_bytes)??0,u=(n==null?void 0:n.finished)||!1,s=l?100:i/o*100,a=(r==Sl||r==Pd)&&!u,m=l?"Error":`${s.toFixed(2)}%`,h=l?"danger":u?"success":r==Sl?"warning":"primary",f=()=>{var R;let x=(R=n==null?void 0:n.live)==null?void 0:R.snapshot.peer_stats;return x?`${x.live} / ${x.seen}`:""},w=()=>{var x;if(u)return"Completed";switch(r){case wa:return"Paused";case Sl:return"Checking files";case ry:return"Error"}return((x=n==null?void 0:n.live)==null?void 0:x.download_speed.human_readable)??"N/A"};let g=[];return l?g.push("bg-warning"):e%2==0&&g.push("bg-light"),d.jsxs(Ld,{className:g.join(" "),children:[d.jsx(vt,{size:3,label:"Name",children:t?d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"text-truncate",children:yy(t)}),l&&d.jsxs("p",{className:"text-danger",children:[d.jsx("strong",{children:"Error:"})," ",l]})]}):d.jsx(Un,{})}),n?d.jsxs(d.Fragment,{children:[d.jsx(vt,{label:"Size",children:`${zd(o)} `}),d.jsx(vt,{size:2,label:(r==wa,"Progress"),children:d.jsx(ny,{now:s,label:m,animated:a,variant:h})}),d.jsx(vt,{size:2,label:"Down Speed",children:w()}),d.jsx(vt,{label:"ETA",children:gy(n)}),d.jsx(vt,{size:2,label:"Peers",children:f()}),d.jsx(vt,{label:"Actions",children:d.jsx(oy,{id:e,statsResponse:n})})]}):d.jsx(vt,{label:"Loading stats",size:8,children:d.jsx(Un,{})})]})},vt=({size:e,label:t,children:n})=>d.jsxs(Vu,{md:e||1,className:"py-3",children:[d.jsx("div",{className:"fw-bold",children:t}),n]}),uy=({id:e,torrent:t})=>{const[n,r]=y.useState(null),[l,o]=y.useState(null),[i,u]=y.useState(0),s=y.useContext(ln),a=()=>{u(i+1)};return y.useEffect(()=>{if(n===null)return Sy(async()=>{await s.getTorrentDetails(t.id).then(r)},1e3)},[n]),y.useEffect(()=>$d(async()=>s.getTorrentStats(t.id).then(g=>(o(g),g)).then(g=>g.finished?1e4:g.state==Sl||g.state==Pd?1e3:1e4,()=>1e4),0),[i]),d.jsx(Fd.Provider,{value:{refresh:a},children:d.jsx(iy,{id:e,detailsResponse:n,statsResponse:l})})},sy=e=>{if(e.torrents===null&&e.loading)return d.jsx(Un,{});if(e.torrents!==null)return e.torrents.length===0?d.jsx("div",{className:"text-center",children:d.jsx("p",{children:"No existing torrents found. Add them through buttons below."})}):d.jsx(d.Fragment,{children:e.torrents.map(t=>d.jsx(uy,{id:t.id,torrent:t},t.id))})},ay=e=>{const[t,n]=y.useState(null),[r,l]=y.useState(null),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(ln),m=async()=>{s(!0);let f=await a.listTorrents().finally(()=>s(!1));i(f.torrents)};y.useEffect(()=>$d(async()=>m().then(()=>(l(null),5e3),f=>(l({text:"Error refreshing torrents",details:f}),console.error(f),5e3)),0),[]);const h={setCloseableError:n,refreshTorrents:m};return d.jsx(Ur.Provider,{value:h,children:d.jsxs("div",{className:"text-center",children:[d.jsx("h1",{className:"mt-3 mb-4",children:e.title}),d.jsx(vy,{closeableError:t,otherError:r,torrents:o,torrentsLoading:u})]})})},cy=e=>{let{details:t}=e;return t?d.jsxs(d.Fragment,{children:[d.jsx("p",{children:t.status&&d.jsxs("strong",{children:[t.status," ",t.statusText]})}),d.jsx("pre",{children:t.text})]}):null},Mr=e=>{let{error:t,remove:n}=e;return t==null?null:d.jsxs(fa,{variant:"danger",onClose:n,dismissible:n!=null,children:[d.jsx(fa.Heading,{children:t.text}),d.jsx(cy,{details:t.details})]})},Md=({buttonText:e,onClick:t,data:n,resetData:r,variant:l})=>{const[o,i]=y.useState(!1),[u,s]=y.useState(null),[a,m]=y.useState(null),h=y.useContext(ln);y.useEffect(()=>{if(n===null)return;let w=setTimeout(async()=>{i(!0);try{const g=await h.uploadTorrent(n,{list_only:!0});s(g)}catch(g){m({text:"Error listing torrent files",details:g})}finally{i(!1)}},0);return()=>clearTimeout(w)},[n]);const f=()=>{r(),m(null),s(null),i(!1)};return d.jsxs(d.Fragment,{children:[d.jsx(tn,{variant:l,onClick:t,className:"m-1",children:e}),n&&d.jsx(my,{onHide:f,listTorrentError:a,listTorrentResponse:u,data:n,listTorrentLoading:o})]})},fy=({show:e,setUrl:t,cancel:n})=>{let[r,l]=y.useState("");return d.jsxs(ge,{show:e,onHide:n,size:"lg",children:[d.jsx(ge.Header,{closeButton:!0,children:d.jsx(ge.Title,{children:"Add torrent"})}),d.jsx(ge.Body,{children:d.jsx(pe,{children:d.jsxs(pe.Group,{className:"mb-3",controlId:"url",children:[d.jsx(pe.Label,{children:"Enter magnet or HTTP(S) URL to the .torrent"}),d.jsx(pe.Control,{value:r,placeholder:"magnet:?xt=urn:btih:...",onChange:o=>{l(o.target.value)}})]})})}),d.jsxs(ge.Footer,{children:[d.jsx(tn,{variant:"primary",onClick:()=>{t(r),l("")},disabled:r.length==0,children:"OK"}),d.jsx(tn,{variant:"secondary",onClick:n,children:"Cancel"})]})]})},dy=()=>{let[e,t]=y.useState(null),[n,r]=y.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsx(Md,{variant:"primary",buttonText:"Add Torrent from Magnet / URL",onClick:()=>{r(!0)},data:e,resetData:()=>t(null)}),d.jsx(fy,{show:n,setUrl:l=>{r(!1),t(l)},cancel:()=>{r(!1),t(null)}})]})},py=()=>{const e=y.useRef(),[t,n]=y.useState(null),r=async()=>{var u;if(!((u=e==null?void 0:e.current)!=null&&u.files))return;const i=e.current.files[0];n(i)},l=()=>{e!=null&&e.current&&(e.current.value="",n(null))},o=()=>{e!=null&&e.current&&e.current.click()};return d.jsxs(d.Fragment,{children:[d.jsx("input",{type:"file",ref:e,accept:".torrent",onChange:r,className:"d-none"}),d.jsx(Md,{variant:"secondary",buttonText:"Upload .torrent File",onClick:o,data:t,resetData:l})]})},my=e=>{let{onHide:t,listTorrentResponse:n,listTorrentError:r,listTorrentLoading:l,data:o}=e;const[i,u]=y.useState([]),[s,a]=y.useState(!1),[m,h]=y.useState(null),[f,w]=y.useState(!1),[g,x]=y.useState(""),R=y.useContext(Ur),p=y.useContext(ln);y.useEffect(()=>{console.log(n),u(n?n.details.files.map((E,N)=>N):[]),x((n==null?void 0:n.output_folder)||"")},[n]);const c=()=>{t(),u([]),h(null),a(!1)},v=E=>{i.includes(E)?u(i.filter(N=>N!==E)):u([...i,E])},S=async()=>{if(!n)return;a(!0);let E=n.seen_peers?n.seen_peers.slice(0,32):null,N={overwrite:!0,only_files:i,initial_peers:E,output_folder:g};f&&(N.peer_opts={connect_timeout:20,read_write_timeout:60}),p.uploadTorrent(o,N).then(()=>{t(),R.refreshTorrents()},j=>{h({text:"Error starting torrent",details:j})}).finally(()=>a(!1))},T=()=>{if(l)return d.jsx(Un,{});if(r)return d.jsx(Mr,{error:r});if(n)return d.jsxs(pe,{children:[d.jsxs("fieldset",{className:"mb-4",children:[d.jsx("legend",{children:"Pick the files to download"}),n.details.files.map((E,N)=>d.jsx(pe.Group,{controlId:`check-${N}`,children:d.jsx(pe.Check,{type:"checkbox",label:`${E.name} (${zd(E.length)})`,checked:i.includes(N),onChange:()=>v(N)})},N))]}),d.jsxs("fieldset",{children:[d.jsx("legend",{children:"Options"}),d.jsxs(pe.Group,{controlId:"output-folder",className:"mb-3",children:[d.jsx(pe.Label,{children:"Output folder"}),d.jsx(pe.Control,{type:"text",value:g,onChange:E=>x(E.target.value)})]}),d.jsxs(pe.Group,{controlId:"unpopular-torrent",className:"mb-3",children:[d.jsx(pe.Check,{type:"checkbox",label:"Increase timeouts",checked:f,onChange:()=>w(!f)}),d.jsx("small",{id:"emailHelp",className:"form-text text-muted",children:"This might be useful for unpopular torrents with few peers. It will slow down fast torrents though."})]})]})]})};return d.jsxs(ge,{show:!0,onHide:c,size:"lg",children:[d.jsx(ge.Header,{closeButton:!0,children:d.jsx(ge.Title,{children:"Add torrent"})}),d.jsxs(ge.Body,{children:[T(),d.jsx(Mr,{error:m})]}),d.jsxs(ge.Footer,{children:[s&&d.jsx(Un,{}),d.jsx(tn,{variant:"primary",onClick:S,disabled:l||s||i.length==0,children:"OK"}),d.jsx(tn,{variant:"secondary",onClick:c,children:"Cancel"})]})]})},hy=()=>d.jsxs("div",{id:"buttons-container",className:"mt-3",children:[d.jsx(dy,{}),d.jsx(py,{})]}),vy=e=>{let t=y.useContext(Ur);return d.jsxs(pv,{children:[d.jsx(Mr,{error:e.closeableError,remove:()=>t.setCloseableError(null)}),d.jsx(Mr,{error:e.otherError}),d.jsx(sy,{torrents:e.torrents,loading:e.torrentsLoading}),d.jsx(hy,{})]})};function zd(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+n[r]}function yy(e){return e.files.filter(n=>n.included).reduce((n,r)=>n.length>r.length?n:r).name}function gy(e){var n,r,l;let t=(l=(r=(n=e==null?void 0:e.live)==null?void 0:n.time_remaining)==null?void 0:r.duration)==null?void 0:l.secs;return t==null?"N/A":wy(t)}function wy(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60,l=(o,i)=>o>0?`${o}${i}`:"";return t>0?`${l(t,"h")} ${l(n,"m")}`.trim():n>0?`${l(n,"m")} ${l(r,"s")}`.trim():`${l(r,"s")}`.trim()}function $d(e,t){let n,r=t;const l=async()=>{if(r=await e(),r==null)throw"asyncCallback returned null or undefined";o()};let o=()=>{n=setTimeout(l,r)};return o(),()=>{clearTimeout(n)}}function Sy(e,t){let n;const r=async()=>{await e().then(()=>!1,()=>!0)&&l()};let l=o=>{n=setTimeout(r,o!==void 0?o:t)};return l(0),()=>clearTimeout(n)}const xy=window.origin==="null"||window.origin==="http://localhost:3031"?"http://localhost:3030":"",yt=async(e,t,n)=>{console.log(e,t);const r=xy+t,l={method:e,headers:{Accept:"application/json"},body:n};let o={method:e,path:t,text:""},i;try{i=await fetch(r,l)}catch{return o.text="network error",Promise.reject(o)}if(o.status=i.status,o.statusText=i.statusText,!i.ok){const s=await i.text();try{const a=JSON.parse(s);o.text=a.human_readable!==void 0?a.human_readable:JSON.stringify(a,null,2)}catch{o.text=s}return Promise.reject(o)}return await i.json()},ky={listTorrents:()=>yt("GET","/torrents"),getTorrentDetails:e=>yt("GET",`/torrents/${e}`),getTorrentStats:e=>yt("GET",`/torrents/${e}/stats/v1`),uploadTorrent:(e,t)=>{var r,l;let n="/torrents?&overwrite=true";return t!=null&&t.list_only&&(n+="&list_only=true"),(t==null?void 0:t.only_files)!=null&&(n+=`&only_files=${t.only_files.join(",")}`),(r=t==null?void 0:t.peer_opts)!=null&&r.connect_timeout&&(n+=`&peer_connect_timeout=${t.peer_opts.connect_timeout}`),(l=t==null?void 0:t.peer_opts)!=null&&l.read_write_timeout&&(n+=`&peer_read_write_timeout=${t.peer_opts.read_write_timeout}`),t!=null&&t.initial_peers&&(n+=`&initial_peers=${t.initial_peers.join(",")}`),t!=null&&t.output_folder&&(n+=`&output_folder=${t.output_folder}`),typeof e=="string"&&(n+="&is_url=true"),yt("POST",n,e)},pause:e=>yt("POST",`/torrents/${e}/pause`),start:e=>yt("POST",`/torrents/${e}/start`),forget:e=>yt("POST",`/torrents/${e}/forget`),delete:e=>yt("POST",`/torrents/${e}/delete`)};Yo.createRoot(document.getElementById("app")).render(d.jsx(y.StrictMode,{children:d.jsx(ln.Provider,{value:ky,children:d.jsx(ay,{title:"rqbit web UI - version 4.0.0-beta.3"})})})); +*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r=[],l=0;l=0)&&(n[l]=e[l]);return n}function ia(e){return"default"+e.charAt(0).toUpperCase()+e.substr(1)}function mh(e){var t=hh(e,"string");return typeof t=="symbol"?t:String(t)}function hh(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function vh(e,t,n){var r=y.useRef(e!==void 0),l=y.useState(t),o=l[0],i=l[1],u=e!==void 0,s=r.current;return r.current=u,!u&&s&&o!==t&&i(t),[u?e:o,y.useCallback(function(a){for(var m=arguments.length,h=new Array(m>1?m-1:0),f=1;f{o.target===e&&(l(),t(o))},n+r)}function Uh(e){e.offsetHeight}const aa=e=>!e||typeof e=="function"?e:t=>{e.current=t};function Bh(e,t){const n=aa(e),r=aa(t);return l=>{n&&n(l),r&&r(l)}}function mo(e,t){return y.useMemo(()=>Bh(e,t),[e,t])}function Hh(e){return e&&"setState"in e?Tn.findDOMNode(e):e??null}const Wh=Wt.forwardRef(({onEnter:e,onEntering:t,onEntered:n,onExit:r,onExiting:l,onExited:o,addEndListener:i,children:u,childRef:s,...a},m)=>{const h=y.useRef(null),f=mo(h,s),w=E=>{f(Hh(E))},g=E=>N=>{E&&h.current&&E(h.current,N)},x=y.useCallback(g(e),[e]),R=y.useCallback(g(t),[t]),p=y.useCallback(g(n),[n]),c=y.useCallback(g(r),[r]),v=y.useCallback(g(l),[l]),S=y.useCallback(g(o),[o]),T=y.useCallback(g(i),[i]);return d.jsx(zh,{ref:m,...a,onEnter:x,onEntered:p,onEntering:R,onExit:c,onExited:S,onExiting:v,addEndListener:T,nodeRef:h,children:typeof u=="function"?(E,N)=>u(E,{...N,ref:w}):Wt.cloneElement(u,{ref:w})})}),Vh=Wh;function Qh(e){const t=y.useRef(e);return y.useEffect(()=>{t.current=e},[e]),t}function Me(e){const t=Qh(e);return y.useCallback(function(...n){return t.current&&t.current(...n)},[t])}const Qf=e=>y.forwardRef((t,n)=>d.jsx("div",{...t,ref:n,className:M(t.className,e)})),Kf=Qf("h4");Kf.displayName="DivStyledAsH4";const Gf=y.forwardRef(({className:e,bsPrefix:t,as:n=Kf,...r},l)=>(t=H(t,"alert-heading"),d.jsx(n,{ref:l,className:M(e,t),...r})));Gf.displayName="AlertHeading";const Kh=Gf;function Gh(){return y.useState(null)}function Yh(){const e=y.useRef(!0),t=y.useRef(()=>e.current);return y.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function Xh(e){const t=y.useRef(null);return y.useEffect(()=>{t.current=e}),t.current}const Zh=typeof global<"u"&&global.navigator&&global.navigator.product==="ReactNative",Jh=typeof document<"u",ca=Jh||Zh?y.useLayoutEffect:y.useEffect,qh=["as","disabled"];function bh(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function ev(e){return!e||e.trim()==="#"}function Hu({tagName:e,disabled:t,href:n,target:r,rel:l,role:o,onClick:i,tabIndex:u=0,type:s}){e||(n!=null||r!=null||l!=null?e="a":e="button");const a={tagName:e};if(e==="button")return[{type:s||"button",disabled:t},a];const m=f=>{if((t||e==="a"&&ev(n))&&f.preventDefault(),t){f.stopPropagation();return}i==null||i(f)},h=f=>{f.key===" "&&(f.preventDefault(),m(f))};return e==="a"&&(n||(n="#"),t&&(n=void 0)),[{role:o??"button",disabled:void 0,tabIndex:t?void 0:u,href:n,target:e==="a"?r:void 0,"aria-disabled":t||void 0,rel:e==="a"?l:void 0,onClick:m,onKeyDown:h},a]}const tv=y.forwardRef((e,t)=>{let{as:n,disabled:r}=e,l=bh(e,qh);const[o,{tagName:i}]=Hu(Object.assign({tagName:n,disabled:r},l));return d.jsx(i,Object.assign({},l,o,{ref:t}))});tv.displayName="Button";const nv=["onKeyDown"];function rv(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function lv(e){return!e||e.trim()==="#"}const Yf=y.forwardRef((e,t)=>{let{onKeyDown:n}=e,r=rv(e,nv);const[l]=Hu(Object.assign({tagName:"a"},r)),o=Me(i=>{l.onKeyDown(i),n==null||n(i)});return lv(r.href)||r.role==="button"?d.jsx("a",Object.assign({ref:t},r,l,{onKeyDown:o})):d.jsx("a",Object.assign({ref:t},r,{onKeyDown:n}))});Yf.displayName="Anchor";const ov=Yf,Xf=y.forwardRef(({className:e,bsPrefix:t,as:n=ov,...r},l)=>(t=H(t,"alert-link"),d.jsx(n,{ref:l,className:M(e,t),...r})));Xf.displayName="AlertLink";const iv=Xf,uv={[St]:"show",[Ht]:"show"},Zf=y.forwardRef(({className:e,children:t,transitionClasses:n={},onEnter:r,...l},o)=>{const i={in:!1,timeout:300,mountOnEnter:!1,unmountOnExit:!1,appear:!1,...l},u=y.useCallback((s,a)=>{Uh(s),r==null||r(s,a)},[r]);return d.jsx(Vh,{ref:o,addEndListener:Ah,...i,onEnter:u,childRef:t.ref,children:(s,a)=>y.cloneElement(t,{...a,className:M("fade",e,t.props.className,uv[s],n[s])})})});Zf.displayName="Fade";const Kl=Zf,sv={"aria-label":it.string,onClick:it.func,variant:it.oneOf(["white"])},Wu=y.forwardRef(({className:e,variant:t,"aria-label":n="Close",...r},l)=>d.jsx("button",{ref:l,type:"button",className:M("btn-close",t&&`btn-close-${t}`,e),"aria-label":n,...r}));Wu.displayName="CloseButton";Wu.propTypes=sv;const Jf=Wu,qf=y.forwardRef((e,t)=>{const{bsPrefix:n,show:r=!0,closeLabel:l="Close alert",closeVariant:o,className:i,children:u,variant:s="primary",onClose:a,dismissible:m,transition:h=Kl,...f}=yh(e,{show:"onClose"}),w=H(n,"alert"),g=Me(p=>{a&&a(!1,p)}),x=h===!0?Kl:h,R=d.jsxs("div",{role:"alert",...x?void 0:f,ref:t,className:M(i,w,s&&`${w}-${s}`,m&&`${w}-dismissible`),children:[m&&d.jsx(Jf,{onClick:g,"aria-label":l,variant:o}),u]});return x?d.jsx(x,{unmountOnExit:!0,...f,ref:void 0,in:r,children:R}):r?R:null});qf.displayName="Alert";const fa=Object.assign(qf,{Link:iv,Heading:Kh}),bf=y.forwardRef(({as:e,bsPrefix:t,variant:n="primary",size:r,active:l=!1,disabled:o=!1,className:i,...u},s)=>{const a=H(t,"btn"),[m,{tagName:h}]=Hu({tagName:e,disabled:o,...u}),f=h;return d.jsx(f,{...m,...u,ref:s,disabled:o,className:M(i,a,l&&"active",n&&`${a}-${n}`,r&&`${a}-${r}`,u.href&&o&&"disabled")})});bf.displayName="Button";const tn=bf;function av(e){const t=y.useRef(e);return t.current=e,t}function ed(e){const t=av(e);y.useEffect(()=>()=>t.current(),[])}function cv(e,t){let n=0;return y.Children.map(e,r=>y.isValidElement(r)?t(r,n++):r)}function fv(e,t){return y.Children.toArray(e).some(n=>y.isValidElement(n)&&n.type===t)}function dv({as:e,bsPrefix:t,className:n,...r}){t=H(t,"col");const l=Df(),o=If(),i=[],u=[];return l.forEach(s=>{const a=r[s];delete r[s];let m,h,f;typeof a=="object"&&a!=null?{span:m,offset:h,order:f}=a:m=a;const w=s!==o?`-${s}`:"";m&&i.push(m===!0?`${t}${w}`:`${t}${w}-${m}`),f!=null&&u.push(`order${w}-${f}`),h!=null&&u.push(`offset${w}-${h}`)}),[{...r,className:M(n,...i,...u)},{as:e,bsPrefix:t,spans:i}]}const td=y.forwardRef((e,t)=>{const[{className:n,...r},{as:l="div",bsPrefix:o,spans:i}]=dv(e);return d.jsx(l,{...r,ref:t,className:M(n,!i.length&&o)})});td.displayName="Col";const Vu=td,nd=y.forwardRef(({bsPrefix:e,fluid:t=!1,as:n="div",className:r,...l},o)=>{const i=H(e,"container"),u=typeof t=="string"?`-${t}`:"-fluid";return d.jsx(n,{ref:o,...l,className:M(r,t?`${i}${u}`:i)})});nd.displayName="Container";const pv=nd;var mv=Function.prototype.bind.call(Function.prototype.call,[].slice);function dn(e,t){return mv(e.querySelectorAll(t))}function da(e,t){if(e.contains)return e.contains(t);if(e.compareDocumentPosition)return e===t||!!(e.compareDocumentPosition(t)&16)}const hv="data-rr-ui-";function vv(e){return`${hv}${e}`}const rd=y.createContext(Vn?window:void 0);rd.Provider;function Qu(){return y.useContext(rd)}const yv={type:it.string,tooltip:it.bool,as:it.elementType},Ku=y.forwardRef(({as:e="div",className:t,type:n="valid",tooltip:r=!1,...l},o)=>d.jsx(e,{...l,ref:o,className:M(t,`${n}-${r?"tooltip":"feedback"}`)}));Ku.displayName="Feedback";Ku.propTypes=yv;const ld=Ku,gv=y.createContext({}),ft=gv,od=y.forwardRef(({id:e,bsPrefix:t,className:n,type:r="checkbox",isValid:l=!1,isInvalid:o=!1,as:i="input",...u},s)=>{const{controlId:a}=y.useContext(ft);return t=H(t,"form-check-input"),d.jsx(i,{...u,ref:s,type:r,id:e||a,className:M(n,t,l&&"is-valid",o&&"is-invalid")})});od.displayName="FormCheckInput";const id=od,ud=y.forwardRef(({bsPrefix:e,className:t,htmlFor:n,...r},l)=>{const{controlId:o}=y.useContext(ft);return e=H(e,"form-check-label"),d.jsx("label",{...r,ref:l,htmlFor:n||o,className:M(t,e)})});ud.displayName="FormCheckLabel";const Gi=ud,sd=y.forwardRef(({id:e,bsPrefix:t,bsSwitchPrefix:n,inline:r=!1,reverse:l=!1,disabled:o=!1,isValid:i=!1,isInvalid:u=!1,feedbackTooltip:s=!1,feedback:a,feedbackType:m,className:h,style:f,title:w="",type:g="checkbox",label:x,children:R,as:p="input",...c},v)=>{t=H(t,"form-check"),n=H(n,"form-switch");const{controlId:S}=y.useContext(ft),T=y.useMemo(()=>({controlId:e||S}),[S,e]),E=!R&&x!=null&&x!==!1||fv(R,Gi),N=d.jsx(id,{...c,type:g==="switch"?"checkbox":g,ref:v,isValid:i,isInvalid:u,disabled:o,as:p});return d.jsx(ft.Provider,{value:T,children:d.jsx("div",{style:f,className:M(h,E&&t,r&&`${t}-inline`,l&&`${t}-reverse`,g==="switch"&&n),children:R||d.jsxs(d.Fragment,{children:[N,E&&d.jsx(Gi,{title:w,children:x}),a&&d.jsx(ld,{type:m,tooltip:s,children:a})]})})})});sd.displayName="FormCheck";const Gl=Object.assign(sd,{Input:id,Label:Gi}),ad=y.forwardRef(({bsPrefix:e,type:t,size:n,htmlSize:r,id:l,className:o,isValid:i=!1,isInvalid:u=!1,plaintext:s,readOnly:a,as:m="input",...h},f)=>{const{controlId:w}=y.useContext(ft);return e=H(e,"form-control"),d.jsx(m,{...h,type:t,size:r,ref:f,readOnly:a,id:l||w,className:M(o,s?`${e}-plaintext`:e,n&&`${e}-${n}`,t==="color"&&`${e}-color`,i&&"is-valid",u&&"is-invalid")})});ad.displayName="FormControl";const wv=Object.assign(ad,{Feedback:ld}),cd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"form-floating"),d.jsx(n,{ref:l,className:M(e,t),...r})));cd.displayName="FormFloating";const Sv=cd,fd=y.forwardRef(({controlId:e,as:t="div",...n},r)=>{const l=y.useMemo(()=>({controlId:e}),[e]);return d.jsx(ft.Provider,{value:l,children:d.jsx(t,{...n,ref:r})})});fd.displayName="FormGroup";const dd=fd,pd=y.forwardRef(({as:e="label",bsPrefix:t,column:n=!1,visuallyHidden:r=!1,className:l,htmlFor:o,...i},u)=>{const{controlId:s}=y.useContext(ft);t=H(t,"form-label");let a="col-form-label";typeof n=="string"&&(a=`${a} ${a}-${n}`);const m=M(l,t,r&&"visually-hidden",n&&a);return o=o||s,n?d.jsx(Vu,{ref:u,as:"label",className:m,htmlFor:o,...i}):d.jsx(e,{ref:u,className:m,htmlFor:o,...i})});pd.displayName="FormLabel";const xv=pd,md=y.forwardRef(({bsPrefix:e,className:t,id:n,...r},l)=>{const{controlId:o}=y.useContext(ft);return e=H(e,"form-range"),d.jsx("input",{...r,type:"range",ref:l,className:M(t,e),id:n||o})});md.displayName="FormRange";const kv=md,hd=y.forwardRef(({bsPrefix:e,size:t,htmlSize:n,className:r,isValid:l=!1,isInvalid:o=!1,id:i,...u},s)=>{const{controlId:a}=y.useContext(ft);return e=H(e,"form-select"),d.jsx("select",{...u,size:n,ref:s,className:M(r,e,t&&`${e}-${t}`,l&&"is-valid",o&&"is-invalid"),id:i||a})});hd.displayName="FormSelect";const Ev=hd,vd=y.forwardRef(({bsPrefix:e,className:t,as:n="small",muted:r,...l},o)=>(e=H(e,"form-text"),d.jsx(n,{...l,ref:o,className:M(t,e,r&&"text-muted")})));vd.displayName="FormText";const Cv=vd,yd=y.forwardRef((e,t)=>d.jsx(Gl,{...e,ref:t,type:"switch"}));yd.displayName="Switch";const Nv=Object.assign(yd,{Input:Gl.Input,Label:Gl.Label}),gd=y.forwardRef(({bsPrefix:e,className:t,children:n,controlId:r,label:l,...o},i)=>(e=H(e,"form-floating"),d.jsxs(dd,{ref:i,className:M(t,e),controlId:r,...o,children:[n,d.jsx("label",{htmlFor:r,children:l})]})));gd.displayName="FloatingLabel";const Tv=gd,_v={_ref:it.any,validated:it.bool,as:it.elementType},Gu=y.forwardRef(({className:e,validated:t,as:n="form",...r},l)=>d.jsx(n,{...r,ref:l,className:M(e,t&&"was-validated")}));Gu.displayName="Form";Gu.propTypes=_v;const pe=Object.assign(Gu,{Group:dd,Control:wv,Floating:Sv,Check:Gl,Switch:Nv,Label:xv,Text:Cv,Range:kv,Select:Ev,FloatingLabel:Tv});var ul;function pa(e){if((!ul&&ul!==0||e)&&Vn){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),ul=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return ul}function Wo(e){e===void 0&&(e=po());try{var t=e.activeElement;return!t||!t.nodeName?null:t}catch{return e.body}}function jv(e=document){const t=e.defaultView;return Math.abs(t.innerWidth-e.documentElement.clientWidth)}const ma=vv("modal-open");class Rv{constructor({ownerDocument:t,handleContainerOverflow:n=!0,isRTL:r=!1}={}){this.handleContainerOverflow=n,this.isRTL=r,this.modals=[],this.ownerDocument=t}getScrollbarWidth(){return jv(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(t){}removeModalAttributes(t){}setContainerStyle(t){const n={overflow:"hidden"},r=this.isRTL?"paddingLeft":"paddingRight",l=this.getElement();t.style={overflow:l.style.overflow,[r]:l.style[r]},t.scrollBarWidth&&(n[r]=`${parseInt(Xt(l,r)||"0",10)+t.scrollBarWidth}px`),l.setAttribute(ma,""),Xt(l,n)}reset(){[...this.modals].forEach(t=>this.remove(t))}removeContainerStyle(t){const n=this.getElement();n.removeAttribute(ma),Object.assign(n.style,t.style)}add(t){let n=this.modals.indexOf(t);return n!==-1||(n=this.modals.length,this.modals.push(t),this.setModalAttributes(t),n!==0)||(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state)),n}remove(t){const n=this.modals.indexOf(t);n!==-1&&(this.modals.splice(n,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(t))}isTopModal(t){return!!this.modals.length&&this.modals[this.modals.length-1]===t}}const Yu=Rv,Vo=(e,t)=>Vn?e==null?(t||po()).body:(typeof e=="function"&&(e=e()),e&&"current"in e&&(e=e.current),e&&("nodeType"in e||e.getBoundingClientRect)?e:null):null;function Lv(e,t){const n=Qu(),[r,l]=y.useState(()=>Vo(e,n==null?void 0:n.document));if(!r){const o=Vo(e);o&&l(o)}return y.useEffect(()=>{t&&r&&t(r)},[t,r]),y.useEffect(()=>{const o=Vo(e);o!==r&&l(o)},[e,r]),r}function Ov({children:e,in:t,onExited:n,mountOnEnter:r,unmountOnExit:l}){const o=y.useRef(null),i=y.useRef(t),u=Me(n);y.useEffect(()=>{t?i.current=!0:u(o.current)},[t,u]);const s=mo(o,e.ref),a=y.cloneElement(e,{ref:s});return t?a:l||!i.current&&r?null:a}function Pv({in:e,onTransition:t}){const n=y.useRef(null),r=y.useRef(!0),l=Me(t);return ca(()=>{if(!n.current)return;let o=!1;return l({in:e,element:n.current,initial:r.current,isStale:()=>o}),()=>{o=!0}},[e,l]),ca(()=>(r.current=!1,()=>{r.current=!0}),[]),n}function Fv({children:e,in:t,onExited:n,onEntered:r,transition:l}){const[o,i]=y.useState(!t);t&&o&&i(!1);const u=Pv({in:!!t,onTransition:a=>{const m=()=>{a.isStale()||(a.in?r==null||r(a.element,a.initial):(i(!0),n==null||n(a.element)))};Promise.resolve(l(a)).then(m,h=>{throw a.in||i(!0),h})}}),s=mo(u,e.ref);return o&&!t?null:y.cloneElement(e,{ref:s})}function ha(e,t,n){return e?d.jsx(e,Object.assign({},n)):t?d.jsx(Fv,Object.assign({},n,{transition:t})):d.jsx(Ov,Object.assign({},n))}function Mv(e){return e.code==="Escape"||e.keyCode===27}const zv=["show","role","className","style","children","backdrop","keyboard","onBackdropClick","onEscapeKeyDown","transition","runTransition","backdropTransition","runBackdropTransition","autoFocus","enforceFocus","restoreFocus","restoreFocusOptions","renderDialog","renderBackdrop","manager","container","onShow","onHide","onExit","onExited","onExiting","onEnter","onEntering","onEntered"];function $v(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}let Qo;function Dv(e){return Qo||(Qo=new Yu({ownerDocument:e==null?void 0:e.document})),Qo}function Iv(e){const t=Qu(),n=e||Dv(t),r=y.useRef({dialog:null,backdrop:null});return Object.assign(r.current,{add:()=>n.add(r.current),remove:()=>n.remove(r.current),isTopModal:()=>n.isTopModal(r.current),setDialogRef:y.useCallback(l=>{r.current.dialog=l},[]),setBackdropRef:y.useCallback(l=>{r.current.backdrop=l},[])})}const wd=y.forwardRef((e,t)=>{let{show:n=!1,role:r="dialog",className:l,style:o,children:i,backdrop:u=!0,keyboard:s=!0,onBackdropClick:a,onEscapeKeyDown:m,transition:h,runTransition:f,backdropTransition:w,runBackdropTransition:g,autoFocus:x=!0,enforceFocus:R=!0,restoreFocus:p=!0,restoreFocusOptions:c,renderDialog:v,renderBackdrop:S=K=>d.jsx("div",Object.assign({},K)),manager:T,container:E,onShow:N,onHide:j=()=>{},onExit:U,onExited:P,onExiting:ie,onEnter:Ke,onEntering:Ge,onEntered:on}=e,Qn=$v(e,zv);const Re=Qu(),Ye=Lv(E),C=Iv(T),L=Yh(),O=Xh(n),[D,A]=y.useState(!n),fe=y.useRef(null);y.useImperativeHandle(t,()=>C,[C]),Vn&&!O&&n&&(fe.current=Wo(Re==null?void 0:Re.document)),n&&D&&A(!1);const Le=Me(()=>{if(C.add(),sn.current=Ql(document,"keydown",ho),un.current=Ql(document,"focus",()=>setTimeout(Oe),!0),N&&N(),x){var K,Hr;const Yn=Wo((K=(Hr=C.dialog)==null?void 0:Hr.ownerDocument)!=null?K:Re==null?void 0:Re.document);C.dialog&&Yn&&!da(C.dialog,Yn)&&(fe.current=Yn,C.dialog.focus())}}),et=Me(()=>{if(C.remove(),sn.current==null||sn.current(),un.current==null||un.current(),p){var K;(K=fe.current)==null||K.focus==null||K.focus(c),fe.current=null}});y.useEffect(()=>{!n||!Ye||Le()},[n,Ye,Le]),y.useEffect(()=>{D&&et()},[D,et]),ed(()=>{et()});const Oe=Me(()=>{if(!R||!L()||!C.isTopModal())return;const K=Wo(Re==null?void 0:Re.document);C.dialog&&K&&!da(C.dialog,K)&&C.dialog.focus()}),mt=Me(K=>{K.target===K.currentTarget&&(a==null||a(K),u===!0&&j())}),ho=Me(K=>{s&&Mv(K)&&C.isTopModal()&&(m==null||m(K),K.defaultPrevented||j())}),un=y.useRef(),sn=y.useRef(),Kn=(...K)=>{A(!0),P==null||P(...K)};if(!Ye)return null;const Br=Object.assign({role:r,ref:C.setDialogRef,"aria-modal":r==="dialog"?!0:void 0},Qn,{style:o,className:l,tabIndex:-1});let Gn=v?v(Br):d.jsx("div",Object.assign({},Br,{children:y.cloneElement(i,{role:"document"})}));Gn=ha(h,f,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:U,onExiting:ie,onExited:Kn,onEnter:Ke,onEntering:Ge,onEntered:on,children:Gn});let It=null;return u&&(It=S({ref:C.setBackdropRef,onClick:mt}),It=ha(w,g,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:It})),d.jsx(d.Fragment,{children:Tn.createPortal(d.jsxs(d.Fragment,{children:[It,Gn]}),Ye)})});wd.displayName="Modal";const Av=Object.assign(wd,{Manager:Yu});function Uv(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function Bv(e,t){e.classList?e.classList.add(t):Uv(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function va(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Hv(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=va(e.className,t):e.setAttribute("class",va(e.className&&e.className.baseVal||"",t))}const pn={FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"};class Wv extends Yu{adjustAndStore(t,n,r){const l=n.style[t];n.dataset[t]=l,Xt(n,{[t]:`${parseFloat(Xt(n,t))+r}px`})}restore(t,n){const r=n.dataset[t];r!==void 0&&(delete n.dataset[t],Xt(n,{[t]:r}))}setContainerStyle(t){super.setContainerStyle(t);const n=this.getElement();if(Bv(n,"modal-open"),!t.scrollBarWidth)return;const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";dn(n,pn.FIXED_CONTENT).forEach(o=>this.adjustAndStore(r,o,t.scrollBarWidth)),dn(n,pn.STICKY_CONTENT).forEach(o=>this.adjustAndStore(l,o,-t.scrollBarWidth)),dn(n,pn.NAVBAR_TOGGLER).forEach(o=>this.adjustAndStore(l,o,t.scrollBarWidth))}removeContainerStyle(t){super.removeContainerStyle(t);const n=this.getElement();Hv(n,"modal-open");const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";dn(n,pn.FIXED_CONTENT).forEach(o=>this.restore(r,o)),dn(n,pn.STICKY_CONTENT).forEach(o=>this.restore(l,o)),dn(n,pn.NAVBAR_TOGGLER).forEach(o=>this.restore(l,o))}}let Ko;function Vv(e){return Ko||(Ko=new Wv(e)),Ko}const Sd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-body"),d.jsx(n,{ref:l,className:M(e,t),...r})));Sd.displayName="ModalBody";const Qv=Sd,Kv=y.createContext({onHide(){}}),xd=Kv,kd=y.forwardRef(({bsPrefix:e,className:t,contentClassName:n,centered:r,size:l,fullscreen:o,children:i,scrollable:u,...s},a)=>{e=H(e,"modal");const m=`${e}-dialog`,h=typeof o=="string"?`${e}-fullscreen-${o}`:`${e}-fullscreen`;return d.jsx("div",{...s,ref:a,className:M(m,t,l&&`${e}-${l}`,r&&`${m}-centered`,u&&`${m}-scrollable`,o&&h),children:d.jsx("div",{className:M(`${e}-content`,n),children:i})})});kd.displayName="ModalDialog";const Ed=kd,Cd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-footer"),d.jsx(n,{ref:l,className:M(e,t),...r})));Cd.displayName="ModalFooter";const Gv=Cd,Yv=y.forwardRef(({closeLabel:e="Close",closeVariant:t,closeButton:n=!1,onHide:r,children:l,...o},i)=>{const u=y.useContext(xd),s=Me(()=>{u==null||u.onHide(),r==null||r()});return d.jsxs("div",{ref:i,...o,children:[l,n&&d.jsx(Jf,{"aria-label":e,variant:t,onClick:s})]})}),Xv=Yv,Nd=y.forwardRef(({bsPrefix:e,className:t,closeLabel:n="Close",closeButton:r=!1,...l},o)=>(e=H(e,"modal-header"),d.jsx(Xv,{ref:o,...l,className:M(t,e),closeLabel:n,closeButton:r})));Nd.displayName="ModalHeader";const Zv=Nd,Jv=Qf("h4"),Td=y.forwardRef(({className:e,bsPrefix:t,as:n=Jv,...r},l)=>(t=H(t,"modal-title"),d.jsx(n,{ref:l,className:M(e,t),...r})));Td.displayName="ModalTitle";const qv=Td;function bv(e){return d.jsx(Kl,{...e,timeout:null})}function ey(e){return d.jsx(Kl,{...e,timeout:null})}const _d=y.forwardRef(({bsPrefix:e,className:t,style:n,dialogClassName:r,contentClassName:l,children:o,dialogAs:i=Ed,"aria-labelledby":u,"aria-describedby":s,"aria-label":a,show:m=!1,animation:h=!0,backdrop:f=!0,keyboard:w=!0,onEscapeKeyDown:g,onShow:x,onHide:R,container:p,autoFocus:c=!0,enforceFocus:v=!0,restoreFocus:S=!0,restoreFocusOptions:T,onEntered:E,onExit:N,onExiting:j,onEnter:U,onEntering:P,onExited:ie,backdropClassName:Ke,manager:Ge,...on},Qn)=>{const[Re,Ye]=y.useState({}),[C,L]=y.useState(!1),O=y.useRef(!1),D=y.useRef(!1),A=y.useRef(null),[fe,Le]=Gh(),et=mo(Qn,Le),Oe=Me(R),mt=xh();e=H(e,"modal");const ho=y.useMemo(()=>({onHide:Oe}),[Oe]);function un(){return Ge||Vv({isRTL:mt})}function sn($){if(!Vn)return;const an=un().getScrollbarWidth()>0,Zu=$.scrollHeight>po($).documentElement.clientHeight;Ye({paddingRight:an&&!Zu?pa():void 0,paddingLeft:!an&&Zu?pa():void 0})}const Kn=Me(()=>{fe&&sn(fe.dialog)});ed(()=>{Ki(window,"resize",Kn),A.current==null||A.current()});const Br=()=>{O.current=!0},Gn=$=>{O.current&&fe&&$.target===fe.dialog&&(D.current=!0),O.current=!1},It=()=>{L(!0),A.current=Vf(fe.dialog,()=>{L(!1)})},K=$=>{$.target===$.currentTarget&&It()},Hr=$=>{if(f==="static"){K($);return}if(D.current||$.target!==$.currentTarget){D.current=!1;return}R==null||R()},Yn=$=>{w?g==null||g($):($.preventDefault(),f==="static"&&It())},Dd=($,an)=>{$&&sn($),U==null||U($,an)},Id=$=>{A.current==null||A.current(),N==null||N($)},Ad=($,an)=>{P==null||P($,an),Wf(window,"resize",Kn)},Ud=$=>{$&&($.style.display=""),ie==null||ie($),Ki(window,"resize",Kn)},Bd=y.useCallback($=>d.jsx("div",{...$,className:M(`${e}-backdrop`,Ke,!h&&"show")}),[h,Ke,e]),Xu={...n,...Re};Xu.display="block";const Hd=$=>d.jsx("div",{role:"dialog",...$,style:Xu,className:M(t,e,C&&`${e}-static`,!h&&"show"),onClick:f?Hr:void 0,onMouseUp:Gn,"aria-label":a,"aria-labelledby":u,"aria-describedby":s,children:d.jsx(i,{...on,onMouseDown:Br,className:r,contentClassName:l,children:o})});return d.jsx(xd.Provider,{value:ho,children:d.jsx(Av,{show:m,ref:et,backdrop:f,container:p,keyboard:!0,autoFocus:c,enforceFocus:v,restoreFocus:S,restoreFocusOptions:T,onEscapeKeyDown:Yn,onShow:x,onHide:R,onEnter:Dd,onEntering:Ad,onEntered:E,onExit:Id,onExiting:j,onExited:Ud,manager:un(),transition:h?bv:void 0,backdropTransition:h?ey:void 0,renderBackdrop:Bd,renderDialog:Hd})})});_d.displayName="Modal";const ge=Object.assign(_d,{Body:Qv,Header:Zv,Title:qv,Footer:Gv,Dialog:Ed,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150}),ya=1e3;function ty(e,t,n){const r=(e-t)/(n-t)*100;return Math.round(r*ya)/ya}function ga({min:e,now:t,max:n,label:r,visuallyHidden:l,striped:o,animated:i,className:u,style:s,variant:a,bsPrefix:m,...h},f){return d.jsx("div",{ref:f,...h,role:"progressbar",className:M(u,`${m}-bar`,{[`bg-${a}`]:a,[`${m}-bar-animated`]:i,[`${m}-bar-striped`]:i||o}),style:{width:`${ty(t,e,n)}%`,...s},"aria-valuenow":t,"aria-valuemin":e,"aria-valuemax":n,children:l?d.jsx("span",{className:"visually-hidden",children:r}):r})}const jd=y.forwardRef(({isChild:e=!1,...t},n)=>{const r={min:0,max:100,animated:!1,visuallyHidden:!1,striped:!1,...t};if(r.bsPrefix=H(r.bsPrefix,"progress"),e)return ga(r,n);const{min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:f,className:w,children:g,...x}=r;return d.jsx("div",{ref:n,...x,className:M(w,h),children:g?cv(g,R=>y.cloneElement(R,{isChild:!0})):ga({min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:f},n)})});jd.displayName="ProgressBar";const ny=jd,Rd=y.forwardRef(({bsPrefix:e,className:t,as:n="div",...r},l)=>{const o=H(e,"row"),i=Df(),u=If(),s=`${o}-cols`,a=[];return i.forEach(m=>{const h=r[m];delete r[m];let f;h!=null&&typeof h=="object"?{cols:f}=h:f=h;const w=m!==u?`-${m}`:"";f!=null&&a.push(`${s}${w}-${f}`)}),d.jsx(n,{ref:l,...r,className:M(t,o,...a)})});Rd.displayName="Row";const Ld=Rd,Od=y.forwardRef(({bsPrefix:e,variant:t,animation:n="border",size:r,as:l="div",className:o,...i},u)=>{e=H(e,"spinner");const s=`${e}-${n}`;return d.jsx(l,{ref:u,...i,className:M(o,s,r&&`${s}-${r}`,t&&`text-${t}`)})});Od.displayName="Spinner";const Un=Od,Sl="initializing",wa="paused",Pd="live",ry="error",ln=y.createContext({listTorrents:()=>{throw new Error("Function not implemented.")},getTorrentDetails:()=>{throw new Error("Function not implemented.")},getTorrentStats:()=>{throw new Error("Function not implemented.")},uploadTorrent:()=>{throw new Error("Function not implemented.")},pause:()=>{throw new Error("Function not implemented.")},start:()=>{throw new Error("Function not implemented.")},forget:()=>{throw new Error("Function not implemented.")},delete:()=>{throw new Error("Function not implemented.")}}),Ur=y.createContext({setCloseableError:e=>{},refreshTorrents:()=>{}}),Fd=y.createContext({refresh:()=>{}}),Go=({className:e,onClick:t,disabled:n,color:r})=>{const l=o=>{o.stopPropagation(),!n&&t()};return d.jsx("a",{className:`bi ${e} p-1`,onClick:l,href:"#"})},ly=({id:e,show:t,onHide:n})=>{if(!t)return null;const[r,l]=y.useState(!1),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(Ur),m=y.useContext(ln),h=()=>{l(!1),i(null),s(!1),n()},f=()=>{s(!0),(r?m.delete:m.forget)(e).then(()=>{a.refreshTorrents(),h()}).catch(g=>{i({text:`Error deleting torrent id=${e}`,details:g}),s(!1)})};return d.jsxs(ge,{show:t,onHide:h,children:[d.jsx(ge.Header,{closeButton:!0,children:"Delete torrent"}),d.jsxs(ge.Body,{children:[d.jsx(pe,{children:d.jsx(pe.Group,{controlId:"delete-torrent",children:d.jsx(pe.Check,{type:"checkbox",label:"Also delete files",checked:r,onChange:()=>l(!r)})})}),o&&d.jsx(Mr,{error:o})]}),d.jsxs(ge.Footer,{children:[u&&d.jsx(Un,{}),d.jsx(tn,{variant:"primary",onClick:f,disabled:u,children:"OK"}),d.jsx(tn,{variant:"secondary",onClick:h,children:"Cancel"})]})]})},oy=({id:e,statsResponse:t})=>{let n=t.state,[r,l]=y.useState(!1),[o,i]=y.useState(!1),u=y.useContext(Fd);const s=n=="live",a=n=="paused"||n=="error",m=y.useContext(Ur),h=y.useContext(ln),f=()=>{l(!0),h.start(e).then(()=>{u.refresh()},R=>{m.setCloseableError({text:`Error starting torrent id=${e}`,details:R})}).finally(()=>l(!1))},w=()=>{l(!0),h.pause(e).then(()=>{u.refresh()},R=>{m.setCloseableError({text:`Error pausing torrent id=${e}`,details:R})}).finally(()=>l(!1))},g=()=>{l(!0),i(!0)},x=()=>{l(!1),i(!1)};return d.jsx(Ld,{children:d.jsxs(Vu,{children:[a&&d.jsx(Go,{className:"bi-play-circle",onClick:f,disabled:r,color:"success"}),s&&d.jsx(Go,{className:"bi-pause-circle",onClick:w,disabled:r}),d.jsx(Go,{className:"bi-x-circle",onClick:g,disabled:r,color:"danger"}),d.jsx(ly,{id:e,show:o,onHide:x})]})})},iy=({id:e,detailsResponse:t,statsResponse:n})=>{const r=(n==null?void 0:n.state)??"",l=n==null?void 0:n.error,o=(n==null?void 0:n.total_bytes)??1,i=(n==null?void 0:n.progress_bytes)??0,u=(n==null?void 0:n.finished)||!1,s=l?100:i/o*100,a=(r==Sl||r==Pd)&&!u,m=l?"Error":`${s.toFixed(2)}%`,h=l?"danger":u?"success":r==Sl?"warning":"primary",f=()=>{var R;let x=(R=n==null?void 0:n.live)==null?void 0:R.snapshot.peer_stats;return x?`${x.live} / ${x.seen}`:""},w=()=>{var x;if(u)return"Completed";switch(r){case wa:return"Paused";case Sl:return"Checking files";case ry:return"Error"}return((x=n==null?void 0:n.live)==null?void 0:x.download_speed.human_readable)??"N/A"};let g=[];return l?g.push("bg-warning"):e%2==0&&g.push("bg-light"),d.jsxs(Ld,{className:g.join(" "),children:[d.jsx(vt,{size:3,label:"Name",children:t?d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"text-truncate",children:yy(t)}),l&&d.jsxs("p",{className:"text-danger",children:[d.jsx("strong",{children:"Error:"})," ",l]})]}):d.jsx(Un,{})}),n?d.jsxs(d.Fragment,{children:[d.jsx(vt,{label:"Size",children:`${zd(o)} `}),d.jsx(vt,{size:2,label:(r==wa,"Progress"),children:d.jsx(ny,{now:s,label:m,animated:a,variant:h})}),d.jsx(vt,{size:2,label:"Down Speed",children:w()}),d.jsx(vt,{label:"ETA",children:gy(n)}),d.jsx(vt,{size:2,label:"Peers",children:f()}),d.jsx(vt,{label:"Actions",children:d.jsx(oy,{id:e,statsResponse:n})})]}):d.jsx(vt,{label:"Loading stats",size:8,children:d.jsx(Un,{})})]})},vt=({size:e,label:t,children:n})=>d.jsxs(Vu,{md:e||1,className:"py-3",children:[d.jsx("div",{className:"fw-bold",children:t}),n]}),uy=({id:e,torrent:t})=>{const[n,r]=y.useState(null),[l,o]=y.useState(null),[i,u]=y.useState(0),s=y.useContext(ln),a=()=>{u(i+1)};return y.useEffect(()=>{if(n===null)return Sy(async()=>{await s.getTorrentDetails(t.id).then(r)},1e3)},[n]),y.useEffect(()=>$d(async()=>s.getTorrentStats(t.id).then(g=>(o(g),g)).then(g=>g.finished?1e4:g.state==Sl||g.state==Pd?1e3:1e4,()=>1e4),0),[i]),d.jsx(Fd.Provider,{value:{refresh:a},children:d.jsx(iy,{id:e,detailsResponse:n,statsResponse:l})})},sy=e=>{if(e.torrents===null&&e.loading)return d.jsx(Un,{});if(e.torrents!==null)return e.torrents.length===0?d.jsx("div",{className:"text-center",children:d.jsx("p",{children:"No existing torrents found. Add them through buttons below."})}):d.jsx("div",{style:{fontSize:"smaller"},children:e.torrents.map(t=>d.jsx(uy,{id:t.id,torrent:t},t.id))})},ay=e=>{const[t,n]=y.useState(null),[r,l]=y.useState(null),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(ln),m=async()=>{s(!0);let f=await a.listTorrents().finally(()=>s(!1));i(f.torrents)};y.useEffect(()=>$d(async()=>m().then(()=>(l(null),5e3),f=>(l({text:"Error refreshing torrents",details:f}),console.error(f),5e3)),0),[]);const h={setCloseableError:n,refreshTorrents:m};return d.jsx(Ur.Provider,{value:h,children:d.jsxs("div",{className:"text-center",children:[d.jsx("h1",{className:"mt-3 mb-4",children:e.title}),d.jsx(vy,{closeableError:t,otherError:r,torrents:o,torrentsLoading:u})]})})},cy=e=>{let{details:t}=e;return t?d.jsxs(d.Fragment,{children:[t.statusText&&d.jsx("p",{children:d.jsx("strong",{children:t.statusText})}),d.jsx("pre",{children:t.text})]}):null},Mr=e=>{let{error:t,remove:n}=e;return t==null?null:d.jsxs(fa,{variant:"danger",onClose:n,dismissible:n!=null,children:[d.jsx(fa.Heading,{children:t.text}),d.jsx(cy,{details:t.details})]})},Md=({buttonText:e,onClick:t,data:n,resetData:r,variant:l})=>{const[o,i]=y.useState(!1),[u,s]=y.useState(null),[a,m]=y.useState(null),h=y.useContext(ln);y.useEffect(()=>{if(n===null)return;let w=setTimeout(async()=>{i(!0);try{const g=await h.uploadTorrent(n,{list_only:!0});s(g)}catch(g){m({text:"Error listing torrent files",details:g})}finally{i(!1)}},0);return()=>clearTimeout(w)},[n]);const f=()=>{r(),m(null),s(null),i(!1)};return d.jsxs(d.Fragment,{children:[d.jsx(tn,{variant:l,onClick:t,className:"m-1",children:e}),n&&d.jsx(my,{onHide:f,listTorrentError:a,listTorrentResponse:u,data:n,listTorrentLoading:o})]})},fy=({show:e,setUrl:t,cancel:n})=>{let[r,l]=y.useState("");return d.jsxs(ge,{show:e,onHide:n,size:"lg",children:[d.jsx(ge.Header,{closeButton:!0,children:d.jsx(ge.Title,{children:"Add torrent"})}),d.jsx(ge.Body,{children:d.jsx(pe,{children:d.jsxs(pe.Group,{className:"mb-3",controlId:"url",children:[d.jsx(pe.Label,{children:"Enter magnet or HTTP(S) URL to the .torrent"}),d.jsx(pe.Control,{value:r,placeholder:"magnet:?xt=urn:btih:...",onChange:o=>{l(o.target.value)}})]})})}),d.jsxs(ge.Footer,{children:[d.jsx(tn,{variant:"primary",onClick:()=>{t(r),l("")},disabled:r.length==0,children:"OK"}),d.jsx(tn,{variant:"secondary",onClick:n,children:"Cancel"})]})]})},dy=()=>{let[e,t]=y.useState(null),[n,r]=y.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsx(Md,{variant:"primary",buttonText:"Add Torrent from Magnet / URL",onClick:()=>{r(!0)},data:e,resetData:()=>t(null)}),d.jsx(fy,{show:n,setUrl:l=>{r(!1),t(l)},cancel:()=>{r(!1),t(null)}})]})},py=()=>{const e=y.useRef(),[t,n]=y.useState(null),r=async()=>{var u;if(!((u=e==null?void 0:e.current)!=null&&u.files))return;const i=e.current.files[0];n(i)},l=()=>{e!=null&&e.current&&(e.current.value="",n(null))},o=()=>{e!=null&&e.current&&e.current.click()};return d.jsxs(d.Fragment,{children:[d.jsx("input",{type:"file",ref:e,accept:".torrent",onChange:r,className:"d-none"}),d.jsx(Md,{variant:"secondary",buttonText:"Upload .torrent File",onClick:o,data:t,resetData:l})]})},my=e=>{let{onHide:t,listTorrentResponse:n,listTorrentError:r,listTorrentLoading:l,data:o}=e;const[i,u]=y.useState([]),[s,a]=y.useState(!1),[m,h]=y.useState(null),[f,w]=y.useState(!1),[g,x]=y.useState(""),R=y.useContext(Ur),p=y.useContext(ln);y.useEffect(()=>{console.log(n),u(n?n.details.files.map((E,N)=>N):[]),x((n==null?void 0:n.output_folder)||"")},[n]);const c=()=>{t(),u([]),h(null),a(!1)},v=E=>{i.includes(E)?u(i.filter(N=>N!==E)):u([...i,E])},S=async()=>{if(!n)return;a(!0);let E=n.seen_peers?n.seen_peers.slice(0,32):null,N={overwrite:!0,only_files:i,initial_peers:E,output_folder:g};f&&(N.peer_opts={connect_timeout:20,read_write_timeout:60}),p.uploadTorrent(o,N).then(()=>{t(),R.refreshTorrents()},j=>{h({text:"Error starting torrent",details:j})}).finally(()=>a(!1))},T=()=>{if(l)return d.jsx(Un,{});if(r)return d.jsx(Mr,{error:r});if(n)return d.jsxs(pe,{children:[d.jsxs("fieldset",{className:"mb-4",children:[d.jsx("legend",{children:"Pick the files to download"}),n.details.files.map((E,N)=>d.jsx(pe.Group,{controlId:`check-${N}`,children:d.jsx(pe.Check,{type:"checkbox",label:`${E.name} (${zd(E.length)})`,checked:i.includes(N),onChange:()=>v(N)})},N))]}),d.jsxs("fieldset",{children:[d.jsx("legend",{children:"Options"}),d.jsxs(pe.Group,{controlId:"output-folder",className:"mb-3",children:[d.jsx(pe.Label,{children:"Output folder"}),d.jsx(pe.Control,{type:"text",value:g,onChange:E=>x(E.target.value)})]}),d.jsxs(pe.Group,{controlId:"unpopular-torrent",className:"mb-3",children:[d.jsx(pe.Check,{type:"checkbox",label:"Increase timeouts",checked:f,onChange:()=>w(!f)}),d.jsx("small",{id:"emailHelp",className:"form-text text-muted",children:"This might be useful for unpopular torrents with few peers. It will slow down fast torrents though."})]})]})]})};return d.jsxs(ge,{show:!0,onHide:c,size:"lg",children:[d.jsx(ge.Header,{closeButton:!0,children:d.jsx(ge.Title,{children:"Add torrent"})}),d.jsxs(ge.Body,{children:[T(),d.jsx(Mr,{error:m})]}),d.jsxs(ge.Footer,{children:[s&&d.jsx(Un,{}),d.jsx(tn,{variant:"primary",onClick:S,disabled:l||s||i.length==0,children:"OK"}),d.jsx(tn,{variant:"secondary",onClick:c,children:"Cancel"})]})]})},hy=()=>d.jsxs("div",{id:"buttons-container",className:"mt-3",children:[d.jsx(dy,{}),d.jsx(py,{})]}),vy=e=>{let t=y.useContext(Ur);return d.jsxs(pv,{children:[d.jsx(Mr,{error:e.closeableError,remove:()=>t.setCloseableError(null)}),d.jsx(Mr,{error:e.otherError}),d.jsx(sy,{torrents:e.torrents,loading:e.torrentsLoading}),d.jsx(hy,{})]})};function zd(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+n[r]}function yy(e){return e.files.filter(n=>n.included).reduce((n,r)=>n.length>r.length?n:r).name}function gy(e){var n,r,l;let t=(l=(r=(n=e==null?void 0:e.live)==null?void 0:n.time_remaining)==null?void 0:r.duration)==null?void 0:l.secs;return t==null?"N/A":wy(t)}function wy(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60,l=(o,i)=>o>0?`${o}${i}`:"";return t>0?`${l(t,"h")} ${l(n,"m")}`.trim():n>0?`${l(n,"m")} ${l(r,"s")}`.trim():`${l(r,"s")}`.trim()}function $d(e,t){let n,r=t;const l=async()=>{if(r=await e(),r==null)throw"asyncCallback returned null or undefined";o()};let o=()=>{n=setTimeout(l,r)};return o(),()=>{clearTimeout(n)}}function Sy(e,t){let n;const r=async()=>{await e().then(()=>!1,()=>!0)&&l()};let l=o=>{n=setTimeout(r,o!==void 0?o:t)};return l(0),()=>clearTimeout(n)}const xy=window.origin==="null"||window.origin==="http://localhost:3031"?"http://localhost:3030":"",yt=async(e,t,n)=>{console.log(e,t);const r=xy+t,l={method:e,headers:{Accept:"application/json"},body:n};let o={method:e,path:t,text:""},i;try{i=await fetch(r,l)}catch{return o.text="network error",Promise.reject(o)}if(o.status=i.status,o.statusText=`${i.status} ${i.statusText}`,!i.ok){const s=await i.text();try{const a=JSON.parse(s);o.text=a.human_readable!==void 0?a.human_readable:JSON.stringify(a,null,2)}catch{o.text=s}return Promise.reject(o)}return await i.json()},ky={listTorrents:()=>yt("GET","/torrents"),getTorrentDetails:e=>yt("GET",`/torrents/${e}`),getTorrentStats:e=>yt("GET",`/torrents/${e}/stats/v1`),uploadTorrent:(e,t)=>{var r,l;let n="/torrents?&overwrite=true";return t!=null&&t.list_only&&(n+="&list_only=true"),(t==null?void 0:t.only_files)!=null&&(n+=`&only_files=${t.only_files.join(",")}`),(r=t==null?void 0:t.peer_opts)!=null&&r.connect_timeout&&(n+=`&peer_connect_timeout=${t.peer_opts.connect_timeout}`),(l=t==null?void 0:t.peer_opts)!=null&&l.read_write_timeout&&(n+=`&peer_read_write_timeout=${t.peer_opts.read_write_timeout}`),t!=null&&t.initial_peers&&(n+=`&initial_peers=${t.initial_peers.join(",")}`),t!=null&&t.output_folder&&(n+=`&output_folder=${t.output_folder}`),typeof e=="string"&&(n+="&is_url=true"),yt("POST",n,e)},pause:e=>yt("POST",`/torrents/${e}/pause`),start:e=>yt("POST",`/torrents/${e}/start`),forget:e=>yt("POST",`/torrents/${e}/forget`),delete:e=>yt("POST",`/torrents/${e}/delete`)};Yo.createRoot(document.getElementById("app")).render(d.jsx(y.StrictMode,{children:d.jsx(ln.Provider,{value:ky,children:d.jsx(ay,{title:"rqbit web UI - version 4.0.0-beta.3"})})})); diff --git a/crates/librqbit/webui/dist/manifest.json b/crates/librqbit/webui/dist/manifest.json index 716bea5..f2846c2 100644 --- a/crates/librqbit/webui/dist/manifest.json +++ b/crates/librqbit/webui/dist/manifest.json @@ -4,7 +4,7 @@ "src": "assets/logo.svg" }, "index.html": { - "file": "assets/index-3e661b92.js", + "file": "assets/index-6d4556f3.js", "isEntry": true, "src": "index.html" }