var zn=Object.defineProperty;var Wn=(t,r,s)=>r in t?zn(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var ke=(t,r,s)=>Wn(t,typeof r!="symbol"?r+"":r,s);import{u as Dn,i as B,j as e,B as d,T as c,a as J,I as Xe,b as U,F as oe,C as Fn,c as E,d as Pt,P as Fe,e as It,f as Rt,g as me,h as W,k as Ot,S as Te,l as Is,m as Be,n as Re,L as Pe,o as he,p as qe,q as jt,A as ze,r as ce,s as ee,G as F,t as ne,v as Jr,w as ae,x as st,Y as Kr,y as V,z as Rs,R as lt,D as nt,E as je,H as ve,J as we,K as Se,M as Xr,O as Ve,W as Os,N as Ce,Q as Es,U as Zr,V as Nt,X as Mn,Z as Bt,_ as Et,$ as Ae,a0 as $n,a1 as ct,a2 as es,a3 as Ln,a4 as Ts,a5 as zs,a6 as Ws,a7 as Ne,a8 as He,a9 as le,aa as Un,ab as Nn,ac as at,ad as ot,ae as be,af as qt,ag as Ds,ah as Bn,ai as wt,aj as ts,ak as qn,al as Hn,am as Vn,an as Gn,ao as Yn,ap as Qn,aq as Jn,ar as rs,as as Kn,at as ss,au as Xn,av as Zn,aw as ea,ax as ns,ay as ta,az as as,aA as ra,aB as sa,aC as na,aD as aa}from"./mui-DW1KyNMb.js";import{c as oa,g as ia,r as y,u as Le,d as la,a as pe,N as Fs,e as ca,f as da,h as fe,B as ua}from"./vendor-Bv7lQTk9.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).observe(document,{childList:!0,subtree:!0});function s(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(a){if(a.ep)return;a.ep=!0;const o=s(a);fetch(a.href,o)}})();var Ht={},os=oa;Ht.createRoot=os.createRoot,Ht.hydrateRoot=os.hydrateRoot;var tr={},Mt={};const ha=ia(Dn);var is;function q(){return is||(is=1,function(t){"use client";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return r.createSvgIcon}});var r=ha}(Mt)),Mt}var fa=B;Object.defineProperty(tr,"__esModule",{value:!0});var _e=tr.default=void 0,xa=fa(q()),pa=e;_e=tr.default=(0,xa.default)((0,pa.jsx)("path",{d:"M8 5v14l11-7z"}),"PlayArrow");var rr={},ma=B;Object.defineProperty(rr,"__esModule",{value:!0});var sr=rr.default=void 0,ga=ma(q()),ya=e;sr=rr.default=(0,ga.default)((0,ya.jsx)("path",{d:"M6 19h4V5H6zm8-14v14h4V5z"}),"Pause");var nr={},ba=B;Object.defineProperty(nr,"__esModule",{value:!0});var Ms=nr.default=void 0,ja=ba(q()),va=e;Ms=nr.default=(0,ja.default)((0,va.jsx)("path",{d:"M12 5.9c1.16 0 2.1.94 2.1 2.1s-.94 2.1-2.1 2.1S9.9 9.16 9.9 8s.94-2.1 2.1-2.1m0 9c2.97 0 6.1 1.46 6.1 2.1v1.1H5.9V17c0-.64 3.13-2.1 6.1-2.1M12 4C9.79 4 8 5.79 8 8s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4m0 9c-2.67 0-8 1.34-8 4v3h16v-3c0-2.66-5.33-4-8-4"}),"PersonOutline");var ar={},wa=B;Object.defineProperty(ar,"__esModule",{value:!0});var Vt=ar.default=void 0,Sa=wa(q()),_a=e;Vt=ar.default=(0,Sa.default)((0,_a.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2M9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9zm9 14H6V10h12zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2"}),"LockOutlined");var or={},Ca=B;Object.defineProperty(or,"__esModule",{value:!0});var $s=or.default=void 0,ka=Ca(q()),Aa=e;$s=or.default=(0,ka.default)((0,Aa.jsx)("path",{d:"M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4m0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7"}),"VisibilityOutlined");var ir={},Pa=B;Object.defineProperty(ir,"__esModule",{value:!0});var Ls=ir.default=void 0,Ia=Pa(q()),Ra=e;Ls=ir.default=(0,Ia.default)((0,Ra.jsx)("path",{d:"M12 6c3.79 0 7.17 2.13 8.82 5.5-.59 1.22-1.42 2.27-2.41 3.12l1.41 1.41c1.39-1.23 2.49-2.77 3.18-4.53C21.27 7.11 17 4 12 4c-1.27 0-2.49.2-3.64.57l1.65 1.65C10.66 6.09 11.32 6 12 6m-1.07 1.14L13 9.21c.57.25 1.03.71 1.28 1.28l2.07 2.07c.08-.34.14-.7.14-1.07C16.5 9.01 14.48 7 12 7c-.37 0-.72.05-1.07.14M2.01 3.87l2.68 2.68C3.06 7.83 1.77 9.53 1 11.5 2.73 15.89 7 19 12 19c1.52 0 2.98-.29 4.32-.82l3.42 3.42 1.41-1.41L3.42 2.45zm7.5 7.5 2.61 2.61c-.04.01-.08.02-.12.02-1.38 0-2.5-1.12-2.5-2.5 0-.05.01-.08.01-.13m-3.4-3.4 1.75 1.75c-.23.55-.36 1.15-.36 1.78 0 2.48 2.02 4.5 4.5 4.5.63 0 1.23-.13 1.77-.36l.98.98c-.88.24-1.8.38-2.75.38-3.79 0-7.17-2.13-8.82-5.5.7-1.43 1.72-2.61 2.93-3.53"}),"VisibilityOffOutlined");var lr={},Oa=B;Object.defineProperty(lr,"__esModule",{value:!0});var Us=lr.default=void 0,Ea=Oa(q()),Ta=e;Us=lr.default=(0,Ea.default)((0,Ta.jsx)("path",{d:"m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"}),"ArrowForward");function Ns(t,r){return function(){return t.apply(r,arguments)}}const{toString:za}=Object.prototype,{getPrototypeOf:cr}=Object,{iterator:Tt,toStringTag:Bs}=Symbol,zt=(t=>r=>{const s=za.call(r);return t[s]||(t[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),ge=t=>(t=t.toLowerCase(),r=>zt(r)===t),Wt=t=>r=>typeof r===t,{isArray:Ye}=Array,Ge=Wt("undefined");function dt(t){return t!==null&&!Ge(t)&&t.constructor!==null&&!Ge(t.constructor)&&de(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const qs=ge("ArrayBuffer");function Wa(t){let r;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?r=ArrayBuffer.isView(t):r=t&&t.buffer&&qs(t.buffer),r}const Da=Wt("string"),de=Wt("function"),Hs=Wt("number"),ut=t=>t!==null&&typeof t=="object",Fa=t=>t===!0||t===!1,St=t=>{if(zt(t)!=="object")return!1;const r=cr(t);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Bs in t)&&!(Tt in t)},Ma=t=>{if(!ut(t)||dt(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},$a=ge("Date"),La=ge("File"),Ua=ge("Blob"),Na=ge("FileList"),Ba=t=>ut(t)&&de(t.pipe),qa=t=>{let r;return t&&(typeof FormData=="function"&&t instanceof FormData||de(t.append)&&((r=zt(t))==="formdata"||r==="object"&&de(t.toString)&&t.toString()==="[object FormData]"))},Ha=ge("URLSearchParams"),[Va,Ga,Ya,Qa]=["ReadableStream","Request","Response","Headers"].map(ge),Ja=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ht(t,r,{allOwnKeys:s=!1}={}){if(t===null||typeof t>"u")return;let n,a;if(typeof t!="object"&&(t=[t]),Ye(t))for(n=0,a=t.length;n0;)if(a=s[n],r===a.toLowerCase())return a;return null}const We=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Gs=t=>!Ge(t)&&t!==We;function Gt(){const{caseless:t,skipUndefined:r}=Gs(this)&&this||{},s={},n=(a,o)=>{const i=t&&Vs(s,o)||o;St(s[i])&&St(a)?s[i]=Gt(s[i],a):St(a)?s[i]=Gt({},a):Ye(a)?s[i]=a.slice():(!r||!Ge(a))&&(s[i]=a)};for(let a=0,o=arguments.length;a(ht(r,(a,o)=>{s&&de(a)?t[o]=Ns(a,s):t[o]=a},{allOwnKeys:n}),t),Xa=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Za=(t,r,s,n)=>{t.prototype=Object.create(r.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:r.prototype}),s&&Object.assign(t.prototype,s)},eo=(t,r,s,n)=>{let a,o,i;const l={};if(r=r||{},t==null)return r;do{for(a=Object.getOwnPropertyNames(t),o=a.length;o-- >0;)i=a[o],(!n||n(i,t,r))&&!l[i]&&(r[i]=t[i],l[i]=!0);t=s!==!1&&cr(t)}while(t&&(!s||s(t,r))&&t!==Object.prototype);return r},to=(t,r,s)=>{t=String(t),(s===void 0||s>t.length)&&(s=t.length),s-=r.length;const n=t.indexOf(r,s);return n!==-1&&n===s},ro=t=>{if(!t)return null;if(Ye(t))return t;let r=t.length;if(!Hs(r))return null;const s=new Array(r);for(;r-- >0;)s[r]=t[r];return s},so=(t=>r=>t&&r instanceof t)(typeof Uint8Array<"u"&&cr(Uint8Array)),no=(t,r)=>{const n=(t&&t[Tt]).call(t);let a;for(;(a=n.next())&&!a.done;){const o=a.value;r.call(t,o[0],o[1])}},ao=(t,r)=>{let s;const n=[];for(;(s=t.exec(r))!==null;)n.push(s);return n},oo=ge("HTMLFormElement"),io=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,n,a){return n.toUpperCase()+a}),ls=(({hasOwnProperty:t})=>(r,s)=>t.call(r,s))(Object.prototype),lo=ge("RegExp"),Ys=(t,r)=>{const s=Object.getOwnPropertyDescriptors(t),n={};ht(s,(a,o)=>{let i;(i=r(a,o,t))!==!1&&(n[o]=i||a)}),Object.defineProperties(t,n)},co=t=>{Ys(t,(r,s)=>{if(de(t)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const n=t[s];if(de(n)){if(r.enumerable=!1,"writable"in r){r.writable=!1;return}r.set||(r.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},uo=(t,r)=>{const s={},n=a=>{a.forEach(o=>{s[o]=!0})};return Ye(t)?n(t):n(String(t).split(r)),s},ho=()=>{},fo=(t,r)=>t!=null&&Number.isFinite(t=+t)?t:r;function xo(t){return!!(t&&de(t.append)&&t[Bs]==="FormData"&&t[Tt])}const po=t=>{const r=new Array(10),s=(n,a)=>{if(ut(n)){if(r.indexOf(n)>=0)return;if(dt(n))return n;if(!("toJSON"in n)){r[a]=n;const o=Ye(n)?[]:{};return ht(n,(i,l)=>{const b=s(i,a+1);!Ge(b)&&(o[l]=b)}),r[a]=void 0,o}}return n};return s(t,0)},mo=ge("AsyncFunction"),go=t=>t&&(ut(t)||de(t))&&de(t.then)&&de(t.catch),Qs=((t,r)=>t?setImmediate:r?((s,n)=>(We.addEventListener("message",({source:a,data:o})=>{a===We&&o===s&&n.length&&n.shift()()},!1),a=>{n.push(a),We.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",de(We.postMessage)),yo=typeof queueMicrotask<"u"?queueMicrotask.bind(We):typeof process<"u"&&process.nextTick||Qs,bo=t=>t!=null&&de(t[Tt]),v={isArray:Ye,isArrayBuffer:qs,isBuffer:dt,isFormData:qa,isArrayBufferView:Wa,isString:Da,isNumber:Hs,isBoolean:Fa,isObject:ut,isPlainObject:St,isEmptyObject:Ma,isReadableStream:Va,isRequest:Ga,isResponse:Ya,isHeaders:Qa,isUndefined:Ge,isDate:$a,isFile:La,isBlob:Ua,isRegExp:lo,isFunction:de,isStream:Ba,isURLSearchParams:Ha,isTypedArray:so,isFileList:Na,forEach:ht,merge:Gt,extend:Ka,trim:Ja,stripBOM:Xa,inherits:Za,toFlatObject:eo,kindOf:zt,kindOfTest:ge,endsWith:to,toArray:ro,forEachEntry:no,matchAll:ao,isHTMLForm:oo,hasOwnProperty:ls,hasOwnProp:ls,reduceDescriptors:Ys,freezeMethods:co,toObjectSet:uo,toCamelCase:io,noop:ho,toFiniteNumber:fo,findKey:Vs,global:We,isContextDefined:Gs,isSpecCompliantForm:xo,toJSONObject:po,isAsyncFn:mo,isThenable:go,setImmediate:Qs,asap:yo,isIterable:bo};function L(t,r,s,n,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",r&&(this.code=r),s&&(this.config=s),n&&(this.request=n),a&&(this.response=a,this.status=a.status?a.status:null)}v.inherits(L,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:v.toJSONObject(this.config),code:this.code,status:this.status}}});const Js=L.prototype,Ks={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{Ks[t]={value:t}});Object.defineProperties(L,Ks);Object.defineProperty(Js,"isAxiosError",{value:!0});L.from=(t,r,s,n,a,o)=>{const i=Object.create(Js);v.toFlatObject(t,i,function(p){return p!==Error.prototype},f=>f!=="isAxiosError");const l=t&&t.message?t.message:"Error",b=r==null&&t?t.code:r;return L.call(i,l,b,s,n,a),t&&i.cause==null&&Object.defineProperty(i,"cause",{value:t,configurable:!0}),i.name=t&&t.name||"Error",o&&Object.assign(i,o),i};const jo=null;function Yt(t){return v.isPlainObject(t)||v.isArray(t)}function Xs(t){return v.endsWith(t,"[]")?t.slice(0,-2):t}function cs(t,r,s){return t?t.concat(r).map(function(a,o){return a=Xs(a),!s&&o?"["+a+"]":a}).join(s?".":""):r}function vo(t){return v.isArray(t)&&!t.some(Yt)}const wo=v.toFlatObject(v,{},null,function(r){return/^is[A-Z]/.test(r)});function Dt(t,r,s){if(!v.isObject(t))throw new TypeError("target must be an object");r=r||new FormData,s=v.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(j,h){return!v.isUndefined(h[j])});const n=s.metaTokens,a=s.visitor||p,o=s.dots,i=s.indexes,b=(s.Blob||typeof Blob<"u"&&Blob)&&v.isSpecCompliantForm(r);if(!v.isFunction(a))throw new TypeError("visitor must be a function");function f(u){if(u===null)return"";if(v.isDate(u))return u.toISOString();if(v.isBoolean(u))return u.toString();if(!b&&v.isBlob(u))throw new L("Blob is not supported. Use a Buffer instead.");return v.isArrayBuffer(u)||v.isTypedArray(u)?b&&typeof Blob=="function"?new Blob([u]):Buffer.from(u):u}function p(u,j,h){let x=u;if(u&&!h&&typeof u=="object"){if(v.endsWith(j,"{}"))j=n?j:j.slice(0,-2),u=JSON.stringify(u);else if(v.isArray(u)&&vo(u)||(v.isFileList(u)||v.endsWith(j,"[]"))&&(x=v.toArray(u)))return j=Xs(j),x.forEach(function(C,g){!(v.isUndefined(C)||C===null)&&r.append(i===!0?cs([j],g,o):i===null?j:j+"[]",f(C))}),!1}return Yt(u)?!0:(r.append(cs(h,j,o),f(u)),!1)}const _=[],w=Object.assign(wo,{defaultVisitor:p,convertValue:f,isVisitable:Yt});function k(u,j){if(!v.isUndefined(u)){if(_.indexOf(u)!==-1)throw Error("Circular reference detected in "+j.join("."));_.push(u),v.forEach(u,function(x,m){(!(v.isUndefined(x)||x===null)&&a.call(r,x,v.isString(m)?m.trim():m,j,w))===!0&&k(x,j?j.concat(m):[m])}),_.pop()}}if(!v.isObject(t))throw new TypeError("data must be an object");return k(t),r}function ds(t){const r={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return r[n]})}function dr(t,r){this._pairs=[],t&&Dt(t,this,r)}const Zs=dr.prototype;Zs.append=function(r,s){this._pairs.push([r,s])};Zs.toString=function(r){const s=r?function(n){return r.call(this,n,ds)}:ds;return this._pairs.map(function(a){return s(a[0])+"="+s(a[1])},"").join("&")};function So(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function en(t,r,s){if(!r)return t;const n=s&&s.encode||So;v.isFunction(s)&&(s={serialize:s});const a=s&&s.serialize;let o;if(a?o=a(r,s):o=v.isURLSearchParams(r)?r.toString():new dr(r,s).toString(n),o){const i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class us{constructor(){this.handlers=[]}use(r,s,n){return this.handlers.push({fulfilled:r,rejected:s,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(r){this.handlers[r]&&(this.handlers[r]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(r){v.forEach(this.handlers,function(n){n!==null&&r(n)})}}const tn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},_o=typeof URLSearchParams<"u"?URLSearchParams:dr,Co=typeof FormData<"u"?FormData:null,ko=typeof Blob<"u"?Blob:null,Ao={isBrowser:!0,classes:{URLSearchParams:_o,FormData:Co,Blob:ko},protocols:["http","https","file","blob","url","data"]},ur=typeof window<"u"&&typeof document<"u",Qt=typeof navigator=="object"&&navigator||void 0,Po=ur&&(!Qt||["ReactNative","NativeScript","NS"].indexOf(Qt.product)<0),Io=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ro=ur&&window.location.href||"http://localhost",Oo=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ur,hasStandardBrowserEnv:Po,hasStandardBrowserWebWorkerEnv:Io,navigator:Qt,origin:Ro},Symbol.toStringTag,{value:"Module"})),ie={...Oo,...Ao};function Eo(t,r){return Dt(t,new ie.classes.URLSearchParams,{visitor:function(s,n,a,o){return ie.isNode&&v.isBuffer(s)?(this.append(n,s.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...r})}function To(t){return v.matchAll(/\w+|\[(\w*)]/g,t).map(r=>r[0]==="[]"?"":r[1]||r[0])}function zo(t){const r={},s=Object.keys(t);let n;const a=s.length;let o;for(n=0;n=s.length;return i=!i&&v.isArray(a)?a.length:i,b?(v.hasOwnProp(a,i)?a[i]=[a[i],n]:a[i]=n,!l):((!a[i]||!v.isObject(a[i]))&&(a[i]=[]),r(s,n,a[i],o)&&v.isArray(a[i])&&(a[i]=zo(a[i])),!l)}if(v.isFormData(t)&&v.isFunction(t.entries)){const s={};return v.forEachEntry(t,(n,a)=>{r(To(n),a,s,0)}),s}return null}function Wo(t,r,s){if(v.isString(t))try{return(r||JSON.parse)(t),v.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(s||JSON.stringify)(t)}const ft={transitional:tn,adapter:["xhr","http","fetch"],transformRequest:[function(r,s){const n=s.getContentType()||"",a=n.indexOf("application/json")>-1,o=v.isObject(r);if(o&&v.isHTMLForm(r)&&(r=new FormData(r)),v.isFormData(r))return a?JSON.stringify(rn(r)):r;if(v.isArrayBuffer(r)||v.isBuffer(r)||v.isStream(r)||v.isFile(r)||v.isBlob(r)||v.isReadableStream(r))return r;if(v.isArrayBufferView(r))return r.buffer;if(v.isURLSearchParams(r))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),r.toString();let l;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Eo(r,this.formSerializer).toString();if((l=v.isFileList(r))||n.indexOf("multipart/form-data")>-1){const b=this.env&&this.env.FormData;return Dt(l?{"files[]":r}:r,b&&new b,this.formSerializer)}}return o||a?(s.setContentType("application/json",!1),Wo(r)):r}],transformResponse:[function(r){const s=this.transitional||ft.transitional,n=s&&s.forcedJSONParsing,a=this.responseType==="json";if(v.isResponse(r)||v.isReadableStream(r))return r;if(r&&v.isString(r)&&(n&&!this.responseType||a)){const i=!(s&&s.silentJSONParsing)&&a;try{return JSON.parse(r,this.parseReviver)}catch(l){if(i)throw l.name==="SyntaxError"?L.from(l,L.ERR_BAD_RESPONSE,this,null,this.response):l}}return r}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ie.classes.FormData,Blob:ie.classes.Blob},validateStatus:function(r){return r>=200&&r<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};v.forEach(["delete","get","head","post","put","patch"],t=>{ft.headers[t]={}});const Do=v.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Fo=t=>{const r={};let s,n,a;return t&&t.split(` `).forEach(function(i){a=i.indexOf(":"),s=i.substring(0,a).trim().toLowerCase(),n=i.substring(a+1).trim(),!(!s||r[s]&&Do[s])&&(s==="set-cookie"?r[s]?r[s].push(n):r[s]=[n]:r[s]=r[s]?r[s]+", "+n:n)}),r},hs=Symbol("internals");function Ke(t){return t&&String(t).trim().toLowerCase()}function _t(t){return t===!1||t==null?t:v.isArray(t)?t.map(_t):String(t)}function Mo(t){const r=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=s.exec(t);)r[n[1]]=n[2];return r}const $o=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function $t(t,r,s,n,a){if(v.isFunction(n))return n.call(this,r,s);if(a&&(r=s),!!v.isString(r)){if(v.isString(n))return r.indexOf(n)!==-1;if(v.isRegExp(n))return n.test(r)}}function Lo(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(r,s,n)=>s.toUpperCase()+n)}function Uo(t,r){const s=v.toCamelCase(" "+r);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+s,{value:function(a,o,i){return this[n].call(this,r,a,o,i)},configurable:!0})})}let ue=class{constructor(r){r&&this.set(r)}set(r,s,n){const a=this;function o(l,b,f){const p=Ke(b);if(!p)throw new Error("header name must be a non-empty string");const _=v.findKey(a,p);(!_||a[_]===void 0||f===!0||f===void 0&&a[_]!==!1)&&(a[_||b]=_t(l))}const i=(l,b)=>v.forEach(l,(f,p)=>o(f,p,b));if(v.isPlainObject(r)||r instanceof this.constructor)i(r,s);else if(v.isString(r)&&(r=r.trim())&&!$o(r))i(Fo(r),s);else if(v.isObject(r)&&v.isIterable(r)){let l={},b,f;for(const p of r){if(!v.isArray(p))throw TypeError("Object iterator must return a key-value pair");l[f=p[0]]=(b=l[f])?v.isArray(b)?[...b,p[1]]:[b,p[1]]:p[1]}i(l,s)}else r!=null&&o(s,r,n);return this}get(r,s){if(r=Ke(r),r){const n=v.findKey(this,r);if(n){const a=this[n];if(!s)return a;if(s===!0)return Mo(a);if(v.isFunction(s))return s.call(this,a,n);if(v.isRegExp(s))return s.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(r,s){if(r=Ke(r),r){const n=v.findKey(this,r);return!!(n&&this[n]!==void 0&&(!s||$t(this,this[n],n,s)))}return!1}delete(r,s){const n=this;let a=!1;function o(i){if(i=Ke(i),i){const l=v.findKey(n,i);l&&(!s||$t(n,n[l],l,s))&&(delete n[l],a=!0)}}return v.isArray(r)?r.forEach(o):o(r),a}clear(r){const s=Object.keys(this);let n=s.length,a=!1;for(;n--;){const o=s[n];(!r||$t(this,this[o],o,r,!0))&&(delete this[o],a=!0)}return a}normalize(r){const s=this,n={};return v.forEach(this,(a,o)=>{const i=v.findKey(n,o);if(i){s[i]=_t(a),delete s[o];return}const l=r?Lo(o):String(o).trim();l!==o&&delete s[o],s[l]=_t(a),n[l]=!0}),this}concat(...r){return this.constructor.concat(this,...r)}toJSON(r){const s=Object.create(null);return v.forEach(this,(n,a)=>{n!=null&&n!==!1&&(s[a]=r&&v.isArray(n)?n.join(", "):n)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([r,s])=>r+": "+s).join(` `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(r){return r instanceof this?r:new this(r)}static concat(r,...s){const n=new this(r);return s.forEach(a=>n.set(a)),n}static accessor(r){const n=(this[hs]=this[hs]={accessors:{}}).accessors,a=this.prototype;function o(i){const l=Ke(i);n[l]||(Uo(a,i),n[l]=!0)}return v.isArray(r)?r.forEach(o):o(r),this}};ue.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);v.reduceDescriptors(ue.prototype,({value:t},r)=>{let s=r[0].toUpperCase()+r.slice(1);return{get:()=>t,set(n){this[s]=n}}});v.freezeMethods(ue);function Lt(t,r){const s=this||ft,n=r||s,a=ue.from(n.headers);let o=n.data;return v.forEach(t,function(l){o=l.call(s,o,a.normalize(),r?r.status:void 0)}),a.normalize(),o}function sn(t){return!!(t&&t.__CANCEL__)}function Qe(t,r,s){L.call(this,t??"canceled",L.ERR_CANCELED,r,s),this.name="CanceledError"}v.inherits(Qe,L,{__CANCEL__:!0});function nn(t,r,s){const n=s.config.validateStatus;!s.status||!n||n(s.status)?t(s):r(new L("Request failed with status code "+s.status,[L.ERR_BAD_REQUEST,L.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function No(t){const r=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return r&&r[1]||""}function Bo(t,r){t=t||10;const s=new Array(t),n=new Array(t);let a=0,o=0,i;return r=r!==void 0?r:1e3,function(b){const f=Date.now(),p=n[o];i||(i=f),s[a]=b,n[a]=f;let _=o,w=0;for(;_!==a;)w+=s[_++],_=_%t;if(a=(a+1)%t,a===o&&(o=(o+1)%t),f-i{s=p,a=null,o&&(clearTimeout(o),o=null),t(...f)};return[(...f)=>{const p=Date.now(),_=p-s;_>=n?i(f,p):(a=f,o||(o=setTimeout(()=>{o=null,i(a)},n-_)))},()=>a&&i(a)]}const At=(t,r,s=3)=>{let n=0;const a=Bo(50,250);return qo(o=>{const i=o.loaded,l=o.lengthComputable?o.total:void 0,b=i-n,f=a(b),p=i<=l;n=i;const _={loaded:i,total:l,progress:l?i/l:void 0,bytes:b,rate:f||void 0,estimated:f&&l&&p?(l-i)/f:void 0,event:o,lengthComputable:l!=null,[r?"download":"upload"]:!0};t(_)},s)},fs=(t,r)=>{const s=t!=null;return[n=>r[0]({lengthComputable:s,total:t,loaded:n}),r[1]]},xs=t=>(...r)=>v.asap(()=>t(...r)),Ho=ie.hasStandardBrowserEnv?((t,r)=>s=>(s=new URL(s,ie.origin),t.protocol===s.protocol&&t.host===s.host&&(r||t.port===s.port)))(new URL(ie.origin),ie.navigator&&/(msie|trident)/i.test(ie.navigator.userAgent)):()=>!0,Vo=ie.hasStandardBrowserEnv?{write(t,r,s,n,a,o,i){if(typeof document>"u")return;const l=[`${t}=${encodeURIComponent(r)}`];v.isNumber(s)&&l.push(`expires=${new Date(s).toUTCString()}`),v.isString(n)&&l.push(`path=${n}`),v.isString(a)&&l.push(`domain=${a}`),o===!0&&l.push("secure"),v.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(t){if(typeof document>"u")return null;const r=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return r?decodeURIComponent(r[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Go(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Yo(t,r){return r?t.replace(/\/?\/$/,"")+"/"+r.replace(/^\/+/,""):t}function an(t,r,s){let n=!Go(r);return t&&(n||s==!1)?Yo(t,r):r}const ps=t=>t instanceof ue?{...t}:t;function $e(t,r){r=r||{};const s={};function n(f,p,_,w){return v.isPlainObject(f)&&v.isPlainObject(p)?v.merge.call({caseless:w},f,p):v.isPlainObject(p)?v.merge({},p):v.isArray(p)?p.slice():p}function a(f,p,_,w){if(v.isUndefined(p)){if(!v.isUndefined(f))return n(void 0,f,_,w)}else return n(f,p,_,w)}function o(f,p){if(!v.isUndefined(p))return n(void 0,p)}function i(f,p){if(v.isUndefined(p)){if(!v.isUndefined(f))return n(void 0,f)}else return n(void 0,p)}function l(f,p,_){if(_ in r)return n(f,p);if(_ in t)return n(void 0,f)}const b={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:l,headers:(f,p,_)=>a(ps(f),ps(p),_,!0)};return v.forEach(Object.keys({...t,...r}),function(p){const _=b[p]||a,w=_(t[p],r[p],p);v.isUndefined(w)&&_!==l||(s[p]=w)}),s}const on=t=>{const r=$e({},t);let{data:s,withXSRFToken:n,xsrfHeaderName:a,xsrfCookieName:o,headers:i,auth:l}=r;if(r.headers=i=ue.from(i),r.url=en(an(r.baseURL,r.url,r.allowAbsoluteUrls),t.params,t.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),v.isFormData(s)){if(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(v.isFunction(s.getHeaders)){const b=s.getHeaders(),f=["content-type","content-length"];Object.entries(b).forEach(([p,_])=>{f.includes(p.toLowerCase())&&i.set(p,_)})}}if(ie.hasStandardBrowserEnv&&(n&&v.isFunction(n)&&(n=n(r)),n||n!==!1&&Ho(r.url))){const b=a&&o&&Vo.read(o);b&&i.set(a,b)}return r},Qo=typeof XMLHttpRequest<"u",Jo=Qo&&function(t){return new Promise(function(s,n){const a=on(t);let o=a.data;const i=ue.from(a.headers).normalize();let{responseType:l,onUploadProgress:b,onDownloadProgress:f}=a,p,_,w,k,u;function j(){k&&k(),u&&u(),a.cancelToken&&a.cancelToken.unsubscribe(p),a.signal&&a.signal.removeEventListener("abort",p)}let h=new XMLHttpRequest;h.open(a.method.toUpperCase(),a.url,!0),h.timeout=a.timeout;function x(){if(!h)return;const C=ue.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),A={data:!l||l==="text"||l==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:C,config:t,request:h};nn(function($){s($),j()},function($){n($),j()},A),h=null}"onloadend"in h?h.onloadend=x:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(x)},h.onabort=function(){h&&(n(new L("Request aborted",L.ECONNABORTED,t,h)),h=null)},h.onerror=function(g){const A=g&&g.message?g.message:"Network Error",R=new L(A,L.ERR_NETWORK,t,h);R.event=g||null,n(R),h=null},h.ontimeout=function(){let g=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const A=a.transitional||tn;a.timeoutErrorMessage&&(g=a.timeoutErrorMessage),n(new L(g,A.clarifyTimeoutError?L.ETIMEDOUT:L.ECONNABORTED,t,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&v.forEach(i.toJSON(),function(g,A){h.setRequestHeader(A,g)}),v.isUndefined(a.withCredentials)||(h.withCredentials=!!a.withCredentials),l&&l!=="json"&&(h.responseType=a.responseType),f&&([w,u]=At(f,!0),h.addEventListener("progress",w)),b&&h.upload&&([_,k]=At(b),h.upload.addEventListener("progress",_),h.upload.addEventListener("loadend",k)),(a.cancelToken||a.signal)&&(p=C=>{h&&(n(!C||C.type?new Qe(null,t,h):C),h.abort(),h=null)},a.cancelToken&&a.cancelToken.subscribe(p),a.signal&&(a.signal.aborted?p():a.signal.addEventListener("abort",p)));const m=No(a.url);if(m&&ie.protocols.indexOf(m)===-1){n(new L("Unsupported protocol "+m+":",L.ERR_BAD_REQUEST,t));return}h.send(o||null)})},Ko=(t,r)=>{const{length:s}=t=t?t.filter(Boolean):[];if(r||s){let n=new AbortController,a;const o=function(f){if(!a){a=!0,l();const p=f instanceof Error?f:this.reason;n.abort(p instanceof L?p:new Qe(p instanceof Error?p.message:p))}};let i=r&&setTimeout(()=>{i=null,o(new L(`timeout ${r} of ms exceeded`,L.ETIMEDOUT))},r);const l=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(f=>{f.unsubscribe?f.unsubscribe(o):f.removeEventListener("abort",o)}),t=null)};t.forEach(f=>f.addEventListener("abort",o));const{signal:b}=n;return b.unsubscribe=()=>v.asap(l),b}},Xo=function*(t,r){let s=t.byteLength;if(s{const a=Zo(t,r);let o=0,i,l=b=>{i||(i=!0,n&&n(b))};return new ReadableStream({async pull(b){try{const{done:f,value:p}=await a.next();if(f){l(),b.close();return}let _=p.byteLength;if(s){let w=o+=_;s(w)}b.enqueue(new Uint8Array(p))}catch(f){throw l(f),f}},cancel(b){return l(b),a.return()}},{highWaterMark:2})},gs=64*1024,{isFunction:vt}=v,ti=(({Request:t,Response:r})=>({Request:t,Response:r}))(v.global),{ReadableStream:ys,TextEncoder:bs}=v.global,js=(t,...r)=>{try{return!!t(...r)}catch{return!1}},ri=t=>{t=v.merge.call({skipUndefined:!0},ti,t);const{fetch:r,Request:s,Response:n}=t,a=r?vt(r):typeof fetch=="function",o=vt(s),i=vt(n);if(!a)return!1;const l=a&&vt(ys),b=a&&(typeof bs=="function"?(u=>j=>u.encode(j))(new bs):async u=>new Uint8Array(await new s(u).arrayBuffer())),f=o&&l&&js(()=>{let u=!1;const j=new s(ie.origin,{body:new ys,method:"POST",get duplex(){return u=!0,"half"}}).headers.has("Content-Type");return u&&!j}),p=i&&l&&js(()=>v.isReadableStream(new n("").body)),_={stream:p&&(u=>u.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(u=>{!_[u]&&(_[u]=(j,h)=>{let x=j&&j[u];if(x)return x.call(j);throw new L(`Response type '${u}' is not supported`,L.ERR_NOT_SUPPORT,h)})});const w=async u=>{if(u==null)return 0;if(v.isBlob(u))return u.size;if(v.isSpecCompliantForm(u))return(await new s(ie.origin,{method:"POST",body:u}).arrayBuffer()).byteLength;if(v.isArrayBufferView(u)||v.isArrayBuffer(u))return u.byteLength;if(v.isURLSearchParams(u)&&(u=u+""),v.isString(u))return(await b(u)).byteLength},k=async(u,j)=>{const h=v.toFiniteNumber(u.getContentLength());return h??w(j)};return async u=>{let{url:j,method:h,data:x,signal:m,cancelToken:C,timeout:g,onDownloadProgress:A,onUploadProgress:R,responseType:$,headers:z,withCredentials:P="same-origin",fetchOptions:H}=on(u),K=r||fetch;$=$?($+"").toLowerCase():"text";let Q=Ko([m,C&&C.toAbortSignal()],g),N=null;const I=Q&&Q.unsubscribe&&(()=>{Q.unsubscribe()});let S;try{if(R&&f&&h!=="get"&&h!=="head"&&(S=await k(z,x))!==0){let re=new s(j,{method:"POST",body:x,duplex:"half"}),se;if(v.isFormData(x)&&(se=re.headers.get("content-type"))&&z.setContentType(se),re.body){const[Je,bt]=fs(S,At(xs(R)));x=ms(re.body,gs,Je,bt)}}v.isString(P)||(P=P?"include":"omit");const T=o&&"credentials"in s.prototype,G={...H,signal:Q,method:h.toUpperCase(),headers:z.normalize().toJSON(),body:x,duplex:"half",credentials:T?P:void 0};N=o&&new s(j,G);let O=await(o?K(N,H):K(j,G));const D=p&&($==="stream"||$==="response");if(p&&(A||D&&I)){const re={};["status","statusText","headers"].forEach(Qr=>{re[Qr]=O[Qr]});const se=v.toFiniteNumber(O.headers.get("content-length")),[Je,bt]=A&&fs(se,At(xs(A),!0))||[];O=new n(ms(O.body,gs,Je,()=>{bt&&bt(),I&&I()}),re)}$=$||"text";let X=await _[v.findKey(_,$)||"text"](O,u);return!D&&I&&I(),await new Promise((re,se)=>{nn(re,se,{data:X,headers:ue.from(O.headers),status:O.status,statusText:O.statusText,config:u,request:N})})}catch(T){throw I&&I(),T&&T.name==="TypeError"&&/Load failed|fetch/i.test(T.message)?Object.assign(new L("Network Error",L.ERR_NETWORK,u,N),{cause:T.cause||T}):L.from(T,T&&T.code,u,N)}}},si=new Map,ln=t=>{let r=t&&t.env||{};const{fetch:s,Request:n,Response:a}=r,o=[n,a,s];let i=o.length,l=i,b,f,p=si;for(;l--;)b=o[l],f=p.get(b),f===void 0&&p.set(b,f=l?new Map:ri(r)),p=f;return f};ln();const hr={http:jo,xhr:Jo,fetch:{get:ln}};v.forEach(hr,(t,r)=>{if(t){try{Object.defineProperty(t,"name",{value:r})}catch{}Object.defineProperty(t,"adapterName",{value:r})}});const vs=t=>`- ${t}`,ni=t=>v.isFunction(t)||t===null||t===!1;function ai(t,r){t=v.isArray(t)?t:[t];const{length:s}=t;let n,a;const o={};for(let i=0;i`adapter ${b} `+(f===!1?"is not supported by the environment":"is not available in the build"));let l=s?i.length>1?`since : `+i.map(vs).join(` `):" "+vs(i[0]):"as no adapter specified";throw new L("There is no suitable adapter to dispatch the request "+l,"ERR_NOT_SUPPORT")}return a}const cn={getAdapter:ai,adapters:hr};function Ut(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Qe(null,t)}function ws(t){return Ut(t),t.headers=ue.from(t.headers),t.data=Lt.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),cn.getAdapter(t.adapter||ft.adapter,t)(t).then(function(n){return Ut(t),n.data=Lt.call(t,t.transformResponse,n),n.headers=ue.from(n.headers),n},function(n){return sn(n)||(Ut(t),n&&n.response&&(n.response.data=Lt.call(t,t.transformResponse,n.response),n.response.headers=ue.from(n.response.headers))),Promise.reject(n)})}const dn="1.13.2",Ft={};["object","boolean","number","function","string","symbol"].forEach((t,r)=>{Ft[t]=function(n){return typeof n===t||"a"+(r<1?"n ":" ")+t}});const Ss={};Ft.transitional=function(r,s,n){function a(o,i){return"[Axios v"+dn+"] Transitional option '"+o+"'"+i+(n?". "+n:"")}return(o,i,l)=>{if(r===!1)throw new L(a(i," has been removed"+(s?" in "+s:"")),L.ERR_DEPRECATED);return s&&!Ss[i]&&(Ss[i]=!0,console.warn(a(i," has been deprecated since v"+s+" and will be removed in the near future"))),r?r(o,i,l):!0}};Ft.spelling=function(r){return(s,n)=>(console.warn(`${n} is likely a misspelling of ${r}`),!0)};function oi(t,r,s){if(typeof t!="object")throw new L("options must be an object",L.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let a=n.length;for(;a-- >0;){const o=n[a],i=r[o];if(i){const l=t[o],b=l===void 0||i(l,o,t);if(b!==!0)throw new L("option "+o+" must be "+b,L.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new L("Unknown option "+o,L.ERR_BAD_OPTION)}}const Ct={assertOptions:oi,validators:Ft},ye=Ct.validators;let Me=class{constructor(r){this.defaults=r||{},this.interceptors={request:new us,response:new us}}async request(r,s){try{return await this._request(r,s)}catch(n){if(n instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const o=a.stack?a.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=` `+o):n.stack=o}catch{}}throw n}}_request(r,s){typeof r=="string"?(s=s||{},s.url=r):s=r||{},s=$e(this.defaults,s);const{transitional:n,paramsSerializer:a,headers:o}=s;n!==void 0&&Ct.assertOptions(n,{silentJSONParsing:ye.transitional(ye.boolean),forcedJSONParsing:ye.transitional(ye.boolean),clarifyTimeoutError:ye.transitional(ye.boolean)},!1),a!=null&&(v.isFunction(a)?s.paramsSerializer={serialize:a}:Ct.assertOptions(a,{encode:ye.function,serialize:ye.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),Ct.assertOptions(s,{baseUrl:ye.spelling("baseURL"),withXsrfToken:ye.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let i=o&&v.merge(o.common,o[s.method]);o&&v.forEach(["delete","get","head","post","put","patch","common"],u=>{delete o[u]}),s.headers=ue.concat(i,o);const l=[];let b=!0;this.interceptors.request.forEach(function(j){typeof j.runWhen=="function"&&j.runWhen(s)===!1||(b=b&&j.synchronous,l.unshift(j.fulfilled,j.rejected))});const f=[];this.interceptors.response.forEach(function(j){f.push(j.fulfilled,j.rejected)});let p,_=0,w;if(!b){const u=[ws.bind(this),void 0];for(u.unshift(...l),u.push(...f),w=u.length,p=Promise.resolve(s);_{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](a);n._listeners=null}),this.promise.then=a=>{let o;const i=new Promise(l=>{n.subscribe(l),o=l}).then(a);return i.cancel=function(){n.unsubscribe(o)},i},r(function(o,i,l){n.reason||(n.reason=new Qe(o,i,l),s(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(r){if(this.reason){r(this.reason);return}this._listeners?this._listeners.push(r):this._listeners=[r]}unsubscribe(r){if(!this._listeners)return;const s=this._listeners.indexOf(r);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const r=new AbortController,s=n=>{r.abort(n)};return this.subscribe(s),r.signal.unsubscribe=()=>this.unsubscribe(s),r.signal}static source(){let r;return{token:new un(function(a){r=a}),cancel:r}}};function li(t){return function(s){return t.apply(null,s)}}function ci(t){return v.isObject(t)&&t.isAxiosError===!0}const Jt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Jt).forEach(([t,r])=>{Jt[r]=t});function hn(t){const r=new Me(t),s=Ns(Me.prototype.request,r);return v.extend(s,Me.prototype,r,{allOwnKeys:!0}),v.extend(s,r,null,{allOwnKeys:!0}),s.create=function(a){return hn($e(t,a))},s}const te=hn(ft);te.Axios=Me;te.CanceledError=Qe;te.CancelToken=ii;te.isCancel=sn;te.VERSION=dn;te.toFormData=Dt;te.AxiosError=L;te.Cancel=te.CanceledError;te.all=function(r){return Promise.all(r)};te.spread=li;te.isAxiosError=ci;te.mergeConfig=$e;te.AxiosHeaders=ue;te.formToJSON=t=>rn(v.isHTMLForm(t)?new FormData(t):t);te.getAdapter=cn.getAdapter;te.HttpStatusCode=Jt;te.default=te;const{Axios:Zc,AxiosError:ed,CanceledError:td,isCancel:rd,CancelToken:sd,VERSION:nd,all:ad,Cancel:od,isAxiosError:id,spread:ld,toFormData:cd,AxiosHeaders:dd,HttpStatusCode:ud,formToJSON:hd,getAdapter:fd,mergeConfig:xd}=te;function di(t){var n;const s=`; ${document.cookie}`.split(`; ${t}=`);return s.length===2&&((n=s.pop())==null?void 0:n.split(";").shift())||null}const M=te.create({baseURL:"/api",headers:{"Content-Type":"application/json"},withCredentials:!0});M.interceptors.request.use(t=>{const r=localStorage.getItem("token");if(r&&(t.headers.Authorization=`Token ${r}`),t.method&&!["get","head","options"].includes(t.method.toLowerCase())){const s=di("csrftoken");s&&(t.headers["X-CSRFToken"]=s)}return t});const it={list:t=>M.get("/audio/list/",{params:t}),get:t=>M.get(`/audio/${t}/`),delete:t=>M.delete(`/audio/${t}/`),download:t=>M.post(`/audio/${t}/`,{action:"download"}),downloadFile:async t=>{const r=localStorage.getItem("token"),s=await fetch(`/api/audio/${t}/download/`,{headers:{Authorization:`Token ${r}`}});if(!s.ok)throw new Error("Download failed");return await s.blob()},getPlayer:t=>M.get(`/audio/${t}/player/`),updateProgress:(t,r)=>M.post(`/audio/${t}/progress/`,r),getLyrics:t=>M.get(`/audio/${t}/lyrics/`),fetchLyrics:(t,r)=>M.post(`/audio/${t}/lyrics/fetch/`,{force:r}),updateLyrics:(t,r)=>M.put(`/audio/${t}/lyrics/`,r),deleteLyrics:t=>M.delete(`/audio/${t}/lyrics/`),fetchBatchLyrics:t=>M.post("/audio/lyrics/fetch_batch/",{youtube_ids:t}),fetchAllMissingLyrics:t=>M.post("/audio/lyrics/fetch_all_missing/",{limit:t}),getLyricsStats:()=>M.get("/audio/lyrics/stats/")},kt={list:()=>M.get("/channel/"),get:t=>M.get(`/channel/${t}/`),subscribe:t=>M.post("/channel/",t),unsubscribe:t=>M.delete(`/channel/${t}/`)},De={list:()=>M.get("/playlist/"),get:t=>M.get(`/playlist/${t}/`),getWithItems:t=>M.get(`/playlist/${t}/`,{params:{include_items:"true"}}),create:t=>M.post("/playlist/",t),delete:t=>M.delete(`/playlist/${t}/`),download:t=>M.post(`/playlist/${t}/`,{action:"download"})},Oe={login:t=>M.post("/user/login/",t),logout:()=>M.post("/user/logout/"),account:()=>M.get("/user/account/"),config:()=>M.get("/user/config/"),updateConfig:t=>M.post("/user/config/",t),twoFactorStatus:()=>M.get("/user/2fa/status/"),twoFactorSetup:()=>M.post("/user/2fa/setup/"),twoFactorVerify:t=>M.post("/user/2fa/verify/",t),twoFactorDisable:t=>M.post("/user/2fa/disable/",t),twoFactorRegenerateCodes:()=>M.post("/user/2fa/regenerate-codes/"),twoFactorDownloadCodes:()=>M.get("/user/2fa/download-codes/",{responseType:"blob"})};function ui({onLoginSuccess:t}){const[r,s]=y.useState(""),[n,a]=y.useState(""),[o,i]=y.useState(!1),[l,b]=y.useState(!1),[f,p]=y.useState(""),[_,w]=y.useState(!1),[k,u]=y.useState(""),j=async()=>{var x,m;try{const C=await Oe.login({username:r,password:n,..._&&{two_factor_code:k}});if(C.data.requires_2fa){w(!0),p("Please enter your two-factor authentication code");return}localStorage.setItem("token",C.data.token),t()}catch(C){(m=(x=C.response)==null?void 0:x.data)!=null&&m.requires_2fa?(w(!0),p("Please enter your two-factor authentication code")):p("Invalid credentials or verification code")}},h=x=>{x.key==="Enter"&&j()};return e.jsxs(d,{sx:{display:"flex",flexDirection:"column",minHeight:"100vh",width:"100vw",background:"linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%)",position:"relative",overflow:"auto"},children:[e.jsxs(d,{sx:{flex:{xs:.6,sm:1},display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:{xs:3,sm:4},paddingTop:{xs:6,sm:8}},children:[e.jsx(d,{component:"img",src:"/img/logo.png",alt:"SoundWave Logo",sx:{width:{xs:180,sm:220},height:{xs:180,sm:220},borderRadius:"50%",mb:3,boxShadow:"0 20px 60px rgba(34, 211, 238, 0.3)",border:"4px solid rgba(34, 211, 238, 0.2)",position:"relative",animation:"pulse 2s ease-in-out infinite","@keyframes pulse":{"0%, 100%":{transform:"scale(1)",boxShadow:"0 20px 60px rgba(34, 211, 238, 0.3)"},"50%":{transform:"scale(1.05)",boxShadow:"0 25px 70px rgba(34, 211, 238, 0.5)"}}}}),e.jsx(c,{sx:{fontSize:{xs:"2.5rem",sm:"3.5rem"},fontWeight:800,letterSpacing:"-0.03em",color:"#22d3ee",textAlign:"center",textShadow:"0 4px 20px rgba(34, 211, 238, 0.4)",mb:1},children:"SoundWave"}),e.jsx(c,{sx:{fontSize:{xs:"0.9rem",sm:"1rem"},color:"#94a3b8",textAlign:"center",fontWeight:500},children:"Your Personal Music Hub"})]}),e.jsx(d,{sx:{flex:{xs:1,sm:1.2},backgroundColor:"rgba(30, 41, 59, 0.8)",backdropFilter:"blur(20px)",borderTopLeftRadius:{xs:32,sm:40},borderTopRightRadius:{xs:32,sm:40},padding:{xs:3,sm:4},paddingTop:{xs:4,sm:5},display:"flex",flexDirection:"column",alignItems:"center",border:"1px solid rgba(34, 211, 238, 0.1)",borderBottom:"none"},children:e.jsxs(d,{sx:{width:"100%",maxWidth:{xs:"100%",sm:420},padding:{xs:0,sm:2}},children:[e.jsx(c,{variant:"h4",sx:{color:"#f8fafc",fontWeight:700,marginBottom:{xs:3,sm:4},fontSize:{xs:"1.5rem",sm:"1.75rem"},textAlign:"center"},children:"Welcome Back"}),e.jsx(J,{fullWidth:!0,placeholder:"Username",value:r,onChange:x=>s(x.target.value),onKeyPress:h,autoFocus:!0,sx:{marginBottom:2,"& .MuiOutlinedInput-root":{backgroundColor:"rgba(15, 23, 42, 0.6)",borderRadius:3,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.3)","& fieldset":{borderColor:"rgba(34, 211, 238, 0.2)",borderWidth:2},"&:hover fieldset":{borderColor:"rgba(34, 211, 238, 0.4)"},"&.Mui-focused fieldset":{borderColor:"#22d3ee",borderWidth:2}},"& .MuiOutlinedInput-input":{padding:{xs:"14px 16px",sm:"16px 18px"},fontSize:"0.95rem",color:"#f8fafc"}},InputProps:{startAdornment:e.jsx(Xe,{position:"start",children:e.jsx(Ms,{sx:{color:"#94a3b8",fontSize:22}})})}}),e.jsx(J,{fullWidth:!0,type:o?"text":"password",placeholder:"Password",value:n,onChange:x=>a(x.target.value),onKeyPress:h,sx:{marginBottom:1.5,"& .MuiOutlinedInput-root":{backgroundColor:"rgba(15, 23, 42, 0.6)",borderRadius:3,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.3)","& fieldset":{borderColor:"rgba(34, 211, 238, 0.2)",borderWidth:2},"&:hover fieldset":{borderColor:"rgba(34, 211, 238, 0.4)"},"&.Mui-focused fieldset":{borderColor:"#22d3ee",borderWidth:2}},"& .MuiOutlinedInput-input":{padding:{xs:"14px 16px",sm:"16px 18px"},fontSize:"0.95rem",color:"#f8fafc"}},InputProps:{startAdornment:e.jsx(Xe,{position:"start",children:e.jsx(Vt,{sx:{color:"#94a3b8",fontSize:22}})}),endAdornment:e.jsx(Xe,{position:"end",children:e.jsx(U,{onClick:()=>i(!o),edge:"end",sx:{backgroundColor:"rgba(34, 211, 238, 0.2)",borderRadius:"50%",width:36,height:36,"&:hover":{backgroundColor:"rgba(34, 211, 238, 0.3)"}},children:o?e.jsx(Ls,{sx:{color:"#22d3ee",fontSize:18}}):e.jsx($s,{sx:{color:"#22d3ee",fontSize:18}})})})}}),_&&e.jsx(J,{fullWidth:!0,placeholder:"Two-Factor Code",value:k,onChange:x=>u(x.target.value),onKeyPress:h,autoFocus:!0,inputProps:{maxLength:6},sx:{marginBottom:1.5,"& .MuiOutlinedInput-root":{backgroundColor:"rgba(15, 23, 42, 0.6)",borderRadius:3,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.3)","& fieldset":{borderColor:"rgba(34, 211, 238, 0.2)",borderWidth:2},"&:hover fieldset":{borderColor:"rgba(34, 211, 238, 0.4)"},"&.Mui-focused fieldset":{borderColor:"#22d3ee",borderWidth:2}},"& .MuiOutlinedInput-input":{padding:"14px 16px",fontSize:"0.95rem",color:"#f8fafc",textAlign:"center",letterSpacing:"0.5em"}},InputProps:{startAdornment:e.jsx(Xe,{position:"start",children:e.jsx(Vt,{sx:{color:"#94a3b8",fontSize:22}})})}}),e.jsx(oe,{control:e.jsx(Fn,{checked:l,onChange:x=>b(x.target.checked),sx:{color:"#475569","&.Mui-checked":{color:"#22d3ee"}}}),label:e.jsx(c,{sx:{color:"#94a3b8",fontSize:"0.9rem"},children:"Remember Password"}),sx:{marginBottom:{xs:2.5,sm:3}}}),e.jsx(E,{fullWidth:!0,variant:"contained",onClick:j,sx:{background:"linear-gradient(135deg, #22d3ee 0%, #06b6d4 100%)",color:"#0f172a",padding:{xs:"14px",sm:"16px"},borderRadius:3,fontSize:"0.95rem",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",boxShadow:"0 4px 20px rgba(34, 211, 238, 0.4)",border:"1px solid rgba(34, 211, 238, 0.3)","&:hover":{background:"linear-gradient(135deg, #06b6d4 0%, #0891b2 100%)",boxShadow:"0 6px 30px rgba(34, 211, 238, 0.6)",transform:"translateY(-2px)"},transition:"all 0.3s ease"},endIcon:e.jsx(Us,{}),children:"Login"}),f&&e.jsx(c,{sx:{color:"#ef4444",fontSize:"0.875rem",marginTop:2,textAlign:"center",backgroundColor:"rgba(239, 68, 68, 0.1)",padding:"8px 12px",borderRadius:2,border:"1px solid rgba(239, 68, 68, 0.2)"},children:f})]})})]})}function hi({setCurrentAudio:t}){const r=Le(),[s,n]=y.useState([]),[a,o]=y.useState([]);y.useEffect(()=>{i(),l()},[]);const i=async()=>{var b;try{const f=await it.list({sort:"downloaded",order:"desc"}),p=((b=f.data)==null?void 0:b.data)||f.data||[];n(Array.isArray(p)?p.slice(0,3):[])}catch(f){console.error("Failed to load audio:",f),n([])}},l=async()=>{var b;try{const f=await De.list(),p=((b=f.data)==null?void 0:b.data)||f.data||[];o(Array.isArray(p)?p.slice(0,3):[])}catch(f){console.error("Failed to load playlists:",f),o([])}};return e.jsxs(d,{children:[e.jsxs(d,{sx:{mb:6},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2,px:.5},children:[e.jsx(c,{variant:"h6",sx:{fontWeight:700,letterSpacing:"-0.02em"},children:"Newly Added Songs"}),e.jsx(c,{variant:"body2",onClick:()=>r("/library"),sx:{color:"primary.main",cursor:"pointer",fontWeight:500,"&:hover":{opacity:.8}},children:"See All"})]}),e.jsx(d,{sx:{display:"flex",gap:3,overflowX:"auto",pb:2,"&::-webkit-scrollbar":{height:8},"&::-webkit-scrollbar-thumb":{bgcolor:"rgba(255,255,255,0.1)",borderRadius:1}},children:s.map(b=>e.jsxs(d,{sx:{minWidth:160,width:160,cursor:"pointer","& .play-button":{opacity:0,transform:"translateY(8px)"},"&:hover .play-button":{opacity:1,transform:"translateY(0)"},"&:hover .card-image":{transform:"scale(1.05)"}},onClick:()=>t(b),children:[e.jsxs(d,{sx:{position:"relative",aspectRatio:"1",borderRadius:3,overflow:"hidden",mb:1.5},children:[e.jsx(d,{className:"card-image",sx:{width:"100%",height:"100%",backgroundImage:`url(${b.thumbnail_url||"/placeholder.jpg"})`,backgroundSize:"cover",backgroundPosition:"center",transition:"transform 0.5s ease"}}),e.jsx(d,{sx:{position:"absolute",inset:0,bgcolor:"rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s ease","&:hover":{bgcolor:"rgba(0, 0, 0, 0.4)"}}}),e.jsx(U,{className:"play-button",sx:{position:"absolute",bottom:12,right:12,width:40,height:40,bgcolor:"primary.main",color:"background.dark",transition:"all 0.3s ease",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)","&:hover":{bgcolor:"primary.main",transform:"scale(1.1)"}},children:e.jsx(_e,{})})]}),e.jsx(c,{variant:"body2",noWrap:!0,sx:{fontWeight:600,mb:.5},children:b.title}),e.jsx(c,{variant:"caption",color:"text.secondary",noWrap:!0,children:b.channel_name})]},b.id))})]}),e.jsxs(d,{children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2,px:.5},children:[e.jsx(c,{variant:"h6",sx:{fontWeight:700,letterSpacing:"-0.02em"},children:"Your Playlists"}),e.jsx(c,{variant:"body2",onClick:()=>r("/playlists"),sx:{color:"primary.main",cursor:"pointer",fontWeight:500,"&:hover":{opacity:.8}},children:"See All"})]}),e.jsx(d,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:a.map(b=>e.jsxs(d,{onClick:()=>r(`/playlists/${b.playlist_id}`),sx:{display:"flex",alignItems:"center",gap:2,p:1.5,borderRadius:3,cursor:"pointer",transition:"background-color 0.3s ease","&:hover":{bgcolor:"rgba(255, 255, 255, 0.05)"},"& .play-btn":{opacity:0,transition:"opacity 0.3s ease"},"&:hover .play-btn":{opacity:1}},children:[e.jsx(d,{sx:{width:56,height:56,borderRadius:2,bgcolor:"primary.main",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.2)"},children:e.jsx(_e,{sx:{fontSize:28,color:"background.dark"}})}),e.jsxs(d,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(c,{variant:"subtitle2",noWrap:!0,sx:{fontWeight:600,mb:.25},children:b.title}),e.jsxs(c,{variant:"caption",color:"text.secondary",children:[b.item_count," Tracks"]})]}),e.jsx(U,{className:"play-btn",size:"small",sx:{width:32,height:32,border:"1px solid",borderColor:"rgba(255, 255, 255, 0.1)"},children:e.jsx(_e,{sx:{fontSize:18}})})]},b.id))})]})]})}var fr={},fi=B;Object.defineProperty(fr,"__esModule",{value:!0});var fn=fr.default=void 0,xi=fi(q()),pi=e;fn=fr.default=(0,xi.default)((0,pi.jsx)("path",{d:"M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3m-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05"}),"FavoriteBorder");var xr={},mi=B;Object.defineProperty(xr,"__esModule",{value:!0});var pr=xr.default=void 0,gi=mi(q()),yi=e;pr=xr.default=(0,gi.default)((0,yi.jsx)("path",{d:"M10.59 9.17 5.41 4 4 5.41l5.17 5.17zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4zm.33 9.41-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04z"}),"Shuffle");function bi({setCurrentAudio:t}){const[r,s]=y.useState([]),[n,a]=y.useState(!1),[o,i]=y.useState("");y.useEffect(()=>{l()},[]);const l=async()=>{var w;try{const k=await it.list(),u=((w=k.data)==null?void 0:w.data)||k.data||[];s(Array.isArray(u)?u:[])}catch(k){console.error("Failed to load audio:",k),s([])}},b=w=>{const k=Math.floor(w/60),u=w%60;return`${k}:${u.toString().padStart(2,"0")}`},f=w=>`${(w/1048576).toFixed(1)} MB`,p=()=>{if(r.length===0){i("No tracks in library"),a(!0);return}t(r[0],r),i(`Playing ${r.length} tracks`),a(!0)},_=()=>{if(r.length===0){i("No tracks to shuffle"),a(!0);return}const w=[...r];for(let k=w.length-1;k>0;k--){const u=Math.floor(Math.random()*(k+1));[w[k],w[u]]=[w[u],w[k]]}t(w[0],w),i(`Shuffled ${w.length} tracks`),a(!0)};return e.jsxs(d,{children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:3,flexWrap:"wrap",gap:2},children:[e.jsx(c,{variant:"h4",sx:{fontWeight:700,letterSpacing:"-0.02em"},children:"Library"}),e.jsxs(d,{sx:{display:"flex",gap:1.5},children:[e.jsx(E,{variant:"contained",startIcon:e.jsx(_e,{}),onClick:p,disabled:r.length===0,sx:{minWidth:{xs:"48px",sm:"120px"},bgcolor:"primary.main",color:"background.dark",fontWeight:600,"&:hover":{bgcolor:"primary.dark"},"&:disabled":{bgcolor:"rgba(255, 255, 255, 0.1)"}},children:e.jsx(d,{sx:{display:{xs:"none",sm:"block"}},children:"Play All"})}),e.jsx(E,{variant:"outlined",startIcon:e.jsx(pr,{}),onClick:_,disabled:r.length===0,sx:{minWidth:{xs:"48px",sm:"120px"},borderColor:"primary.main",color:"primary.main",fontWeight:600,"&:hover":{borderColor:"primary.dark",bgcolor:"rgba(19, 236, 106, 0.05)"},"&:disabled":{borderColor:"rgba(255, 255, 255, 0.1)",color:"rgba(255, 255, 255, 0.3)"}},children:e.jsx(d,{sx:{display:{xs:"none",sm:"block"}},children:"Shuffle"})})]})]}),e.jsx(Pt,{component:Fe,sx:{bgcolor:"background.paper",borderRadius:3,border:"1px solid",borderColor:"rgba(255, 255, 255, 0.05)","& .MuiTableCell-root":{borderColor:"rgba(255, 255, 255, 0.05)"}},children:e.jsxs(It,{children:[e.jsx(Rt,{children:e.jsxs(me,{children:[e.jsx(W,{width:50,sx:{fontWeight:600},children:"#"}),e.jsx(W,{sx:{fontWeight:600},children:"Title"}),e.jsx(W,{sx:{fontWeight:600},children:"Channel"}),e.jsx(W,{align:"right",sx:{fontWeight:600},children:"Duration"}),e.jsx(W,{align:"right",sx:{fontWeight:600},children:"Size"}),e.jsx(W,{align:"right",sx:{fontWeight:600},children:"Plays"}),e.jsx(W,{align:"center",width:100,sx:{fontWeight:600},children:"Actions"})]})}),e.jsx(Ot,{children:r.map((w,k)=>e.jsxs(me,{sx:{cursor:"pointer",transition:"background-color 0.3s ease","&:hover":{bgcolor:"rgba(19, 236, 106, 0.05)"}},onClick:()=>t(w),children:[e.jsx(W,{sx:{color:"text.secondary"},children:k+1}),e.jsx(W,{children:e.jsx(c,{variant:"body2",noWrap:!0,sx:{maxWidth:300,fontWeight:500},children:w.title})}),e.jsx(W,{children:e.jsx(c,{variant:"body2",color:"text.secondary",children:w.channel_name})}),e.jsx(W,{align:"right",sx:{color:"text.secondary"},children:b(w.duration)}),e.jsx(W,{align:"right",sx:{color:"text.secondary"},children:f(w.file_size)}),e.jsx(W,{align:"right",sx:{color:"text.secondary"},children:w.play_count}),e.jsxs(W,{align:"center",onClick:u=>u.stopPropagation(),children:[e.jsx(U,{size:"small",sx:{color:"primary.main","&:hover":{bgcolor:"rgba(19, 236, 106, 0.1)"}},children:e.jsx(_e,{})}),e.jsx(U,{size:"small",sx:{"&:hover":{color:"primary.main",bgcolor:"rgba(19, 236, 106, 0.1)"}},children:e.jsx(fn,{})})]})]},w.id))})]})}),e.jsx(Te,{open:n,autoHideDuration:3e3,onClose:()=>a(!1),message:o,anchorOrigin:{vertical:"bottom",horizontal:"center"}})]})}var mr={},ji=B;Object.defineProperty(mr,"__esModule",{value:!0});var Ze=mr.default=void 0,vi=ji(q()),wi=e;Ze=mr.default=(0,vi.default)((0,wi.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"}),"Search");var gr={},Si=B;Object.defineProperty(gr,"__esModule",{value:!0});var et=gr.default=void 0,_i=Si(q()),Ci=e;et=gr.default=(0,_i.default)((0,Ci.jsx)("path",{d:"M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3z"}),"MusicNote");var yr={},ki=B;Object.defineProperty(yr,"__esModule",{value:!0});var br=yr.default=void 0,Ai=ki(q()),Pi=e;br=yr.default=(0,Ai.default)((0,Pi.jsx)("path",{d:"M3 10h11v2H3zm0-4h11v2H3zm0 8h7v2H3zm13-1v8l6-4z"}),"PlaylistPlay");var jr={},Ii=B;Object.defineProperty(jr,"__esModule",{value:!0});var tt=jr.default=void 0;Ei(y);var Ri=Ii(q()),Oi=e;function xn(t){if(typeof WeakMap!="function")return null;var r=new WeakMap,s=new WeakMap;return(xn=function(n){return n?s:r})(t)}function Ei(t,r){if(t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var s=xn(r);if(s&&s.has(t))return s.get(t);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if(o!=="default"&&Object.prototype.hasOwnProperty.call(t,o)){var i=a?Object.getOwnPropertyDescriptor(t,o):null;i&&(i.get||i.set)?Object.defineProperty(n,o,i):n[o]=t[o]}return n.default=t,s&&s.set(t,n),n}tt=jr.default=(0,Ri.default)((0,Oi.jsx)("path",{d:"M10 15l5.19-3L10 9v6m11.56-7.83c.13.47.22 1.1.28 1.9.07.8.1 1.49.1 2.09L22 12c0 2.19-.16 3.8-.44 4.83-.25.9-.83 1.48-1.73 1.73-.47.13-1.33.22-2.65.28-1.3.07-2.49.1-3.59.1L12 19c-4.19 0-6.8-.16-7.83-.44-.9-.25-1.48-.83-1.73-1.73-.13-.47-.22-1.1-.28-1.9-.07-.8-.1-1.49-.1-2.09L2 12c0-2.19.16-3.8.44-4.83.25-.9.83-1.48 1.73-1.73.47-.13 1.33-.22 2.65-.28 1.3-.07 2.49-.1 3.59-.1L12 5c4.19 0 6.8.16 7.83.44.9.25 1.48.83 1.73 1.73z"}),"YouTube");function Ti({setCurrentAudio:t}){const r=Le(),[s,n]=y.useState(""),[a,o]=y.useState(0),[i,l]=y.useState(!1),[b,f]=y.useState([]),[p,_]=y.useState([]),[w,k]=y.useState([]);y.useEffect(()=>{if(!s.trim()){f([]),_([]),k([]);return}const x=setTimeout(()=>{u()},500);return()=>clearTimeout(x)},[s]);const u=async()=>{var x,m,C;if(s.trim()){l(!0);try{const g=s.toLowerCase(),A=await it.list(),R=((x=A.data)==null?void 0:x.data)||A.data||[],$=(Array.isArray(R)?R:[]).filter(I=>{var S,T;return((S=I.title)==null?void 0:S.toLowerCase().includes(g))||((T=I.channel_name)==null?void 0:T.toLowerCase().includes(g))});f($);const z=await De.list(),P=((m=z.data)==null?void 0:m.data)||z.data||[],H=(Array.isArray(P)?P:[]).filter(I=>{var S,T;return((S=I.title)==null?void 0:S.toLowerCase().includes(g))||((T=I.channel_name)==null?void 0:T.toLowerCase().includes(g))});_(H);const K=await kt.list(),Q=((C=K.data)==null?void 0:C.data)||K.data||[],N=(Array.isArray(Q)?Q:[]).filter(I=>{var S;return(S=I.channel_name)==null?void 0:S.toLowerCase().includes(g)});k(N)}catch(g){console.error("Search failed:",g)}finally{l(!1)}}},j=x=>{const m=Math.floor(x/60),C=x%60;return`${m}:${C.toString().padStart(2,"0")}`},h=b.length+p.length+w.length;return e.jsxs(d,{children:[e.jsx(c,{variant:"h5",sx:{mb:3,fontWeight:700,letterSpacing:"-0.02em"},children:"Search"}),e.jsx(J,{fullWidth:!0,value:s,onChange:x=>n(x.target.value),placeholder:"Search for songs, artists, playlists, or channels...",variant:"outlined",InputProps:{startAdornment:e.jsx(Xe,{position:"start",children:e.jsx(Ze,{})})},sx:{mb:3,maxWidth:800,"& .MuiOutlinedInput-root":{borderRadius:"9999px",bgcolor:"rgba(255, 255, 255, 0.05)"}}}),s&&e.jsxs(e.Fragment,{children:[e.jsx(d,{sx:{borderBottom:1,borderColor:"divider",mb:3},children:e.jsxs(Is,{value:a,onChange:(x,m)=>o(m),children:[e.jsx(Be,{label:`All (${h})`,sx:{textTransform:"none",fontWeight:600}}),e.jsx(Be,{label:`Songs (${b.length})`,sx:{textTransform:"none",fontWeight:600}}),e.jsx(Be,{label:`Playlists (${p.length})`,sx:{textTransform:"none",fontWeight:600}}),e.jsx(Be,{label:`Channels (${w.length})`,sx:{textTransform:"none",fontWeight:600}})]})}),i?e.jsx(d,{sx:{display:"flex",justifyContent:"center",py:8},children:e.jsx(Re,{})}):h===0?e.jsxs(d,{sx:{textAlign:"center",py:8},children:[e.jsx(Ze,{sx:{fontSize:64,color:"text.secondary",opacity:.3,mb:2}}),e.jsx(c,{variant:"h6",color:"text.secondary",children:"No results found"}),e.jsx(c,{variant:"body2",color:"text.secondary",sx:{mt:1},children:"Try searching with different keywords"})]}):e.jsxs(d,{children:[a===0&&e.jsxs(d,{children:[b.length>0&&e.jsxs(d,{sx:{mb:4},children:[e.jsxs(c,{variant:"h6",sx:{mb:2,fontWeight:600,display:"flex",alignItems:"center",gap:1},children:[e.jsx(et,{})," Songs"]}),e.jsx(Pe,{children:b.slice(0,5).map(x=>e.jsx(he,{disablePadding:!0,secondaryAction:e.jsx(U,{edge:"end",onClick:()=>t(x),disabled:!x.file_path,sx:{color:"primary.main"},children:e.jsx(_e,{})}),children:e.jsxs(qe,{onClick:()=>t(x),disabled:!x.file_path,children:[e.jsx(jt,{children:e.jsx(ze,{src:x.thumbnail_url,variant:"rounded",sx:{width:56,height:56},children:e.jsx(et,{})})}),e.jsx(ce,{primary:x.title,secondary:`${x.channel_name} • ${j(x.duration)}`,primaryTypographyProps:{fontWeight:500}}),!x.file_path&&e.jsx(ee,{label:"Not Downloaded",size:"small",color:"warning",sx:{mr:2}})]})},x.id))})]}),p.length>0&&e.jsxs(d,{sx:{mb:4},children:[e.jsxs(c,{variant:"h6",sx:{mb:2,fontWeight:600,display:"flex",alignItems:"center",gap:1},children:[e.jsx(br,{})," Playlists"]}),e.jsx(F,{container:!0,spacing:2,children:p.slice(0,4).map(x=>e.jsx(F,{item:!0,xs:12,sm:6,md:3,children:e.jsxs(ne,{onClick:()=>r(`/playlists/${x.playlist_id}`),sx:{cursor:"pointer",transition:"transform 0.2s","&:hover":{transform:"translateY(-4px)"}},children:[e.jsx(Jr,{component:"img",height:"160",image:x.thumbnail_url,alt:x.title}),e.jsxs(ae,{children:[e.jsx(c,{variant:"body2",fontWeight:600,noWrap:!0,children:x.title}),e.jsxs(c,{variant:"caption",color:"text.secondary",noWrap:!0,children:[x.downloaded_count,"/",x.item_count," tracks"]})]})]})},x.id))})]}),w.length>0&&e.jsxs(d,{sx:{mb:4},children:[e.jsxs(c,{variant:"h6",sx:{mb:2,fontWeight:600,display:"flex",alignItems:"center",gap:1},children:[e.jsx(tt,{})," Channels"]}),e.jsx(Pe,{children:w.slice(0,5).map(x=>e.jsx(he,{disablePadding:!0,children:e.jsxs(qe,{onClick:()=>r("/channels"),children:[e.jsx(jt,{children:e.jsx(ze,{src:x.thumbnail_url,children:e.jsx(tt,{})})}),e.jsx(ce,{primary:x.channel_name,secondary:x.subscribed?"Subscribed":"Not subscribed",primaryTypographyProps:{fontWeight:500}})]})},x.id))})]})]}),a===1&&e.jsx(Pe,{children:b.map(x=>e.jsx(he,{disablePadding:!0,secondaryAction:e.jsx(U,{edge:"end",onClick:()=>t(x),disabled:!x.file_path,sx:{color:"primary.main"},children:e.jsx(_e,{})}),children:e.jsxs(qe,{onClick:()=>t(x),disabled:!x.file_path,children:[e.jsx(jt,{children:e.jsx(ze,{src:x.thumbnail_url,variant:"rounded",sx:{width:56,height:56},children:e.jsx(et,{})})}),e.jsx(ce,{primary:x.title,secondary:`${x.channel_name} • ${j(x.duration)}`,primaryTypographyProps:{fontWeight:500}}),!x.file_path&&e.jsx(ee,{label:"Not Downloaded",size:"small",color:"warning",sx:{mr:2}})]})},x.id))}),a===2&&e.jsx(F,{container:!0,spacing:2,children:p.map(x=>e.jsx(F,{item:!0,xs:12,sm:6,md:3,children:e.jsxs(ne,{onClick:()=>r(`/playlists/${x.playlist_id}`),sx:{cursor:"pointer",transition:"transform 0.2s","&:hover":{transform:"translateY(-4px)"}},children:[e.jsx(Jr,{component:"img",height:"160",image:x.thumbnail_url,alt:x.title}),e.jsxs(ae,{children:[e.jsx(c,{variant:"body2",fontWeight:600,noWrap:!0,children:x.title}),e.jsx(c,{variant:"caption",color:"text.secondary",noWrap:!0,children:x.channel_name}),e.jsxs(c,{variant:"caption",color:"text.secondary",display:"block",children:[x.downloaded_count,"/",x.item_count," tracks"]})]})]})},x.id))}),a===3&&e.jsx(Pe,{children:w.map(x=>e.jsx(he,{disablePadding:!0,children:e.jsxs(qe,{onClick:()=>r("/channels"),children:[e.jsx(jt,{children:e.jsx(ze,{src:x.thumbnail_url,sx:{width:56,height:56},children:e.jsx(tt,{})})}),e.jsx(ce,{primary:x.channel_name,secondary:x.subscribed?"Subscribed":"Not subscribed",primaryTypographyProps:{fontWeight:500,fontSize:"1rem"}}),x.subscribed&&e.jsx(ee,{label:"Subscribed",size:"small",color:"success"})]})},x.id))})]})]}),!s&&e.jsxs(d,{sx:{textAlign:"center",py:8},children:[e.jsx(Ze,{sx:{fontSize:80,color:"text.secondary",opacity:.3,mb:2}}),e.jsx(c,{variant:"h6",color:"text.secondary",gutterBottom:!0,children:"Search Your Library"}),e.jsx(c,{variant:"body2",color:"text.secondary",children:"Find songs, playlists, and channels in your collection"})]})]})}var vr={},zi=B;Object.defineProperty(vr,"__esModule",{value:!0});var wr=vr.default=void 0,Wi=zi(q()),Di=e;wr=vr.default=(0,Wi.default)((0,Di.jsx)("path",{d:"m12 21.35-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54z"}),"Favorite");function Fi({setCurrentAudio:t}){return e.jsxs(d,{children:[e.jsx(c,{variant:"h4",sx:{mb:2,fontWeight:600},children:"Favorites"}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:300,gap:1.5},children:[e.jsx(wr,{sx:{fontSize:48,color:"text.secondary"}}),e.jsx(c,{variant:"subtitle1",color:"text.secondary",children:"No favorites yet"}),e.jsx(c,{variant:"caption",color:"text.secondary",children:"Start adding songs to your favorites"})]})]})}function Mi(){const[t,r]=y.useState([]),[s,n]=y.useState(!0),[a,o]=y.useState(!1),[i,l]=y.useState(""),[b,f]=y.useState(""),p=async()=>{var h,x;try{const m=await kt.list(),C=Array.isArray(m.data)?m.data:((h=m.data)==null?void 0:h.results)||((x=m.data)==null?void 0:x.data)||[];r(C)}catch(m){console.error("Failed to load channels:",m),r([])}finally{n(!1)}};y.useEffect(()=>{p()},[]);const _=async()=>{var h,x;f("");try{await kt.subscribe({url:i}),l(""),o(!1),p()}catch(m){f(((x=(h=m.response)==null?void 0:h.data)==null?void 0:x.detail)||"Failed to subscribe to channel")}},w=async h=>{if(confirm("Are you sure you want to unsubscribe from this channel?"))try{await kt.unsubscribe(h),p()}catch(x){console.error("Failed to unsubscribe:",x)}},k=h=>h>=1e6?`${(h/1e6).toFixed(1)}M`:h>=1e3?`${(h/1e3).toFixed(1)}K`:h.toString(),u=h=>{switch(h){case"syncing":return"primary";case"success":return"success";case"failed":return"error";case"stale":return"warning";default:return"default"}},j=h=>{const x=new Date(h),C=new Date().getTime()-x.getTime(),g=Math.floor(C/6e4),A=Math.floor(C/36e5),R=Math.floor(C/864e5);return g<1?"Just now":g<60?`${g}m ago`:A<24?`${A}h ago`:`${R}d ago`};return e.jsxs(d,{children:[e.jsxs(d,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[e.jsx(c,{variant:"h4",fontWeight:"bold",children:"YouTube Channels"}),e.jsx(E,{variant:"contained",size:"small",startIcon:e.jsx(st,{}),onClick:()=>o(!0),children:"Subscribe to Channel"})]}),e.jsx(F,{container:!0,spacing:2,children:t.map(h=>e.jsx(F,{item:!0,xs:12,sm:6,md:4,children:e.jsxs(ne,{children:[e.jsxs(ae,{children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1.5,mt:h.channel_thumbnail?-3:0},children:[e.jsx(ze,{src:h.channel_thumbnail,sx:{width:64,height:64,border:"3px solid",borderColor:"background.paper",boxShadow:2},children:e.jsx(Kr,{})}),e.jsx(d,{sx:{ml:1.5,flex:1},children:e.jsx(c,{variant:"subtitle1",fontWeight:"bold",noWrap:!0,children:h.channel_name})})]}),e.jsxs(d,{sx:{display:"flex",gap:.5,flexWrap:"wrap",mb:.5},children:[e.jsx(ee,{label:h.status_display,color:u(h.sync_status),size:"small"}),!h.active&&e.jsx(ee,{label:"Inactive",color:"error",size:"small",variant:"outlined"})]}),e.jsx(c,{variant:"caption",color:"text.secondary",display:"block",sx:{mb:1},children:j(h.last_refreshed)}),h.error_message&&e.jsx(V,{severity:"error",sx:{mt:1,mb:1,py:0},children:e.jsx(c,{variant:"caption",children:h.error_message})}),e.jsxs(d,{sx:{display:"flex",gap:1.5,mt:1.5},children:[e.jsxs(d,{children:[e.jsx(c,{variant:"caption",color:"text.secondary",sx:{fontSize:"0.7rem"},children:"Subscribers"}),e.jsx(c,{variant:"body2",fontWeight:"bold",sx:{fontSize:"0.8125rem"},children:k(h.subscriber_count)})]}),e.jsxs(d,{children:[e.jsx(c,{variant:"caption",color:"text.secondary",children:"Videos"}),e.jsx(c,{variant:"body2",fontWeight:"bold",children:k(h.video_count)})]}),e.jsxs(d,{children:[e.jsx(c,{variant:"caption",color:"text.secondary",children:"Downloaded"}),e.jsxs(c,{variant:"body2",fontWeight:"bold",children:[h.downloaded_count," (",h.progress_percent,"%)"]})]})]})]}),e.jsxs(Rs,{sx:{justifyContent:"space-between",px:2,pb:2},children:[e.jsx(U,{size:"small",title:"Refresh channel",children:e.jsx(lt,{})}),e.jsx(U,{size:"small",color:"error",onClick:()=>w(h.channel_id),title:"Unsubscribe",children:e.jsx(nt,{})})]})]})},h.id))}),!s&&t.length===0&&e.jsxs(d,{sx:{textAlign:"center",py:8,color:"text.secondary"},children:[e.jsx(Kr,{sx:{fontSize:64,mb:2,opacity:.3}}),e.jsx(c,{variant:"h6",gutterBottom:!0,children:"No channels subscribed"}),e.jsx(c,{variant:"body2",sx:{mb:3},children:"Subscribe to YouTube channels to automatically download their content"}),e.jsx(E,{variant:"contained",startIcon:e.jsx(st,{}),onClick:()=>o(!0),children:"Subscribe to Channel"})]}),e.jsxs(je,{open:a,onClose:()=>o(!1),maxWidth:"sm",fullWidth:!0,children:[e.jsx(ve,{children:"Subscribe to YouTube Channel"}),e.jsxs(we,{children:[b&&e.jsx(V,{severity:"error",sx:{mb:2},children:b}),e.jsx(J,{autoFocus:!0,margin:"dense",label:"Channel URL",placeholder:"https://www.youtube.com/@channelname or channel ID",fullWidth:!0,value:i,onChange:h=>l(h.target.value),helperText:"Enter a YouTube channel URL or channel ID"})]}),e.jsxs(Se,{children:[e.jsx(E,{onClick:()=>o(!1),children:"Cancel"}),e.jsx(E,{onClick:_,variant:"contained",disabled:!i,children:"Subscribe"})]})]})]})}class $i{constructor(){ke(this,"deferredPrompt",null);ke(this,"isInstalled",!1);ke(this,"isOnline",navigator.onLine);ke(this,"listeners",new Map);ke(this,"registration",null);this.init()}init(){this.checkIfInstalled(),window.addEventListener("beforeinstallprompt",r=>{r.preventDefault(),this.deferredPrompt=r,this.emit("canInstall",!0)}),window.addEventListener("appinstalled",()=>{this.isInstalled=!0,this.deferredPrompt=null,this.emit("installed",!0)}),window.addEventListener("online",()=>{this.isOnline=!0,this.emit("online",!0)}),window.addEventListener("offline",()=>{this.isOnline=!1,this.emit("offline",!0)}),"serviceWorker"in navigator&&navigator.serviceWorker.addEventListener("controllerchange",()=>{this.emit("update",!0)})}checkIfInstalled(){return window.matchMedia("(display-mode: standalone)").matches?(this.isInstalled=!0,!0):navigator.standalone===!0?(this.isInstalled=!0,!0):!1}async registerServiceWorker(){if(!("serviceWorker"in navigator))return null;try{return this.registration=await navigator.serviceWorker.register("/service-worker.js",{scope:"/"}),console.log("Service Worker registered:",this.registration),this.registration.addEventListener("updatefound",()=>{const r=this.registration.installing;r&&r.addEventListener("statechange",()=>{r.state==="installed"&&navigator.serviceWorker.controller&&this.emit("updateAvailable",r)})}),this.registration}catch(r){return console.error("Service Worker registration failed:",r),null}}async showInstallPrompt(){if(!this.deferredPrompt)return console.warn("Install prompt not available"),!1;try{await this.deferredPrompt.prompt();const{outcome:r}=await this.deferredPrompt.userChoice;return r==="accepted"?(console.log("User accepted install prompt"),this.deferredPrompt=null,!0):(console.log("User dismissed install prompt"),!1)}catch(r){return console.error("Error showing install prompt:",r),!1}}async updateServiceWorker(){if(!this.registration)return;const r=this.registration.waiting;r&&(r.postMessage({type:"SKIP_WAITING"}),window.location.reload())}async clearCache(){if(!("serviceWorker"in navigator))return!1;try{const r=await navigator.serviceWorker.ready,s=new MessageChannel;return new Promise(n=>{var a;s.port1.onmessage=o=>{n(o.data.success)},(a=r.active)==null||a.postMessage({type:"CLEAR_CACHE"},[s.port2])})}catch(r){return console.error("Error clearing cache:",r),!1}}async cacheAudio(r){if(!("serviceWorker"in navigator))return!1;try{const s=await navigator.serviceWorker.ready,n=new MessageChannel;return new Promise(a=>{var o;n.port1.onmessage=i=>{a(i.data.success)},(o=s.active)==null||o.postMessage({type:"CACHE_AUDIO",url:r},[n.port2])})}catch(s){return console.error("Error caching audio:",s),!1}}async requestNotificationPermission(){return"Notification"in window?Notification.permission==="granted"?"granted":Notification.permission!=="denied"?await Notification.requestPermission():Notification.permission:(console.warn("Notifications not supported"),"denied")}async showNotification(r,s){if(Notification.permission==="granted"){if(!this.registration){new Notification(r,s);return}await this.registration.showNotification(r,{icon:"/img/icon-192x192.png",badge:"/img/icon-72x72.png",...s})}}canInstall(){return this.deferredPrompt!==null}getIsInstalled(){return this.isInstalled}getIsOnline(){return this.isOnline}on(r,s){this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(s)}off(r,s){this.listeners.has(r)&&this.listeners.get(r).delete(s)}emit(r,s){this.listeners.has(r)&&this.listeners.get(r).forEach(n=>n(s))}async cachePlaylist(r,s){if(!("serviceWorker"in navigator))return!1;try{const n=await navigator.serviceWorker.ready,a=new MessageChannel;return new Promise(o=>{var i;a.port1.onmessage=l=>{o(l.data.success)},(i=n.active)==null||i.postMessage({type:"CACHE_PLAYLIST",playlistId:r,audioUrls:s},[a.port2])})}catch(n){return console.error("Error caching playlist:",n),!1}}async removePlaylistCache(r,s){if(!("serviceWorker"in navigator))return!1;try{const n=await navigator.serviceWorker.ready,a=new MessageChannel;return new Promise(o=>{var i;a.port1.onmessage=l=>{o(l.data.success)},(i=n.active)==null||i.postMessage({type:"REMOVE_PLAYLIST_CACHE",playlistId:r,audioUrls:s},[a.port2])})}catch(n){return console.error("Error removing playlist cache:",n),!1}}async getCacheSize(){if("storage"in navigator&&"estimate"in navigator.storage){const r=await navigator.storage.estimate();return{usage:r.usage||0,quota:r.quota||0}}return null}}const Z=new $i,pn=y.createContext(void 0),xt=()=>{const t=y.useContext(pn);if(!t)throw new Error("usePWA must be used within PWAProvider");return t},Li=({children:t})=>{const[r,s]=y.useState(navigator.onLine),[n,a]=y.useState(!1),[o,i]=y.useState(Z.getIsInstalled()),[l,b]=y.useState(!1),[f,p]=y.useState(null);y.useEffect(()=>{Z.registerServiceWorker();const C=()=>s(!0),g=()=>s(!1),A=()=>a(!0),R=()=>{i(!0),a(!1)},$=()=>b(!0);return Z.on("online",C),Z.on("offline",g),Z.on("canInstall",A),Z.on("installed",R),Z.on("updateAvailable",$),(async()=>{const P=await Z.getCacheSize();p(P)})(),a(Z.canInstall()),()=>{Z.off("online",C),Z.off("offline",g),Z.off("canInstall",A),Z.off("installed",R),Z.off("updateAvailable",$)}},[]);const m={isOnline:r,canInstall:n,isInstalled:o,isUpdateAvailable:l,cacheSize:f,showInstallPrompt:async()=>await Z.showInstallPrompt(),updateApp:async()=>{await Z.updateServiceWorker()},clearCache:async()=>{const C=await Z.clearCache();if(C){const g=await Z.getCacheSize();p(g)}return C},cacheAudio:async C=>{const g=await Z.cacheAudio(C);if(g){const A=await Z.getCacheSize();p(A)}return g},cachePlaylist:async(C,g)=>{const A=await Z.cachePlaylist(C,g);if(A){const R=await Z.getCacheSize();p(R)}return A},removePlaylistCache:async(C,g)=>{const A=await Z.removePlaylistCache(C,g);if(A){const R=await Z.getCacheSize();p(R)}return A},requestNotifications:async()=>await Z.requestNotificationPermission()};return e.jsx(pn.Provider,{value:m,children:t})},Ui="soundwave-offline",Ni=1,Y={AUDIO_QUEUE:"audioQueue",FAVORITES:"favorites",PLAYLISTS:"playlists",SETTINGS:"settings",PENDING_UPLOADS:"pendingUploads"};class Bi{constructor(){ke(this,"db",null)}async init(){return new Promise((r,s)=>{const n=indexedDB.open(Ui,Ni);n.onerror=()=>s(n.error),n.onsuccess=()=>{this.db=n.result,r()},n.onupgradeneeded=a=>{const o=a.target.result;o.objectStoreNames.contains(Y.AUDIO_QUEUE)||o.createObjectStore(Y.AUDIO_QUEUE,{keyPath:"id"}),o.objectStoreNames.contains(Y.FAVORITES)||o.createObjectStore(Y.FAVORITES,{keyPath:"id"}).createIndex("timestamp","timestamp",{unique:!1}),o.objectStoreNames.contains(Y.PLAYLISTS)||o.createObjectStore(Y.PLAYLISTS,{keyPath:"id"}),o.objectStoreNames.contains(Y.SETTINGS)||o.createObjectStore(Y.SETTINGS,{keyPath:"key"}),o.objectStoreNames.contains(Y.PENDING_UPLOADS)||o.createObjectStore(Y.PENDING_UPLOADS,{keyPath:"id",autoIncrement:!0}).createIndex("timestamp","timestamp",{unique:!1})}})}async get(r,s){return this.db||await this.init(),new Promise((n,a)=>{const l=this.db.transaction(r,"readonly").objectStore(r).get(s);l.onsuccess=()=>n(l.result),l.onerror=()=>a(l.error)})}async getAll(r){return this.db||await this.init(),new Promise((s,n)=>{const i=this.db.transaction(r,"readonly").objectStore(r).getAll();i.onsuccess=()=>s(i.result),i.onerror=()=>n(i.error)})}async put(r,s){return this.db||await this.init(),new Promise((n,a)=>{const l=this.db.transaction(r,"readwrite").objectStore(r).put(s);l.onsuccess=()=>n(),l.onerror=()=>a(l.error)})}async delete(r,s){return this.db||await this.init(),new Promise((n,a)=>{const l=this.db.transaction(r,"readwrite").objectStore(r).delete(s);l.onsuccess=()=>n(),l.onerror=()=>a(l.error)})}async clear(r){return this.db||await this.init(),new Promise((s,n)=>{const i=this.db.transaction(r,"readwrite").objectStore(r).clear();i.onsuccess=()=>s(),i.onerror=()=>n(i.error)})}async saveAudioQueue(r){await this.clear(Y.AUDIO_QUEUE);for(const s of r)await this.put(Y.AUDIO_QUEUE,s)}async getAudioQueue(){return await this.getAll(Y.AUDIO_QUEUE)}async addFavorite(r){await this.put(Y.FAVORITES,{...r,timestamp:Date.now()})}async removeFavorite(r){await this.delete(Y.FAVORITES,r)}async getFavorites(){return await this.getAll(Y.FAVORITES)}async addPendingUpload(r){await this.put(Y.PENDING_UPLOADS,{...r,timestamp:Date.now()})}async getPendingUploads(){return await this.getAll(Y.PENDING_UPLOADS)}async removePendingUpload(r){await this.delete(Y.PENDING_UPLOADS,r)}async saveSetting(r,s){await this.put(Y.SETTINGS,{key:r,value:s})}async getSetting(r){const s=await this.get(Y.SETTINGS,r);return s==null?void 0:s.value}async savePlaylist(r){await this.put(Y.PLAYLISTS,{...r,offline:!0,lastSync:Date.now()})}async getPlaylist(r){return await this.get(Y.PLAYLISTS,r)}async getPlaylists(){return await this.getAll(Y.PLAYLISTS)}async getOfflinePlaylists(){return(await this.getAll(Y.PLAYLISTS)).filter(s=>s.offline)}async removePlaylist(r){await this.delete(Y.PLAYLISTS,r)}async updatePlaylistSyncStatus(r,s){const n=await this.getPlaylist(r);n&&(n.syncStatus=s,n.lastSync=Date.now(),await this.put(Y.PLAYLISTS,n))}async clearAllData(){await this.clear(Y.AUDIO_QUEUE),await this.clear(Y.FAVORITES),await this.clear(Y.PLAYLISTS),await this.clear(Y.PENDING_UPLOADS)}}const Ie=new Bi;Ie.init().catch(t=>{console.error("Failed to initialize offline storage:",t)});function qi(){const t=Le(),{isOnline:r}=xt(),[s,n]=y.useState([]),[a,o]=y.useState(!0),[i,l]=y.useState(!1),[b,f]=y.useState(""),[p,_]=y.useState(""),[w,k]=y.useState(new Set),u=async()=>{var g,A;try{const R=await De.list(),$=Array.isArray(R.data)?R.data:((g=R.data)==null?void 0:g.results)||((A=R.data)==null?void 0:A.data)||[];n($),await j()}catch(R){console.error("Failed to load playlists:",R),n([])}finally{o(!1)}},j=async()=>{try{const g=await Ie.getOfflinePlaylists(),A=new Set(g.map(R=>R.id));k(A)}catch(g){console.error("Failed to load offline status:",g)}};y.useEffect(()=>{u()},[]);const h=async()=>{var g,A;_(""),o(!0);try{await De.create({url:b}),f(""),l(!1),alert("✅ Playlist subscription started! Fetching metadata and downloading audio..."),await u(),o(!1);const R=setInterval(async()=>{await u()},3e3);setTimeout(()=>clearInterval(R),3e4)}catch(R){o(!1),_(((A=(g=R.response)==null?void 0:g.data)==null?void 0:A.detail)||"Failed to subscribe to playlist")}},x=async g=>{try{await De.download(g),setTimeout(u,1e3)}catch(A){console.error("Failed to start download:",A)}},m=async g=>{if(confirm("Are you sure you want to remove this playlist?"))try{await De.delete(g),u()}catch(A){console.error("Failed to delete playlist:",A)}},C=g=>g.progress_percent||0;return e.jsxs(d,{children:[e.jsxs(d,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,px:.5},children:[e.jsx(c,{variant:"h6",sx:{fontWeight:700,letterSpacing:"-0.02em"},children:"YouTube Playlists"}),e.jsx(E,{variant:"contained",size:"small",startIcon:e.jsx(st,{}),onClick:()=>l(!0),sx:{borderRadius:"9999px",textTransform:"none",fontWeight:600},children:"Add Playlist"})]}),e.jsx(d,{sx:{display:"flex",gap:3,overflowX:"auto",pb:2,"&::-webkit-scrollbar":{height:8},"&::-webkit-scrollbar-thumb":{bgcolor:"rgba(255,255,255,0.1)",borderRadius:1}},children:s.map(g=>e.jsxs(ne,{onClick:()=>t(`/playlists/${g.playlist_id}`),sx:{minWidth:160,width:160,cursor:"pointer",transition:"transform 0.2s","&:hover":{transform:"translateY(-4px)",bgcolor:"rgba(255, 255, 255, 0.05)"}},children:[e.jsxs(d,{sx:{height:160,width:160,backgroundImage:`url(${g.thumbnail_url})`,backgroundSize:"cover",backgroundPosition:"center",backgroundColor:"grey.900",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"12px 12px 0 0",position:"relative"},children:[!g.thumbnail_url&&e.jsx(Xr,{sx:{fontSize:40,color:"grey.600"}}),w.has(g.id)&&e.jsx(ee,{icon:e.jsx(Ve,{sx:{fontSize:14}}),label:"Offline",size:"small",sx:{position:"absolute",top:8,right:8,height:20,fontSize:"0.65rem",fontWeight:600,bgcolor:"success.main",color:"white","& .MuiChip-icon":{color:"white"}}}),!r&&!w.has(g.id)&&e.jsx(ee,{icon:e.jsx(Os,{sx:{fontSize:14}}),label:"Unavailable",size:"small",sx:{position:"absolute",top:8,right:8,height:20,fontSize:"0.65rem",fontWeight:600,bgcolor:"rgba(0, 0, 0, 0.7)",color:"warning.main","& .MuiChip-icon":{color:"warning.main"}}})]}),e.jsxs(ae,{sx:{p:1.5,pb:1},children:[e.jsx(c,{variant:"body2",fontWeight:600,noWrap:!0,sx:{mb:.5},children:g.title}),e.jsx(c,{variant:"caption",color:"text.secondary",noWrap:!0,children:g.channel_name}),e.jsxs(d,{sx:{mt:1},children:[e.jsxs(c,{variant:"caption",color:"text.secondary",sx:{fontSize:"0.65rem"},children:[g.downloaded_count,"/",g.item_count]}),e.jsx(Ce,{variant:"determinate",value:C(g),sx:{height:3,borderRadius:1,mt:.5}})]})]}),e.jsxs(Rs,{sx:{justifyContent:"space-between",px:1,py:.5,gap:.5},children:[e.jsx(U,{size:"small",color:"primary",onClick:A=>{A.stopPropagation(),x(g.playlist_id)},disabled:g.sync_status==="syncing",title:g.sync_status==="syncing"?"Downloading...":"Download",sx:{width:28,height:28},children:e.jsx(Es,{sx:{fontSize:16}})}),e.jsx(U,{size:"small",color:"error",onClick:A=>{A.stopPropagation(),m(g.playlist_id)},title:"Remove",sx:{width:28,height:28},children:e.jsx(nt,{sx:{fontSize:16}})})]})]},g.id))}),!a&&s.length===0&&e.jsxs(d,{sx:{textAlign:"center",py:8,color:"text.secondary"},children:[e.jsx(Xr,{sx:{fontSize:64,mb:2,opacity:.3}}),e.jsx(c,{variant:"h6",gutterBottom:!0,children:"No playlists added"}),e.jsx(c,{variant:"body2",sx:{mb:3},children:"Add YouTube playlists to automatically download all their videos"}),e.jsx(E,{variant:"contained",startIcon:e.jsx(st,{}),onClick:()=>l(!0),children:"Add Playlist"})]}),e.jsxs(je,{open:i,onClose:()=>l(!1),maxWidth:"sm",fullWidth:!0,children:[e.jsx(ve,{children:"Add YouTube Playlist"}),e.jsxs(we,{children:[p&&e.jsx(V,{severity:"error",sx:{mb:2},children:p}),e.jsx(J,{autoFocus:!0,margin:"dense",label:"Playlist URL",placeholder:"https://www.youtube.com/playlist?list=...",fullWidth:!0,value:b,onChange:g=>f(g.target.value),helperText:"Enter a YouTube playlist URL"})]}),e.jsxs(Se,{children:[e.jsx(E,{onClick:()=>l(!1),children:"Cancel"}),e.jsx(E,{onClick:h,variant:"contained",disabled:!b,children:"Add Playlist"})]})]})]})}function Hi({setCurrentAudio:t}){const{playlistId:r}=la(),s=Le(),{isOnline:n,cachePlaylist:a,removePlaylistCache:o,cacheSize:i}=xt(),[l,b]=y.useState(null),[f,p]=y.useState(!0),[_,w]=y.useState(""),[k,u]=y.useState(!1),[j,h]=y.useState(""),[x,m]=y.useState(!1),[C,g]=y.useState(!1),[A,R]=y.useState(0);y.useEffect(()=>{r&&(z(),$())},[r]);const $=async()=>{if(r)try{const O=await Ie.getPlaylist(r);m((O==null?void 0:O.offline)||!1)}catch(O){console.error("Failed to check offline status:",O)}},z=async()=>{var O,D;try{p(!0);const X=await De.getWithItems(r);b(X.data),w("")}catch(X){console.error("Failed to load playlist:",X),w(((D=(O=X.response)==null?void 0:O.data)==null?void 0:D.detail)||"Failed to load playlist")}finally{p(!1)}},P=async()=>{if(!(l!=null&&l.items))return;const O=l.items.filter(D=>D.audio.file_path&&D.audio.youtube_id);if(O.length===0){h("No downloaded tracks to save"),u(!0);return}h(`Downloading ${O.length} tracks to your device`),u(!0);for(const D of O)try{const X=await it.downloadFile(D.audio.youtube_id),re=window.URL.createObjectURL(X),se=document.createElement("a");se.href=re,se.download=D.audio.title||"audio",se.style.display="none",document.body.appendChild(se),se.click(),document.body.removeChild(se),window.URL.revokeObjectURL(re),await new Promise(Je=>setTimeout(Je,500))}catch(X){console.error(`Failed to download ${D.audio.title}:`,X)}},H=async()=>{if(!(l!=null&&l.items)||!n){h(n?"No tracks to cache":"Must be online to download for offline use"),u(!0);return}const O=l.items.filter(D=>D.audio.file_path);if(O.length===0){h("No tracks downloaded yet. Download tracks first."),u(!0);return}g(!0),R(0),h(`Caching ${O.length} tracks for offline...`),u(!0);try{const D=O.map(re=>`/api/audio/${re.audio.youtube_id}/download/`);await a(l.playlist_id,D)?(await Ie.savePlaylist({id:l.id,playlist_id:l.playlist_id,title:l.title,description:l.description,channel_name:l.channel_name,thumbnail_url:l.thumbnail_url,item_count:l.item_count,downloaded_count:O.length,items:O.map(re=>({id:re.id,position:re.position,audio:re.audio})),offline:!0,lastSync:Date.now()}),m(!0),h(`✅ ${O.length} tracks available offline!`)):h("Failed to cache playlist")}catch(D){console.error("Failed to cache offline:",D),h("Offline caching failed")}finally{g(!1),R(0),u(!0)}},K=async()=>{if(l!=null&&l.items)try{const O=l.items.filter(D=>D.audio.file_path).map(D=>`/api/audio/${D.audio.youtube_id}/download/`);await o(l.playlist_id,O),await Ie.removePlaylist(l.id),m(!1),h("Offline data removed"),u(!0)}catch(O){console.error("Failed to remove offline data:",O),h("Failed to remove offline data"),u(!0)}},Q=async(O,D)=>{try{h(`Downloading "${D}" to your device`),u(!0);const X=await it.downloadFile(O),re=window.URL.createObjectURL(X),se=document.createElement("a");se.href=re,se.download=D||"audio",se.style.display="none",document.body.appendChild(se),se.click(),document.body.removeChild(se),window.URL.revokeObjectURL(re)}catch(X){console.error("Download failed:",X),h("Download failed"),u(!0)}},N=()=>{if(!(l!=null&&l.items))return;const O=l.items.filter(D=>D.audio.file_path).map(D=>D.audio);O.length>0?(t(O[0],O),h(`Playing ${O.length} tracks`),u(!0)):(h("No downloaded tracks to play"),u(!0))},I=()=>{if(!(l!=null&&l.items))return;const O=l.items.filter(D=>D.audio.file_path).map(D=>D.audio);if(O.length>0){const D=[...O];for(let X=D.length-1;X>0;X--){const re=Math.floor(Math.random()*(X+1));[D[X],D[re]]=[D[re],D[X]]}t(D[0],D),h(`Shuffled ${D.length} tracks`),u(!0)}else h("No downloaded tracks to shuffle"),u(!0)},S=O=>{const D=Math.floor(O/60),X=O%60;return`${D}:${X.toString().padStart(2,"0")}`},T=O=>new Date(O).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),G=O=>{switch(O){case"syncing":return"primary";case"success":return"success";case"failed":return"error";case"stale":return"warning";default:return"default"}};return f?e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"60vh"},children:e.jsx(Re,{})}):_||!l?e.jsxs(d,{children:[e.jsx(U,{onClick:()=>s("/playlists"),sx:{mb:2},children:e.jsx(Zr,{})}),e.jsx(V,{severity:"error",children:_||"Playlist not found"})]}):e.jsxs(d,{children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:2,mb:3,flexWrap:"wrap"},children:[e.jsx(U,{onClick:()=>s("/playlists"),sx:{bgcolor:"rgba(255, 255, 255, 0.05)","&:hover":{bgcolor:"rgba(255, 255, 255, 0.1)"}},children:e.jsx(Zr,{})}),e.jsxs(d,{sx:{flex:1,minWidth:200},children:[e.jsx(c,{variant:"h5",sx:{fontWeight:700,letterSpacing:"-0.02em",mb:.5},children:l.title}),e.jsx(c,{variant:"body2",color:"text.secondary",children:l.channel_name})]}),e.jsx(ee,{label:l.status_display,color:G(l.sync_status),size:"small"})]}),!n&&e.jsx(ne,{sx:{mb:3,bgcolor:"rgba(255, 193, 7, 0.1)",border:"1px solid rgba(255, 193, 7, 0.3)"},children:e.jsxs(d,{sx:{p:2,display:"flex",alignItems:"center",gap:2},children:[e.jsx(Os,{sx:{color:"warning.main"}}),e.jsxs(d,{sx:{flex:1},children:[e.jsx(c,{variant:"subtitle2",sx:{fontWeight:600,color:"warning.main"},children:"Offline Mode"}),e.jsx(c,{variant:"caption",color:"text.secondary",children:x?"This playlist is available offline":"You are offline. Cache playlists when online for offline access."})]})]})}),e.jsxs(d,{sx:{display:"flex",gap:1.5,mb:3,flexWrap:"wrap"},children:[e.jsx(E,{variant:"contained",startIcon:e.jsx(Nt,{}),onClick:N,disabled:!l.downloaded_count,sx:{minWidth:{xs:"48px",sm:"120px"},bgcolor:"primary.main",color:"background.dark",fontWeight:600,"&:hover":{bgcolor:"primary.dark"},"&:disabled":{bgcolor:"rgba(255, 255, 255, 0.1)"}},children:e.jsx(d,{sx:{display:{xs:"none",sm:"block"}},children:"Play All"})}),e.jsx(E,{variant:"outlined",startIcon:e.jsx(Mn,{}),onClick:I,disabled:!l.downloaded_count,sx:{minWidth:{xs:"48px",sm:"120px"},borderColor:"primary.main",color:"primary.main",fontWeight:600,"&:hover":{borderColor:"primary.dark",bgcolor:"rgba(19, 236, 106, 0.05)"},"&:disabled":{borderColor:"rgba(255, 255, 255, 0.1)",color:"rgba(255, 255, 255, 0.3)"}},children:e.jsx(d,{sx:{display:{xs:"none",sm:"block"}},children:"Shuffle"})}),e.jsx(E,{variant:"outlined",startIcon:e.jsx(Bt,{}),onClick:P,disabled:!l.downloaded_count,sx:{minWidth:{xs:"48px",sm:"150px"},borderColor:"primary.main",color:"primary.main",fontWeight:600,"&:hover":{borderColor:"primary.dark",bgcolor:"rgba(19, 236, 106, 0.05)"},"&:disabled":{borderColor:"rgba(255, 255, 255, 0.1)",color:"rgba(255, 255, 255, 0.3)"}},title:"Download all tracks to your device",children:e.jsx(d,{sx:{display:{xs:"none",sm:"block"}},children:"Save All"})})]}),e.jsx(ne,{sx:{mb:3,bgcolor:x?"rgba(76, 175, 80, 0.1)":"rgba(33, 150, 243, 0.1)",border:`1px solid ${x?"rgba(76, 175, 80, 0.3)":"rgba(33, 150, 243, 0.3)"}`},children:e.jsxs(d,{sx:{p:2},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[x?e.jsx(Ve,{sx:{color:"success.main"}}):e.jsx(Et,{sx:{color:"info.main"}}),e.jsxs(d,{sx:{flex:1},children:[e.jsx(c,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:x?"📱 Offline Ready":"💾 Cache for Offline"}),e.jsx(c,{variant:"caption",color:"text.secondary",children:x?`${l.downloaded_count} tracks cached and available without internet`:"Download this playlist to listen without an internet connection"})]})]}),C&&e.jsxs(d,{sx:{mb:2},children:[e.jsx(Ce,{variant:"determinate",value:A,sx:{height:6,borderRadius:1,mb:1}}),e.jsxs(c,{variant:"caption",color:"text.secondary",children:["Caching tracks... ",A,"%"]})]}),e.jsxs(d,{sx:{display:"flex",gap:1.5,flexWrap:"wrap"},children:[x?e.jsxs(e.Fragment,{children:[e.jsx(Ae,{title:"Remove offline cache to free up storage space",children:e.jsx(E,{variant:"outlined",startIcon:e.jsx($n,{}),onClick:K,size:"small",sx:{borderColor:"error.main",color:"error.main",fontWeight:600,"&:hover":{borderColor:"error.dark",bgcolor:"rgba(244, 67, 54, 0.05)"}},children:"Remove Offline"})}),e.jsx(ee,{icon:e.jsx(Ve,{}),label:"Cached",color:"success",size:"small",sx:{fontWeight:600}})]}):e.jsx(E,{variant:"contained",startIcon:e.jsx(Bt,{}),onClick:H,disabled:!n||C||!l.downloaded_count,size:"small",sx:{bgcolor:"info.main",color:"white",fontWeight:600,"&:hover":{bgcolor:"info.dark"},"&:disabled":{bgcolor:"rgba(255, 255, 255, 0.1)"}},children:C?"Caching...":"Make Available Offline"}),i&&e.jsxs(d,{sx:{ml:"auto",display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[e.jsx(c,{variant:"caption",color:"text.secondary",children:"Storage Used"}),e.jsxs(c,{variant:"caption",sx:{fontWeight:600},children:[(i.usage/1024/1024).toFixed(1)," MB / ",(i.quota/1024/1024/1024).toFixed(1)," GB"]})]})]})]})}),l.downloaded_count0?l.items.map((O,D)=>e.jsxs(me,{sx:{cursor:"pointer",transition:"background-color 0.3s ease","&:hover":{bgcolor:"rgba(19, 236, 106, 0.05)"},opacity:O.audio.file_path?1:.5},onClick:()=>O.audio.file_path&&t(O.audio),children:[e.jsx(W,{sx:{color:"text.secondary",fontSize:{xs:"0.7rem",sm:"0.75rem"}},children:D+1}),e.jsx(W,{children:e.jsxs(d,{children:[e.jsx(c,{variant:"body2",noWrap:!0,sx:{maxWidth:{xs:200,sm:300,md:400},fontWeight:500,fontSize:{xs:"0.75rem",sm:"0.875rem"}},children:O.audio.title}),!O.audio.file_path&&e.jsx(ee,{label:"Not Downloaded",size:"small",color:"warning",sx:{mt:.5,height:18,fontSize:"0.65rem"}})]})}),e.jsx(W,{sx:{display:{xs:"none",md:"table-cell"}},children:e.jsx(c,{variant:"body2",color:"text.secondary",noWrap:!0,sx:{maxWidth:150,fontSize:"0.75rem"},children:O.audio.channel_name})}),e.jsx(W,{align:"right",sx:{color:"text.secondary",fontSize:{xs:"0.7rem",sm:"0.75rem"}},children:S(O.audio.duration)}),e.jsx(W,{align:"center",onClick:X=>X.stopPropagation(),children:e.jsxs(d,{sx:{display:"flex",gap:.5,justifyContent:"center"},children:[e.jsx(U,{size:"small",onClick:()=>O.audio.file_path&&t(O.audio),disabled:!O.audio.file_path,sx:{color:"primary.main","&:disabled":{color:"rgba(255, 255, 255, 0.3)"}},title:"Play",children:e.jsx(Nt,{})}),O.audio.file_path&&O.audio.youtube_id&&e.jsx(U,{size:"small",onClick:()=>Q(O.audio.youtube_id,O.audio.title),sx:{color:"primary.main"},title:"Download to device",children:e.jsx(Es,{})})]})})]},O.id)):e.jsx(me,{children:e.jsx(W,{colSpan:5,align:"center",sx:{py:4},children:e.jsx(c,{variant:"body2",color:"text.secondary",children:"No tracks found in this playlist"})})})})]})}),e.jsx(Te,{open:k,autoHideDuration:3e3,onClose:()=>u(!1),message:j,anchorOrigin:{vertical:"bottom",horizontal:"center"}})]})}var Sr={},Vi=B;Object.defineProperty(Sr,"__esModule",{value:!0});var Kt=Sr.default=void 0,Gi=Vi(q()),Yi=e;Kt=Sr.default=(0,Gi.default)((0,Yi.jsx)("path",{d:"M12 1 3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5zm0 10.99h7c-.53 4.12-3.28 7.79-7 8.94V12H5V6.3l7-3.11z"}),"Security");var _r={},Qi=B;Object.defineProperty(_r,"__esModule",{value:!0});var Xt=_r.default=void 0,Ji=Qi(q()),Ki=e;Xt=_r.default=(0,Ji.default)((0,Ki.jsx)("path",{d:"M5 20h14v-2H5zM19 9h-4V3H9v6H5l7 7z"}),"Download");var Cr={},Xi=B;Object.defineProperty(Cr,"__esModule",{value:!0});var rt=Cr.default=void 0,Zi=Xi(q()),el=e;rt=Cr.default=(0,Zi.default)((0,el.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");var kr={},tl=B;Object.defineProperty(kr,"__esModule",{value:!0});var mn=kr.default=void 0,rl=tl(q()),sl=e;mn=kr.default=(0,rl.default)((0,sl.jsx)("path",{d:"M12 2C6.49 2 2 6.49 2 12s4.49 10 10 10c1.38 0 2.5-1.12 2.5-2.5 0-.61-.23-1.2-.64-1.67-.08-.1-.13-.21-.13-.33 0-.28.22-.5.5-.5H16c3.31 0 6-2.69 6-6 0-4.96-4.49-9-10-9m5.5 11c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m-3-4c-.83 0-1.5-.67-1.5-1.5S13.67 6 14.5 6s1.5.67 1.5 1.5S15.33 9 14.5 9M5 11.5c0-.83.67-1.5 1.5-1.5s1.5.67 1.5 1.5S7.33 13 6.5 13 5 12.33 5 11.5m6-4c0 .83-.67 1.5-1.5 1.5S8 8.33 8 7.5 8.67 6 9.5 6s1.5.67 1.5 1.5"}),"Palette");var Ar={},nl=B;Object.defineProperty(Ar,"__esModule",{value:!0});var gn=Ar.default=void 0,al=nl(q()),ol=e;gn=Ar.default=(0,al.default)((0,ol.jsx)("path",{d:"m20.38 8.57-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83"}),"Speed");var Pr={},il=B;Object.defineProperty(Pr,"__esModule",{value:!0});var yn=Pr.default=void 0,ll=il(q()),cl=e;yn=Pr.default=(0,ll.default)((0,cl.jsx)("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");var Ir={},dl=B;Object.defineProperty(Ir,"__esModule",{value:!0});var Zt=Ir.default=void 0,ul=dl(q()),hl=e;Zt=Ir.default=(0,ul.default)((0,hl.jsx)("path",{d:"M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3m-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3m0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5m8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5"}),"Group");const pt={fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif',fontSize:13,h1:{fontWeight:600,fontSize:"1.8rem"},h2:{fontWeight:600,fontSize:"1.6rem"},h3:{fontWeight:600,fontSize:"1.4rem"},h4:{fontWeight:600,fontSize:"1.2rem"},h5:{fontWeight:500,fontSize:"1.1rem"},h6:{fontWeight:500,fontSize:"1rem"},body1:{fontSize:"0.875rem"},body2:{fontSize:"0.8125rem"},button:{fontSize:"0.8125rem"},caption:{fontSize:"0.75rem"}},mt={borderRadius:12},gt={MuiButton:{styleOverrides:{root:{textTransform:"none",fontWeight:500,padding:"8px 16px",minHeight:"36px",fontSize:"0.875rem",borderRadius:"9999px",transition:"all 0.3s ease"},sizeSmall:{padding:"6px 12px",minHeight:"32px",fontSize:"0.8125rem"},sizeLarge:{padding:"10px 20px",minHeight:"40px"}}},MuiCard:{styleOverrides:{root:{backgroundImage:"none",borderRadius:"16px",transition:"transform 0.3s ease, box-shadow 0.3s ease","&:hover":{transform:"translateY(-2px)"}}}},MuiCardContent:{styleOverrides:{root:{padding:"12px","&:last-child":{paddingBottom:"12px"}}}},MuiIconButton:{styleOverrides:{root:{padding:"6px"},sizeSmall:{padding:"4px"}}},MuiChip:{styleOverrides:{root:{height:"24px",fontSize:"0.75rem"}}},MuiTableCell:{styleOverrides:{root:{padding:"8px 12px",fontSize:"0.8125rem"},head:{fontWeight:600,fontSize:"0.8125rem"}}},MuiListItem:{styleOverrides:{root:{paddingTop:"4px",paddingBottom:"4px"}}},MuiListItemButton:{styleOverrides:{root:{paddingTop:"6px",paddingBottom:"6px"}}},MuiAlert:{styleOverrides:{root:{padding:"6px 12px",fontSize:"0.8125rem"}}},MuiTextField:{styleOverrides:{root:{"& .MuiInputBase-root":{fontSize:"0.875rem"}}}},MuiAccordionSummary:{styleOverrides:{root:{minHeight:"42px","&.Mui-expanded":{minHeight:"42px"}},content:{margin:"8px 0","&.Mui-expanded":{margin:"8px 0"}}}},MuiAccordionDetails:{styleOverrides:{root:{padding:"8px 16px 16px"}}}},fl=ct({palette:{mode:"dark",primary:{main:"#22d3ee",light:"#67e8f9",dark:"#06b6d4",contrastText:"#ffffff"},secondary:{main:"#fbbf24",light:"#fcd34d",dark:"#f59e0b",contrastText:"#000000"},background:{default:"#0f172a",paper:"#1e293b"},text:{primary:"#f8fafc",secondary:"#94a3b8"},success:{main:"#10b981"},error:{main:"#ef4444"},warning:{main:"#fbbf24"},info:{main:"#22d3ee"}},typography:pt,shape:mt,components:gt}),xl=ct({palette:{mode:"dark",primary:{main:"#13ec6a",light:"#4fff92",dark:"#0db855"},secondary:{main:"#00BCD4",light:"#4DD0E1",dark:"#0097A7"},background:{default:"#0D1B2A",paper:"#1B263B"},text:{primary:"#E0F7FA",secondary:"#B3E5FC"},success:{main:"#13ec6a"},error:{main:"#FF5252"},warning:{main:"#FFD740"},info:{main:"#13ec6a"}},typography:pt,shape:mt,components:gt}),pl=ct({palette:{mode:"light",primary:{main:"#13ec6a",light:"#4fff92",dark:"#0db855"},secondary:{main:"#13ec6a",light:"#4fff92",dark:"#0db855"},background:{default:"#f6f8f7",paper:"#FFFFFF"},text:{primary:"#0f172a",secondary:"#64748b"},success:{main:"#13ec6a"},error:{main:"#D32F2F"},warning:{main:"#F57C00"},info:{main:"#13ec6a"}},typography:pt,shape:mt,components:{...gt,MuiCard:{styleOverrides:{root:{backgroundImage:"none",boxShadow:"0 2px 8px rgba(0,0,0,0.05)"}}}}}),ml=ct({palette:{mode:"dark",primary:{main:"#13ec6a",light:"#4fff92",dark:"#0db855"},secondary:{main:"#13ec6a",light:"#4fff92",dark:"#0db855"},background:{default:"#102217",paper:"#162e21"},text:{primary:"#ffffff",secondary:"rgba(255, 255, 255, 0.6)"},success:{main:"#13ec6a"},error:{main:"#EF5350"},warning:{main:"#FFA726"},info:{main:"#13ec6a"}},typography:pt,shape:mt,components:gt}),gl=ct({palette:{mode:"light",primary:{main:"#06b6d4",light:"#22d3ee",dark:"#0891b2",contrastText:"#ffffff"},secondary:{main:"#0ea5e9",light:"#38bdf8",dark:"#0284c7",contrastText:"#ffffff"},background:{default:"#ecfeff",paper:"#ffffff"},text:{primary:"#0c4a6e",secondary:"#0369a1"},success:{main:"#10b981"},error:{main:"#ef4444"},warning:{main:"#f59e0b"},info:{main:"#06b6d4"}},typography:pt,shape:mt,components:gt}),_s={dark:fl,blue:xl,white:pl,green:ml,lightBlue:gl},Cs={dark:"Dark",blue:"Ocean Blue",white:"Light",green:"Forest Green",lightBlue:"Light Blue"},yl=t=>_s[t]||_s.dark,bl=t=>{localStorage.setItem("themeMode",t)},jl=()=>localStorage.getItem("themeMode")||"dark";var Rr={},vl=B;Object.defineProperty(Rr,"__esModule",{value:!0});var Or=Rr.default=void 0,wl=vl(q()),Sl=e;Or=Rr.default=(0,wl.default)((0,Sl.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8z"}),"CheckCircle");const _l={dark:{primary:"#22d3ee",secondary:"#fbbf24",bg1:"#0f172a",bg2:"#1e293b",text:"#f8fafc"},blue:{primary:"#2196F3",secondary:"#00BCD4",bg1:"#0D1B2A",bg2:"#1B263B",text:"#E0F7FA"},white:{primary:"#1976D2",secondary:"#9C27B0",bg1:"#F5F7FA",bg2:"#FFFFFF",text:"#1A202C"},green:{primary:"#4CAF50",secondary:"#00E676",bg1:"#0D1F12",bg2:"#1A2F23",text:"#E8F5E9"},lightBlue:{primary:"#06b6d4",secondary:"#0ea5e9",bg1:"#ecfeff",bg2:"#ffffff",text:"#0c4a6e"}};function Cl({name:t,mode:r,isSelected:s,onClick:n}){const a=_l[r];return e.jsxs(d,{onClick:n,sx:{position:"relative",height:100,borderRadius:2,cursor:"pointer",border:3,borderColor:s?a.primary:"divider",transition:"all 0.3s ease",overflow:"hidden","&:hover":{transform:"scale(1.05)",boxShadow:`0 4px 20px ${a.primary}40`}},children:[e.jsx(d,{sx:{position:"absolute",inset:0,background:`linear-gradient(135deg, ${a.bg1} 0%, ${a.bg2} 100%)`}}),e.jsxs(d,{sx:{position:"absolute",top:8,left:8,right:8,bottom:8,display:"flex",flexDirection:"column",gap:.5},children:[e.jsx(d,{sx:{height:8,borderRadius:.5,bgcolor:a.primary,width:"60%"}}),e.jsx(d,{sx:{height:4,borderRadius:.5,bgcolor:a.text,opacity:.7,width:"80%"}}),e.jsx(d,{sx:{height:4,borderRadius:.5,bgcolor:a.text,opacity:.5,width:"60%"}}),e.jsx(d,{sx:{height:4,borderRadius:.5,bgcolor:a.secondary,opacity:.7,width:"40%",mt:.5}})]}),e.jsxs(d,{sx:{position:"absolute",bottom:4,left:8,right:8,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(c,{sx:{color:a.text,fontSize:"0.75rem",fontWeight:600,textShadow:r==="white"?"none":"0 1px 2px rgba(0,0,0,0.5)"},children:t}),s&&e.jsx(Or,{sx:{fontSize:16,color:a.primary}})]})]})}const bn=y.createContext(void 0),kl=()=>{const t=y.useContext(bn);if(!t)throw new Error("useQuickSync must be used within QuickSyncProvider");return t},Al=({children:t})=>{const[r,s]=y.useState(null),[n,a]=y.useState(null),[o,i]=y.useState(!0),l=async()=>{var _,w;try{const k=await M.get("/audio/quick-sync/status/");s(k.data.status),a(k.data.preferences)}catch(k){((_=k==null?void 0:k.response)==null?void 0:_.status)===401||((w=k==null?void 0:k.response)==null?void 0:w.status)===403?(s(null),a(null)):console.error("Error fetching Quick Sync status:",k)}finally{i(!1)}},b=async _=>{try{const w=await M.post("/audio/quick-sync/preferences/",_);a(w.data.preferences),s(w.data.status)}catch(w){throw console.error("Error updating Quick Sync preferences:",w),w}},f=async()=>{try{i(!0);const _=await M.post("/audio/quick-sync/test/");await l()}catch(_){throw console.error("Error running speed test:",_),_}finally{i(!1)}},p=async()=>{i(!0),await l()};return y.useEffect(()=>{if(!localStorage.getItem("token")){i(!1);return}l();const w=setInterval(l,5*60*1e3);return()=>clearInterval(w)},[]),e.jsx(bn.Provider,{value:{status:r,preferences:n,loading:o,updatePreferences:b,runSpeedTest:f,refreshStatus:p},children:t})},Pl=()=>{const{status:t,preferences:r,loading:s,updatePreferences:n,runSpeedTest:a,refreshStatus:o}=kl(),[i,l]=y.useState(!1),[b,f]=y.useState(null),p=async u=>{try{await n({mode:u}),f({type:"success",text:"Quality mode updated successfully"}),setTimeout(()=>f(null),3e3)}catch{f({type:"error",text:"Failed to update quality mode"})}},_=async(u,j)=>{try{await n({[u]:j}),f({type:"success",text:"Preferences updated successfully"}),setTimeout(()=>f(null),3e3)}catch{f({type:"error",text:"Failed to update preferences"})}},w=async()=>{l(!0);try{await a(),f({type:"success",text:"Speed test completed"}),setTimeout(()=>f(null),3e3)}catch{f({type:"error",text:"Speed test failed"})}finally{l(!1)}},k=u=>{switch(u){case"excellent":return e.jsx(at,{color:"success"});case"good":return e.jsx(at,{color:"primary"});case"fair":return e.jsx(Nn,{color:"warning"});case"poor":return e.jsx(Un,{color:"error"});default:return e.jsx(He,{})}};return s?e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"400px",children:e.jsx(Re,{})}):e.jsxs(d,{children:[e.jsxs(d,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(c,{variant:"subtitle1",fontWeight:600,children:"Quick Sync - Adaptive Streaming"}),e.jsx(U,{size:"small",onClick:o,disabled:s,children:e.jsx(lt,{})})]}),b&&e.jsx(V,{severity:b.type,sx:{mb:2},onClose:()=>f(null),children:b.text}),e.jsxs(Fe,{sx:{p:2,mb:2},children:[e.jsx(c,{variant:"body2",gutterBottom:!0,fontWeight:"bold",mb:1.5,children:"Current Status"}),t&&e.jsxs(F,{container:!0,spacing:2,children:[e.jsxs(F,{item:!0,xs:12,md:4,children:[e.jsxs(d,{display:"flex",alignItems:"center",mb:1,children:[e.jsx(es,{sx:{mr:.5,fontSize:"1.1rem"}}),e.jsx(c,{variant:"caption",fontWeight:"bold",children:"Network Speed"}),e.jsx(d,{ml:"auto",children:k(t.network.status)})]}),e.jsxs(c,{variant:"h6",color:"primary",mb:.75,children:[t.network.speed_mbps.toFixed(2)," Mbps"]}),e.jsx(ee,{label:t.network.status.toUpperCase(),size:"small",color:t.network.status==="excellent"||t.network.status==="good"?"success":t.network.status==="fair"?"warning":"error"})]}),e.jsxs(F,{item:!0,xs:12,md:4,children:[e.jsxs(d,{display:"flex",alignItems:"center",mb:1,children:[e.jsx(Ln,{sx:{mr:.5,fontSize:"1.1rem"}}),e.jsx(c,{variant:"caption",fontWeight:"bold",children:"System Resources"})]}),e.jsxs(d,{mb:1.5,children:[e.jsxs(d,{display:"flex",justifyContent:"space-between",mb:.5,children:[e.jsx(c,{variant:"caption",children:"CPU Usage"}),e.jsxs(c,{variant:"caption",children:[t.system.cpu_percent.toFixed(0),"%"]})]}),e.jsx(Ce,{variant:"determinate",value:t.system.cpu_percent,color:t.system.cpu_percent>80?"error":"primary"})]}),e.jsxs(d,{children:[e.jsxs(d,{display:"flex",justifyContent:"space-between",mb:.5,children:[e.jsx(c,{variant:"caption",children:"Memory Usage"}),e.jsxs(c,{variant:"caption",children:[t.system.memory_percent.toFixed(0),"%"]})]}),e.jsx(Ce,{variant:"determinate",value:t.system.memory_percent,color:t.system.memory_percent>85?"error":"primary"})]})]}),e.jsxs(F,{item:!0,xs:12,md:4,children:[e.jsxs(d,{display:"flex",alignItems:"center",mb:1,children:[e.jsx(Et,{sx:{mr:.5,fontSize:"1.1rem"}}),e.jsx(c,{variant:"caption",fontWeight:"bold",children:"Active Quality"})]}),e.jsx(c,{variant:"h6",color:"primary",mb:.75,children:t.quality.level.toUpperCase()}),e.jsxs(c,{variant:"body2",color:"text.secondary",mb:1,children:[t.quality.bitrate," kbps"]}),t.quality.auto_selected&&e.jsx(ee,{label:"Auto-Selected",size:"small",color:"info"})]})]}),e.jsx(d,{mt:3,children:e.jsx(E,{variant:"outlined",startIcon:i?e.jsx(Re,{size:20}):e.jsx(es,{}),onClick:w,disabled:i,fullWidth:!0,children:i?"Testing Connection...":"Run Speed Test"})})]}),e.jsxs(Fe,{sx:{p:3,mb:3},children:[e.jsx(c,{variant:"subtitle1",gutterBottom:!0,fontWeight:"bold",children:"Quality Settings"}),e.jsxs(Ts,{fullWidth:!0,sx:{mb:3},children:[e.jsx(zs,{children:"Quality Mode"}),e.jsxs(Ws,{value:(r==null?void 0:r.mode)||"auto",onChange:u=>p(u.target.value),label:"Quality Mode",children:[e.jsx(Ne,{value:"auto",children:e.jsxs(d,{children:[e.jsx(c,{children:"Auto (Recommended)"}),e.jsx(c,{variant:"caption",color:"text.secondary",children:"Adapts to your connection and system"})]})}),e.jsx(Ne,{value:"ultra",children:e.jsxs(d,{children:[e.jsx(c,{children:"Ultra (320 kbps)"}),e.jsx(c,{variant:"caption",color:"text.secondary",children:"Maximum fidelity - requires 5+ Mbps"})]})}),e.jsx(Ne,{value:"high",children:e.jsxs(d,{children:[e.jsx(c,{children:"High (256 kbps)"}),e.jsx(c,{variant:"caption",color:"text.secondary",children:"Best experience - requires 2+ Mbps"})]})}),e.jsx(Ne,{value:"medium",children:e.jsxs(d,{children:[e.jsx(c,{children:"Medium (128 kbps)"}),e.jsx(c,{variant:"caption",color:"text.secondary",children:"Balanced - requires 1+ Mbps"})]})}),e.jsx(Ne,{value:"low",children:e.jsxs(d,{children:[e.jsx(c,{children:"Low (64 kbps)"}),e.jsx(c,{variant:"caption",color:"text.secondary",children:"Saves bandwidth - requires 0.5+ Mbps"})]})})]})]}),e.jsx(oe,{control:e.jsx(le,{checked:(r==null?void 0:r.prefer_quality)||!1,onChange:u=>_("prefer_quality",u.target.checked)}),label:e.jsxs(d,{display:"flex",alignItems:"center",children:[e.jsx(c,{children:"Prefer Higher Quality"}),e.jsx(Ae,{title:"When system resources allow, automatically upgrade to higher quality",children:e.jsx(He,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})})]})}),e.jsx(oe,{control:e.jsx(le,{checked:(r==null?void 0:r.adapt_to_system)||!1,onChange:u=>_("adapt_to_system",u.target.checked)}),label:e.jsxs(d,{display:"flex",alignItems:"center",children:[e.jsx(c,{children:"Adapt to System Load"}),e.jsx(Ae,{title:"Automatically adjust quality based on CPU and memory usage",children:e.jsx(He,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})})]})}),e.jsx(oe,{control:e.jsx(le,{checked:(r==null?void 0:r.auto_download_quality)||!1,onChange:u=>_("auto_download_quality",u.target.checked)}),label:e.jsxs(d,{display:"flex",alignItems:"center",children:[e.jsx(c,{children:"Apply to Downloads"}),e.jsx(Ae,{title:"Use Quick Sync quality settings when downloading audio",children:e.jsx(He,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})})]})})]}),t&&e.jsxs(Fe,{sx:{p:3},children:[e.jsx(c,{variant:"subtitle1",gutterBottom:!0,fontWeight:"bold",children:"Buffer Settings"}),e.jsxs(F,{container:!0,spacing:2,children:[e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"body2",color:"text.secondary",children:"Buffer Size"}),e.jsxs(c,{variant:"h6",children:[t.buffer.buffer_size,"s"]})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"body2",color:"text.secondary",children:"Max Buffer"}),e.jsxs(c,{variant:"h6",children:[t.buffer.max_buffer_size,"s"]})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"body2",color:"text.secondary",children:"Preload"}),e.jsx(c,{variant:"h6",children:t.buffer.preload})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"body2",color:"text.secondary",children:"Rebuffer Threshold"}),e.jsxs(c,{variant:"h6",children:[t.buffer.rebuffer_threshold.toFixed(1),"s"]})]})]})]})]})},Il=()=>{const{isOnline:t,canInstall:r,isInstalled:s,isUpdateAvailable:n,cacheSize:a,showInstallPrompt:o,updateApp:i,clearCache:l,requestNotifications:b}=xt(),[f,p]=pe.useState("Notification"in window&&Notification.permission==="granted"),[_,w]=pe.useState(!1),[k,u]=pe.useState(null),j=async()=>{const A=await o();u(A?{message:"App installed successfully!",severity:"success"}:{message:"Installation cancelled or not available",severity:"info"})},h=async()=>{await i()},x=async()=>{w(!0);try{const A=await l();u(A?{message:"Cache cleared successfully",severity:"success"}:{message:"Failed to clear cache",severity:"error"})}catch{u({message:"Error clearing cache",severity:"error"})}finally{w(!1)}},m=async()=>{if(!f){const A=await b();p(A==="granted"),u(A==="granted"?{message:"Notifications enabled",severity:"success"}:{message:"Notifications permission denied",severity:"error"})}},C=A=>{if(A===0)return"0 Bytes";const R=1024,$=["Bytes","KB","MB","GB"],z=Math.floor(Math.log(A)/Math.log(R));return Math.round(A/Math.pow(R,z)*100)/100+" "+$[z]},g=a?Math.round(a.usage/a.quota*100):0;return e.jsx(ne,{children:e.jsxs(ae,{children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[e.jsx(Bt,{color:"primary",sx:{fontSize:"1.25rem"}}),e.jsx(c,{variant:"subtitle1",fontWeight:600,children:"Progressive Web App (PWA)"})]}),k&&e.jsx(V,{severity:k.severity,onClose:()=>u(null),sx:{mb:1.5},children:k.message}),e.jsxs(d,{sx:{mb:2},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.75},children:[e.jsx(c,{variant:"subtitle2",color:"textSecondary",children:"Connection Status"}),e.jsx(ee,{icon:t?e.jsx(Ve,{}):e.jsx(ot,{}),label:t?"Online":"Offline",color:t?"success":"warning",size:"small"})]}),!t&&e.jsx(V,{severity:"info",icon:e.jsx(He,{}),sx:{mt:1},children:"You're working offline. Cached content is still available."})]}),e.jsx(be,{sx:{my:2}}),e.jsxs(d,{sx:{mb:2},children:[e.jsx(c,{variant:"caption",color:"textSecondary",gutterBottom:!0,display:"block",fontWeight:600,children:"Installation"}),s?e.jsx(V,{severity:"success",icon:e.jsx(qt,{}),children:"App is installed and ready to use"}):r?e.jsxs(d,{children:[e.jsx(c,{variant:"caption",color:"textSecondary",sx:{mb:.75,display:"block"},children:"Install SoundWave for:"}),e.jsxs(Pe,{dense:!0,sx:{py:0},children:[e.jsx(he,{sx:{py:.25},children:e.jsx(ce,{primary:e.jsx(c,{variant:"caption",children:"• Faster startup and better performance"})})}),e.jsx(he,{sx:{py:.25},children:e.jsx(ce,{primary:e.jsx(c,{variant:"caption",children:"• Offline access to cached content"})})}),e.jsx(he,{sx:{py:.25},children:e.jsx(ce,{primary:e.jsx(c,{variant:"caption",children:"• Native app-like experience"})})}),e.jsx(he,{sx:{py:.25},children:e.jsx(ce,{primary:e.jsx(c,{variant:"caption",children:"• Desktop shortcut access"})})})]}),e.jsx(E,{variant:"contained",size:"small",startIcon:e.jsx(qt,{}),onClick:j,fullWidth:!0,children:"Install App"})]}):e.jsx(V,{severity:"info",children:"Installation not available. You may already be using the installed app or your browser doesn't support PWA installation."})]}),e.jsx(be,{sx:{my:2}}),n&&e.jsxs(e.Fragment,{children:[e.jsx(d,{sx:{mb:3},children:e.jsx(V,{severity:"info",icon:e.jsx(Ds,{}),action:e.jsx(E,{color:"inherit",size:"small",onClick:h,children:"Update"}),children:"New version available! Update now to get the latest features."})}),e.jsx(be,{sx:{my:2}})]}),e.jsxs(d,{sx:{mb:3},children:[e.jsx(c,{variant:"subtitle2",color:"textSecondary",gutterBottom:!0,children:"Cache Storage"}),a&&e.jsxs(e.Fragment,{children:[e.jsxs(d,{sx:{mb:2},children:[e.jsxs(d,{sx:{display:"flex",justifyContent:"space-between",mb:1},children:[e.jsxs(c,{variant:"body2",color:"textSecondary",children:[C(a.usage)," / ",C(a.quota)]}),e.jsxs(c,{variant:"body2",color:"textSecondary",children:[g,"%"]})]}),e.jsx(Ce,{variant:"determinate",value:Math.min(g,100),sx:{height:8,borderRadius:1}})]}),e.jsx(c,{variant:"caption",color:"textSecondary",display:"block",sx:{mb:2},children:"Cached data allows offline access to previously viewed content and improves loading times."})]}),e.jsx(E,{variant:"outlined",startIcon:e.jsx(Bn,{}),onClick:x,disabled:_,fullWidth:!0,children:_?"Clearing Cache...":"Clear Cache"})]}),e.jsx(be,{sx:{my:2}}),e.jsxs(d,{children:[e.jsx(c,{variant:"subtitle2",color:"textSecondary",gutterBottom:!0,children:"Notifications"}),e.jsx(oe,{control:e.jsx(le,{checked:f,onChange:m,disabled:f}),label:e.jsxs(d,{children:[e.jsx(c,{variant:"body2",children:"Enable push notifications"}),e.jsx(c,{variant:"caption",color:"textSecondary",children:"Get notified about downloads, updates, and more"})]})})]}),e.jsx(be,{sx:{my:2}}),e.jsxs(d,{children:[e.jsx(c,{variant:"subtitle2",color:"textSecondary",gutterBottom:!0,children:"PWA Features"}),e.jsxs(Pe,{dense:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{primary:"Offline Mode",secondary:"Access cached content without internet"}),e.jsx(wt,{children:e.jsx(ee,{label:"Active",color:"success",size:"small"})})]}),e.jsxs(he,{children:[e.jsx(ce,{primary:"Background Sync",secondary:"Sync data when connection is restored"}),e.jsx(wt,{children:e.jsx(ee,{label:"Active",color:"success",size:"small"})})]}),e.jsxs(he,{children:[e.jsx(ce,{primary:"Audio Caching",secondary:"Cache audio files for offline playback"}),e.jsx(wt,{children:e.jsx(ee,{label:"Active",color:"success",size:"small"})})]})]})]})]})})};var Er={},Rl=B;Object.defineProperty(Er,"__esModule",{value:!0});var er=Er.default=void 0,Ol=Rl(q()),El=e;er=Er.default=(0,Ol.default)((0,El.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6m0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20"}),"AccountCircle");var Tr={},Tl=B;Object.defineProperty(Tr,"__esModule",{value:!0});var jn=Tr.default=void 0,zl=Tl(q()),Wl=e;jn=Tr.default=(0,zl.default)((0,Wl.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1z"}),"Lock");function Dl(){const[t,r]=y.useState(null),[s,n]=y.useState(!1),[a,o]=y.useState(""),[i,l]=y.useState(""),[b,f]=y.useState(""),[p,_]=y.useState(""),[w,k]=y.useState(""),[u,j]=y.useState(""),[h,x]=y.useState(""),[m,C]=y.useState(""),[g,A]=y.useState("");y.useEffect(()=>{R()},[]);const R=async()=>{try{const P=await te.get("/api/user/account/",{headers:{Authorization:`Token ${localStorage.getItem("token")}`}});r(P.data),f(P.data.username),_(P.data.first_name||""),k(P.data.last_name||""),j(P.data.email)}catch{o("Failed to load user data")}},$=async()=>{var N,I;const P=b!==(t==null?void 0:t.username),H=p!==((t==null?void 0:t.first_name)||""),K=w!==((t==null?void 0:t.last_name)||""),Q=u!==(t==null?void 0:t.email);if(!P&&!H&&!K&&!Q){o("No changes detected");return}if((P||Q)&&!h){o("Current password required to change username or email");return}if(P){if(b.length<3){o("Username must be at least 3 characters long");return}if(!/^[a-zA-Z0-9_]+$/.test(b)){o("Username can only contain letters, numbers, and underscores");return}}n(!0),o(""),l("");try{const S={};P&&(S.username=b),H&&(S.first_name=p),K&&(S.last_name=w),Q&&(S.email=u),(P||Q)&&h.trim()&&(S.current_password=h);const T=await te.patch("/api/user/profile/",S,{headers:{Authorization:`Token ${localStorage.getItem("token")}`,"Content-Type":"application/json"}});T.data.user&&(r(T.data.user),f(T.data.user.username),_(T.data.user.first_name||""),k(T.data.user.last_name||""),j(T.data.user.email)),l("Profile updated successfully!"),x(""),setTimeout(()=>l(""),3e3)}catch(S){o(((I=(N=S.response)==null?void 0:N.data)==null?void 0:I.error)||"Failed to update profile")}finally{n(!1)}},z=async()=>{var P,H;if(!h||!m||!g){o("Please fill in all password fields");return}if(m!==g){o("New passwords do not match");return}if(m.length<8){o("Password must be at least 8 characters long");return}n(!0),o(""),l("");try{await te.post("/api/user/change-password/",{current_password:h,new_password:m},{headers:{Authorization:`Token ${localStorage.getItem("token")}`,"Content-Type":"application/json"}}),l("Password changed successfully!"),x(""),C(""),A(""),setTimeout(()=>l(""),3e3)}catch(K){o(((H=(P=K.response)==null?void 0:P.data)==null?void 0:H.error)||"Failed to change password")}finally{n(!1)}};return e.jsxs(Fe,{sx:{p:3},children:[e.jsxs(d,{display:"flex",alignItems:"center",mb:3,children:[e.jsx(er,{sx:{mr:1,fontSize:32,color:"primary.main"}}),e.jsx(c,{variant:"h6",children:"Profile Information"})]}),a&&e.jsx(V,{severity:"error",sx:{mb:2},onClose:()=>o(""),children:a}),i&&e.jsx(V,{severity:"success",sx:{mb:2},onClose:()=>l(""),children:i}),t&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{container:!0,spacing:2,sx:{mb:3},children:[e.jsxs(F,{item:!0,xs:12,sm:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Username"}),e.jsx(c,{variant:"body1",fontWeight:600,children:t.username})]}),e.jsxs(F,{item:!0,xs:12,sm:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Member Since"}),e.jsx(c,{variant:"body1",children:new Date(t.date_joined).toLocaleDateString()})]}),e.jsxs(F,{item:!0,xs:12,sm:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Storage"}),e.jsxs(c,{variant:"body1",children:[(t.storage_used_gb||0).toFixed(2)," / ",t.storage_quota_gb||0," GB"]})]}),e.jsxs(F,{item:!0,xs:12,sm:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Limits"}),e.jsxs(c,{variant:"body1",children:[t.max_channels||0," channels, ",t.max_playlists||0," playlists"]})]})]}),e.jsx(be,{sx:{my:3}}),e.jsxs(d,{mb:3,children:[e.jsxs(d,{display:"flex",alignItems:"center",mb:2,children:[e.jsx(er,{sx:{mr:1,color:"primary.main"}}),e.jsx(c,{variant:"h6",children:"Update Profile"})]}),e.jsxs(F,{container:!0,spacing:2,children:[e.jsx(F,{item:!0,xs:12,children:e.jsx(J,{label:"Username (Login ID)",value:b,onChange:P=>f(P.target.value),fullWidth:!0,helperText:"Used for login - requires password to change"})}),e.jsx(F,{item:!0,xs:12,sm:6,children:e.jsx(J,{label:"First Name",value:p,onChange:P=>_(P.target.value),fullWidth:!0})}),e.jsx(F,{item:!0,xs:12,sm:6,children:e.jsx(J,{label:"Last Name",value:w,onChange:P=>k(P.target.value),fullWidth:!0})}),e.jsx(F,{item:!0,xs:12,children:e.jsx(J,{label:"Email Address",type:"email",value:u,onChange:P=>j(P.target.value),fullWidth:!0})}),e.jsx(F,{item:!0,xs:12,children:e.jsx(J,{label:"Current Password",type:"password",value:h,onChange:P=>x(P.target.value),fullWidth:!0,helperText:"Required for username or email changes"})}),e.jsx(F,{item:!0,xs:12,children:e.jsx(E,{variant:"contained",onClick:$,disabled:s,fullWidth:!0,children:"Update Profile"})})]})]}),e.jsx(be,{sx:{my:3}}),e.jsxs(d,{children:[e.jsxs(d,{display:"flex",alignItems:"center",mb:2,children:[e.jsx(jn,{sx:{mr:1,color:"primary.main"}}),e.jsx(c,{variant:"h6",children:"Change Password"})]}),e.jsxs(F,{container:!0,spacing:2,children:[e.jsx(F,{item:!0,xs:12,children:e.jsx(J,{label:"Current Password",type:"password",value:h,onChange:P=>x(P.target.value),fullWidth:!0})}),e.jsx(F,{item:!0,xs:12,children:e.jsx(J,{label:"New Password",type:"password",value:m,onChange:P=>C(P.target.value),fullWidth:!0,helperText:"Minimum 8 characters"})}),e.jsx(F,{item:!0,xs:12,children:e.jsx(J,{label:"Confirm New Password",type:"password",value:g,onChange:P=>A(P.target.value),fullWidth:!0})}),e.jsx(F,{item:!0,xs:12,children:e.jsx(E,{variant:"contained",onClick:z,disabled:s,fullWidth:!0,children:"Change Password"})})]})]})]})]})}function Fl(){const t=Le(),{themeMode:r,setThemeMode:s}=Vc(),[n,a]=y.useState({enabled:!1,backup_codes_count:0}),[o,i]=y.useState(!1),[l,b]=y.useState(!1),[f,p]=y.useState(null),[_,w]=y.useState(""),[k,u]=y.useState(""),[j,h]=y.useState(""),[x,m]=y.useState(""),[C,g]=y.useState(!1),[A,R]=y.useState(!1);y.useEffect(()=>{z(),$()},[]);const $=async()=>{try{const I=await te.get("/api/user/account/",{headers:{Authorization:`Token ${localStorage.getItem("token")}`}});R(I.data.is_admin||I.data.is_superuser)}catch(I){console.error("Failed to check admin status:",I)}},z=async()=>{try{const I=await Oe.twoFactorStatus();a(I.data)}catch(I){console.error("Failed to load 2FA status:",I)}},P=async()=>{try{h("");const I=await Oe.twoFactorSetup();p(I.data),i(!0),g(!1)}catch{h("Failed to setup 2FA")}},H=async()=>{try{h(""),await Oe.twoFactorVerify({code:_}),m("Two-factor authentication enabled successfully!"),i(!1),w(""),z(),setTimeout(()=>m(""),3e3)}catch{h("Invalid verification code")}},K=async()=>{try{h(""),await Oe.twoFactorDisable({code:k}),m("Two-factor authentication disabled"),b(!1),u(""),z(),setTimeout(()=>m(""),3e3)}catch{h("Invalid verification code")}},Q=async()=>{try{h("");const I=await Oe.twoFactorRegenerateCodes();p({...f,backup_codes:I.data.backup_codes}),g(!0),m("Backup codes regenerated successfully!"),z(),setTimeout(()=>m(""),3e3)}catch{h("Failed to regenerate backup codes")}},N=async()=>{try{const I=await Oe.twoFactorDownloadCodes(),S=window.URL.createObjectURL(new Blob([I.data])),T=document.createElement("a");T.href=S;const G=I.headers["content-disposition"];let O="backup_codes.pdf";if(G){const D=G.match(/filename="?(.+)"?/);D&&(O=D[1])}T.setAttribute("download",O),document.body.appendChild(T),T.click(),T.remove(),window.URL.revokeObjectURL(S)}catch{h("Failed to download backup codes")}};return e.jsxs(d,{children:[e.jsx(c,{variant:"h4",sx:{mb:2,fontWeight:600},children:"Settings"}),x&&e.jsx(V,{severity:"success",sx:{mb:1.5,maxWidth:600},children:x}),j&&e.jsx(V,{severity:"error",sx:{mb:1.5,maxWidth:600},children:j}),e.jsx(ne,{sx:{maxWidth:600,bgcolor:"background.paper",mb:1.5},children:e.jsxs(ae,{children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1.5},children:[e.jsx(mn,{sx:{mr:1,color:"primary.main",fontSize:"1.25rem"}}),e.jsx(c,{variant:"subtitle1",fontWeight:600,children:"Appearance"})]}),e.jsx(c,{variant:"caption",color:"text.secondary",sx:{mb:2,display:"block"},children:"Customize the look and feel of SoundWave with different color themes."}),e.jsxs(Ts,{fullWidth:!0,sx:{mb:1.5},size:"small",children:[e.jsx(zs,{children:"Theme"}),e.jsx(Ws,{value:r,label:"Theme",onChange:I=>s(I.target.value),children:Object.entries(Cs).map(([I,S])=>e.jsx(Ne,{value:I,children:S},I))})]}),e.jsx(F,{container:!0,spacing:1.5,children:Object.entries(Cs).map(([I,S])=>e.jsx(F,{item:!0,xs:6,sm:3,children:e.jsx(Cl,{name:S,mode:I,isSelected:r===I,onClick:()=>s(I)})},I))})]})}),e.jsx(Il,{}),e.jsx(ne,{sx:{maxWidth:600,bgcolor:"background.paper",mb:1.5},children:e.jsxs(ae,{children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1.5},children:[e.jsx(Kt,{sx:{mr:1,color:"primary.main",fontSize:"1.25rem"}}),e.jsx(c,{variant:"subtitle1",fontWeight:600,children:"Two-Factor Authentication"})]}),e.jsx(c,{variant:"caption",color:"text.secondary",sx:{mb:1.5,display:"block"},children:"Add an extra layer of security to your account. You'll need to enter a code from your authenticator app when you sign in."}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:1.5},children:[e.jsx(ee,{label:n.enabled?"Enabled":"Disabled",color:n.enabled?"success":"default",size:"small"}),n.enabled&&e.jsxs(c,{variant:"caption",color:"text.secondary",children:[n.backup_codes_count," backup codes remaining"]})]}),e.jsx(ts,{spacing:1.5,children:n.enabled?e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"outlined",color:"error",onClick:()=>b(!0),children:"Disable Two-Factor Authentication"}),e.jsx(be,{}),e.jsxs(d,{children:[e.jsx(c,{variant:"subtitle2",sx:{mb:1},children:"Backup Codes"}),e.jsxs(ts,{direction:"row",spacing:1,children:[e.jsx(E,{variant:"outlined",size:"small",startIcon:e.jsx(Xt,{}),onClick:N,children:"Download Backup Codes"}),e.jsx(E,{variant:"outlined",size:"small",startIcon:e.jsx(rt,{}),onClick:Q,children:"Regenerate Codes"})]})]})]}):e.jsx(E,{variant:"contained",size:"small",onClick:P,startIcon:e.jsx(Kt,{}),children:"Enable Two-Factor Authentication"})})]})}),e.jsx(ne,{sx:{maxWidth:600,bgcolor:"background.paper",mb:1.5},children:e.jsxs(ae,{children:[e.jsx(c,{variant:"subtitle1",fontWeight:600,sx:{mb:1.5},children:"Playback"}),e.jsx(oe,{control:e.jsx(le,{defaultChecked:!0,size:"small"}),label:e.jsx(c,{variant:"body2",children:"Autoplay"}),sx:{mb:1,display:"block"}}),e.jsx(oe,{control:e.jsx(le,{size:"small"}),label:e.jsx(c,{variant:"body2",children:"Crossfade"}),sx:{mb:1,display:"block"}}),e.jsx(oe,{control:e.jsx(le,{defaultChecked:!0}),label:"Normalize audio",sx:{display:"block"}})]})}),e.jsx(ne,{sx:{maxWidth:600,bgcolor:"background.paper",mb:1.5},children:e.jsxs(ae,{children:[e.jsx(c,{variant:"subtitle1",fontWeight:600,sx:{mb:1.5},children:"Download Quality"}),e.jsx(oe,{control:e.jsx(le,{defaultChecked:!0,size:"small"}),label:e.jsx(c,{variant:"body2",children:"Download in best quality"}),sx:{display:"block"}})]})}),e.jsx(ne,{sx:{maxWidth:600,bgcolor:"background.paper"},children:e.jsxs(ae,{children:[e.jsx(c,{variant:"subtitle1",fontWeight:600,sx:{mb:1.5},children:"Lyrics"}),e.jsx(c,{variant:"caption",color:"text.secondary",sx:{mb:1.5,display:"block"},children:"Automatically fetch and cache synchronized lyrics for your audio files using LRCLIB API."}),e.jsx(oe,{control:e.jsx(le,{defaultChecked:!0}),label:"Auto-fetch lyrics for new downloads",sx:{mb:2,display:"block"}}),e.jsx(oe,{control:e.jsx(le,{defaultChecked:!0}),label:"Show synchronized lyrics in player",sx:{display:"block"}})]})}),e.jsxs(je,{open:o,onClose:()=>i(!1),maxWidth:"sm",fullWidth:!0,children:[e.jsx(ve,{children:"Enable Two-Factor Authentication"}),e.jsx(we,{children:f&&e.jsx(d,{children:C?e.jsxs(e.Fragment,{children:[e.jsx(V,{severity:"warning",sx:{mb:2},children:"Save these backup codes in a safe place. Each code can only be used once."}),e.jsx(d,{sx:{bgcolor:"background.default",p:2,borderRadius:1,mb:2},children:f.backup_codes.map((I,S)=>e.jsxs(c,{sx:{fontFamily:"monospace",mb:.5},children:[S+1,". ",I]},S))}),e.jsx(E,{fullWidth:!0,variant:"outlined",startIcon:e.jsx(Xt,{}),onClick:()=>{const I=new Blob([f.backup_codes.join(` `)],{type:"text/plain"}),S=URL.createObjectURL(I),T=document.createElement("a");T.href=S,T.download="soundwave-backup-codes.txt",T.click()},sx:{mb:2},children:"Download Backup Codes"}),e.jsx(E,{fullWidth:!0,variant:"text",onClick:()=>g(!1),children:"Back to Setup"})]}):e.jsxs(e.Fragment,{children:[e.jsx(c,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx(d,{sx:{display:"flex",justifyContent:"center",mb:2},children:e.jsx("img",{src:f.qr_code,alt:"QR Code",style:{width:200,height:200}})}),e.jsx(c,{variant:"body2",color:"text.secondary",sx:{mb:1},children:"Or enter this code manually:"}),e.jsx(J,{fullWidth:!0,value:f.secret,InputProps:{readOnly:!0},sx:{mb:2}}),e.jsx(c,{variant:"body2",color:"text.secondary",sx:{mb:1},children:"Enter the 6-digit code from your app to verify:"}),e.jsx(J,{fullWidth:!0,placeholder:"000000",value:_,onChange:I=>w(I.target.value),inputProps:{maxLength:6}}),j&&e.jsx(V,{severity:"error",sx:{mt:2},children:j}),e.jsx(E,{fullWidth:!0,variant:"text",onClick:()=>g(!0),sx:{mt:2},children:"View Backup Codes"})]})})}),e.jsxs(Se,{children:[e.jsx(E,{onClick:()=>i(!1),children:"Cancel"}),!C&&e.jsx(E,{onClick:H,variant:"contained",disabled:_.length!==6,children:"Verify and Enable"})]})]}),e.jsxs(je,{open:l,onClose:()=>b(!1),maxWidth:"sm",fullWidth:!0,children:[e.jsx(ve,{children:"Disable Two-Factor Authentication"}),e.jsxs(we,{children:[e.jsx(V,{severity:"warning",sx:{mb:2},children:"Disabling two-factor authentication will make your account less secure."}),e.jsx(c,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Enter a verification code from your authenticator app or use a backup code:"}),e.jsx(J,{fullWidth:!0,placeholder:"000000",value:k,onChange:I=>u(I.target.value),inputProps:{maxLength:6}}),j&&e.jsx(V,{severity:"error",sx:{mt:2},children:j})]}),e.jsxs(Se,{children:[e.jsx(E,{onClick:()=>b(!1),children:"Cancel"}),e.jsx(E,{onClick:K,variant:"contained",color:"error",disabled:k.length!==6,children:"Disable 2FA"})]})]}),e.jsx(ne,{sx:{maxWidth:600,bgcolor:"background.paper",mb:2},children:e.jsxs(qn,{defaultExpanded:!0,children:[e.jsx(Hn,{expandIcon:e.jsx(yn,{}),children:e.jsxs(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(gn,{sx:{mr:1,color:"primary.main"}}),e.jsx(c,{variant:"h6",children:"Quick Sync - Adaptive Streaming"})]})}),e.jsx(Vn,{children:e.jsx(Pl,{})})]})}),e.jsx(Dl,{}),A&&e.jsx(ne,{sx:{maxWidth:600,bgcolor:"background.paper",mb:2},children:e.jsxs(ae,{children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:2},children:[e.jsx(Zt,{sx:{mr:1,color:"primary.main"}}),e.jsx(c,{variant:"h6",children:"User Management"})]}),e.jsx(c,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"Manage all users in the system. Create, edit, or delete user accounts and monitor system statistics."}),e.jsx(E,{variant:"contained",startIcon:e.jsx(Zt,{}),onClick:()=>t("/admin/users"),fullWidth:!0,sx:{minHeight:{xs:"44px",sm:"48px"}},children:"Open User Management"})]})})]})}const Ml="SoundWaveLocalAudio",xe="audioFiles",$l=1;class Ll{constructor(){ke(this,"db",null)}async init(){return new Promise((r,s)=>{const n=indexedDB.open(Ml,$l);n.onerror=()=>s(n.error),n.onsuccess=()=>{this.db=n.result,r()},n.onupgradeneeded=a=>{const o=a.target.result;if(!o.objectStoreNames.contains(xe)){const i=o.createObjectStore(xe,{keyPath:"id"});i.createIndex("title","title",{unique:!1}),i.createIndex("artist","artist",{unique:!1}),i.createIndex("album","album",{unique:!1}),i.createIndex("addedDate","addedDate",{unique:!1})}}})}async addFiles(r){this.db||await this.init();const s=this.db.transaction([xe],"readwrite"),n=s.objectStore(xe);for(const a of r)n.put(a);return new Promise((a,o)=>{s.oncomplete=()=>a(),s.onerror=()=>o(s.error)})}async getAll(){this.db||await this.init();const n=this.db.transaction([xe],"readonly").objectStore(xe).getAll();return new Promise((a,o)=>{n.onsuccess=()=>a(n.result),n.onerror=()=>o(n.error)})}async getById(r){this.db||await this.init();const a=this.db.transaction([xe],"readonly").objectStore(xe).get(r);return new Promise((o,i)=>{a.onsuccess=()=>o(a.result),a.onerror=()=>i(a.error)})}async delete(r){this.db||await this.init();const s=this.db.transaction([xe],"readwrite");return s.objectStore(xe).delete(r),new Promise((a,o)=>{s.oncomplete=()=>a(),s.onerror=()=>o(s.error)})}async updatePlayCount(r){const s=await this.getById(r);s&&(s.playCount=(s.playCount||0)+1,s.lastPlayed=new Date,await this.addFiles([s]))}async clear(){this.db||await this.init();const r=this.db.transaction([xe],"readwrite");return r.objectStore(xe).clear(),new Promise((n,a)=>{r.oncomplete=()=>n(),r.onerror=()=>a(r.error)})}}const Ue=new Ll;async function Ul(t){return new Promise(r=>{typeof window.jsmediatags<"u"?window.jsmediatags.read(t,{onSuccess:s=>{const n=s.tags,a={title:n.title||t.name.replace(/\.[^/.]+$/,""),artist:n.artist||"Unknown Artist",album:n.album||"",year:n.year?parseInt(n.year):null,genre:n.genre||""};if(n.picture){const{data:o,format:i}=n.picture,l=btoa(o.reduce((b,f)=>b+String.fromCharCode(f),""));a.coverArt=`data:${i};base64,${l}`}r(a)},onError:()=>{r({title:t.name.replace(/\.[^/.]+$/,""),artist:"Unknown Artist",album:"",year:null,genre:""})}}):r({title:t.name.replace(/\.[^/.]+$/,""),artist:"Unknown Artist",album:"",year:null,genre:""})})}async function Nl(t){return new Promise(r=>{const s=new Audio,n=URL.createObjectURL(t);s.addEventListener("loadedmetadata",()=>{r(Math.round(s.duration)),URL.revokeObjectURL(n)}),s.addEventListener("error",()=>{r(0),URL.revokeObjectURL(n)}),s.src=n})}function Bl({setCurrentAudio:t}){const[r,s]=y.useState([]),[n,a]=y.useState(!1),[o,i]=y.useState(null);y.useEffect(()=>{l()},[]);const l=async()=>{try{const j=await Ue.getAll();s(j)}catch(j){console.error("Error loading files:",j)}},b=async j=>{const h=[];for(const x of j)try{const m=await Ul(x),C=await Nl(x),g={id:`${Date.now()}-${Math.random()}`,title:m.title||x.name,artist:m.artist||"Unknown Artist",album:m.album||"",year:m.year||null,genre:m.genre||"",duration:C,file:x,fileName:x.name,fileSize:x.size,mimeType:x.type,coverArt:m.coverArt,addedDate:new Date,playCount:0};h.push(g)}catch(m){console.error(`Error processing ${x.name}:`,m)}return h},f=async()=>{try{const j=document.createElement("input");j.type="file",j.multiple=!0,j.accept="audio/*",j.onchange=async h=>{const x=h.target,m=Array.from(x.files||[]);if(m.length===0)return;a(!0),i({message:`Processing ${m.length} files...`,severity:"info"});const C=await b(m);await Ue.addFiles(C),await l(),a(!1),i({message:`Added ${C.length} files successfully!`,severity:"success"})},j.click()}catch(j){console.error("Error selecting files:",j),i({message:"Failed to select files",severity:"error"}),a(!1)}},p=async()=>{try{if(!("showDirectoryPicker"in window)){i({message:"Folder selection not supported in this browser. Use Chrome, Edge, or Opera.",severity:"error"});return}if(!window.isSecureContext){i({message:'Folder selection requires HTTPS or localhost. For local network access, use "Select Files" instead or access via https://sound.iulian.uk',severity:"info"});return}const h=await window.showDirectoryPicker({mode:"read"});a(!0),i({message:"Scanning folder and subfolders...",severity:"info"});const x=[],m=[".mp3",".m4a",".flac",".wav",".ogg",".opus",".aac",".wma"];async function C(A,R=""){for await(const $ of A.values())if($.kind==="file"){const z=await $.getFile(),P=z.name.toLowerCase().substring(z.name.lastIndexOf("."));m.includes(P)&&x.push(z)}else $.kind==="directory"&&await C($,`${R}/${$.name}`)}if(await C(h),x.length===0){a(!1),i({message:"No audio files found in the selected folder",severity:"info"});return}i({message:`Processing ${x.length} audio files...`,severity:"info"});const g=await b(x);await Ue.addFiles(g),await l(),a(!1),i({message:`Successfully added ${g.length} files from folder!`,severity:"success"})}catch(j){console.error("Error selecting folder:",j),j.name==="AbortError"?i({message:"Folder selection cancelled",severity:"info"}):i({message:"Failed to read folder",severity:"error"}),a(!1)}},_=async j=>{try{await Ue.updatePlayCount(j.id);const h=j.file?URL.createObjectURL(j.file):"",x={id:parseInt(j.id.split("-")[0])||Date.now(),youtube_id:void 0,title:j.title,channel_name:j.artist,channel_id:"",description:`${j.album}${j.year?` (${j.year})`:""}`,thumbnail_url:j.coverArt||"/placeholder.jpg",duration:j.duration,file_size:j.fileSize,file_path:h,media_url:h,play_count:j.playCount,published_date:j.addedDate.toISOString(),downloaded_date:j.addedDate.toISOString(),view_count:0,like_count:0,audio_format:j.mimeType.split("/")[1]||"mp3",artist:j.artist,album:j.album,cover_art_url:j.coverArt};t(x)}catch(h){console.error("Error playing file:",h),i({message:"Failed to play file",severity:"error"})}},w=async j=>{if(confirm("Remove this file from your library?"))try{await Ue.delete(j),await l(),i({message:"File removed",severity:"success"})}catch(h){console.error("Error deleting file:",h),i({message:"Failed to remove file",severity:"error"})}},k=async()=>{if(confirm("Remove ALL files from your library? This cannot be undone."))try{await Ue.clear(),await l(),i({message:"All files removed",severity:"success"})}catch(j){console.error("Error clearing library:",j),i({message:"Failed to clear library",severity:"error"})}},u=j=>{const h=Math.floor(j/60),x=j%60;return`${h}:${x.toString().padStart(2,"0")}`};return e.jsxs(d,{children:[e.jsxs(d,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,px:.5,flexWrap:"wrap",gap:2},children:[e.jsx(c,{variant:"h6",sx:{fontWeight:700,letterSpacing:"-0.02em"},children:"My Local Files"}),e.jsxs(d,{sx:{display:"flex",gap:1,flexWrap:"wrap"},children:[e.jsx(E,{variant:"outlined",size:"small",startIcon:e.jsx(lt,{}),onClick:l,sx:{borderRadius:1,textTransform:"none",minWidth:"auto",px:1.5,py:.5,fontSize:"0.813rem"},children:"Refresh"}),r.length>0&&e.jsx(E,{variant:"outlined",size:"small",color:"error",onClick:k,sx:{borderRadius:1,textTransform:"none",minWidth:"auto",px:1.5,py:.5,fontSize:"0.813rem"},children:"Clear All"}),e.jsx(E,{variant:"contained",size:"small",startIcon:e.jsx(st,{}),onClick:f,disabled:n,sx:{borderRadius:1,textTransform:"none",fontWeight:600,minWidth:"auto",px:2,py:.5,fontSize:"0.813rem"},children:"Select Files"}),e.jsx(Ae,{title:window.isSecureContext?"Select a folder to scan recursively including all subfolders":'Folder selection requires HTTPS or localhost. Currently viewing over HTTP. Use "Select Files" instead, or access via https://sound.iulian.uk',arrow:!0,children:e.jsx("span",{children:e.jsxs(E,{variant:"contained",size:"small",startIcon:e.jsx(Gn,{}),onClick:p,disabled:n||!window.isSecureContext,color:"secondary",sx:{borderRadius:1,textTransform:"none",fontWeight:600,minWidth:"auto",px:2,py:.5,fontSize:"0.813rem"},children:["Select Folder ",!window.isSecureContext&&"🔒"]})})})]})]}),r.length===0&&!n&&e.jsxs(V,{severity:"info",sx:{mb:3,borderRadius:3},children:[e.jsx(c,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"No local files yet"}),e.jsx(c,{variant:"caption",children:'Click "Select Files" to choose individual audio files (works everywhere), or "Select Folder" to scan an entire folder including subfolders (requires HTTPS or localhost). Files are stored in your browser and play locally without uploading.'})]}),n&&e.jsx(d,{sx:{mb:3},children:e.jsx(Ce,{})}),r.length>0&&e.jsx(Pt,{component:Fe,sx:{bgcolor:"background.paper",borderRadius:3,border:"1px solid",borderColor:"rgba(255, 255, 255, 0.05)","& .MuiTableCell-root":{borderColor:"rgba(255, 255, 255, 0.05)",padding:{xs:"6px 8px",sm:"8px 12px"},fontSize:{xs:"0.7rem",sm:"0.8125rem"}}},children:e.jsxs(It,{size:"small",children:[e.jsx(Rt,{children:e.jsxs(me,{children:[e.jsx(W,{width:30,sx:{fontWeight:600,fontSize:{xs:"0.7rem",sm:"0.75rem"}},children:"#"}),e.jsx(W,{sx:{fontWeight:600,fontSize:{xs:"0.7rem",sm:"0.75rem"}},children:"Title"}),e.jsx(W,{sx:{fontWeight:600,display:{xs:"none",sm:"table-cell"},fontSize:"0.75rem"},children:"Artist"}),e.jsx(W,{sx:{fontWeight:600,display:{xs:"none",md:"table-cell"},fontSize:"0.75rem"},children:"Album"}),e.jsx(W,{align:"right",sx:{fontWeight:600,fontSize:{xs:"0.7rem",sm:"0.75rem"}},children:"Duration"}),e.jsx(W,{align:"center",width:80,sx:{fontWeight:600,fontSize:{xs:"0.7rem",sm:"0.75rem"}},children:"Actions"})]})}),e.jsx(Ot,{children:r.map((j,h)=>e.jsxs(me,{sx:{cursor:"pointer",transition:"background-color 0.3s ease","&:hover":{bgcolor:"rgba(19, 236, 106, 0.05)"}},onClick:()=>_(j),children:[e.jsx(W,{sx:{color:"text.secondary",fontSize:{xs:"0.7rem",sm:"0.75rem"}},children:h+1}),e.jsx(W,{children:e.jsxs(d,{children:[e.jsx(c,{variant:"body2",noWrap:!0,sx:{maxWidth:{xs:150,sm:200,md:300},fontWeight:500,fontSize:{xs:"0.75rem",sm:"0.813rem"},lineHeight:1.3},children:j.title}),e.jsx(c,{variant:"caption",noWrap:!0,sx:{display:{xs:"block",sm:"none"},color:"text.secondary",fontSize:"0.65rem",maxWidth:150},children:j.artist})]})}),e.jsx(W,{sx:{display:{xs:"none",sm:"table-cell"}},children:e.jsx(c,{variant:"body2",color:"text.secondary",noWrap:!0,sx:{maxWidth:120,fontSize:"0.75rem"},children:j.artist})}),e.jsx(W,{sx:{display:{xs:"none",md:"table-cell"}},children:e.jsx(c,{variant:"body2",color:"text.secondary",noWrap:!0,sx:{maxWidth:150,fontSize:"0.75rem"},children:j.album||"-"})}),e.jsx(W,{align:"right",sx:{color:"text.secondary",fontSize:{xs:"0.7rem",sm:"0.75rem"}},children:u(j.duration)}),e.jsxs(W,{align:"center",onClick:x=>x.stopPropagation(),children:[e.jsx(U,{size:"small",onClick:()=>_(j),sx:{color:"primary.main",padding:{xs:"4px",sm:"6px"},"&:hover":{bgcolor:"rgba(19, 236, 106, 0.1)"}},children:e.jsx(Nt,{sx:{fontSize:{xs:"1rem",sm:"1.2rem"}}})}),e.jsx(U,{size:"small",onClick:()=>w(j.id),sx:{color:"error.main",padding:{xs:"4px",sm:"6px"},"&:hover":{bgcolor:"rgba(255, 0, 0, 0.1)"}},children:e.jsx(nt,{sx:{fontSize:{xs:"1rem",sm:"1.2rem"}}})})]})]},j.id))})]})}),e.jsx(Te,{open:!!o,autoHideDuration:4e3,onClose:()=>i(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(V,{onClose:()=>i(null),severity:o==null?void 0:o.severity,sx:{borderRadius:2},children:o==null?void 0:o.message})})]})}const ql=()=>{const[t,r]=y.useState([]),[s,n]=y.useState(null),[a,o]=y.useState(!0),[i,l]=y.useState(""),[b,f]=y.useState(""),[p,_]=y.useState(!1),[w,k]=y.useState(!1),[u,j]=y.useState(null),[h,x]=y.useState(!1),[m,C]=y.useState({username:"",email:"",password:"",password_confirm:"",is_admin:!1,is_active:!0,storage_quota_gb:50,max_channels:50,max_playlists:100,user_notes:""});y.useEffect(()=>{g(),A()},[]);const g=async()=>{var S,T;try{o(!0);const G=await M.get("/user/admin/users/");r(G.data.results||G.data),l("")}catch(G){l(((T=(S=G.response)==null?void 0:S.data)==null?void 0:T.detail)||"Failed to load users")}finally{o(!1)}},A=async()=>{try{const S=await M.get("/user/admin/users/system_stats/");n(S.data)}catch(S){console.error("Failed to load system stats:",S)}},R=async()=>{var S,T;try{await M.post("/user/admin/users/",m),f("User created successfully"),_(!1),N(),g(),A(),setTimeout(()=>f(""),3e3)}catch(G){l(((T=(S=G.response)==null?void 0:S.data)==null?void 0:T.detail)||"Failed to create user")}},$=async()=>{var S,T;if(u)try{await M.patch(`/user/admin/users/${u.id}/`,{is_admin:m.is_admin,is_active:m.is_active,storage_quota_gb:m.storage_quota_gb,max_channels:m.max_channels,max_playlists:m.max_playlists,user_notes:m.user_notes}),f("User updated successfully"),k(!1),g(),setTimeout(()=>f(""),3e3)}catch(G){l(((T=(S=G.response)==null?void 0:S.data)==null?void 0:T.detail)||"Failed to update user")}},z=async S=>{var T,G;try{await M.post(`/user/admin/users/${S.id}/toggle_active/`),f(`User ${S.is_active?"deactivated":"activated"}`),g(),setTimeout(()=>f(""),3e3)}catch(O){l(((G=(T=O.response)==null?void 0:T.data)==null?void 0:G.detail)||"Failed to toggle user status")}},P=async S=>{var T,G;try{await M.post(`/user/admin/users/${S.id}/reset_storage/`),f("Storage reset successfully"),g(),setTimeout(()=>f(""),3e3)}catch(O){l(((G=(T=O.response)==null?void 0:T.data)==null?void 0:G.detail)||"Failed to reset storage")}},H=async S=>{var T,G;try{await M.post(`/user/admin/users/${S.id}/reset_2fa/`),f("2FA reset successfully"),g(),setTimeout(()=>f(""),3e3)}catch(O){l(((G=(T=O.response)==null?void 0:T.data)==null?void 0:G.detail)||"Failed to reset 2FA")}},K=S=>{j(S),C({username:S.username,email:S.email,password:"",password_confirm:"",is_admin:S.is_admin,is_active:S.is_active,storage_quota_gb:S.storage_quota_gb,max_channels:S.max_channels,max_playlists:S.max_playlists,user_notes:""}),k(!0)},Q=S=>{j(S),x(!0)},N=()=>{C({username:"",email:"",password:"",password_confirm:"",is_admin:!1,is_active:!0,storage_quota_gb:50,max_channels:50,max_playlists:100,user_notes:""})},I=S=>S>90?"error":S>75?"warning":"success";return e.jsxs(d,{children:[e.jsxs(d,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:[e.jsx(c,{variant:"h4",fontWeight:"bold",children:"User Management"}),e.jsxs(d,{children:[e.jsx(U,{onClick:g,sx:{mr:1},children:e.jsx(lt,{})}),e.jsx(E,{variant:"contained",startIcon:e.jsx(Yn,{}),onClick:()=>_(!0),children:"Create User"})]})]}),i&&e.jsx(V,{severity:"error",sx:{mb:2},onClose:()=>l(""),children:i}),b&&e.jsx(V,{severity:"success",sx:{mb:2},onClose:()=>f(""),children:b}),s&&e.jsxs(F,{container:!0,spacing:3,sx:{mb:3},children:[e.jsx(F,{item:!0,xs:12,md:3,children:e.jsx(ne,{children:e.jsxs(ae,{children:[e.jsxs(d,{display:"flex",alignItems:"center",mb:1,children:[e.jsx(Qn,{color:"primary",sx:{mr:1}}),e.jsx(c,{variant:"h6",children:"Users"})]}),e.jsx(c,{variant:"h4",children:s.users.total}),e.jsxs(c,{variant:"body2",color:"text.secondary",children:[s.users.active," active, ",s.users.admin," admins"]})]})})}),e.jsx(F,{item:!0,xs:12,md:3,children:e.jsx(ne,{children:e.jsxs(ae,{children:[e.jsxs(d,{display:"flex",alignItems:"center",mb:1,children:[e.jsx(Jn,{color:"primary",sx:{mr:1}}),e.jsx(c,{variant:"h6",children:"Content"})]}),e.jsx(c,{variant:"h4",children:s.content.channels}),e.jsxs(c,{variant:"body2",color:"text.secondary",children:[s.content.playlists," playlists, ",s.content.audio_files," audio"]})]})})}),e.jsx(F,{item:!0,xs:12,md:3,children:e.jsx(ne,{children:e.jsxs(ae,{children:[e.jsxs(d,{display:"flex",alignItems:"center",mb:1,children:[e.jsx(Et,{color:"primary",sx:{mr:1}}),e.jsx(c,{variant:"h6",children:"Storage"})]}),e.jsxs(c,{variant:"h4",children:[s.storage.used_gb.toFixed(1)," GB"]}),e.jsxs(c,{variant:"body2",color:"text.secondary",children:["/ ",s.storage.quota_gb," GB allocated"]})]})})})]}),e.jsx(Pt,{component:Fe,children:e.jsxs(It,{children:[e.jsx(Rt,{children:e.jsxs(me,{children:[e.jsx(W,{children:"Username"}),e.jsx(W,{children:"Email"}),e.jsx(W,{children:"Status"}),e.jsx(W,{children:"Storage"}),e.jsx(W,{children:"Content"}),e.jsx(W,{children:"Joined"}),e.jsx(W,{children:"Actions"})]})}),e.jsx(Ot,{children:a?e.jsx(me,{children:e.jsx(W,{colSpan:7,align:"center",children:e.jsx(Ce,{})})}):t.length===0?e.jsx(me,{children:e.jsx(W,{colSpan:7,align:"center",children:"No users found"})}):t.map(S=>e.jsxs(me,{children:[e.jsx(W,{children:e.jsxs(d,{display:"flex",alignItems:"center",children:[S.username,S.is_admin&&e.jsx(ee,{label:"Admin",size:"small",color:"primary",sx:{ml:1}})]})}),e.jsx(W,{children:S.email}),e.jsx(W,{children:e.jsx(ee,{label:S.is_active?"Active":"Inactive",color:S.is_active?"success":"default",size:"small",icon:S.is_active?e.jsx(at,{}):e.jsx(rs,{})})}),e.jsx(W,{children:e.jsxs(d,{width:120,children:[e.jsxs(c,{variant:"caption",children:[S.storage_used_gb.toFixed(1)," / ",S.storage_quota_gb," GB"]}),e.jsx(Ce,{variant:"determinate",value:Math.min(S.storage_percent_used,100),color:I(S.storage_percent_used)})]})}),e.jsxs(W,{children:[e.jsxs(c,{variant:"body2",children:[S.stats.total_channels," channels"]}),e.jsxs(c,{variant:"caption",color:"text.secondary",children:[S.stats.total_playlists," playlists, ",S.stats.total_audio_files," audio"]})]}),e.jsx(W,{children:e.jsx(c,{variant:"body2",children:new Date(S.date_joined).toLocaleDateString()})}),e.jsxs(W,{children:[e.jsx(Ae,{title:"User Details",children:e.jsx(U,{size:"small",onClick:()=>Q(S),children:e.jsx(He,{})})}),e.jsx(Ae,{title:"Edit User",children:e.jsx(U,{size:"small",onClick:()=>K(S),children:e.jsx(Kn,{})})}),e.jsx(Ae,{title:S.is_active?"Deactivate":"Activate",children:e.jsx(U,{size:"small",onClick:()=>z(S),children:S.is_active?e.jsx(rs,{}):e.jsx(at,{})})})]})]},S.id))})]})}),e.jsxs(je,{open:p,onClose:()=>_(!1),maxWidth:"sm",fullWidth:!0,children:[e.jsx(ve,{children:"Create New User"}),e.jsx(we,{children:e.jsxs(d,{sx:{pt:2,display:"flex",flexDirection:"column",gap:2},children:[e.jsx(J,{label:"Username",value:m.username,onChange:S=>C({...m,username:S.target.value}),fullWidth:!0,required:!0}),e.jsx(J,{label:"Email",type:"email",value:m.email,onChange:S=>C({...m,email:S.target.value}),fullWidth:!0,required:!0}),e.jsx(J,{label:"Password",type:"password",value:m.password,onChange:S=>C({...m,password:S.target.value}),fullWidth:!0,required:!0}),e.jsx(J,{label:"Confirm Password",type:"password",value:m.password_confirm,onChange:S=>C({...m,password_confirm:S.target.value}),fullWidth:!0,required:!0}),e.jsx(J,{label:"Storage Quota (GB)",type:"number",value:m.storage_quota_gb,onChange:S=>C({...m,storage_quota_gb:parseInt(S.target.value)}),fullWidth:!0}),e.jsx(J,{label:"Max Channels",type:"number",value:m.max_channels,onChange:S=>C({...m,max_channels:parseInt(S.target.value)}),fullWidth:!0}),e.jsx(J,{label:"Max Playlists",type:"number",value:m.max_playlists,onChange:S=>C({...m,max_playlists:parseInt(S.target.value)}),fullWidth:!0}),e.jsx(J,{label:"Notes",multiline:!0,rows:3,value:m.user_notes,onChange:S=>C({...m,user_notes:S.target.value}),fullWidth:!0}),e.jsx(oe,{control:e.jsx(le,{checked:m.is_admin,onChange:S=>C({...m,is_admin:S.target.checked})}),label:"Admin User"}),e.jsx(oe,{control:e.jsx(le,{checked:m.is_active,onChange:S=>C({...m,is_active:S.target.checked})}),label:"Active"})]})}),e.jsxs(Se,{children:[e.jsx(E,{onClick:()=>_(!1),children:"Cancel"}),e.jsx(E,{onClick:R,variant:"contained",children:"Create User"})]})]}),e.jsxs(je,{open:w,onClose:()=>k(!1),maxWidth:"sm",fullWidth:!0,children:[e.jsxs(ve,{children:["Edit User: ",u==null?void 0:u.username]}),e.jsx(we,{children:e.jsxs(d,{sx:{pt:2,display:"flex",flexDirection:"column",gap:2},children:[e.jsx(J,{label:"Storage Quota (GB)",type:"number",value:m.storage_quota_gb,onChange:S=>C({...m,storage_quota_gb:parseInt(S.target.value)}),fullWidth:!0}),e.jsx(J,{label:"Max Channels",type:"number",value:m.max_channels,onChange:S=>C({...m,max_channels:parseInt(S.target.value)}),fullWidth:!0}),e.jsx(J,{label:"Max Playlists",type:"number",value:m.max_playlists,onChange:S=>C({...m,max_playlists:parseInt(S.target.value)}),fullWidth:!0}),e.jsx(J,{label:"Notes",multiline:!0,rows:3,value:m.user_notes,onChange:S=>C({...m,user_notes:S.target.value}),fullWidth:!0}),e.jsx(oe,{control:e.jsx(le,{checked:m.is_admin,onChange:S=>C({...m,is_admin:S.target.checked})}),label:"Admin User"}),e.jsx(oe,{control:e.jsx(le,{checked:m.is_active,onChange:S=>C({...m,is_active:S.target.checked})}),label:"Active"}),u&&e.jsxs(d,{display:"flex",gap:1,children:[e.jsx(E,{variant:"outlined",color:"warning",onClick:()=>P(u),fullWidth:!0,children:"Reset Storage"}),e.jsx(E,{variant:"outlined",color:"warning",onClick:()=>H(u),fullWidth:!0,children:"Reset 2FA"})]})]})}),e.jsxs(Se,{children:[e.jsx(E,{onClick:()=>k(!1),children:"Cancel"}),e.jsx(E,{onClick:$,variant:"contained",children:"Save Changes"})]})]}),e.jsxs(je,{open:h,onClose:()=>x(!1),maxWidth:"md",fullWidth:!0,children:[e.jsxs(ve,{children:["User Details: ",u==null?void 0:u.username]}),e.jsx(we,{children:u&&e.jsx(d,{sx:{pt:2},children:e.jsxs(F,{container:!0,spacing:2,children:[e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Email"}),e.jsx(c,{variant:"body1",children:u.email})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Status"}),e.jsx(ee,{label:u.is_active?"Active":"Inactive",color:u.is_active?"success":"default",size:"small"})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Role"}),e.jsx(ee,{label:u.is_admin?"Admin":"User",color:u.is_admin?"primary":"default",size:"small"})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Storage Usage"}),e.jsxs(c,{variant:"body1",children:[u.storage_used_gb.toFixed(2)," / ",u.storage_quota_gb," GB (",u.storage_percent_used.toFixed(1),"%)"]})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Channels"}),e.jsxs(c,{variant:"body1",children:[u.stats.total_channels," / ",u.max_channels]})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Playlists"}),e.jsxs(c,{variant:"body1",children:[u.stats.total_playlists," / ",u.max_playlists]})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Audio Files"}),e.jsx(c,{variant:"body1",children:u.stats.total_audio_files})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Date Joined"}),e.jsx(c,{variant:"body1",children:new Date(u.date_joined).toLocaleString()})]}),e.jsxs(F,{item:!0,xs:6,children:[e.jsx(c,{variant:"subtitle2",color:"text.secondary",children:"Last Login"}),e.jsx(c,{variant:"body1",children:u.last_login?new Date(u.last_login).toLocaleString():"Never"})]})]})})}),e.jsx(Se,{children:e.jsx(E,{onClick:()=>x(!1),children:"Close"})})]})]})};function Hl(){const t=Le(),{isOnline:r,cacheSize:s,clearCache:n,removePlaylistCache:a}=xt(),[o,i]=y.useState([]),[l,b]=y.useState(!0),[f,p]=y.useState({open:!1}),[_,w]=y.useState(!1);y.useEffect(()=>{k()},[]);const k=async()=>{try{const m=await Ie.getOfflinePlaylists();i(m)}catch(m){console.error("Failed to load cached playlists:",m)}finally{b(!1)}},u=async m=>{var C;try{const g=((C=m.items)==null?void 0:C.map(A=>`/api/audio/${A.audio.youtube_id}/download/`))||[];await a(m.playlist_id,g),await Ie.removePlaylist(m.id),await k(),p({open:!1})}catch(g){console.error("Failed to remove playlist:",g),alert("Failed to remove offline data")}},j=async()=>{try{await n(),await Ie.clearAllData(),await k(),w(!1)}catch(m){console.error("Failed to clear all:",m),alert("Failed to clear all offline data")}},h=m=>{if(m===0)return"0 Bytes";const C=1024,g=["Bytes","KB","MB","GB"],A=Math.floor(Math.log(m)/Math.log(C));return Math.round(m/Math.pow(C,A)*100)/100+" "+g[A]},x=m=>new Date(m).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return l?e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"60vh"},children:e.jsx(Re,{})}):e.jsxs(d,{sx:{maxWidth:800,mx:"auto",px:2},children:[e.jsxs(d,{sx:{mb:4},children:[e.jsx(c,{variant:"h5",sx:{fontWeight:700,letterSpacing:"-0.02em",mb:1},children:"Offline Storage"}),e.jsx(c,{variant:"body2",color:"text.secondary",children:"Manage playlists cached for offline playback"})]}),!r&&e.jsx(V,{severity:"warning",icon:e.jsx(ot,{}),sx:{mb:3},children:"You are currently offline. You can only play cached content."}),s&&e.jsx(ne,{sx:{mb:3},children:e.jsxs(ae,{children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:2,mb:2},children:[e.jsx(Et,{color:"primary",sx:{fontSize:32}}),e.jsxs(d,{sx:{flex:1},children:[e.jsx(c,{variant:"subtitle1",sx:{fontWeight:600},children:"Storage Used"}),e.jsx(c,{variant:"h5",sx:{fontWeight:700,color:"primary.main"},children:h(s.usage)})]}),e.jsxs(d,{sx:{textAlign:"right"},children:[e.jsx(c,{variant:"caption",color:"text.secondary",children:"Available"}),e.jsx(c,{variant:"body2",sx:{fontWeight:600},children:h(s.quota-s.usage)})]})]}),e.jsx(Ce,{variant:"determinate",value:s.usage/s.quota*100,sx:{height:8,borderRadius:1}}),e.jsxs(c,{variant:"caption",color:"text.secondary",sx:{mt:1,display:"block"},children:[(s.usage/s.quota*100).toFixed(1),"% of ",h(s.quota)," used"]})]})}),e.jsx(ne,{children:e.jsxs(ae,{children:[e.jsxs(d,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(Ve,{color:"success"}),e.jsx(c,{variant:"subtitle1",sx:{fontWeight:600},children:"Offline Playlists"}),e.jsx(ee,{label:o.length,size:"small",color:"success"})]}),e.jsxs(d,{sx:{display:"flex",gap:1},children:[e.jsx(E,{size:"small",startIcon:e.jsx(lt,{}),onClick:k,children:"Refresh"}),o.length>0&&e.jsx(E,{size:"small",color:"error",startIcon:e.jsx(nt,{}),onClick:()=>w(!0),children:"Clear All"})]})]}),e.jsx(be,{sx:{mb:2}}),o.length===0?e.jsxs(d,{sx:{textAlign:"center",py:4},children:[e.jsx(ot,{sx:{fontSize:48,color:"text.secondary",mb:2,opacity:.3}}),e.jsx(c,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"No playlists cached for offline use"}),e.jsx(E,{variant:"contained",onClick:()=>t("/playlists"),children:"Browse Playlists"})]}):e.jsx(Pe,{disablePadding:!0,children:o.map((m,C)=>e.jsxs(d,{children:[C>0&&e.jsx(be,{}),e.jsxs(he,{sx:{py:2,cursor:"pointer","&:hover":{bgcolor:"rgba(255, 255, 255, 0.05)"}},onClick:()=>t(`/playlists/${m.playlist_id}`),children:[e.jsx(ce,{primary:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[e.jsx(c,{variant:"body1",sx:{fontWeight:600},children:m.title}),e.jsx(at,{sx:{fontSize:16,color:"success.main"}})]}),secondary:e.jsxs(d,{children:[e.jsx(c,{variant:"body2",color:"text.secondary",sx:{mb:.5},children:m.channel_name}),e.jsxs(d,{sx:{display:"flex",gap:2,flexWrap:"wrap"},children:[e.jsx(ee,{label:`${m.downloaded_count} tracks`,size:"small",sx:{height:20,fontSize:"0.7rem"}}),e.jsx(ee,{label:`Cached ${x(m.lastSync)}`,size:"small",sx:{height:20,fontSize:"0.7rem"},variant:"outlined"})]})]})}),e.jsx(wt,{children:e.jsx(U,{edge:"end",color:"error",onClick:g=>{g.stopPropagation(),p({open:!0,playlistId:m.playlist_id,title:m.title})},children:e.jsx(nt,{})})})]})]},m.id))})]})}),e.jsxs(je,{open:f.open,onClose:()=>p({open:!1}),children:[e.jsx(ve,{children:"Remove Offline Playlist?"}),e.jsx(we,{children:e.jsxs(c,{children:['Are you sure you want to remove "',f.title,`" from offline storage? You'll need to re-download it to play offline.`]})}),e.jsxs(Se,{children:[e.jsx(E,{onClick:()=>p({open:!1}),children:"Cancel"}),e.jsx(E,{color:"error",variant:"contained",onClick:()=>{const m=o.find(C=>C.playlist_id===f.playlistId);m&&u(m)},children:"Remove"})]})]}),e.jsxs(je,{open:_,onClose:()=>w(!1),children:[e.jsx(ve,{children:"Clear All Offline Data?"}),e.jsxs(we,{children:[e.jsx(c,{sx:{mb:2},children:"This will remove all cached playlists and free up storage space. You'll need to re-download playlists to use them offline."}),e.jsx(V,{severity:"warning",children:"This action cannot be undone."})]}),e.jsxs(Se,{children:[e.jsx(E,{onClick:()=>w(!1),children:"Cancel"}),e.jsx(E,{color:"error",variant:"contained",onClick:j,children:"Clear All"})]})]})]})}function Vl({children:t}){const[r,s]=y.useState(!0),[n,a]=y.useState(!1);return y.useEffect(()=>{(async()=>{try{const l=(await M.get("/user/account/")).data;a(l.is_admin||l.is_superuser||l.is_staff)}catch(i){console.error("Error checking admin status:",i),a(!1)}finally{s(!1)}})()},[]),r?e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsx(Re,{})}):n?e.jsx(e.Fragment,{children:t}):e.jsx(Fs,{to:"/",replace:!0})}var zr={},Gl=B;Object.defineProperty(zr,"__esModule",{value:!0});var vn=zr.default=void 0,Yl=Gl(q()),Ql=e;vn=zr.default=(0,Yl.default)((0,Ql.jsx)("path",{d:"M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"}),"Home");var Wr={},Jl=B;Object.defineProperty(Wr,"__esModule",{value:!0});var wn=Wr.default=void 0,Kl=Jl(q()),Xl=e;wn=Wr.default=(0,Kl.default)((0,Xl.jsx)("path",{d:"M20 2H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2m-2 5h-3v5.5c0 1.38-1.12 2.5-2.5 2.5S10 13.88 10 12.5s1.12-2.5 2.5-2.5c.57 0 1.08.19 1.5.51V5h4zM4 6H2v14c0 1.1.9 2 2 2h14v-2H4z"}),"LibraryMusic");var Dr={},Zl=B;Object.defineProperty(Dr,"__esModule",{value:!0});var Sn=Dr.default=void 0,ec=Zl(q()),tc=e;Sn=Dr.default=(0,ec.default)((0,tc.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");var Fr={},rc=B;Object.defineProperty(Fr,"__esModule",{value:!0});var Mr=Fr.default=void 0,sc=rc(q()),nc=e;Mr=Fr.default=(0,sc.default)((0,nc.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M14 13v4h-4v-4H7l5-5 5 5z"}),"CloudUpload");var $r={},ac=B;Object.defineProperty($r,"__esModule",{value:!0});var _n=$r.default=void 0,oc=ac(q()),ic=e;_n=$r.default=(0,oc.default)((0,ic.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96M10 17l-3.5-3.5 1.41-1.41L10 14.17 15.18 9l1.41 1.41z"}),"CloudDone");const lc=[{title:"Home",path:"/",icon:e.jsx(vn,{})},{title:"Search",path:"/search",icon:e.jsx(Ze,{})},{title:"Library",path:"/library",icon:e.jsx(wn,{})},{title:"Favorites",path:"/favorites",icon:e.jsx(wr,{})},{title:"Channels",path:"/channels",icon:e.jsx(tt,{})},{title:"Playlists",path:"/playlists",icon:e.jsx(br,{})},{title:"Local Files",path:"/local-files",icon:e.jsx(Mr,{})},{title:"Offline",path:"/offline",icon:e.jsx(_n,{}),isPWA:!0}];function cc({mobileOpen:t=!1,onMobileClose:r}){const s=Le(),n=ca(),a=i=>{s(i),r&&r()},o=e.jsxs(d,{sx:{width:240,bgcolor:"background.default",display:"flex",flexDirection:"column",height:"100%"},children:[e.jsxs(d,{sx:{p:2,display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(d,{component:"img",src:"/img/logo.png",alt:"SoundWave",sx:{width:40,height:40,borderRadius:"50%",objectFit:"cover"}}),e.jsx(d,{sx:{fontWeight:700,fontSize:20,letterSpacing:"-0.02em"},children:"SoundWave"})]}),e.jsx(Pe,{sx:{flexGrow:1,px:1.5,py:2},children:lc.map(i=>e.jsx(he,{disablePadding:!0,sx:{mb:1},children:e.jsxs(qe,{selected:n.pathname===i.path,onClick:()=>a(i.path),sx:{borderRadius:"9999px",py:1.5,px:2,transition:"all 0.3s ease","&.Mui-selected":{bgcolor:"rgba(19, 236, 106, 0.15)",color:"primary.main","&:hover":{bgcolor:"rgba(19, 236, 106, 0.2)"}},"&:not(.Mui-selected)":{color:"text.secondary","&:hover":{bgcolor:"rgba(255, 255, 255, 0.05)",color:"text.primary"}}},children:[e.jsx(ss,{sx:{color:"inherit",minWidth:36},children:i.icon}),e.jsx(ce,{primary:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:.5},children:[i.title,i.isPWA&&e.jsx(ee,{label:"PWA",size:"small",sx:{height:16,fontSize:"0.6rem",fontWeight:700,bgcolor:"success.main",color:"white","& .MuiChip-label":{px:.5}}})]}),primaryTypographyProps:{fontWeight:n.pathname===i.path?600:500,fontSize:"0.875rem"}})]})},i.path))}),e.jsx(d,{sx:{p:1.5,pb:2},children:e.jsxs(qe,{selected:n.pathname==="/settings",onClick:()=>a("/settings"),sx:{borderRadius:"9999px",py:1.5,px:2,transition:"all 0.3s ease","&.Mui-selected":{bgcolor:"rgba(19, 236, 106, 0.15)",color:"primary.main","&:hover":{bgcolor:"rgba(19, 236, 106, 0.2)"}},"&:not(.Mui-selected)":{color:"text.secondary","&:hover":{bgcolor:"rgba(255, 255, 255, 0.05)",color:"text.primary"}}},children:[e.jsx(ss,{sx:{color:"inherit",minWidth:36},children:e.jsx(Sn,{})}),e.jsx(ce,{primary:"Settings",primaryTypographyProps:{fontWeight:n.pathname==="/settings"?600:500,fontSize:"0.875rem"}})]})})]});return e.jsxs(e.Fragment,{children:[e.jsx(Xn,{variant:"temporary",open:t,onClose:r,ModalProps:{keepMounted:!0},sx:{display:{xs:"block",md:"none"},"& .MuiDrawer-paper":{boxSizing:"border-box",width:240,bgcolor:"background.default",borderRight:"1px solid",borderColor:"rgba(255, 255, 255, 0.05)"}},children:o}),e.jsx(d,{sx:{width:240,flexShrink:0,display:{xs:"none",md:"block"},borderRight:"1px solid",borderColor:"rgba(255, 255, 255, 0.05)"},children:o})]})}var Lr={},dc=B;Object.defineProperty(Lr,"__esModule",{value:!0});var Cn=Lr.default=void 0,uc=dc(q()),hc=e;Cn=Lr.default=(0,uc.default)((0,hc.jsx)("path",{d:"M3 18h18v-2H3zm0-5h18v-2H3zm0-7v2h18V6z"}),"Menu");var Ur={},fc=B;Object.defineProperty(Ur,"__esModule",{value:!0});var kn=Ur.default=void 0,xc=fc(q()),pc=e;kn=Ur.default=(0,xc.default)((0,pc.jsx)("path",{d:"m17 7-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4z"}),"Logout");var Nr={},mc=B;Object.defineProperty(Nr,"__esModule",{value:!0});var Ee=Nr.default=void 0,gc=mc(q()),yc=e;Ee=Nr.default=(0,gc.default)((0,yc.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close");var Br={},bc=B;Object.defineProperty(Br,"__esModule",{value:!0});var An=Br.default=void 0,jc=bc(q()),vc=e;An=Br.default=(0,jc.default)((0,vc.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM19 4h-3.5l-1-1h-5l-1 1H5v2h14z"}),"Delete");function wc({open:t,onClose:r,currentAvatar:s,onAvatarChange:n}){const[a,o]=y.useState(null),[i,l]=y.useState(!1),[b,f]=y.useState(null),[p,_]=y.useState(null),w=[1,2,3,4,5],k=async x=>{f(null),_(null),o(x);try{const m=await fetch("/api/user/avatar/preset/",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Token ${localStorage.getItem("token")}`},body:JSON.stringify({preset:x})});if(!m.ok)throw new Error("Failed to set preset avatar");const C=await m.json();_("Avatar updated successfully!"),n(`/avatars/preset_${x}.svg`)}catch(m){f(m instanceof Error?m.message:"Failed to set preset avatar")}},u=async x=>{var g;const m=(g=x.target.files)==null?void 0:g[0];if(!m)return;if(m.size>20*1024*1024){f("File too large. Maximum size is 20MB");return}if(!["image/jpeg","image/png","image/gif","image/webp"].includes(m.type)){f("Invalid file type. Please upload JPEG, PNG, GIF, or WebP");return}f(null),_(null),l(!0),o(null);const C=new FormData;C.append("avatar",m);try{const A=await fetch("/api/user/avatar/upload/",{method:"POST",headers:{Authorization:`Token ${localStorage.getItem("token")}`},body:C});if(!A.ok){const z=await A.json();throw new Error(z.error||"Failed to upload avatar")}const R=await A.json();_("Avatar uploaded successfully!");const $=R.avatar.split("/").pop();n(`/api/user/avatar/file/${$}/`)}catch(A){f(A instanceof Error?A.message:"Failed to upload avatar")}finally{l(!1)}},j=async()=>{f(null),_(null);try{if(!(await fetch("/api/user/avatar/upload/",{method:"DELETE",headers:{Authorization:`Token ${localStorage.getItem("token")}`}})).ok)throw new Error("Failed to remove avatar");_("Avatar removed successfully!"),o(null),n(null)}catch(x){f(x instanceof Error?x.message:"Failed to remove avatar")}},h=x=>s==null?void 0:s.includes(`preset_${x}`);return e.jsxs(je,{open:t,onClose:r,maxWidth:"sm",fullWidth:!0,children:[e.jsx(ve,{children:e.jsxs(d,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[e.jsx(c,{variant:"h6",children:"Choose Your Avatar"}),e.jsx(U,{onClick:r,size:"small",children:e.jsx(Ee,{})})]})}),e.jsxs(we,{children:[b&&e.jsx(V,{severity:"error",sx:{mb:2},onClose:()=>f(null),children:b}),p&&e.jsx(V,{severity:"success",sx:{mb:2},onClose:()=>_(null),children:p}),e.jsx(c,{variant:"subtitle2",gutterBottom:!0,sx:{mt:1},children:"Preset Avatars"}),e.jsx(F,{container:!0,spacing:2,sx:{mb:3},children:w.map(x=>e.jsx(F,{item:!0,xs:4,sm:2.4,children:e.jsxs(d,{sx:{position:"relative",cursor:"pointer","&:hover":{opacity:.8}},onClick:()=>k(x),children:[e.jsx(ze,{src:`/avatars/preset_${x}.svg`,sx:{width:80,height:80,border:h(x)?"3px solid":"2px solid",borderColor:h(x)?"primary.main":"rgba(255, 255, 255, 0.1)"}}),h(x)&&e.jsx(Or,{sx:{position:"absolute",top:-8,right:-8,color:"primary.main",bgcolor:"background.paper",borderRadius:"50%"}})]})},x))}),e.jsx(c,{variant:"subtitle2",gutterBottom:!0,children:"Custom Avatar"}),e.jsx(d,{sx:{border:"2px dashed",borderColor:"rgba(255, 255, 255, 0.2)",borderRadius:2,p:3,textAlign:"center",bgcolor:"rgba(255, 255, 255, 0.02)"},children:i?e.jsx(Re,{size:40}):e.jsxs(e.Fragment,{children:[e.jsx("input",{accept:"image/jpeg,image/png,image/gif,image/webp",style:{display:"none"},id:"avatar-upload",type:"file",onChange:u}),e.jsx("label",{htmlFor:"avatar-upload",children:e.jsx(E,{variant:"outlined",component:"span",startIcon:e.jsx(Mr,{}),sx:{mb:1},children:"Upload Image"})}),e.jsx(c,{variant:"caption",display:"block",color:"text.secondary",children:"Max 20MB • JPEG, PNG, GIF, WebP"})]})})]}),e.jsxs(Se,{sx:{px:3,pb:2},children:[s&&e.jsx(E,{onClick:j,startIcon:e.jsx(An,{}),color:"error",sx:{mr:"auto"},children:"Remove Avatar"}),e.jsx(E,{onClick:r,children:"Close"})]})]})}function Sc({onLogout:t,onMenuClick:r}){var _;const[s,n]=y.useState(!1),[a,o]=y.useState(null),[i,l]=y.useState(null);y.useEffect(()=>{b()},[]);const b=async()=>{try{const w=await fetch("/api/user/account/",{headers:{Authorization:`Token ${localStorage.getItem("token")}`}});if(w.ok){const k=await w.json();o(k),l(k.avatar_url)}}catch(w){console.error("Failed to fetch user data:",w)}},f=()=>{const w=new Date().getHours();return w<12?"Good Morning":w<18?"Good Afternoon":"Good Evening"},p=w=>{l(w)};return e.jsxs(Zn,{position:"static",elevation:0,sx:{bgcolor:"transparent",borderBottom:"none"},children:[e.jsxs(ea,{sx:{minHeight:{xs:"64px",md:"80px"},px:{xs:2,md:3}},children:[e.jsx(U,{color:"inherit","aria-label":"open drawer",edge:"start",onClick:r,sx:{mr:2,display:{md:"none"}},children:e.jsx(Cn,{})}),e.jsxs(d,{sx:{flexGrow:1,display:"flex",alignItems:"center",gap:{xs:1.5,md:2.5}},children:[e.jsxs(d,{sx:{position:"relative"},children:[e.jsx(ze,{src:i||void 0,onClick:()=>n(!0),sx:{width:{xs:40,md:64},height:{xs:40,md:64},border:"2px solid",borderColor:"rgba(255, 255, 255, 0.1)",cursor:"pointer",transition:"all 0.3s ease","&:hover":{transform:"scale(1.05)",borderColor:"primary.main"}},children:(_=a==null?void 0:a.username)==null?void 0:_.charAt(0).toUpperCase()}),e.jsx(d,{sx:{position:"absolute",bottom:0,right:0,width:{xs:12,md:20},height:{xs:12,md:20},bgcolor:"primary.main",borderRadius:"50%",border:{xs:"2px solid",md:"4px solid"},borderColor:"background.default"}})]}),e.jsxs(d,{children:[e.jsx(c,{variant:"h5",sx:{fontWeight:700,letterSpacing:"-0.02em",mb:.5,fontSize:{xs:"1.1rem",md:"1.5rem"}},children:f()}),e.jsx(c,{variant:"body2",color:"text.secondary",sx:{fontWeight:500,display:{xs:"none",sm:"block"}},children:a!=null&&a.first_name||a!=null&&a.last_name?`${a.first_name||""} ${a.last_name||""}`.trim():(a==null?void 0:a.username)||"Music Lover"})]})]}),e.jsx(d,{sx:{display:"flex",gap:1.5},children:e.jsx(Ae,{title:"Logout",arrow:!0,children:e.jsx(U,{onClick:t,sx:{width:{xs:44,md:48},height:{xs:44,md:48},border:"1px solid",borderColor:"rgba(255, 255, 255, 0.1)",transition:"all 0.3s ease","&:hover":{bgcolor:"rgba(255, 82, 82, 0.1)",borderColor:"rgba(255, 82, 82, 0.5)",color:"#ff5252"}},children:e.jsx(kn,{})})})})]}),e.jsx(wc,{open:s,onClose:()=>n(!1),currentAvatar:i,onAvatarChange:p})]})}var qr={},_c=B;Object.defineProperty(qr,"__esModule",{value:!0});var Pn=qr.default=void 0,Cc=_c(q()),kc=e;Pn=qr.default=(0,Cc.default)((0,kc.jsx)("path",{d:"M6 6h2v12H6zm3.5 6 8.5 6V6z"}),"SkipPrevious");var Hr={},Ac=B;Object.defineProperty(Hr,"__esModule",{value:!0});var In=Hr.default=void 0,Pc=Ac(q()),Ic=e;In=Hr.default=(0,Pc.default)((0,Ic.jsx)("path",{d:"m6 18 8.5-6L6 6zM16 6v12h2V6z"}),"SkipNext");var Vr={},Rc=B;Object.defineProperty(Vr,"__esModule",{value:!0});var Rn=Vr.default=void 0,Oc=Rc(q()),Ec=e;Rn=Vr.default=(0,Oc.default)((0,Ec.jsx)("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2z"}),"Repeat");var Gr={},Tc=B;Object.defineProperty(Gr,"__esModule",{value:!0});var On=Gr.default=void 0,zc=Tc(q()),Wc=e;On=Gr.default=(0,zc.default)((0,Wc.jsx)("path",{d:"M3 9v6h4l5 5V4L7 9zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02M14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77"}),"VolumeUp");var Yr={},Dc=B;Object.defineProperty(Yr,"__esModule",{value:!0});var En=Yr.default=void 0,Fc=Dc(q()),Mc=e;En=Yr.default=(0,Fc.default)((0,Mc.jsx)("path",{d:"M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63m2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71M4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9zM12 4 9.91 6.09 12 8.18z"}),"VolumeOff");function $c({youtubeId:t,currentTime:r,onClose:s,embedded:n=!1}){const[a,o]=y.useState(null),[i,l]=y.useState(!0),[b,f]=y.useState(""),[p,_]=y.useState([]),[w,k]=y.useState(-1),[u,j]=y.useState(!0),[h,x]=y.useState(0),m=y.useRef(null),C=y.useRef(null);y.useEffect(()=>{g()},[t]),y.useEffect(()=>{a!=null&&a.is_synced&&p.length>0&&$()},[r,p]),y.useEffect(()=>{if(u&&C.current&&m.current){const z=m.current,P=C.current,H=z.clientHeight,K=P.offsetTop;z.scrollTo({top:K-H/2+P.clientHeight/2,behavior:"smooth"})}},[w,u]);const g=async()=>{var z,P;try{l(!0),f("");const H=await M.get(`/audio/${t}/lyrics/`);if(o(H.data),H.data.is_synced){const K=R(H.data.synced_lyrics);_(K)}}catch(H){f(((P=(z=H.response)==null?void 0:z.data)==null?void 0:P.error)||"Failed to load lyrics")}finally{l(!1)}},A=async()=>{var z,P;try{l(!0),f("");const H=await M.post(`/audio/${t}/lyrics/fetch/`,{force:!0});if(o(H.data),H.data.is_synced){const K=R(H.data.synced_lyrics);_(K)}}catch(H){f(((P=(z=H.response)==null?void 0:z.data)==null?void 0:P.error)||"Failed to fetch lyrics")}finally{l(!1)}},R=z=>{const P=[],H=z.split(` `);for(const K of H){const Q=K.match(/\[(\d{2}):(\d{2})\.(\d{2,3})\](.*)/);if(Q){const N=parseInt(Q[1]),I=parseInt(Q[2]),S=parseInt(Q[3].padEnd(2,"0").substring(0,2)),T=N*60+I+S/100,G=Q[4].trim();G&&P.push({time:T,text:G})}}return P.sort((K,Q)=>K.time-Q.time)},$=()=>{let z=-1;for(let P=p.length-1;P>=0;P--)if(r>=p[P].time){z=P;break}k(z)};return i?e.jsxs(d,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[s&&e.jsx(d,{sx:{display:"flex",justifyContent:"flex-end",p:1},children:e.jsx(U,{size:"small",onClick:s,children:e.jsx(Ee,{})})}),e.jsx(d,{sx:{flex:1,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})})]}):b?e.jsxs(d,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[s&&e.jsx(d,{sx:{display:"flex",justifyContent:"flex-end",p:1},children:e.jsx(U,{size:"small",onClick:s,children:e.jsx(Ee,{})})}),e.jsxs(d,{sx:{flex:1,p:2},children:[e.jsx(V,{severity:"error",sx:{mb:2},children:b}),e.jsx(E,{variant:"contained",onClick:A,startIcon:e.jsx(rt,{}),children:"Try Fetch Lyrics"})]})]}):a?a.is_instrumental?e.jsxs(d,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[s&&e.jsx(d,{sx:{display:"flex",justifyContent:"flex-end",p:1},children:e.jsx(U,{size:"small",onClick:s,children:e.jsx(Ee,{})})}),e.jsxs(d,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",p:4},children:[e.jsx(et,{sx:{fontSize:64,color:"text.secondary",mb:2}}),e.jsx(c,{variant:"h6",color:"text.secondary",children:"Instrumental Track"})]})]}):a.has_lyrics?e.jsxs(ne,{sx:{height:"100%",display:"flex",flexDirection:"column",bgcolor:"background.paper"},children:[e.jsxs(d,{sx:{borderBottom:1,borderColor:"divider",display:"flex",alignItems:"center",px:2,pt:1},children:[e.jsx(c,{variant:"h6",sx:{flexGrow:1},children:"Lyrics"}),e.jsx(U,{size:"small",onClick:A,sx:{mr:1},children:e.jsx(rt,{})}),s&&e.jsx(U,{size:"small",onClick:s,children:e.jsx(Ee,{})})]}),a.is_synced&&e.jsxs(d,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(c,{variant:"caption",color:"text.secondary",children:["Source: ",a.source," ",a.language&&`• ${a.language}`]}),e.jsx(oe,{control:e.jsx(le,{size:"small",checked:u,onChange:z=>j(z.target.checked)}),label:e.jsx(c,{variant:"caption",children:"Auto-scroll"})})]}),a.is_synced&&a.plain_lyrics&&e.jsxs(Is,{value:h,onChange:(z,P)=>x(P),sx:{px:2,minHeight:40},children:[e.jsx(Be,{label:"Synced",sx:{minHeight:40,py:.5}}),e.jsx(Be,{label:"Plain Text",sx:{minHeight:40,py:.5}})]}),e.jsx(ae,{ref:m,sx:{flexGrow:1,overflow:"auto","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-track":{backgroundColor:"rgba(0,0,0,0.1)"},"&::-webkit-scrollbar-thumb":{backgroundColor:"rgba(0,0,0,0.3)",borderRadius:"4px"}},children:h===0&&a.is_synced?e.jsx(d,{children:p.map((z,P)=>e.jsx(d,{ref:P===w?C:null,sx:{py:1.5,px:2,borderRadius:1,transition:"all 0.3s ease",backgroundColor:P===w?"primary.main":"transparent",color:P===w?"primary.contrastText":"text.primary",opacity:P===w?1:.5,transform:P===w?"scale(1.02)":"scale(1)",fontWeight:P===w?600:400},children:e.jsx(c,{variant:"body1",sx:{fontSize:P===w?"1.1rem":"1rem",lineHeight:1.6},children:z.text})},P))}):e.jsx(d,{sx:{px:1},children:a.plain_lyrics.split(` `).map((z,P)=>e.jsx(c,{variant:"body1",sx:{py:.5,lineHeight:1.8,color:"text.primary"},children:z||" "},P))})}),a.last_error&&e.jsxs(V,{severity:"warning",sx:{m:2,mt:0},children:["Last fetch error: ",a.last_error]})]}):e.jsxs(d,{sx:{height:"100%",display:"flex",flexDirection:"column"},children:[s&&e.jsx(d,{sx:{display:"flex",justifyContent:"flex-end",p:1},children:e.jsx(U,{size:"small",onClick:s,children:e.jsx(Ee,{})})}),e.jsxs(d,{sx:{flex:1,p:2},children:[e.jsxs(V,{severity:"info",sx:{mb:2},children:["No lyrics available for this track",a.fetch_attempted&&` (Attempted ${a.fetch_attempts} times)`]}),e.jsx(E,{variant:"contained",onClick:A,startIcon:e.jsx(rt,{}),children:"Fetch Lyrics"})]})]}):null}class Lc{constructor(){ke(this,"isSupported");this.isSupported="mediaSession"in navigator}setMetadata(r){if(!this.isSupported)return;const s=r.artwork||[{src:"/img/icon-96x96.png",sizes:"96x96",type:"image/png"},{src:"/img/icon-128x128.png",sizes:"128x128",type:"image/png"},{src:"/img/icon-192x192.png",sizes:"192x192",type:"image/png"},{src:"/img/icon-256x256.png",sizes:"256x256",type:"image/png"},{src:"/img/icon-384x384.png",sizes:"384x384",type:"image/png"},{src:"/img/icon-512x512.png",sizes:"512x512",type:"image/png"}];navigator.mediaSession.metadata=new MediaMetadata({title:r.title,artist:r.artist,album:r.album||"",artwork:s})}setActionHandlers(r){if(!this.isSupported)return;["play","pause","previoustrack","nexttrack","seekbackward","seekforward","seekto"].forEach(n=>{try{r[n]?navigator.mediaSession.setActionHandler(n,r[n]):navigator.mediaSession.setActionHandler(n,null)}catch{console.warn(`Media Session API doesn't support ${n} action`)}})}setPlaybackState(r){this.isSupported&&(navigator.mediaSession.playbackState=r)}setPositionState(r){if(this.isSupported)try{"setPositionState"in navigator.mediaSession&&navigator.mediaSession.setPositionState(r)}catch(s){console.warn("Failed to set position state:",s)}}clear(){if(!this.isSupported)return;navigator.mediaSession.metadata=null,this.setPlaybackState("none"),["play","pause","previoustrack","nexttrack","seekbackward","seekforward","seekto"].forEach(s=>{try{navigator.mediaSession.setActionHandler(s,null)}catch{}})}isAPISupported(){return this.isSupported}}const yt=new Lc,Uc=t=>yt.setMetadata(t),Nc=t=>yt.setActionHandlers(t),ks=t=>yt.setPlaybackState(t),As=t=>yt.setPositionState(t),Bc=()=>yt.clear();function Ps({audio:t,isPlaying:r,setIsPlaying:s,onClose:n,onNext:a,onPrevious:o,hasNext:i=!1,hasPrevious:l=!1}){const[b,f]=y.useState(0),[p,_]=y.useState(80),[w,k]=y.useState(!1),[u,j]=y.useState(!1),[h,x]=y.useState(""),[m,C]=y.useState(!0),g=y.useRef(null),A=y.useRef(r),R=y.useRef(!1),$=y.useRef(t.id);$.current!==t.id&&($.current=t.id,x(""),C(!0)),y.useEffect(()=>{(async()=>{if(t.media_url){x(t.media_url),C(!1);return}if(t.youtube_id)try{C(!0);const S=await(await fetch(`/api/audio/${t.youtube_id}/player/`,{headers:{Authorization:`Token ${localStorage.getItem("token")}`}})).json();x(S.stream_url),C(!1)}catch(I){console.error("Failed to fetch stream URL:",I),C(!1)}})()},[t.id]),y.useEffect(()=>(Uc({title:t.title,artist:t.artist||"Unknown Artist",album:t.album,artwork:t.cover_art_url?[{src:t.cover_art_url,sizes:"96x96",type:"image/png"},{src:t.cover_art_url,sizes:"128x128",type:"image/png"},{src:t.cover_art_url,sizes:"192x192",type:"image/png"},{src:t.cover_art_url,sizes:"256x256",type:"image/png"},{src:t.cover_art_url,sizes:"384x384",type:"image/png"},{src:t.cover_art_url,sizes:"512x512",type:"image/png"}]:void 0}),Nc({play:()=>{A.current||s(!0)},pause:()=>{A.current&&s(!1)},previoustrack:()=>{l&&o&&o()},nexttrack:()=>{i&&a&&a()},seekbackward:()=>{g.current&&(R.current=!0,g.current.currentTime=Math.max(0,g.current.currentTime-10),setTimeout(()=>{R.current=!1},100))},seekforward:()=>{g.current&&(R.current=!0,g.current.currentTime=Math.min(t.duration,g.current.currentTime+10),setTimeout(()=>{R.current=!1},100))},seekto:N=>{g.current&&N.seekTime!==void 0&&(R.current=!0,g.current.currentTime=N.seekTime,setTimeout(()=>{R.current=!1},100))}}),()=>{Bc()}),[t,i,l,a,o,s]),y.useEffect(()=>{g.current&&(g.current.volume=p/100)},[p]),y.useEffect(()=>{g.current&&h&&(g.current.pause(),f(0),g.current.load(),A.current=!1)},[h]),y.useEffect(()=>{if(!(R.current||m)&&g.current&&h&&r!==A.current)if(A.current=r,r){if(g.current.paused){const N=g.current.play();N!==void 0&&N.then(()=>{ks("playing")}).catch(I=>{console.error("Playback failed:",I),s(!1),A.current=!1})}}else g.current.paused||(g.current.pause(),ks("paused"))},[r,s,m,h]);const z=()=>{g.current&&!R.current&&(f(g.current.currentTime),As({duration:t.duration,playbackRate:g.current.playbackRate,position:g.current.currentTime}))},P=(N,I)=>{R.current=!0,f(I)},H=(N,I)=>{const S=I;if(g.current&&!m){R.current=!0;const T=!g.current.paused;if(g.current.pause(),g.current.readyState>=2)g.current.currentTime=S,T&&g.current.play(),As({duration:t.duration,playbackRate:g.current.playbackRate,position:S});else{const G=()=>{g.current&&(g.current.currentTime=S,T&&g.current.play(),g.current.removeEventListener("canplay",G))};g.current.addEventListener("canplay",G)}}},K=()=>{R.current=!1},Q=N=>{const I=Math.floor(N/60),S=Math.floor(N%60);return`${I}:${S.toString().padStart(2,"0")}`};return e.jsxs(d,{sx:{height:"100%",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[e.jsxs(d,{sx:{position:"absolute",inset:0,zIndex:0},children:[e.jsx(d,{sx:{position:"absolute",inset:0,background:N=>`linear-gradient(to bottom, ${N.palette.background.paper} 0%, ${N.palette.background.paper}e6 50%, ${N.palette.background.default} 100%)`,zIndex:10}}),e.jsx(d,{sx:{width:"100%",height:"100%",backgroundImage:t.cover_art_url||t.thumbnail_url?`url(${t.cover_art_url||t.thumbnail_url})`:"none",backgroundSize:"cover",backgroundPosition:"center",filter:"blur(60px)",opacity:.3,transform:"scale(1.5)"}})]}),e.jsxs(d,{sx:{position:"relative",zIndex:20,display:"flex",flexDirection:"column",height:"100%",p:3,justifyContent:"space-between"},children:[h?e.jsx("audio",{ref:g,src:h,onTimeUpdate:z,onSeeked:K,onEnded:()=>{i&&a?a():s(!1)},onError:N=>{console.error("Audio playback error:",N),console.error("Stream URL:",h),console.error("Audio element:",g.current)}}):e.jsx("audio",{ref:g}),e.jsx(d,{sx:{height:96,display:"flex",alignItems:"flex-end",justifyContent:"center",gap:.75,width:"100%"},children:[40,60,100,100,80,50,70,100,100,60,40,20].map((N,I)=>e.jsx(d,{sx:{width:6,bgcolor:I%3===0?"primary.main":I%2===0?"rgba(19, 236, 106, 0.6)":"rgba(19, 236, 106, 0.4)",borderRadius:"9999px",animation:r?"visualizer-bounce 1.2s infinite ease-in-out":"none",animationDelay:`${I*.1}s`,height:r?void 0:"20%",transition:"height 0.3s ease","@keyframes visualizer-bounce":{"0%, 100%":{height:"20%"},"50%":{height:`${N}%`}}}},I))}),e.jsxs(d,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:4},children:[(t.cover_art_url||t.thumbnail_url)&&e.jsx(d,{onClick:()=>t.youtube_id&&j(!u),sx:{width:200,height:200,borderRadius:3,backgroundImage:`url(${t.cover_art_url||t.thumbnail_url})`,backgroundSize:"cover",backgroundPosition:"center",mb:3,boxShadow:"0 8px 32px rgba(0, 0, 0, 0.4)",cursor:t.youtube_id?"pointer":"default",transition:"transform 0.2s ease","&:hover":t.youtube_id?{transform:"scale(1.05)"}:{}},title:t.youtube_id?"Click to toggle lyrics":"Lyrics not available for local files"}),e.jsx(c,{variant:"h5",sx:{fontWeight:700,mb:.5,textAlign:"center",px:2},children:t.title}),e.jsx(c,{variant:"body1",color:"primary.main",sx:{fontWeight:500},children:t.channel_name})]}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(d,{children:[e.jsx(ns,{value:b,max:t.duration,onChange:P,onChangeCommitted:H,sx:{color:"primary.main",height:6,padding:"13px 0","& .MuiSlider-thumb":{width:12,height:12,backgroundColor:"#fff",boxShadow:"0 0 10px rgba(255, 255, 255, 0.5)","&:hover, &.Mui-focusVisible":{boxShadow:"0 0 0 8px rgba(19, 236, 106, 0.16)"}},"& .MuiSlider-track":{border:"none",height:6},"& .MuiSlider-rail":{opacity:.3,backgroundColor:"#fff",height:6}}}),e.jsxs(d,{sx:{display:"flex",justifyContent:"space-between",mt:1},children:[e.jsx(c,{variant:"caption",sx:{color:"rgba(255, 255, 255, 0.4)",fontWeight:500,fontSize:"0.75rem"},children:Q(b)}),e.jsx(c,{variant:"caption",sx:{color:"rgba(255, 255, 255, 0.4)",fontWeight:500,fontSize:"0.75rem"},children:Q(t.duration)})]})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1},children:[e.jsx(U,{size:"small",sx:{color:"rgba(255, 255, 255, 0.4)","&:hover":{color:"white"}},children:e.jsx(pr,{})}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:3},children:[e.jsx(U,{onClick:o,disabled:!l,sx:{color:"white","&:hover":{color:"primary.main"},"&:disabled":{color:"rgba(255, 255, 255, 0.2)"}},children:e.jsx(Pn,{sx:{fontSize:30}})}),e.jsx(U,{onClick:()=>s(!r),sx:{width:64,height:64,bgcolor:"primary.main",color:"background.dark",boxShadow:"0 0 20px rgba(19, 236, 106, 0.4)","&:hover":{bgcolor:"primary.main",transform:"scale(1.05)"},transition:"all 0.3s ease"},children:r?e.jsx(sr,{sx:{fontSize:36}}):e.jsx(_e,{sx:{fontSize:36}})}),e.jsx(U,{onClick:a,disabled:!i,sx:{color:"white","&:hover":{color:"primary.main"},"&:disabled":{color:"rgba(255, 255, 255, 0.2)"}},children:e.jsx(In,{sx:{fontSize:30}})})]}),e.jsx(U,{size:"small",sx:{color:"rgba(255, 255, 255, 0.4)","&:hover":{color:"white"}},children:e.jsx(Rn,{})})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1.5,mt:1},children:[e.jsx(U,{onClick:()=>k(!w),size:"small",sx:{color:"rgba(255, 255, 255, 0.3)"},children:e.jsx(On,{sx:{fontSize:14}})}),e.jsx(d,{sx:{width:96},children:e.jsx(ns,{value:w?0:p,onChange:(N,I)=>{const S=I;_(S),S>0&&k(!1)},sx:{color:"rgba(255, 255, 255, 0.5)",height:4,padding:"8px 0","& .MuiSlider-thumb":{width:8,height:8,backgroundColor:"#fff"},"& .MuiSlider-track":{border:"none",height:4},"& .MuiSlider-rail":{opacity:.3,backgroundColor:"#fff",height:4}}})}),e.jsx(U,{onClick:()=>k(!w),size:"small",sx:{color:"rgba(255, 255, 255, 0.3)"},children:e.jsx(En,{sx:{fontSize:14}})})]})]})]}),u&&t.youtube_id&&e.jsx(ta,{in:u,children:e.jsx(d,{sx:{position:"absolute",inset:0,bgcolor:"rgba(0, 0, 0, 0.95)",backdropFilter:"blur(10px)",zIndex:20,overflow:"auto"},children:e.jsx($c,{youtubeId:t.youtube_id,currentTime:b,onClose:()=>j(!1),embedded:!0})})})]})}const qc=()=>{const{isOnline:t,canInstall:r,isUpdateAvailable:s,showInstallPrompt:n,updateApp:a}=xt(),[o,i]=pe.useState(!1),[l,b]=pe.useState(!1),[f,p]=pe.useState(!1),[_,w]=pe.useState(!1),[k,u]=pe.useState(!1);pe.useEffect(()=>{t?k&&(i(!1),b(!0),u(!1)):(i(!0),u(!0))},[t,k]),pe.useEffect(()=>{if(r){const x=setTimeout(()=>{p(!0)},3e3);return()=>clearTimeout(x)}},[r]),pe.useEffect(()=>{s&&w(!0)},[s]);const j=async()=>{await n()&&p(!1)},h=async()=>{await a(),w(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Te,{open:o,anchorOrigin:{vertical:"bottom",horizontal:"center"},sx:{bottom:{xs:80,sm:24}},children:e.jsxs(V,{severity:"warning",icon:e.jsx(ot,{}),sx:{width:"100%"},children:[e.jsx(c,{variant:"body2",fontWeight:600,children:"You're offline"}),e.jsx(c,{variant:"caption",children:"Cached content is still available"})]})}),e.jsx(Te,{open:l,autoHideDuration:4e3,onClose:()=>b(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},sx:{bottom:{xs:80,sm:24}},children:e.jsx(V,{severity:"success",icon:e.jsx(Ve,{}),onClose:()=>b(!1),sx:{width:"100%"},children:"You're back online!"})}),e.jsx(Te,{open:f,anchorOrigin:{vertical:"bottom",horizontal:"center"},sx:{bottom:{xs:80,sm:24}},children:e.jsx(V,{severity:"info",icon:e.jsx(qt,{}),action:e.jsxs(d,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx(E,{color:"inherit",size:"small",variant:"outlined",onClick:j,sx:{fontWeight:600},children:"Install"}),e.jsx(U,{size:"small",color:"inherit",onClick:()=>p(!1),children:e.jsx(as,{fontSize:"small"})})]}),sx:{width:"100%",alignItems:"center"},children:e.jsxs(d,{children:[e.jsx(c,{variant:"body2",fontWeight:600,gutterBottom:!0,children:"Install SoundWave"}),e.jsx(c,{variant:"caption",children:"Install the app for faster access and offline playback"})]})})}),e.jsx(Te,{open:_,anchorOrigin:{vertical:"bottom",horizontal:"center"},sx:{bottom:{xs:80,sm:24}},children:e.jsx(V,{severity:"info",icon:e.jsx(Ds,{}),action:e.jsxs(d,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx(E,{color:"inherit",size:"small",variant:"outlined",onClick:h,sx:{fontWeight:600},children:"Update"}),e.jsx(U,{size:"small",color:"inherit",onClick:()=>w(!1),children:e.jsx(as,{fontSize:"small"})})]}),sx:{width:"100%",alignItems:"center"},children:e.jsxs(d,{children:[e.jsx(c,{variant:"body2",fontWeight:600,gutterBottom:!0,children:"Update Available"}),e.jsx(c,{variant:"caption",children:"A new version of SoundWave is ready to install"})]})})}),!t&&e.jsxs(d,{sx:{position:"fixed",top:0,left:0,right:0,bgcolor:"warning.main",color:"warning.contrastText",py:.5,px:2,display:"flex",alignItems:"center",justifyContent:"center",gap:1,zIndex:9999},children:[e.jsx(ot,{fontSize:"small"}),e.jsx(c,{variant:"caption",fontWeight:600,children:"Offline Mode"})]})]})};function Hc(){const[t,r]=y.useState(!1),[s,n]=y.useState(null),[a,o]=y.useState(!1),[i,l]=y.useState(!1),[b,f]=y.useState(!1),[p,_]=y.useState([]),[w,k]=y.useState(0),u=ra(),j=sa(u.breakpoints.up("lg"));y.useEffect(()=>{localStorage.getItem("token")&&r(!0)},[]),y.useEffect(()=>{s&&o(!0)},[s]);const h=()=>{r(!0)},x=async()=>{try{await fetch("/api/user/logout/",{method:"POST",headers:{Authorization:`Token ${localStorage.getItem("token")}`,"Content-Type":"application/json"}})}catch(R){console.error("Logout error:",R)}finally{localStorage.removeItem("token"),r(!1),n(null),_([]),k(0)}},m=()=>{l(!i)},C=()=>{if(p.length>0&&w{if(p.length>0&&w>0){const R=w-1;k(R),n(p[R])}},A=(R,$)=>{if(n(R),$&&$.length>0){_($);const z=$.findIndex(P=>P.id===R.id);k(z>=0?z:0)}else _([R]),k(0)};return t?e.jsxs(d,{sx:{display:"flex",height:"100vh",backgroundColor:"background.default"},children:[e.jsx(cc,{mobileOpen:i,onMobileClose:()=>l(!1)}),e.jsxs(d,{sx:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative"},children:[e.jsx(d,{sx:{position:"absolute",top:0,left:0,right:0,height:"96px",background:R=>`linear-gradient(to bottom, ${R.palette.background.default} 0%, transparent 100%)`,zIndex:10,pointerEvents:"none"}}),e.jsx(Sc,{onLogout:x,onMenuClick:m}),e.jsx(d,{sx:{flex:1,overflow:"auto",px:4,py:2,pb:3,"&::-webkit-scrollbar":{display:"none"},msOverflowStyle:"none",scrollbarWidth:"none"},children:e.jsxs(da,{children:[e.jsx(fe,{path:"/",element:e.jsx(hi,{setCurrentAudio:n})}),e.jsx(fe,{path:"/search",element:e.jsx(Ti,{setCurrentAudio:n})}),e.jsx(fe,{path:"/library",element:e.jsx(bi,{setCurrentAudio:A})}),e.jsx(fe,{path:"/favorites",element:e.jsx(Fi,{setCurrentAudio:n})}),e.jsx(fe,{path:"/channels",element:e.jsx(Mi,{})}),e.jsx(fe,{path:"/playlists",element:e.jsx(qi,{})}),e.jsx(fe,{path:"/playlists/:playlistId",element:e.jsx(Hi,{setCurrentAudio:A})}),e.jsx(fe,{path:"/local-files",element:e.jsx(Bl,{setCurrentAudio:n})}),e.jsx(fe,{path:"/offline",element:e.jsx(Hl,{})}),e.jsx(fe,{path:"/settings",element:e.jsx(Fl,{})}),e.jsx(fe,{path:"/admin/users",element:e.jsx(Vl,{children:e.jsx(ql,{})})}),e.jsx(fe,{path:"*",element:e.jsx(Fs,{to:"/",replace:!0})})]})})]}),s&&j&&e.jsx(d,{sx:{width:380,display:"flex",flexDirection:"column",bgcolor:"background.paper",borderLeft:"1px solid",borderColor:"rgba(255, 255, 255, 0.05)",position:"relative",overflow:"hidden"},children:e.jsx(Ps,{audio:s,isPlaying:a,setIsPlaying:o,onClose:()=>n(null),onNext:C,onPrevious:g,hasNext:w0},s.id)}),s&&!j&&e.jsxs(e.Fragment,{children:[!b&&e.jsx(d,{onClick:()=>f(!0),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:"rgba(0, 0, 0, 0.5)",zIndex:999,backdropFilter:"blur(4px)"}}),e.jsx(d,{sx:{position:"fixed",bottom:0,left:0,right:0,zIndex:1e3,maxHeight:"85vh",overflowY:"auto",transform:b?"translateY(100%)":"translateY(0)",transition:"transform 0.3s ease-in-out",visibility:b?"hidden":"visible"},children:e.jsx(Ps,{audio:s,isPlaying:a,setIsPlaying:o,onClose:()=>n(null),onNext:C,onPrevious:g,hasNext:w0},s.id)}),b&&e.jsxs(d,{onClick:()=>f(!1),sx:{display:{xs:"flex",lg:"none"},position:"fixed",bottom:0,left:0,right:0,height:72,bgcolor:"background.paper",borderTop:"1px solid",borderColor:"rgba(255, 255, 255, 0.1)",alignItems:"center",px:2,gap:2,zIndex:1e3,cursor:"pointer",transition:"all 0.2s ease","&:active":{bgcolor:"rgba(255, 255, 255, 0.05)"}},children:[e.jsx(d,{component:"img",src:s.cover_art_url||"/img/icons/icon-192x192.png",alt:s.title,sx:{width:48,height:48,borderRadius:1,objectFit:"cover",flexShrink:0}}),e.jsxs(d,{sx:{flex:1,minWidth:0},children:[e.jsx(c,{variant:"body2",sx:{fontWeight:600,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.title}),e.jsx(c,{variant:"caption",sx:{color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block"},children:s.artist||"Unknown Artist"})]}),e.jsx(U,{onClick:R=>{R.stopPropagation(),o(!a)},sx:{bgcolor:"primary.main",color:"background.dark",width:40,height:40,flexShrink:0,"&:hover":{bgcolor:"primary.main",transform:"scale(1.05)"}},children:a?e.jsx(sr,{}):e.jsx(_e,{})})]})]}),e.jsx(qc,{})]}):e.jsx(ui,{onLoginSuccess:h})}const Tn=y.createContext({themeMode:"dark",setThemeMode:()=>{}}),Vc=()=>y.useContext(Tn);function Gc(){const[t,r]=y.useState(jl()),s=a=>{r(a),bl(a)},n=yl(t);return e.jsx(Tn.Provider,{value:{themeMode:t,setThemeMode:s},children:e.jsxs(na,{theme:n,children:[e.jsx(aa,{}),e.jsx(Hc,{})]})})}Ht.createRoot(document.getElementById("root")).render(e.jsx(pe.StrictMode,{children:e.jsx(ua,{children:e.jsx(Li,{children:e.jsx(Al,{children:e.jsx(Gc,{})})})})}));