import{n as e}from"./rolldown-runtime-DAXXjFlN.js";import{Fr as t,dn as n,jn as r}from"./vendor-Dnfj1twE.js";import{A as i,j as a}from"./vendor-vue--4CNL3BY.js";import{$t as o,Ht as s,Vt as c,on as l,sn as u}from"./ws-Dl8XkIy4.js";var d,f=e((()=>{a(),n(),d=i(`lyric-store`,()=>{let e=t([]),n=t([]),r=t(null),i=t(0),a=t(null),o=t(null),s=(e,t)=>{o.value={trackId:e,ttml:t},a.value=e,i.value++},c=()=>{let e=o.value;o.value=null,e&&(a.value=e.trackId,i.value++)},l=(t,n,r)=>e.value.find(e=>e.songId===t&&(!n||e.info.timingType===n)&&(!r||e.info.provider===r)),u=(t,n,r,i=[],a=null)=>{e.value.length>=30&&e.value.shift(),e.value.push({lyrics:t,songId:n,info:{...r},writers:i,ttml:a})},d=(e,t)=>n.value.find(n=>n.songId===e&&n.language===t),f=(e,t,r,i=null)=>{n.value.length>=30&&n.value.shift(),n.value.push({translations:e,songId:t,language:r,credit:i})},p=e=>{r.value=e},m=()=>{r.value=null},h=t=>{e.value=e.value.filter(e=>e.songId!==t),n.value=n.value.filter(e=>e.songId!==t)};return{lyricStore:e,getLyrics:l,addLyrics:u,translationsStore:n,getTranslations:d,addTranslations:f,activeTranslationCredit:r,setActiveTranslationCredit:p,clearActiveTranslationCredit:m,clearForTrack:h,requestRefresh:e=>{h(e),a.value=e,i.value++},refreshNonce:i,refreshTrackId:a,draftPreview:o,setDraftPreview:s,clearDraftPreview:c}})})),p,m=e((()=>{a(),s(),l(),n(),p=i(`lyrics-preferences`,()=>{let e=r(()=>({defaultProvider:c(`lyrics.defaultProvider`)||`auto`,thirdPartySources:c(`lyrics.thirdPartySources`)??!0,preferUserLyrics:c(`lyrics.preferUserLyrics`)??!0,translationEnabled:c(`lyrics.translationEnabled`)??!1,translationMode:c(`lyrics.translationMode`)||`manual`,translationLanguage:c(`lyrics.translationLanguage`)||`en`,showDualLanguage:c(`lyrics.showDualLanguage`)??!0,singLyrics:c(`appleMusic.lyrics.singLyrics`)??!0,staticLyrics:c(`appleMusic.lyrics.staticLyrics`)??!1,showTimestamps:c(`lyrics.showTimestamps`)??!0,timestampStyle:c(`lyrics.timestampStyle`)||`ring`,timeOffset:c(`lyrics.timeOffset`)??0,localeOverrides:c(`lyrics.localeOverrides`)||{},trackOverrides:c(`lyrics.trackOverrides`)||{}}));function t(t,n){let r=e.value;if(t&&r.trackOverrides[t]?.provider)return r.trackOverrides[t].provider;if(n){let e=u(n),t=r.localeOverrides[e];if(t?.provider)return t.provider}return r.defaultProvider}function n(t,n){let r=e.value;if(t&&r.trackOverrides[t]?.translationLang)return r.trackOverrides[t].translationLang;if(n){let e=u(n),t=r.localeOverrides[e];if(t?.translationLang)return t.translationLang}switch(r.translationMode){case`app-language`:return u(c(`general.language`))||`en`;case`system`:return u(navigator.language)||`en`;default:return r.translationLanguage||`en`}}function i(t,r=null){if(!e.value.translationEnabled)return!1;let i=n(r,t),a=u(t||``);return!(a&&a===i)}function a(n,r=null){let i=e.value,a=t(r,n);if(a!==`auto`){let e=[a];return i.thirdPartySources?(a!==`apple`&&e.push(`apple`),a!==`mxm`&&e.push(`mxm`),a!==`netease`&&e.push(`netease`)):a!==`apple`&&e.push(`apple`),e}let o=[];return i.preferUserLyrics&&o.push(`user`),o.push(`apple`),i.thirdPartySources&&(o.push(`mxm`),o.push(`netease`)),i.preferUserLyrics||o.push(`user`),o}function s(e,t){let n={...c(`lyrics.trackOverrides`)||{}};n[e]={...n[e],...t},o(`lyrics.trackOverrides`,n)}function l(e){return(c(`lyrics.trackOverrides`)||{})[e]?.instrumental}function d(e,t,n){s(e,{instrumental:t,...n?.trackName?{trackName:n.trackName}:{},...n?.artistName?{artistName:n.artistName}:{}})}function f(e){let t={...c(`lyrics.trackOverrides`)||{}};delete t[e],o(`lyrics.trackOverrides`,t)}function p(e){return e in(c(`lyrics.trackOverrides`)||{})}function m(e,t){let n=u(e),r={...c(`lyrics.localeOverrides`)||{}};r[n]=t,o(`lyrics.localeOverrides`,r)}function h(e){let t=u(e),n={...c(`lyrics.localeOverrides`)||{}};delete n[t],o(`lyrics.localeOverrides`,n)}return{preferences:e,getEffectiveProvider:t,getProviderOrder:a,getEffectiveTranslationLang:n,shouldTranslate:i,setTrackOverride:s,removeTrackOverride:f,hasTrackOverride:p,getInstrumentalOverride:l,setInstrumentalOverride:d,setLocaleOverride:m,removeLocaleOverride:h,normalizeLanguageCode:u}})}));export{d as i,p as n,f as r,m as t};