import{et as e}from"./vendor-quasar-BP3JemFi.js";import{Ao as t,Fn as n,Ht as r,In as i,Jn as a,Lr as o,Mn as s,Mo as c,Po as l,R as u,Vt as d,Yn as f,fa as p,ma as m,or as h,sr as g,z as _,zr as v}from"./ws-Dl8XkIy4.js";import{r as y,t as b}from"./TokenManager-7Ay6nr15.js";import{a as x,d as S,m as C}from"./client-api-D-UNvPyj.js";import{f as w,p as T,u as E}from"./uiLogic-C8mcxylk.js";import{n as D}from"./genten-glhLoq0B.js";import{a as O,n as k,o as A,r as j,s as M}from"./auth-tS4c9ju3.js";import{initHostAudioCapture as N,t as P}from"./HostAudioCapture-CHMiKCxE.js";a(),S(),r(),E(),c(),y(),k(),_(),P(),A(),o(),h(),p(),s();var F=x(),I=e(()=>{if(localStorage.getItem(`mk-disabled`)===`true`||i())return;b.init();let e=localStorage.getItem(`music.ampwebplay.media-user-token`),r=v(),a=g(),o=m();async function s(){if(j(),n(`MusicKit`,`boot:mklite-only`,`info`,`Setting up MKLite-only mode (skipping MusicKit.js)`),a.musicKitReady=!0,r.musicKitLoaded=!0,await b.getDeveloperToken(),a.setAuthorizedStatus(!0),t.setTokens().catch(e=>{n(`MusicKit`,`boot:mklite-only`,`debug`,`Failed to hand tokens to the native host.`,e)}),await f().init(),d(`remote.enabled`)&&d(`remote.tunnelUUID`)!==``)try{let{apiTokens:e}=d(`connectivity`),{tunnelUUID:t}=d(`remote`);for(let r of e)if(r.method===`tunnel`){l(`/tunnel/open`,{method:`POST`,body:JSON.stringify({id:t})}).then(()=>{n(`MusicKit`,`boot:mklite-only:remote`,`debug`,`Opened WAN tunnel!`,t)});break}}catch(e){n(`MusicKit`,`boot:mklite-only:remote`,`debug`,`Failed to open WAN tunnel.`,e)}switch(F){case`dotnet`:case`naru`:await w();break;case`genten`:case`pixie`:await D();break}O(),M(),u(),C(F)&&(T(!0),N());let e=Number(localStorage.getItem(`volume`)||1);a.normalizedVolume=Math.min(Math.max(Number.isFinite(e)?e:1,0),1),n(`MusicKit`,`boot:mklite-only`,`info`,`MKLite-only setup complete.`)}window.__BUILDINFO__.IS_PE!==`true`&&(e&&b.isAuthorized()?(n(`MusicKit`,`boot`,`info`,`User has valid music user token, using MKLite-only mode`),s().catch(e=>{n(`MusicKit`,`boot`,`warn`,`MKLite-only setup failed`,e);try{o.reportAppleIssue(`Apple Music initialization failed`,e?.message??void 0,45e3)}catch{}})):n(`MusicKit`,`boot`,`info`,`No valid tokens`))});export{I as default};