qBitrr2 5.4.2__py3-none-any.whl → 5.4.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qBitrr/auto_update.py +279 -25
- qBitrr/bundled_data.py +2 -2
- qBitrr/main.py +44 -5
- qBitrr/static/assets/LogsView.js +18 -18
- qBitrr/static/assets/LogsView.js.map +1 -1
- qBitrr/static/assets/app.js +2 -2
- qBitrr/static/assets/app.js.map +1 -1
- qBitrr/static/index.html +22 -8
- qBitrr/versioning.py +35 -2
- qBitrr/webui.py +89 -3
- {qbitrr2-5.4.2.dist-info → qbitrr2-5.4.4.dist-info}/METADATA +223 -18
- {qbitrr2-5.4.2.dist-info → qbitrr2-5.4.4.dist-info}/RECORD +16 -16
- {qbitrr2-5.4.2.dist-info → qbitrr2-5.4.4.dist-info}/WHEEL +0 -0
- {qbitrr2-5.4.2.dist-info → qbitrr2-5.4.4.dist-info}/entry_points.txt +0 -0
- {qbitrr2-5.4.2.dist-info → qbitrr2-5.4.4.dist-info}/licenses/LICENSE +0 -0
- {qbitrr2-5.4.2.dist-info → qbitrr2-5.4.4.dist-info}/top_level.txt +0 -0
qBitrr/static/assets/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProcessesView.js","assets/table.js","assets/vendor.js","assets/useInterval.js","assets/LogsView.js","assets/react-select.esm.js","assets/ArrView.js","assets/ConfigView.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as
|
|
2
|
+
import{r as Ee,a as Re}from"./vendor.js";import{r as o}from"./table.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const f of a.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&i(f)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();var F={exports:{}},A={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.min.js
|
|
5
5
|
*
|
|
@@ -7,5 +7,5 @@ import{r as Re,a as Le}from"./vendor.js";import{r as o}from"./table.js";(functio
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var re;function Ne(){if(re)return P;re=1;var e=Re(),s=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function f(h,m,c){var p,y={},d=null,g=null;c!==void 0&&(d=""+c),m.key!==void 0&&(d=""+m.key),m.ref!==void 0&&(g=m.ref);for(p in m)i.call(m,p)&&!a.hasOwnProperty(p)&&(y[p]=m[p]);if(h&&h.defaultProps)for(p in m=h.defaultProps,m)y[p]===void 0&&(y[p]=m[p]);return{$$typeof:s,type:h,key:d,ref:g,props:y,_owner:r.current}}return P.Fragment=n,P.jsx=f,P.jsxs=f,P}var ne;function Ie(){return ne||(ne=1,F.exports=Ne()),F.exports}var t=Ie(),q={},oe;function Te(){if(oe)return q;oe=1;var e=Le();return q.createRoot=e.createRoot,q.hydrateRoot=e.hydrateRoot,q}var Pe=Te();const Ue="modulepreload",$e=function(e){return"/static/"+e},ae={},W=function(s,n,i){let r=Promise.resolve();if(n&&n.length>0){let m=function(c){return Promise.all(c.map(p=>Promise.resolve(p).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),h=f?.nonce||f?.getAttribute("nonce");r=m(n.map(c=>{if(c=$e(c),c in ae)return;ae[c]=!0;const p=c.endsWith(".css"),y=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${y}`))return;const d=document.createElement("link");if(d.rel=p?"stylesheet":Ue,p||(d.as="script"),d.crossOrigin="",d.href=c,h&&d.setAttribute("nonce",h),document.head.appendChild(d),p)return new Promise((g,v)=>{d.addEventListener("load",g),d.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(f){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=f,window.dispatchEvent(h),!h.defaultPrevented)throw f}return r.then(f=>{for(const h of f||[])h.status==="rejected"&&a(h.reason);return s().catch(a)})},ue=o.createContext(void 0);let Ae=0;function Oe({children:e}){const[s,n]=o.useState([]),i=o.useCallback(f=>{n(h=>h.filter(m=>m.id!==f))},[]),r=o.useCallback((f,h="info")=>{const m=++Ae;n(c=>[...c,{id:m,message:f,kind:h}]),window.setTimeout(()=>i(m),3500)},[i]),a=o.useMemo(()=>({toasts:s,push:r,dismiss:i}),[s,r,i]);return t.jsx(ue.Provider,{value:a,children:e})}function de(){const e=o.useContext(ue);if(!e)throw new Error("useToast must be used within a ToastProvider");return e}function De(){const{toasts:e,dismiss:s}=de();return e.length?t.jsx("div",{className:"toasts",children:e.map(n=>t.jsx("div",{className:`toast ${n.kind!=="info"?n.kind:""}`,role:"status",onClick:()=>s(n.id),children:n.message},n.id))}):null}const fe=o.createContext(void 0);function Ve({children:e}){const[s,n]=o.useState(""),i=o.useRef(new Set),r=o.useCallback(m=>{n(m),i.current.forEach(c=>{c?.(m)})},[]),a=o.useCallback(m=>{m&&i.current.add(m)},[]),f=o.useCallback(m=>{i.current.delete(m)},[]),h=o.useMemo(()=>({value:s,setValue:r,register:a,clearHandler:f}),[s,r,a,f]);return t.jsx(fe.Provider,{value:h,children:e})}function Me(){const e=o.useContext(fe);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e}const qe={"Content-Type":"application/json"},Y=["token","webui-token","webui_token"],Be=1,J=new Map;function We(e,s){const n=e instanceof Request?e.url:String(e),i=s?.method||"GET",r=s?.body?String(s.body):"";return`${i}:${n}:${r}`}function me(){for(const e of Y){const s=localStorage.getItem(e)||sessionStorage.getItem(e);if(s)return e!=="token"&&localStorage.setItem("token",s),s}try{const s=new URLSearchParams(window.location.search).get("token");if(s)return localStorage.setItem("token",s),s}catch{}return null}function Ge(){for(const e of Y)localStorage.removeItem(e);try{for(const e of Y)sessionStorage.removeItem(e)}catch{}}function he(e,s){const n=new Headers(e?.headers||{});return Object.entries(qe).forEach(([i,r])=>{n.has(i)||n.set(i,r)}),s&&!n.has("Authorization")&&n.set("Authorization",`Bearer ${s}`),{...e,headers:n}}async function B(e,s,n,i=Be){const r=me(),a=await fetch(e,he(s,r));return a.status===401&&i>0&&r?(Ge(),B(e,s,n,i-1)):n(a)}async function k(e,s){if((s?.method||"GET")==="GET"){const i=We(e,s),r=J.get(i);if(r)return r;const a=B(e,s,f=>ce(f)).finally(()=>{J.delete(i)});return J.set(i,a),a}return B(e,s,i=>ce(i))}async function He(e,s){return B(e,s,n=>ze(n))}async function ce(e){if(!e.ok){let s=null;try{s=await e.json()}catch{}let n=`${e.status} ${e.statusText}`;if(s&&typeof s=="object"&&"error"in s&&typeof s.error=="string"){const i=s.error;i.trim()&&(n=i)}throw new Error(n)}return await e.json()}async function ze(e){if(!e.ok)throw new Error(`${e.status} ${e.statusText}`);return e.text()}async function ie(e){const s=e?.force?"?force=1":"";return k(`/web/meta${s}`)}async function le(){return k("/web/status")}async function gt(){return k("/web/processes")}async function pt(e,s){const n=`/web/processes/${encodeURIComponent(e)}/${encodeURIComponent(s)}/restart`;return k(n,{method:"POST"})}async function vt(){return k("/web/processes/restart_all",{method:"POST"})}async function yt(){return k("/web/arr/rebuild",{method:"POST"})}async function wt(){return k("/web/logs")}async function bt(e){return He(`/web/logs/${encodeURIComponent(e)}`)}function xt(e){return`/web/logs/${encodeURIComponent(e)}/download`}async function _t(){return k("/web/arr")}async function jt(e,s,n,i){const r=new URLSearchParams;return r.set("page",String(s)),r.set("page_size",String(n)),i&&r.set("q",i),k(`/web/radarr/${encodeURIComponent(e)}/movies?${r}`)}async function kt(e,s,n,i,r){const a=new URLSearchParams;return a.set("page",String(s)),a.set("page_size",String(n)),i&&a.set("q",i),r?.missingOnly&&a.set("missing","1"),k(`/web/sonarr/${encodeURIComponent(e)}/series?${a}`)}async function Ct(e,s,n,i){const r=new URLSearchParams;return r.set("page",s.toString()),r.set("page_size",n.toString()),i&&r.set("q",i),r.set("include_tracks","true"),k(`/web/lidarr/${encodeURIComponent(e)}/albums?${r}`)}async function St(e){await k(`/web/arr/${encodeURIComponent(e)}/restart`,{method:"POST"})}async function Fe(){return k("/web/config")}async function Je(e){const s=me(),n=await fetch("/web/config",he({method:"POST",body:JSON.stringify(e)},s));if(!n.ok){let r=null;try{r=await n.json()}catch{}let a=`${n.status} ${n.statusText}`;if(r&&typeof r=="object"&&"error"in r&&typeof r.error=="string"){const f=r.error;f.trim()&&(a=f)}throw new Error(a)}return await n.json()}async function Ke(){await k("/web/update",{method:"POST"})}const ge=o.createContext(null);function Ye({children:e}){const[s,n]=o.useState({liveArr:!0,groupSonarr:!0,groupLidarr:!0,viewDensity:"comfortable",theme:"dark"}),[i,r]=o.useState(!0);o.useEffect(()=>{(async()=>{try{const v=(await Fe())?.WebUI,x=localStorage.getItem("viewDensity"),S=localStorage.getItem("theme"),I=v?.Theme,E=S||I?.toLowerCase()||"dark";n({liveArr:v?.LiveArr===!0,groupSonarr:v?.GroupSonarr===!0,groupLidarr:v?.GroupLidarr===!0,viewDensity:x||"comfortable",theme:E}),document.documentElement.setAttribute("data-theme",E)}catch(g){console.error("Failed to load WebUI settings:",g)}finally{r(!1)}})()},[]);const a=o.useCallback(async(d,g)=>{try{const v={WebUI:{[d]:g}};await Je({changes:v})}catch(v){console.error(`Failed to save ${d}:`,v)}},[]),f=o.useCallback(d=>{n(g=>({...g,liveArr:d})),a("LiveArr",d)},[a]),h=o.useCallback(d=>{n(g=>({...g,groupSonarr:d})),a("GroupSonarr",d)},[a]),m=o.useCallback(d=>{n(g=>({...g,groupLidarr:d})),a("GroupLidarr",d)},[a]),c=o.useCallback(d=>{n(g=>({...g,viewDensity:d})),localStorage.setItem("viewDensity",d)},[]),p=o.useCallback(d=>{n(v=>({...v,theme:d})),localStorage.setItem("theme",d),document.documentElement.setAttribute("data-theme",d),a("Theme",d==="light"?"Light":"Dark")},[a]),y={liveArr:s.liveArr,groupSonarr:s.groupSonarr,groupLidarr:s.groupLidarr,viewDensity:s.viewDensity,theme:s.theme,setLiveArr:f,setGroupSonarr:h,setGroupLidarr:m,setViewDensity:c,setTheme:p,loading:i};return t.jsx(ge.Provider,{value:y,children:e})}function Qe(){const e=o.useContext(ge);if(!e)throw new Error("useWebUI must be used within WebUIProvider");return e}function Xe(){const[e,s]=o.useState(navigator.onLine);return o.useEffect(()=>{const n=()=>s(!0),i=()=>s(!1);return window.addEventListener("online",n),window.addEventListener("offline",i),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",i)}},[]),e}function C({src:e,alt:s,className:n,...i}){return t.jsx("img",{src:e,alt:s??"",className:n?`icon ${n}`:"icon","aria-hidden":s?void 0:!0,...i})}const pe="/static/assets/close.svg",Q="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20viewBox='0%200%20512%20512'%3e%3cpath%20d='M256%206.3C114.6%206.3%200%20120.9%200%20262.3c0%20113.3%2073.3%20209%20175%20242.9%2012.8%202.2%2017.6-5.4%2017.6-12.2%200-6.1-.3-26.2-.3-47.7-64.3%2011.8-81-15.7-86.1-30.1-2.9-7.4-15.4-30.1-26.2-36.2-9-4.8-21.8-16.6-.3-17%2020.2-.3%2034.6%2018.6%2039.4%2026.2%2023%2038.7%2059.8%2027.8%2074.6%2021.1%202.2-16.6%209-27.8%2016.3-34.2-57-6.4-116.5-28.5-116.5-126.4%200-27.8%209.9-50.9%2026.2-68.8-2.6-6.4-11.5-32.6%202.6-67.8%200%200%2021.4-6.7%2070.4%2026.2%2020.5-5.8%2042.2-8.6%2064-8.6s43.5%202.9%2064%208.6c49-33.3%2070.4-26.2%2070.4-26.2%2014.1%2035.2%205.1%2061.4%202.6%2067.8%2016.3%2017.9%2026.2%2040.6%2026.2%2068.8%200%2098.2-59.8%20120-116.8%20126.4%209.3%208%2017.3%2023.4%2017.3%2047.4%200%2034.2-.3%2061.8-.3%2070.4%200%206.7%204.8%2014.7%2017.6%2012.2C438.7%20471.3%20512%20375.3%20512%20262.3c0-141.4-114.6-256-256-256'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%231b1f23'/%3e%3c/svg%3e",Ze="/static/assets/refresh-arrow.svg",ve="/static/assets/up-arrow.svg",et="/static/assets/process.svg",tt="/static/assets/log.svg",st="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20id='Layer_1'%20x='0'%20y='0'%20version='1.1'%20viewBox='0%200%20512%20512'%3e%3cstyle%3e.st0{fill:%2324292e}%3c/style%3e%3cg%20id='Group-Copy'%20transform='translate(70%2021)'%3e%3cpath%20id='Shape'%20d='m10.3%2059.8%203.9%20372.4c-31.4%203.9-54.9-11.8-54.9-43.1l-3.9-309.7c0-98%2090.2-121.5%20145.1-82.3l278.3%20160.7c39.2%2027.4%2047%2078.4%2027.4%20113.7-3.9-27.4-15.7-43.1-39.2-58.8L53.4%2036.2C29.9%2020.6%2010.3%2024.5%2010.3%2059.8'%20class='st0'/%3e%3cpath%20id='Shape_00000114049535938561773820000018271523940913105341_'%20d='M-13.2%20451.8c23.5%207.8%2047%203.9%2066.6-7.8l321.5-188.2c19.6%2027.4%2015.7%2054.9-7.8%2070.6L96.5%20483.2c-39.2%2019.6-90.1%200-109.7-31.4'%20class='st0'/%3e%3cpath%20id='Shape_00000165935924413286433040000003668002807793862576_'%20d='M80.9%20342%20273%20232.3%2084.8%20126.4z'%20style='fill:%23ffc230'/%3e%3c/g%3e%3c/svg%3e",rt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20viewBox='0%200%20512%20512'%3e%3cpath%20d='M511.8%20256c0%2070.4-24.9%20130.8-74.6%20181.1-1.7%202-3.5%203.8-5.5%205.4-8.2%208-16.8%2015.3-26%2021.8Q341.05%20512%20256.3%20512c-56.6%200-106.3-15.9-149.2-47.7-11.3-8-22-17.1-31.9-27.3C36.5%20398.7%2012.8%20354%204%20303.2c-1.7-9.9-2.9-20-3.4-30.2-.2-5.7-.4-11.3-.4-17%200-6%20.1-11.7.4-17.1%200-.6.2-1.1.5-1.7%203.7-62.8%2028.4-117%2074.1-162.8C125.5%2024.8%20185.8%200%20256.2%200c70.7%200%20131%2024.8%20180.9%2074.5q74.7%2075.9%2074.7%20181.5'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%23eee'/%3e%3cpath%20d='m459.7%20100.3-52.9%2052.9c-30.9%2030.9-33.6%2057.8-33.6%20105.3%200%2042.3%206.7%2081.1%2038.2%20112.6%2023%2023%2044.9%2044.7%2044.9%2044.7-5.9%207.2-12.3%2014.3-19.1%2021.2-1.7%202-3.5%203.8-5.5%205.4-6%205.9-12.2%2011.4-18.6%2016.4l-41.4-41.4C334.9%20380.6%20305.6%20377%20257%20377c-46.7%200-78.4%204.3-112.6%2038.5-20.4%2020.4-43.8%2043.9-43.8%2043.9-8.9-6.8-17.3-14.2-25.3-22.4-6.6-6.6-12.8-13.4-18.5-20.3%200%200%2023.1-23.2%2045.2-45.3%2032.7-32.7%2038-70.6%2038-113%200-41.3-6.8-79.8-36.8-109.9C82.2%20127.7%2053.3%2099%2053.3%2099c6.7-8.5%2014-16.7%2021.8-24.5%206.9-6.8%2014-13.1%2021.2-19l48%2048c30.7%2030.7%2070%2038.6%20112.4%2038.6%2043.6%200%2082.8-8.4%20114.7-40.4C391%2082.1%20417%2056.3%20417%2056.3c6.8%205.6%2013.5%2011.6%2020.1%2018.2%208.3%208.3%2015.8%2016.9%2022.6%2025.8'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%233a3f51'/%3e%3cpath%20d='M186%20269.1c-.5-2.8-.8-5.5-.9-8.4-.1-1.6-.1-3.1-.1-4.7%200-1.7%200-3.2.1-4.7%200-.2%200-.3.1-.5%201-17.4%207.9-32.4%2020.5-45.1%2013.9-13.8%2030.6-20.7%2050.2-20.7s36.3%206.9%2050.2%2020.7c13.8%2014%2020.7%2030.8%2020.7%2050.3s-6.9%2036.2-20.7%2050.2c-.5.5-1%201.1-1.5%201.5q-3.45%203.3-7.2%206-18%2013.2-41.4%2013.2c-23.4%200-29.4-4.4-41.3-13.2-3.1-2.2-6.1-4.7-8.9-7.6-10.8-10.6-17.3-22.9-19.8-37'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%230cf'/%3e%3cpath%20d='m372.7%20141-35.4%2034.6M72.9%2076.8l96.5%2096.1m199.7%20198.9%2065.6%2067.9m4.4-363.3L372.7%20141M76.6%20438.5l64.6-64.7'%20style='fill:none;stroke:%230cf;stroke-width:2;stroke-miterlimit:1'/%3e%3cpath%20d='m372.7%20141-40%2040.6m-193.3-38.5%2040.6%2040.5M141%20374l39.5-41.1m146.2-3.3%2042.6%2042.4'%20style='fill:none;stroke:%230cf;stroke-width:7;stroke-miterlimit:1'/%3e%3c/svg%3e",nt="/static/assets/lidarr.svg",ot="/static/assets/gear.svg",at=o.lazy(()=>W(()=>import("./ProcessesView.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.ProcessesView}))),ct=o.lazy(()=>W(()=>import("./LogsView.js"),__vite__mapDeps([4,1,2,5,3])).then(e=>({default:e.LogsView}))),K=o.lazy(()=>W(()=>import("./ArrView.js"),__vite__mapDeps([6,1,2,3])).then(e=>({default:e.ArrView}))),it=o.lazy(()=>W(()=>import("./ConfigView.js"),__vite__mapDeps([7,1,2,5])).then(e=>({default:e.ConfigView})));function U(e){if(!e)return"unknown";const s=e.trim();return s?s[0]==="v"||s[0]==="V"?s:`v${s}`:"unknown"}function lt({currentVersion:e,changelog:s,changelogUrl:n,repositoryUrl:i,onClose:r}){return t.jsx("div",{className:"modal-backdrop",role:"presentation",onClick:r,children:t.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"welcome-title",onClick:a=>a.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsxs("h2",{id:"welcome-title",children:["🎉 Welcome to qBitrr ",U(e),"!"]}),t.jsxs("button",{className:"btn ghost",type:"button",onClick:r,children:[t.jsx(C,{src:pe}),"Close"]})]}),t.jsxs("div",{className:"modal-body changelog-modal__body",children:[t.jsx("div",{className:"changelog-meta",children:t.jsxs("p",{style:{marginBottom:"1rem",color:"var(--text-secondary)"},children:["You've been updated to version ",t.jsx("strong",{children:U(e)}),". Here's what's new in this release:"]})}),t.jsxs("div",{className:"changelog-section",children:[t.jsx("h3",{children:"Release Notes"}),t.jsx("pre",{className:"changelog-body",children:s?.trim()?s.trim():"No changelog available for this version."})]})]}),t.jsxs("div",{className:"modal-footer",children:[t.jsx("div",{className:"changelog-links",children:(n||i)&&t.jsxs("a",{className:"btn ghost small",href:n??i,target:"_blank",rel:"noreferrer",children:[t.jsx(C,{src:Q}),"View Full Release on GitHub"]})}),t.jsx("div",{className:"changelog-buttons",children:t.jsx("button",{className:"btn primary",type:"button",onClick:r,children:"Got it!"})})]})]})})}function ut({currentVersion:e,latestVersion:s,changelog:n,changelogUrl:i,repositoryUrl:r,updateState:a,updating:f,onClose:h,onUpdate:m}){const[c,p]=o.useState(null),y=f||!!a?.in_progress,d=a?.completed_at?new Date(a.completed_at).toLocaleString():null;o.useEffect(()=>{if(a?.last_result==="success"&&a?.completed_at){let x=10;p(x);const S=setInterval(()=>{x-=1,x<=0?(clearInterval(S),window.location.reload()):p(x)},1e3);return()=>clearInterval(S)}},[a?.last_result,a?.completed_at]);let g="",v=null;if(a?.in_progress)g="text-info",v="⏳ Update in progress...";else if(a?.last_result==="success")g="text-success",c!==null?v=`✓ Update completed! Reloading in ${c}s...`:(v="✓ Update completed successfully",d&&(v=`${v} (${d})`));else if(a?.last_result==="error"){g="text-danger";const x=a.last_error?a.last_error.trim():"";v=x?`✗ Update failed: ${x}`:"✗ Update failed"}return t.jsx("div",{className:"modal-backdrop",role:"presentation",onClick:h,children:t.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"changelog-title",onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsx("h2",{id:"changelog-title",children:a?.in_progress?"⚙️ Updating...":"🚀 Update Available"}),t.jsxs("button",{className:"btn ghost",type:"button",onClick:h,disabled:a?.in_progress,children:[t.jsx(C,{src:pe}),"Close"]})]}),t.jsxs("div",{className:"modal-body changelog-modal__body",children:[t.jsxs("div",{className:"changelog-meta",children:[t.jsxs("div",{className:"version-comparison",children:[t.jsxs("span",{className:"version-item",children:[t.jsx("strong",{children:"Current:"})," ",t.jsx("span",{className:"version-badge version-current",children:U(e)})]}),t.jsx("span",{className:"version-arrow",children:"→"}),t.jsxs("span",{className:"version-item",children:[t.jsx("strong",{children:"Latest:"})," ",t.jsx("span",{className:"version-badge version-latest",children:s?U(s):"Unknown"})]})]}),v?t.jsx("div",{className:`update-status ${g}`,children:v}):null]}),t.jsxs("div",{className:"changelog-section",children:[t.jsx("h3",{children:"What's New"}),t.jsx("pre",{className:"changelog-body",children:n?.trim()?n.trim():"No changelog provided."})]})]}),t.jsxs("div",{className:"modal-footer",children:[t.jsx("div",{className:"changelog-links",children:(i||r)&&t.jsxs("a",{className:"btn ghost small",href:i??r,target:"_blank",rel:"noreferrer",children:[t.jsx(C,{src:Q}),"View on GitHub"]})}),t.jsx("div",{className:"changelog-buttons",children:t.jsxs("button",{className:"btn primary",type:"button",onClick:m,disabled:y,children:[t.jsx(C,{src:ve}),y?"Updating...":"Update Now"]})})]})]})})}function dt(){const[e,s]=o.useState("processes"),[n,i]=o.useState(!1),{push:r}=de(),{setValue:a}=Me(),{viewDensity:f,setViewDensity:h}=Qe(),m=Xe(),[c,p]=o.useState(null),[y,d]=o.useState(!1),[g,v]=o.useState(!1),[x,S]=o.useState(!1),[I,E]=o.useState(!1),R=o.useRef(0),G=o.useRef(null),H=o.useRef(!1),$=o.useRef(!1),L=o.useRef(null),[N,X]=o.useState(0),[Z,ee]=o.useState(null),[ye,te]=o.useState(!1);o.useEffect(()=>{(async()=>{if("caches"in window)try{const l=await caches.keys();await Promise.all(l.map(b=>caches.delete(b))),console.log("Cache cleared on page load")}catch(l){console.error("Failed to clear cache:",l)}})()},[]);const _=o.useCallback(async u=>{const l=u?.force??!1,b=u?.silent??!l;b||d(!0);try{const j=await ie({force:l});p(j)}catch(j){if(!b){const w=j instanceof Error?j.message:"Failed to fetch version information";r(w,"error")}}finally{b||d(!1)}},[r]);o.useEffect(()=>{_({force:!0})},[_]),o.useEffect(()=>{if(!c?.current_version)return;const u=localStorage.getItem("lastSeenVersion"),l=c.current_version;u&&u!==l&&(!c.current_version_changelog&&!c.changelog&&_({force:!0,silent:!0}),te(!0)),u||localStorage.setItem("lastSeenVersion",l)},[c?.current_version,c?.changelog,_]),o.useEffect(()=>{m||r("You are offline. Some features may not work.","warning")},[m,r]),o.useEffect(()=>{const u=l=>{if(l.target instanceof HTMLInputElement||l.target instanceof HTMLTextAreaElement||l.target instanceof HTMLSelectElement)return;const b=l.ctrlKey||l.metaKey;if(b&&l.key==="k"){l.preventDefault(),document.querySelector('input[type="text"][placeholder*="Search"]')?.focus();return}if(l.key==="r"||l.key==="R"){l.preventDefault(),X(j=>j+1),r("Refreshed","success");return}if(l.key==="Escape"){a("");return}if(l.key>="1"&&l.key<="6"&&!b){l.preventDefault();const j=parseInt(l.key)-1,w=["processes","logs","radarr","sonarr","lidarr","config"];j<w.length&&s(w[j]);return}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a,r]),o.useEffect(()=>{const u=window.setInterval(()=>{_()},3e5);return()=>window.clearInterval(u)},[_]),o.useEffect(()=>{const u=()=>{document.visibilityState==="visible"&&(X(l=>l+1),_({force:!0}),A())};return document.addEventListener("visibilitychange",u),()=>{document.removeEventListener("visibilitychange",u)}},[_]);const A=o.useCallback(async()=>{try{const u=await le();ee(u)}catch{}},[]);o.useEffect(()=>{A();const u=window.setInterval(()=>{A()},5*1e3);return()=>window.clearInterval(u)},[A]),o.useEffect(()=>{if(!c?.update_state?.in_progress&&!I){R.current=0;return}const u=window.setInterval(async()=>{try{const l=await ie({force:!0});p(l),I&&window.location.reload(),R.current=0}catch{if(R.current+=1,R.current>20){E(!1),R.current=0,r("Update completed but backend restart timed out. Please refresh the page manually.","warning");return}c?.update_state?.in_progress&&E(!0)}},3e3);return()=>window.clearInterval(u)},[c?.update_state?.in_progress,I,c,r]),o.useEffect(()=>{const u=c?.update_state;if(!u){G.current=null;return}const l=u.last_result??null;l&&l!==G.current&&(l==="success"?(r("Update completed successfully. Restarting...","success"),E(!0),R.current=0):l==="error"&&r(u.last_error||"Update failed.","error")),G.current=l},[c?.update_state,r]),o.useEffect(()=>{let u=!1,l=0;const b=w=>{L.current!==null&&window.clearTimeout(L.current),L.current=window.setTimeout(()=>{j()},w)},j=async()=>{if(!(u||H.current)){l+=1;try{const w=await le();if(u)return;if(ee(w),w.ready??(Array.isArray(w.arrs)&&w.arrs.length>0)){H.current=!0;return}w.ready===!1&&l>=3&&!$.current&&($.current=!0,r("qBitrr backend is still initialising. Check the logs if this persists.","warning"))}catch(w){if(!$.current&&l>=3){$.current=!0;const M=w instanceof Error?w.message:"Unknown backend error";r(`Unable to confirm qBitrr readiness (${M}). Please inspect the logs.`,"warning")}}finally{if(!u&&!H.current){const w=l<3?3e3:1e4;b(w)}}}};return b(0),()=>{u=!0,L.current!==null&&(window.clearTimeout(L.current),L.current=null)}},[r]);const O=o.useMemo(()=>{const u=[{id:"processes",label:"Processes",icon:et},{id:"logs",label:"Logs",icon:tt}],l=[],b=Z?.arrs??[],j=b.some(T=>T.type==="radarr"),w=b.some(T=>T.type==="sonarr"),M=b.some(T=>T.type==="lidarr");return j&&l.push({id:"radarr",label:"Radarr",icon:st}),w&&l.push({id:"sonarr",label:"Sonarr",icon:rt}),M&&l.push({id:"lidarr",label:"Lidarr",icon:nt}),[...u,...l,{id:"config",label:"Config",icon:ot}]},[Z]),D=c?.repository_url??"https://github.com/Feramance/qBitrr",we=c?.current_version?U(c.current_version):"...",be=c?.latest_version??null,xe=!!c?.update_available,z=c?.update_state,se=c?.changelog_url??D,V=[];c?.last_checked&&V.push(`Last checked ${new Date(c.last_checked).toLocaleString()}`),c?.error&&V.push(`Update check failed: ${c.error}`);const _e=V.length?V.join(" • "):void 0;o.useEffect(()=>{!O.some(l=>l.id===e)&&O.length>0&&s("processes")},[O,e]);const je=o.useCallback(()=>{_({force:!0})},[_]),ke=o.useCallback(()=>{v(!0),c?.changelog||_({force:!0,silent:!0})},[c?.changelog,_]),Ce=o.useCallback(()=>{v(!1)},[]),Se=o.useCallback(()=>{te(!1),c?.current_version&&localStorage.setItem("lastSeenVersion",c.current_version)},[c?.current_version]),Ee=o.useCallback(async()=>{S(!0),E(!1),R.current=0;try{await Ke(),r("Update started in the background.","info"),await _({force:!0,silent:!0})}catch(u){const l=u instanceof Error?u.message:"Failed to start update";r(l,"error")}finally{S(!1)}},[r,_]);return t.jsxs("div",{"data-density":f,children:[t.jsx("header",{className:"appbar",children:t.jsxs("div",{className:"appbar__inner",children:[t.jsxs("div",{className:"appbar__title",children:[t.jsx("h1",{children:"qBitrr"}),t.jsx("span",{className:"appbar__version",title:_e,children:we}),y?t.jsx("span",{className:"spinner","aria-hidden":"true"}):null,z?.in_progress?t.jsx("span",{className:"appbar__status text-info",children:"Updating..."}):null,xe?t.jsxs("button",{type:"button",className:"btn small primary appbar__update",onClick:ke,disabled:x||!!z?.in_progress,children:[t.jsx("span",{className:"appbar__update-indicator","aria-hidden":"true"}),t.jsx(C,{src:ve}),"Update available"]}):null]}),t.jsxs("div",{className:"appbar__actions",children:[!m&&t.jsx("span",{className:"badge",style:{background:"rgba(239, 68, 68, 0.15)",borderColor:"rgba(239, 68, 68, 0.3)",color:"var(--danger)"},children:"Offline"}),t.jsxs("div",{className:"view-density-toggle",children:[t.jsx("button",{type:"button",className:f==="comfortable"?"active":"",onClick:()=>h("comfortable"),title:"Comfortable view",children:"Comfortable"}),t.jsx("button",{type:"button",className:f==="compact"?"active":"",onClick:()=>h("compact"),title:"Compact view",children:"Compact"})]}),t.jsxs("button",{type:"button",className:"btn small ghost",onClick:je,disabled:y,children:[t.jsx(C,{src:Ze}),y?"Checking...":"Check Updates"]}),t.jsxs("a",{href:D,target:"_blank",rel:"noreferrer",className:"btn small ghost",children:[t.jsx(C,{src:Q}),"GitHub"]})]})]})}),t.jsxs("main",{className:"container",children:[t.jsx("nav",{className:"nav",children:O.map(u=>t.jsxs("button",{type:"button",className:e===u.id?"active":"",onClick:()=>{e==="config"&&u.id!=="config"&&n&&!window.confirm("You have unsaved configuration changes. Leave without saving?")||(s(u.id),a(""))},children:[t.jsx(C,{src:u.icon}),t.jsx("span",{children:u.label})]},u.id))}),t.jsxs(o.Suspense,{fallback:t.jsx("div",{className:"loading",children:"Loading..."}),children:[e==="processes"&&t.jsx(at,{active:!0},`processes-${N}`),e==="logs"&&t.jsx(ct,{active:!0},`logs-${N}`),e==="radarr"&&t.jsx(K,{type:"radarr",active:!0},`radarr-${N}`),e==="sonarr"&&t.jsx(K,{type:"sonarr",active:!0},`sonarr-${N}`),e==="lidarr"&&t.jsx(K,{type:"lidarr",active:!0},`lidarr-${N}`),e==="config"&&t.jsx(it,{onDirtyChange:i},`config-${N}`)]})]}),g&&c?t.jsx(ut,{currentVersion:c.current_version,latestVersion:be,changelog:c.changelog,changelogUrl:se,repositoryUrl:D,updateState:z,updating:x,onClose:Ce,onUpdate:Ee}):null,ye&&c?t.jsx(lt,{currentVersion:c.current_version,changelog:c.current_version_changelog||c.changelog,changelogUrl:se,repositoryUrl:D,onClose:Se}):null]})}function ft(){return t.jsx(Oe,{children:t.jsx(Ve,{children:t.jsxs(Ye,{children:[t.jsx(dt,{}),t.jsx(De,{})]})})})}Pe.createRoot(document.getElementById("root")).render(t.jsx(o.StrictMode,{children:t.jsx(ft,{})}));export{pe as C,C as I,Ze as R,le as a,vt as b,yt as c,wt as d,bt as e,xt as f,gt as g,Me as h,Qe as i,t as j,_t as k,jt as l,St as m,kt as n,Ct as o,Fe as p,Je as q,pt as r,ot as s,de as u};
|
|
10
|
+
*/var se;function Ne(){if(se)return A;se=1;var e=Ee(),r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function f(h,m,c){var g,v={},u=null,p=null;c!==void 0&&(u=""+c),m.key!==void 0&&(u=""+m.key),m.ref!==void 0&&(p=m.ref);for(g in m)i.call(m,g)&&!a.hasOwnProperty(g)&&(v[g]=m[g]);if(h&&h.defaultProps)for(g in m=h.defaultProps,m)v[g]===void 0&&(v[g]=m[g]);return{$$typeof:r,type:h,key:u,ref:p,props:v,_owner:s.current}}return A.Fragment=n,A.jsx=f,A.jsxs=f,A}var ne;function Le(){return ne||(ne=1,F.exports=Ne()),F.exports}var t=Le(),W={},oe;function Ie(){if(oe)return W;oe=1;var e=Re();return W.createRoot=e.createRoot,W.hydrateRoot=e.hydrateRoot,W}var Te=Ie();const Ue="modulepreload",Pe=function(e){return"/static/"+e},ae={},z=function(r,n,i){let s=Promise.resolve();if(n&&n.length>0){let m=function(c){return Promise.all(c.map(g=>Promise.resolve(g).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),h=f?.nonce||f?.getAttribute("nonce");s=m(n.map(c=>{if(c=Pe(c),c in ae)return;ae[c]=!0;const g=c.endsWith(".css"),v=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${v}`))return;const u=document.createElement("link");if(u.rel=g?"stylesheet":Ue,g||(u.as="script"),u.crossOrigin="",u.href=c,h&&u.setAttribute("nonce",h),document.head.appendChild(u),g)return new Promise((p,w)=>{u.addEventListener("load",p),u.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(f){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=f,window.dispatchEvent(h),!h.defaultPrevented)throw f}return s.then(f=>{for(const h of f||[])h.status==="rejected"&&a(h.reason);return r().catch(a)})},de=o.createContext(void 0);let $e=0;function Ae({children:e}){const[r,n]=o.useState([]),i=o.useCallback(f=>{n(h=>h.filter(m=>m.id!==f))},[]),s=o.useCallback((f,h="info")=>{const m=++$e;n(c=>[...c,{id:m,message:f,kind:h}]),window.setTimeout(()=>i(m),3500)},[i]),a=o.useMemo(()=>({toasts:r,push:s,dismiss:i}),[r,s,i]);return t.jsx(de.Provider,{value:a,children:e})}function ue(){const e=o.useContext(de);if(!e)throw new Error("useToast must be used within a ToastProvider");return e}function Oe(){const{toasts:e,dismiss:r}=ue();return e.length?t.jsx("div",{className:"toasts",children:e.map(n=>t.jsx("div",{className:`toast ${n.kind!=="info"?n.kind:""}`,role:"status",onClick:()=>r(n.id),children:n.message},n.id))}):null}const fe=o.createContext(void 0);function De({children:e}){const[r,n]=o.useState(""),i=o.useRef(new Set),s=o.useCallback(m=>{n(m),i.current.forEach(c=>{c?.(m)})},[]),a=o.useCallback(m=>{m&&i.current.add(m)},[]),f=o.useCallback(m=>{i.current.delete(m)},[]),h=o.useMemo(()=>({value:r,setValue:s,register:a,clearHandler:f}),[r,s,a,f]);return t.jsx(fe.Provider,{value:h,children:e})}function Ve(){const e=o.useContext(fe);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e}const Me={"Content-Type":"application/json"},Y=["token","webui-token","webui_token"],qe=1,J=new Map;function Be(e,r){const n=e instanceof Request?e.url:String(e),i=r?.method||"GET",s=r?.body?String(r.body):"";return`${i}:${n}:${s}`}function me(){for(const e of Y){const r=localStorage.getItem(e)||sessionStorage.getItem(e);if(r)return e!=="token"&&localStorage.setItem("token",r),r}try{const r=new URLSearchParams(window.location.search).get("token");if(r)return localStorage.setItem("token",r),r}catch{}return null}function We(){for(const e of Y)localStorage.removeItem(e);try{for(const e of Y)sessionStorage.removeItem(e)}catch{}}function he(e,r){const n=new Headers(e?.headers||{});return Object.entries(Me).forEach(([i,s])=>{n.has(i)||n.set(i,s)}),r&&!n.has("Authorization")&&n.set("Authorization",`Bearer ${r}`),{...e,headers:n}}async function G(e,r,n,i=qe){const s=me(),a=await fetch(e,he(r,s));return a.status===401&&i>0&&s?(We(),G(e,r,n,i-1)):n(a)}async function j(e,r){if((r?.method||"GET")==="GET"){const i=Be(e,r),s=J.get(i);if(s)return s;const a=G(e,r,f=>ce(f)).finally(()=>{J.delete(i)});return J.set(i,a),a}return G(e,r,i=>ce(i))}async function Ge(e,r){return G(e,r,n=>ze(n))}async function ce(e){if(!e.ok){let r=null;try{r=await e.json()}catch{}let n=`${e.status} ${e.statusText}`;if(r&&typeof r=="object"&&"error"in r&&typeof r.error=="string"){const i=r.error;i.trim()&&(n=i)}throw new Error(n)}return await e.json()}async function ze(e){if(!e.ok)throw new Error(`${e.status} ${e.statusText}`);return e.text()}async function ie(e){const r=e?.force?"?force=1":"";return j(`/web/meta${r}`)}async function le(){return j("/web/status")}async function pt(){return j("/web/processes")}async function vt(e,r){const n=`/web/processes/${encodeURIComponent(e)}/${encodeURIComponent(r)}/restart`;return j(n,{method:"POST"})}async function yt(){return j("/web/processes/restart_all",{method:"POST"})}async function wt(){return j("/web/arr/rebuild",{method:"POST"})}async function bt(){return j("/web/logs")}async function xt(e){return Ge(`/web/logs/${encodeURIComponent(e)}`)}function _t(e){return`/web/logs/${encodeURIComponent(e)}/download`}async function jt(){return j("/web/arr")}async function kt(e,r,n,i){const s=new URLSearchParams;return s.set("page",String(r)),s.set("page_size",String(n)),i&&s.set("q",i),j(`/web/radarr/${encodeURIComponent(e)}/movies?${s}`)}async function Ct(e,r,n,i,s){const a=new URLSearchParams;return a.set("page",String(r)),a.set("page_size",String(n)),i&&a.set("q",i),s?.missingOnly&&a.set("missing","1"),j(`/web/sonarr/${encodeURIComponent(e)}/series?${a}`)}async function St(e,r,n,i){const s=new URLSearchParams;return s.set("page",r.toString()),s.set("page_size",n.toString()),i&&s.set("q",i),s.set("include_tracks","true"),j(`/web/lidarr/${encodeURIComponent(e)}/albums?${s}`)}async function Et(e){await j(`/web/arr/${encodeURIComponent(e)}/restart`,{method:"POST"})}async function He(){return j("/web/config")}async function Fe(e){const r=me(),n=await fetch("/web/config",he({method:"POST",body:JSON.stringify(e)},r));if(!n.ok){let s=null;try{s=await n.json()}catch{}let a=`${n.status} ${n.statusText}`;if(s&&typeof s=="object"&&"error"in s&&typeof s.error=="string"){const f=s.error;f.trim()&&(a=f)}throw new Error(a)}return await n.json()}async function Je(){await j("/web/update",{method:"POST"})}const ge=o.createContext(null);function Ke({children:e}){const[r,n]=o.useState({liveArr:!0,groupSonarr:!0,groupLidarr:!0,viewDensity:"comfortable",theme:"dark"}),[i,s]=o.useState(!0);o.useEffect(()=>{(async()=>{try{const w=(await He())?.WebUI,L=localStorage.getItem("viewDensity"),I=localStorage.getItem("theme"),N=w?.Theme,E=I||N?.toLowerCase()||"dark";n({liveArr:w?.LiveArr===!0,groupSonarr:w?.GroupSonarr===!0,groupLidarr:w?.GroupLidarr===!0,viewDensity:L||"comfortable",theme:E}),document.documentElement.setAttribute("data-theme",E)}catch(p){console.error("Failed to load WebUI settings:",p)}finally{s(!1)}})()},[]);const a=o.useCallback(async(u,p)=>{try{const w={WebUI:{[u]:p}};await Fe({changes:w})}catch(w){console.error(`Failed to save ${u}:`,w)}},[]),f=o.useCallback(u=>{n(p=>({...p,liveArr:u})),a("LiveArr",u)},[a]),h=o.useCallback(u=>{n(p=>({...p,groupSonarr:u})),a("GroupSonarr",u)},[a]),m=o.useCallback(u=>{n(p=>({...p,groupLidarr:u})),a("GroupLidarr",u)},[a]),c=o.useCallback(u=>{n(p=>({...p,viewDensity:u})),localStorage.setItem("viewDensity",u)},[]),g=o.useCallback(u=>{n(w=>({...w,theme:u})),localStorage.setItem("theme",u),document.documentElement.setAttribute("data-theme",u),a("Theme",u==="light"?"Light":"Dark")},[a]),v={liveArr:r.liveArr,groupSonarr:r.groupSonarr,groupLidarr:r.groupLidarr,viewDensity:r.viewDensity,theme:r.theme,setLiveArr:f,setGroupSonarr:h,setGroupLidarr:m,setViewDensity:c,setTheme:g,loading:i};return t.jsx(ge.Provider,{value:v,children:e})}function Ye(){const e=o.useContext(ge);if(!e)throw new Error("useWebUI must be used within WebUIProvider");return e}function Qe(){const[e,r]=o.useState(navigator.onLine);return o.useEffect(()=>{const n=()=>r(!0),i=()=>r(!1);return window.addEventListener("online",n),window.addEventListener("offline",i),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",i)}},[]),e}function R({src:e,alt:r,className:n,...i}){return t.jsx("img",{src:e,alt:r??"",className:n?`icon ${n}`:"icon","aria-hidden":r?void 0:!0,...i})}const Xe="/static/assets/close.svg",Q="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20viewBox='0%200%20512%20512'%3e%3cpath%20d='M256%206.3C114.6%206.3%200%20120.9%200%20262.3c0%20113.3%2073.3%20209%20175%20242.9%2012.8%202.2%2017.6-5.4%2017.6-12.2%200-6.1-.3-26.2-.3-47.7-64.3%2011.8-81-15.7-86.1-30.1-2.9-7.4-15.4-30.1-26.2-36.2-9-4.8-21.8-16.6-.3-17%2020.2-.3%2034.6%2018.6%2039.4%2026.2%2023%2038.7%2059.8%2027.8%2074.6%2021.1%202.2-16.6%209-27.8%2016.3-34.2-57-6.4-116.5-28.5-116.5-126.4%200-27.8%209.9-50.9%2026.2-68.8-2.6-6.4-11.5-32.6%202.6-67.8%200%200%2021.4-6.7%2070.4%2026.2%2020.5-5.8%2042.2-8.6%2064-8.6s43.5%202.9%2064%208.6c49-33.3%2070.4-26.2%2070.4-26.2%2014.1%2035.2%205.1%2061.4%202.6%2067.8%2016.3%2017.9%2026.2%2040.6%2026.2%2068.8%200%2098.2-59.8%20120-116.8%20126.4%209.3%208%2017.3%2023.4%2017.3%2047.4%200%2034.2-.3%2061.8-.3%2070.4%200%206.7%204.8%2014.7%2017.6%2012.2C438.7%20471.3%20512%20375.3%20512%20262.3c0-141.4-114.6-256-256-256'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%231b1f23'/%3e%3c/svg%3e",Ze="/static/assets/refresh-arrow.svg",pe="/static/assets/up-arrow.svg",et="/static/assets/download.svg",tt="/static/assets/process.svg",rt="/static/assets/log.svg",st="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20id='Layer_1'%20x='0'%20y='0'%20version='1.1'%20viewBox='0%200%20512%20512'%3e%3cstyle%3e.st0{fill:%2324292e}%3c/style%3e%3cg%20id='Group-Copy'%20transform='translate(70%2021)'%3e%3cpath%20id='Shape'%20d='m10.3%2059.8%203.9%20372.4c-31.4%203.9-54.9-11.8-54.9-43.1l-3.9-309.7c0-98%2090.2-121.5%20145.1-82.3l278.3%20160.7c39.2%2027.4%2047%2078.4%2027.4%20113.7-3.9-27.4-15.7-43.1-39.2-58.8L53.4%2036.2C29.9%2020.6%2010.3%2024.5%2010.3%2059.8'%20class='st0'/%3e%3cpath%20id='Shape_00000114049535938561773820000018271523940913105341_'%20d='M-13.2%20451.8c23.5%207.8%2047%203.9%2066.6-7.8l321.5-188.2c19.6%2027.4%2015.7%2054.9-7.8%2070.6L96.5%20483.2c-39.2%2019.6-90.1%200-109.7-31.4'%20class='st0'/%3e%3cpath%20id='Shape_00000165935924413286433040000003668002807793862576_'%20d='M80.9%20342%20273%20232.3%2084.8%20126.4z'%20style='fill:%23ffc230'/%3e%3c/g%3e%3c/svg%3e",nt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20viewBox='0%200%20512%20512'%3e%3cpath%20d='M511.8%20256c0%2070.4-24.9%20130.8-74.6%20181.1-1.7%202-3.5%203.8-5.5%205.4-8.2%208-16.8%2015.3-26%2021.8Q341.05%20512%20256.3%20512c-56.6%200-106.3-15.9-149.2-47.7-11.3-8-22-17.1-31.9-27.3C36.5%20398.7%2012.8%20354%204%20303.2c-1.7-9.9-2.9-20-3.4-30.2-.2-5.7-.4-11.3-.4-17%200-6%20.1-11.7.4-17.1%200-.6.2-1.1.5-1.7%203.7-62.8%2028.4-117%2074.1-162.8C125.5%2024.8%20185.8%200%20256.2%200c70.7%200%20131%2024.8%20180.9%2074.5q74.7%2075.9%2074.7%20181.5'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%23eee'/%3e%3cpath%20d='m459.7%20100.3-52.9%2052.9c-30.9%2030.9-33.6%2057.8-33.6%20105.3%200%2042.3%206.7%2081.1%2038.2%20112.6%2023%2023%2044.9%2044.7%2044.9%2044.7-5.9%207.2-12.3%2014.3-19.1%2021.2-1.7%202-3.5%203.8-5.5%205.4-6%205.9-12.2%2011.4-18.6%2016.4l-41.4-41.4C334.9%20380.6%20305.6%20377%20257%20377c-46.7%200-78.4%204.3-112.6%2038.5-20.4%2020.4-43.8%2043.9-43.8%2043.9-8.9-6.8-17.3-14.2-25.3-22.4-6.6-6.6-12.8-13.4-18.5-20.3%200%200%2023.1-23.2%2045.2-45.3%2032.7-32.7%2038-70.6%2038-113%200-41.3-6.8-79.8-36.8-109.9C82.2%20127.7%2053.3%2099%2053.3%2099c6.7-8.5%2014-16.7%2021.8-24.5%206.9-6.8%2014-13.1%2021.2-19l48%2048c30.7%2030.7%2070%2038.6%20112.4%2038.6%2043.6%200%2082.8-8.4%20114.7-40.4C391%2082.1%20417%2056.3%20417%2056.3c6.8%205.6%2013.5%2011.6%2020.1%2018.2%208.3%208.3%2015.8%2016.9%2022.6%2025.8'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%233a3f51'/%3e%3cpath%20d='M186%20269.1c-.5-2.8-.8-5.5-.9-8.4-.1-1.6-.1-3.1-.1-4.7%200-1.7%200-3.2.1-4.7%200-.2%200-.3.1-.5%201-17.4%207.9-32.4%2020.5-45.1%2013.9-13.8%2030.6-20.7%2050.2-20.7s36.3%206.9%2050.2%2020.7c13.8%2014%2020.7%2030.8%2020.7%2050.3s-6.9%2036.2-20.7%2050.2c-.5.5-1%201.1-1.5%201.5q-3.45%203.3-7.2%206-18%2013.2-41.4%2013.2c-23.4%200-29.4-4.4-41.3-13.2-3.1-2.2-6.1-4.7-8.9-7.6-10.8-10.6-17.3-22.9-19.8-37'%20style='fill-rule:evenodd;clip-rule:evenodd;fill:%230cf'/%3e%3cpath%20d='m372.7%20141-35.4%2034.6M72.9%2076.8l96.5%2096.1m199.7%20198.9%2065.6%2067.9m4.4-363.3L372.7%20141M76.6%20438.5l64.6-64.7'%20style='fill:none;stroke:%230cf;stroke-width:2;stroke-miterlimit:1'/%3e%3cpath%20d='m372.7%20141-40%2040.6m-193.3-38.5%2040.6%2040.5M141%20374l39.5-41.1m146.2-3.3%2042.6%2042.4'%20style='fill:none;stroke:%230cf;stroke-width:7;stroke-miterlimit:1'/%3e%3c/svg%3e",ot="/static/assets/lidarr.svg",at="/static/assets/gear.svg",ct=o.lazy(()=>z(()=>import("./ProcessesView.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.ProcessesView}))),it=o.lazy(()=>z(()=>import("./LogsView.js"),__vite__mapDeps([4,1,2,5,3])).then(e=>({default:e.LogsView}))),K=o.lazy(()=>z(()=>import("./ArrView.js"),__vite__mapDeps([6,1,2,3])).then(e=>({default:e.ArrView}))),lt=o.lazy(()=>z(()=>import("./ConfigView.js"),__vite__mapDeps([7,1,2,5])).then(e=>({default:e.ConfigView})));function O(e){if(!e)return"unknown";const r=e.trim();return r?r[0]==="v"||r[0]==="V"?r:`v${r}`:"unknown"}function dt({currentVersion:e,changelog:r,changelogUrl:n,repositoryUrl:i,onClose:s}){return t.jsx("div",{className:"modal-backdrop",role:"presentation",onClick:s,children:t.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"welcome-title",onClick:a=>a.stopPropagation(),children:[t.jsx("div",{className:"modal-header",children:t.jsxs("h2",{id:"welcome-title",children:["🎉 Welcome to qBitrr ",O(e),"!"]})}),t.jsxs("div",{className:"modal-body changelog-modal__body",children:[t.jsx("div",{className:"changelog-meta",children:t.jsxs("p",{style:{marginBottom:"1rem",color:"var(--text-secondary)"},children:["You've been updated to version ",t.jsx("strong",{children:O(e)}),". Here's what's new in this release:"]})}),t.jsxs("div",{className:"changelog-section",children:[t.jsx("h3",{children:"Release Notes"}),t.jsx("pre",{className:"changelog-body",children:r?.trim()?r.trim():"No changelog available for this version."})]})]}),t.jsxs("div",{className:"modal-footer",children:[t.jsx("div",{className:"changelog-links",children:(n||i)&&t.jsxs("a",{className:"btn ghost small",href:n??i,target:"_blank",rel:"noreferrer",children:[t.jsx(R,{src:Q}),"View Full Release on GitHub"]})}),t.jsx("div",{className:"changelog-buttons",children:t.jsx("button",{className:"btn primary",type:"button",onClick:s,children:"Got it!"})})]})]})})}function ut({currentVersion:e,latestVersion:r,changelog:n,changelogUrl:i,repositoryUrl:s,updateState:a,updating:f,installationType:h,binaryDownloadUrl:m,binaryDownloadName:c,binaryDownloadSize:g,binaryDownloadError:v,onClose:u,onUpdate:p}){const[w,L]=o.useState(null),I=f||!!a?.in_progress,N=a?.completed_at?new Date(a.completed_at).toLocaleString():null,E=h==="binary";o.useEffect(()=>{if(a?.last_result==="success"&&a?.completed_at){let k=10;L(k);const T=setInterval(()=>{k-=1,k<=0?(clearInterval(T),window.location.reload()):L(k)},1e3);return()=>clearInterval(T)}},[a?.last_result,a?.completed_at]);let C="",S=null;if(a?.in_progress)C="text-info",S="⏳ Update in progress...";else if(a?.last_result==="success")C="text-success",w!==null?S=`✓ Update completed! Reloading in ${w}s...`:(S="✓ Update completed successfully",N&&(S=`${S} (${N})`));else if(a?.last_result==="error"){C="text-danger";const k=a.last_error?a.last_error.trim():"";S=k?`✗ Update failed: ${k}`:"✗ Update failed"}return t.jsx("div",{className:"modal-backdrop",role:"presentation",onClick:u,children:t.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"changelog-title",onClick:k=>k.stopPropagation(),children:[t.jsxs("div",{className:"modal-header",children:[t.jsx("h2",{id:"changelog-title",children:a?.in_progress?"⚙️ Updating...":"🚀 Update Available"}),t.jsxs("button",{className:"btn ghost",type:"button",onClick:u,disabled:a?.in_progress,children:[t.jsx(R,{src:Xe}),"Close"]})]}),t.jsxs("div",{className:"modal-body changelog-modal__body",children:[t.jsxs("div",{className:"changelog-meta",children:[t.jsxs("div",{className:"version-comparison",children:[t.jsxs("span",{className:"version-item",children:[t.jsx("strong",{children:"Current:"})," ",t.jsx("span",{className:"version-badge version-current",children:O(e)})]}),t.jsx("span",{className:"version-arrow",children:"→"}),t.jsxs("span",{className:"version-item",children:[t.jsx("strong",{children:"Latest:"})," ",t.jsx("span",{className:"version-badge version-latest",children:r?O(r):"Unknown"})]})]}),S?t.jsx("div",{className:`update-status ${C}`,children:S}):null]}),t.jsxs("div",{className:"changelog-section",children:[t.jsx("h3",{children:"What's New"}),t.jsx("pre",{className:"changelog-body",children:n?.trim()?n.trim():"No changelog provided."})]})]}),t.jsxs("div",{className:"modal-footer",children:[t.jsx("div",{className:"changelog-links",children:(i||s)&&t.jsxs("a",{className:"btn ghost small",href:i??s,target:"_blank",rel:"noreferrer",children:[t.jsx(R,{src:Q}),"View on GitHub"]})}),t.jsx("div",{className:"changelog-buttons",children:E?v?t.jsx("div",{className:"update-status text-danger",style:{marginBottom:"0.5rem"},children:v}):m?t.jsxs(t.Fragment,{children:[t.jsxs("a",{className:"btn primary",href:"/web/download-update",download:c??void 0,target:"_blank",rel:"noreferrer",children:[t.jsx(R,{src:et}),"Download Update",g&&g>0?t.jsxs("span",{style:{marginLeft:"0.5rem",opacity:.8,fontSize:"0.875rem"},children:["(",(g/(1024*1024)).toFixed(1)," MB)"]}):null]}),t.jsx("div",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginTop:"0.5rem"},children:"Binary installation detected. Download and manually replace the executable."})]}):t.jsx("div",{className:"update-status text-danger",children:"Unable to fetch binary download URL. Please update manually."}):t.jsxs("button",{className:"btn primary",type:"button",onClick:p,disabled:I,children:[t.jsx(R,{src:pe}),I?"Updating...":"Update Now"]})})]})]})})}function ft(){const[e,r]=o.useState("processes"),[n,i]=o.useState(!1),{push:s}=ue(),{setValue:a}=Ve(),{viewDensity:f,setViewDensity:h}=Ye(),m=Qe(),[c,g]=o.useState(null),[v,u]=o.useState(!1),[p,w]=o.useState(!1),[L,I]=o.useState(!1),[N,E]=o.useState(!1),C=o.useRef(0),S=o.useRef(null),k=o.useRef(!1),T=o.useRef(!1),U=o.useRef(null),[P,X]=o.useState(0),[Z,ee]=o.useState(null),[ve,te]=o.useState(!1);o.useEffect(()=>{(async()=>{if("caches"in window)try{const l=await caches.keys();await Promise.all(l.map(b=>caches.delete(b))),console.log("Cache cleared on page load")}catch(l){console.error("Failed to clear cache:",l)}})()},[]);const x=o.useCallback(async d=>{const l=d?.force??!1,b=d?.silent??!l;b||u(!0);try{const _=await ie({force:l});g(_)}catch(_){if(!b){const y=_ instanceof Error?_.message:"Failed to fetch version information";s(y,"error")}}finally{b||u(!1)}},[s]);o.useEffect(()=>{x({force:!0})},[x]),o.useEffect(()=>{if(!c?.current_version)return;const d=localStorage.getItem("lastSeenVersion"),l=c.current_version;d&&d!==l&&(!c.current_version_changelog&&!c.changelog&&x({force:!0,silent:!0}),te(!0)),d||localStorage.setItem("lastSeenVersion",l)},[c?.current_version,c?.changelog,x]),o.useEffect(()=>{m||s("You are offline. Some features may not work.","warning")},[m,s]),o.useEffect(()=>{const d=l=>{if(l.target instanceof HTMLInputElement||l.target instanceof HTMLTextAreaElement||l.target instanceof HTMLSelectElement)return;const b=l.ctrlKey||l.metaKey;if(b&&l.key==="k"){l.preventDefault(),document.querySelector('input[type="text"][placeholder*="Search"]')?.focus();return}if(l.key==="r"||l.key==="R"){l.preventDefault(),X(_=>_+1),s("Refreshed","success");return}if(l.key==="Escape"){a("");return}if(l.key>="1"&&l.key<="6"&&!b){l.preventDefault();const _=parseInt(l.key)-1,y=["processes","logs","radarr","sonarr","lidarr","config"];_<y.length&&r(y[_]);return}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,s]),o.useEffect(()=>{const d=window.setInterval(()=>{x()},3e5);return()=>window.clearInterval(d)},[x]),o.useEffect(()=>{const d=()=>{document.visibilityState==="visible"&&(X(l=>l+1),x({force:!0}),D())};return document.addEventListener("visibilitychange",d),()=>{document.removeEventListener("visibilitychange",d)}},[x]);const D=o.useCallback(async()=>{try{const d=await le();ee(d)}catch{}},[]);o.useEffect(()=>{D();const d=window.setInterval(()=>{D()},5*1e3);return()=>window.clearInterval(d)},[D]),o.useEffect(()=>{if(!c?.update_state?.in_progress&&!N){C.current=0;return}const d=window.setInterval(async()=>{try{const l=await ie({force:!0});g(l),N&&window.location.reload(),C.current=0}catch{if(C.current+=1,C.current>20){E(!1),C.current=0,s("Update completed but backend restart timed out. Please refresh the page manually.","warning");return}c?.update_state?.in_progress&&E(!0)}},3e3);return()=>window.clearInterval(d)},[c?.update_state?.in_progress,N,c,s]),o.useEffect(()=>{const d=c?.update_state;if(!d){S.current=null;return}const l=d.last_result??null;l&&l!==S.current&&(l==="success"?(s("Update completed successfully. Restarting...","success"),E(!0),C.current=0):l==="error"&&s(d.last_error||"Update failed.","error")),S.current=l},[c?.update_state,s]),o.useEffect(()=>{let d=!1,l=0;const b=y=>{U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{_()},y)},_=async()=>{if(!(d||k.current)){l+=1;try{const y=await le();if(d)return;if(ee(y),y.ready??(Array.isArray(y.arrs)&&y.arrs.length>0)){k.current=!0;return}y.ready===!1&&l>=3&&!T.current&&(T.current=!0,s("qBitrr backend is still initialising. Check the logs if this persists.","warning"))}catch(y){if(!T.current&&l>=3){T.current=!0;const B=y instanceof Error?y.message:"Unknown backend error";s(`Unable to confirm qBitrr readiness (${B}). Please inspect the logs.`,"warning")}}finally{if(!d&&!k.current){const y=l<3?3e3:1e4;b(y)}}}};return b(0),()=>{d=!0,U.current!==null&&(window.clearTimeout(U.current),U.current=null)}},[s]);const V=o.useMemo(()=>{const d=[{id:"processes",label:"Processes",icon:tt},{id:"logs",label:"Logs",icon:rt}],l=[],b=Z?.arrs??[],_=b.some($=>$.type==="radarr"),y=b.some($=>$.type==="sonarr"),B=b.some($=>$.type==="lidarr");return _&&l.push({id:"radarr",label:"Radarr",icon:st}),y&&l.push({id:"sonarr",label:"Sonarr",icon:nt}),B&&l.push({id:"lidarr",label:"Lidarr",icon:ot}),[...d,...l,{id:"config",label:"Config",icon:at}]},[Z]),M=c?.repository_url??"https://github.com/Feramance/qBitrr",ye=c?.current_version?O(c.current_version):"...",we=c?.latest_version??null,be=!!c?.update_available,H=c?.update_state,re=c?.changelog_url??M,q=[];c?.last_checked&&q.push(`Last checked ${new Date(c.last_checked).toLocaleString()}`),c?.error&&q.push(`Update check failed: ${c.error}`);const xe=q.length?q.join(" • "):void 0;o.useEffect(()=>{!V.some(l=>l.id===e)&&V.length>0&&r("processes")},[V,e]);const _e=o.useCallback(()=>{x({force:!0})},[x]),je=o.useCallback(()=>{w(!0),c?.changelog||x({force:!0,silent:!0})},[c?.changelog,x]),ke=o.useCallback(()=>{w(!1)},[]),Ce=o.useCallback(()=>{te(!1),c?.current_version&&localStorage.setItem("lastSeenVersion",c.current_version)},[c?.current_version]),Se=o.useCallback(async()=>{I(!0),E(!1),C.current=0;try{await Je(),s("Update started in the background.","info"),await x({force:!0,silent:!0})}catch(d){const l=d instanceof Error?d.message:"Failed to start update";s(l,"error")}finally{I(!1)}},[s,x]);return t.jsxs("div",{"data-density":f,children:[t.jsx("header",{className:"appbar",children:t.jsxs("div",{className:"appbar__inner",children:[t.jsxs("div",{className:"appbar__title",children:[t.jsx("h1",{children:"qBitrr"}),t.jsx("span",{className:"appbar__version",title:xe,children:ye}),v?t.jsx("span",{className:"spinner","aria-hidden":"true"}):null,H?.in_progress?t.jsx("span",{className:"appbar__status text-info",children:"Updating..."}):null,be?t.jsxs("button",{type:"button",className:"btn small primary appbar__update",onClick:je,disabled:L||!!H?.in_progress,children:[t.jsx("span",{className:"appbar__update-indicator","aria-hidden":"true"}),t.jsx(R,{src:pe}),"Update available"]}):null]}),t.jsxs("div",{className:"appbar__actions",children:[!m&&t.jsx("span",{className:"badge",style:{background:"rgba(239, 68, 68, 0.15)",borderColor:"rgba(239, 68, 68, 0.3)",color:"var(--danger)"},children:"Offline"}),t.jsxs("div",{className:"view-density-toggle",children:[t.jsx("button",{type:"button",className:f==="comfortable"?"active":"",onClick:()=>h("comfortable"),title:"Comfortable view",children:"Comfortable"}),t.jsx("button",{type:"button",className:f==="compact"?"active":"",onClick:()=>h("compact"),title:"Compact view",children:"Compact"})]}),t.jsxs("button",{type:"button",className:"btn small ghost",onClick:_e,disabled:v,children:[t.jsx(R,{src:Ze}),v?"Checking...":"Check Updates"]}),t.jsxs("a",{href:M,target:"_blank",rel:"noreferrer",className:"btn small ghost",children:[t.jsx(R,{src:Q}),"GitHub"]})]})]})}),t.jsxs("main",{className:"container",children:[t.jsx("nav",{className:"nav",children:V.map(d=>t.jsxs("button",{type:"button",className:e===d.id?"active":"",onClick:()=>{e==="config"&&d.id!=="config"&&n&&!window.confirm("You have unsaved configuration changes. Leave without saving?")||(r(d.id),a(""))},children:[t.jsx(R,{src:d.icon}),t.jsx("span",{children:d.label})]},d.id))}),t.jsxs(o.Suspense,{fallback:t.jsx("div",{className:"loading",children:"Loading..."}),children:[e==="processes"&&t.jsx(ct,{active:!0},`processes-${P}`),e==="logs"&&t.jsx(it,{active:!0},`logs-${P}`),e==="radarr"&&t.jsx(K,{type:"radarr",active:!0},`radarr-${P}`),e==="sonarr"&&t.jsx(K,{type:"sonarr",active:!0},`sonarr-${P}`),e==="lidarr"&&t.jsx(K,{type:"lidarr",active:!0},`lidarr-${P}`),e==="config"&&t.jsx(lt,{onDirtyChange:i},`config-${P}`)]})]}),p&&c?t.jsx(ut,{currentVersion:c.current_version,latestVersion:we,changelog:c.changelog,changelogUrl:re,repositoryUrl:M,updateState:H,updating:L,installationType:c.installation_type,binaryDownloadUrl:c.binary_download_url,binaryDownloadName:c.binary_download_name,binaryDownloadSize:c.binary_download_size,binaryDownloadError:c.binary_download_error,onClose:ke,onUpdate:Se}):null,ve&&c?t.jsx(dt,{currentVersion:c.current_version,changelog:c.current_version_changelog||c.changelog,changelogUrl:re,repositoryUrl:M,onClose:Ce}):null]})}function mt(){return t.jsx(Ae,{children:t.jsx(De,{children:t.jsxs(Ke,{children:[t.jsx(ft,{}),t.jsx(Oe,{})]})})})}Te.createRoot(document.getElementById("root")).render(t.jsx(o.StrictMode,{children:t.jsx(mt,{})}));export{Xe as C,et as D,R as I,Ze as R,le as a,yt as b,wt as c,bt as d,xt as e,_t as f,pt as g,Ve as h,Ye as i,t as j,jt as k,kt as l,Et as m,Ct as n,St as o,He as p,Fe as q,vt as r,at as s,ue as u};
|
|
11
11
|
//# sourceMappingURL=app.js.map
|