1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[14402,24224,81317],{90061:(e,t,s)=>{s.d(t,{e:()=>l});var r=s(95155),a=s(12115),i=s(21567);let o={xs:"w-6 h-6 text-xs",sm:"w-8 h-8 text-sm",md:"w-12 h-12 text-base",lg:"w-16 h-16 text-lg",xl:"w-20 h-20 text-xl","2xl":"w-24 h-24 text-2xl"},n=["from-blue-500 to-purple-600","from-purple-500 to-pink-600","from-pink-500 to-rose-600","from-rose-500 to-orange-600","from-orange-500 to-yellow-600","from-yellow-500 to-green-600","from-green-500 to-teal-600","from-teal-500 to-cyan-600","from-cyan-500 to-blue-600","from-indigo-500 to-purple-600"],l=e=>{let{src:t,alt:s,name:a,size:l="md",className:d,fallbackType:c="gradient",showBorder:m=!0,priority:p=!1}=e,v=o[l],h=e=>e?e.split(" ").map(e=>e.charAt(0).toUpperCase()).slice(0,2).join(""):"?",y=e=>e?n[e.split("").reduce((e,t)=>e+t.charCodeAt(0),0)%n.length]:n[0],g=()=>{switch(c){case"initials":return(0,r.jsx)("div",{className:(0,i.cn)(v,"rounded-full flex items-center justify-center text-white font-semibold","bg-slate-600/80 backdrop-blur-sm",m&&"border-2 border-white/20",d),children:h(a)});case"gradient":let e=y(a);return(0,r.jsx)("div",{className:(0,i.cn)(v,"rounded-full flex items-center justify-center text-white font-semibold","bg-gradient-to-br ".concat(e),m&&"border-2 border-white/20 shadow-lg","transition-all duration-300 hover:shadow-xl hover:scale-105",d),children:h(a)});case"earonman":return(0,r.jsx)("div",{className:(0,i.cn)(v,"rounded-full overflow-hidden bg-card flex items-center justify-center",m&&"border-2 border-white/20",d),children:(0,r.jsx)("img",{src:"/avatars/Earonman-NoBackground.png",alt:"Default Avatar",width:96,height:96,className:"w-full h-full object-cover scale-110"})});default:return g()}};return t?(0,r.jsx)(u,{src:t,alt:s||a||"Avatar",name:a,sizeClass:v,showBorder:m,className:d,getGradientClass:y,getInitials:h}):g()};function u(e){let{src:t,alt:s,name:o,sizeClass:n,showBorder:l,className:u,getGradientClass:d,getInitials:c}=e,[m,p]=(0,a.useState)(!1);return m?(0,r.jsx)("div",{className:(0,i.cn)(n,"rounded-full flex items-center justify-center text-white font-semibold","bg-gradient-to-br ".concat(d(o)),l&&"border-2 border-white/20 shadow-lg",u),children:c(o)}):(0,r.jsx)("div",{className:(0,i.cn)(n,"rounded-full overflow-hidden bg-card",l&&"border-2 border-white/20","transition-all duration-300 hover:shadow-lg hover:scale-105",u),children:(0,r.jsx)("img",{src:t,alt:s,width:96,height:96,className:"w-full h-full object-cover",onError:()=>p(!0)})})}},24224:(e,t,s)=>{s.d(t,{d:()=>m,notify:()=>u,t:()=>c});var r=s(95155),a=s(12115),i=s(47650),o=s(25683),n=s(2178);let l=new Set;function u(e){l.forEach(t=>t(e))}function d(e){let{variant:t}=e,s="w-4 h-4";return"success"===t?(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:s,children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"})}):"error"===t?(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:s,children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M12 2.25a9.75 9.75 0 1 0 9.75 9.75A9.76 9.76 0 0 0 12 2.25Zm.75 5.25a.75.75 0 0 0-1.5 0v6a.75.75 0 0 0 1.5 0Zm-.75 9a1.125 1.125 0 1 0 1.125 1.125A1.125 1.125 0 0 0 12 16.5Z",clipRule:"evenodd"})}):"warning"===t?(0,r.jsxs)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:s,children:[(0,r.jsx)("path",{d:"M10.29 3.86a1.5 1.5 0 0 1 2.42 0l8.4 12.6A1.5 1.5 0 0 1 19.9 18H4.1a1.5 1.5 0 0 1-1.21-2.54l8.4-12.6Z"}),(0,r.jsx)("path",{d:"M12 8v5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),(0,r.jsx)("circle",{cx:"12",cy:"16",r:"1",fill:"#000"})]}):(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:s,children:(0,r.jsx)("path",{d:"M12 2.25a9.75 9.75 0 1 0 9.75 9.75A9.76 9.76 0 0 0 12 2.25Zm.75 5.25a.75.75 0 0 0-1.5 0v6a.75.75 0 0 0 1.5 0Zm-.75 9a1.125 1.125 0 1 0 1.125 1.125A1.125 1.125 0 0 0 12 16.5Z"})})}function c(e){let{children:t}=e,[s,u]=(0,a.useState)([]),c=(0,a.useRef)(new Map);(0,a.useEffect)(()=>{var e;let t=(e=e=>{var t,s,r;let a=null!==(t=e.id)&&void 0!==t?t:"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2)),i=null!==(s=e.variant)&&void 0!==s?s:"info",o=null!==(r=e.duration)&&void 0!==r?r:3500;u(t=>[...t,{...e,id:a,variant:i,duration:o}]);let n=setTimeout(()=>m(a),o);c.current.set(a,n)},l.add(e),()=>l.delete(e));return()=>{t()}},[]);let m=e=>{let t=c.current.get(e);t&&(clearTimeout(t),c.current.delete(e)),u(t=>t.filter(t=>t.id!==e))},p=document.getElementById("portal-root"),v=(0,r.jsx)("div",{className:"pointer-events-none fixed top-[calc(env(safe-area-inset-top)+16px)] right-[calc(env(safe-area-inset-right)+16px)] z-[100] flex flex-col gap-2",children:(0,r.jsx)(o.N,{children:s.map(e=>{var t,s;return(0,r.jsx)(n.P.div,{initial:{opacity:0,y:-10,scale:.98}
1,animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-10,scale:.98},transition:{duration:.18},className:["pointer-events-auto min-w-[280px] max-w-[380px] p-3 sm:p-3.5 rounded-xl shadow-lg ring-1","glass-chip-strong",function(e){switch(e){case"success":return"tint-emerald";case"error":return"tint-red";case"warning":return"tint-amber";default:return"tint-steel"}}(null!==(t=e.variant)&&void 0!==t?t:"info")].join(" "),children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"mt-0.5 opacity-90",children:(0,r.jsx)(d,{variant:null!==(s=e.variant)&&void 0!==s?s:"info"})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[e.title&&(0,r.jsx)("div",{className:"text-sm font-medium leading-none mb-1",children:e.title}),(0,r.jsx)("div",{className:"text-sm leading-snug opacity-90 whitespace-pre-line break-words",children:e.description})]}),(0,r.jsx)("button",{"aria-label":"Close notification",className:"ml-1 rounded-md px-2 py-1 text-xs bg-white/10 hover:bg-white/15",onClick:()=>m(e.id),children:"Close"})]})},e.id)})})});return(0,r.jsxs)(r.Fragment,{children:[t,p?(0,i.createPortal)(v,p):v]})}function m(){return(0,a.useMemo)(()=>({notify:u}),[])}},40947:(e,t,s)=>{s.d(t,{E:()=>n});var r=s(95155);s(12115);var a=s(31027),i=s(21567);let o=(0,a.F)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function n(e){let{className:t,variant:s,...a}=e;return(0,r.jsx)("div",{className:(0,i.cn)(o({variant:s}),t),...a})}},70734:(e,t,s)=>{s.d(t,{Cf:()=>c,Es:()=>p,L3:()=>v,c7:()=>m,lG:()=>l,rr:()=>h});var r=s(95155),a=s(12115),i=s(30042),o=s(87365),n=s(21567);let l=i.bL;i.l9;let u=i.ZL;i.bm;let d=a.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)(i.hJ,{ref:t,className:(0,n.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...a})});d.displayName=i.hJ.displayName;let c=a.forwardRef((e,t)=>{let{className:s,children:a,...l}=e;return(0,r.jsxs)(u,{children:[(0,r.jsx)(d,{}),(0,r.jsxs)(i.UC,{ref:t,className:(0,n.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...l,children:[a,(0,r.jsxs)(i.bm,{className:"absolute right-4 top-4 roun
1ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground p-2 sm:p-0",children:[(0,r.jsx)(o.MKb,{className:"h-6 w-6 sm:h-4 sm:w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});c.displayName=i.UC.displayName;let m=e=>{let{className:t,...s}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...s})};m.displayName="DialogHeader";let p=e=>{let{className:t,...s}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s})};p.displayName="DialogFooter";let v=a.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)(i.hE,{ref:t,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",s),...a})});v.displayName=i.hE.displayName;let h=a.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)(i.VY,{ref:t,className:(0,n.cn)("text-sm text-muted-foreground",s),...a})});h.displayName=i.VY.displayName},12538:(e,t,s)=>{s.d(t,{Q:()=>l,k:()=>n});var r=s(95155),a=s(12115),i=s(2615);let o=(0,a.createContext)(void 0);function n(e){var t,s;let{children:n}=e,[l,u]=(0,a.useState)(!1),{data:d}=(0,i.useSession)(),c=!!(null==d?void 0:null===(t=d.user)||void 0===t?void 0:t.devMode)||!!(null==d?void 0:null===(s=d.user)||void 0===s?void 0:s.isAdmin);return(0,a.useEffect)(()=>{if(!c){u(!1);return}u("true"===localStorage.getItem("devMode"));let e=e=>{"devMode"===e.key&&c&&u("true"===e.newValue)},t=()=>{try{let e=localStorage.getItem("devMode");c&&u("true"===e)}catch(e){}};return window.addEventListener("storage",e),window.addEventListener("devmode-change",t),()=>{window.removeEventListener("storage",e),window.removeEventListener("devmode-change",t)}},[c]),(0,r.jsx)(o.Provider,{value:{devMode:l,toggleDevMode:()=>{if(!c){console.warn("You are not allowed to toggle DevMode");return}u(e=>{let t=!e;localStorage.setItem("devMode",t?"true":"false");try{window.dispatchEvent(new Event("devmode-change"))}catch(e){}return t})}},children:n})}function l(){let e=(0,a.useContext)(o);if(void 0===e)throw Error("useDevMode must be used within a DevModeProvider");return e}},68370:(e,t,s)=>{s.d(t,{P:()=>o,l:()=>n});var r=s(95155),a=s(12115);let i=(0,a.createContext)(void 0);function o(e){let{children:t}=e,[s,o]=(0,a.useState)(!1);return(0,r.jsx)(i.Provider,{value:{isInActiveGame:s,setIsInActiveGame:o},children:t})}function n(){let e=(0,a.useContext)(i);return void 0===e?{isInActiveGame:!1,setIsInActiveGame:()=>{}}:e}},12096:(e,t,s)=>{s.d(t,{LV:()=>l,vU:()=>n});var r=s(95155),a=s(12115);let i=(0,a.createContext)(void 0);function o(e,t){switch(t.type){case"INITIALIZE":let s=t.payload.levelProgress||[],r=t.payload.lessonProgress||[],a=s.filter(e=>e.completed).map(e=>e.levelId),i=r.filter(e=>e.completed).map(e=>e.lessonId);return{...e,user:t.payload.user,levels:t.payload.levels,lessons:t.payload.lessons,levelProgress:s,lessonProgress:r,completedLevels:a,completedLessons:i,isLoading:!1,error:null};case"SET_LOADING":return{...e,isLoading:t.payload};case"SET_ERROR":return{...e,error:t.payload,isLoading:!1};case"SET_CURRENT_LEVEL":return{...e,currentLevelId:t.payload};case"UPDATE_PROGRESS":let o=e.levelProgress.map(e=>e.levelId===t.payload.levelId?{...e,completed:t.payload.completed,completedAt:t.payload.completed?new Date:e.completedAt}:e),n=o.filter(e=>e.completed).map(e=>e.levelId);return{...e,levelProgress:o,completedLevels:n};case"UPDATE_LESSON_PROGRESS":let l;let u=(l=e.lessonProgress.findIndex(e=>e.lessonId===t.payload.lessonId)>-1?e.lessonProgress.map(e=>e.lessonId===t.payload.lessonId?{...e,completed:t.payload.completed,viewedAt:t.payload.viewedAt}:e):[...e.lessonProgress,{lessonId:t.payload.lessonId,completed:t.payload.completed,viewedAt:t.payload.viewedAt}]).filter(e=>e.completed).map(e=>e.lessonId);return{...e,lessonProgress:l,completedLessons:u};case"REVERT_PROGRESS":let d=e.levelProgress.map(e=>e.levelId===t.payload.levelId?{...e,completed:!1,completedAt:e.completedAt}:e),c=d.filter(e=>e.completed).map(e=>e.levelId);return{...e,levelProgress:d,completedLevels:c};case"REVERT_LESSON_PROGRESS":let m=e.lessonProgress.map(e=>e.lessonId===t.payload.lessonId?{...e,completed:!1,viewedAt:e.viewedAt}:e),p=m.filter(e=>e.completed).map(e=>e.lessonId);return{...e,lessonProgress:m,completedLessons:p};case"REPLACE_LEVEL_PROGRESS":let v=t.payload.filter(e=>e.completed).map(e=>e.levelId);return{...e,levelProgress:t.payload,completedLevels:v};case"REPLACE_LESSON_PROGRESS":let h=t.payload.filter(e=>e.completed).map(e=>e.lessonId);return{...e,lessonProgress:t.payload,completedLessons:h};case"UPDATE_USER":return{...e,user:{...e.user,...t.payload}};case"SET_COMPLETED_LEVELS":return{...e,completedLevels:t.payload};case"SET_COMPLETED_LESSONS":return{...e,completedLessons:t.payload};case"SET_LEVEL_REVIEW":return{...e,levels:e.levels.map(e=>e.id===t.payload.levelId?{...e,markedForReview:t.payload.markedForReview}:e)};case"UPDATE_PRACTICE_STATS":return{...e,practice:{...e.practice,stats:{...e.practice.stats,...t.payload}}};case"UNLOCK_ACHIEVEMENT":if(!e.practice.stats.unlockedAchievements.includes(t.payload))return{...e,practice:{...e.practice,stats:{...e.practice.stats,unlockedAchievements:[...e.practice.stats.unlockedAchievements,t.payload]}}};return e;case"COMPLETE_TUTORIAL_STEP":return{...e,practice:{...e.practice,tutorial:{...e.practice.tutorial,completed:[...e.practice.tutorial.completed,t.payload]}}};case"SET_CURRENT_TUTORIAL_STEP":return{...e,practice:{...e.practice,tutorial:{...e.practice.tutorial,current:t.payload}}};case"COMPLETE_TUTORIAL":return{...e,practice:{...e.practice,tutorial:{...e.practice.tutorial,completed:e.practice.tutorial.completed,current:null}}};case"SKIP_TUTORIAL":return{...e,practice:{...e.practice,tutorial:{...e.practice.tutorial,skipped:!0,current:null}}};case"START_ANIMATION":return{...e,practice:{...e.practice,currentAnimation:t.payload}};case"CLEAR_ANIMATION":return{...e,practice:{...e.practice,currentAnimation:null}};case"TOGGLE_MOBILE_STATS":return{...e,practice:{...e.practice,isMobileStatsPanelOpen:!e.practice.isMobileStatsPanelOpen}};default:return e}}function n(){let e=(0,a.useContext)(i);if(!e)throw Error("useGameState must be used within a GameStateProvider");return e}function l(e){var t;let{children:s,initialData:n}=e,l={user:null,levels:[],lessons:[],levelProgress:[],lessonProgress:[]},u=n||l,d=!!((null==n?void 0:n.user)||(null==n?void 0:n.levels)&&n.levels.length>0),[c,m]=(0,a.useReducer)(o,{...l,...u,currentLevelId:null,completedLevels:(u.levelProgress||[]).filter(e=>e.completed).map(e=>e.levelId),completedLessons:(u.lessonProgress||[]).filter(e=>e.completed).map(e=>e.lessonId),isLoading:!d,error:null,practice:{stats:{totalSessions:0,currentStreak:0,maxStreak:0,focusMinutes:0,lastPracticeDate:null,exerciseAccuracy:{intervals:0,chords:0,scales:0,"jazz-voicings":0,"harmonic-quest":0,guido:0,functioneer:0,slashmaster:0,"hybrid-lab":0,polychordist:0},personalBests:{intervals:0,chords:0,scales:0,"jazz-voicings":0,"harmonic-quest":0,guido:0,functioneer:0,slashmaster:0,"hybrid-lab":0,polychordist:0},averageResponseTime:{intervals:0,chords:0,scales:0,"jazz-voicings":0,"harmonic-quest":0,guido:0,functioneer:0,slashmaster:0,"hybrid-lab":0,polychordist:0},unlockedAchievements:[],masteredConcepts:{intervals:[],chords:[],scales:[],voicings:[],harmonicQuest:[],guido:[],tonalProgressions:[],slashmaster:[],hybridLab:[],polychordist:[]}},achievements:[],tutorial:{completed:[],current:null,skipped:!1},currentAnimation:null,showMobileStats:!1,isMobileStatsPanelOpen:!1}}),p=a.useRef(d),v=a.useRef(d?JSON.stringify(null!==(t=u.levelProgress)&&void 0!==t?t:[]):null);return(0,a.useEffect)(()=>{var e,t;if(!(null==u?void 0:u.user))return;let s=JSON.stringify(null!==(e=u.levelProgress)&&void 0!==e?e:[]);if(!p.current){p.current=!0,v.current=s,m({type:"INITIALIZE",payload:u});return}s!==v.current&&(v.current=s,m({type:"REPLACE_LEVEL_PROGRESS",payload:null!==(t=u.levelProgress)&&void 0!==t?t:[]}))},[u,m]),(0,r.jsx)(i.Provider,{value:{state:c,dispatch:m},children:s})}},79112:(e,t,s)=>{s.d(t,{E:()=>m,X:()=>c});var r=s(95155),a=s(12115),i=s(69483),o=s(19223),n=s(35906),l=s(25848),u=s(2615);let d=(0,a.createContext)(void 0),c=e=>{let{children:t}=e,{data:c,status:m}=(0,u.useSession)(),p=null==c?void 0:c.user.id,{data:v,isLoading:h,error:y}=(0,i.m)(p),{data:g,isLoading:f,error:b}=(0,o.X)(p,!!(null==c?void 0:c.user.createdAt)),w=(0,n.jE)(),x=new Date,S=(0,a.useMemo)(()=>{var e,t;
1return{...(null==c?void 0:c.user)?{name:c.user.name,createdAt:c.user.createdAt,profilePictureUrl:c.user.profilePictureUrl,subscription:(null===(e=c.user)||void 0===e?void 0:e.subscription)||null}:{},...g,...v,subscription:(null==c?void 0:null===(t=c.user)||void 0===t?void 0:t.subscription)||(null==g?void 0:g.subscription)||(null==v?void 0:v.subscription)||null}},[c,g,v]),E=(0,a.useCallback)(e=>{w.setQueryData(["dynamicUserData"],t=>({...t,xp:e}))},[w]),P=(0,a.useCallback)(e=>{w.setQueryData(["dynamicUserData"],t=>({...t,level:e}))},[w]),I=(0,a.useCallback)(e=>{w.setQueryData(["dynamicUserData"],t=>({...t,badges:e}))},[w]),A=(0,l.n)({mutationFn:async e=>{try{if(!(await fetch("/api/user/update-progress",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({xp:e})})).ok)throw Error("Failed to update XP")}catch(t){if(!navigator.onLine||t instanceof TypeError){let{queueMutation:t}=await s.e(14402).then(s.bind(s,14402));await t("/api/user/update-progress","POST",{xp:e},"update-xp-".concat(e));return}throw t}},onSuccess:()=>w.invalidateQueries({queryKey:["dynamicUserData"]})}),L=async e=>{await A.mutateAsync(e)},j=(0,l.n)({mutationFn:async e=>{try{if(!(await fetch("/api/user/update-progress",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:e})})).ok)throw Error("Failed to update level")}catch(t){if(!navigator.onLine||t instanceof TypeError){let{queueMutation:t}=await s.e(14402).then(s.bind(s,14402));await t("/api/user/update-progress","POST",{level:e},"update-level-".concat(e));return}throw t}},onSuccess:()=>w.invalidateQueries({queryKey:["dynamicUserData"]})}),V=async e=>{await j.mutateAsync(e)},N="loading"===m||h||f,T=y||b,C=!!S&&"loading"!==m,R=(0,a.useMemo)(()=>({userName:(null==S?void 0:S.name)||"User",xp:(null==S?void 0:S.xp)||0,level:(null==S?void 0:S.level)||1,badges:(null==S?void 0:S.badges)||[],createdAt:(()=>{if(!(null==S?void 0:S.createdAt))return"";if("string"==typeof S.createdAt)return S.createdAt;try{return S.createdAt.toISOString()}catch(e){return console.error("Error formatting createdAt:",e),""}})(),profilePictureUrl:(null==S?void 0:S.profilePictureUrl)||null,country:(null==S?void 0:S.country)||null,subscription:(null==S?void 0:S.subscription)||null,isLoading:N,error:T,lastUpdated:x,hasLoaded:C,setXp:E,setLevel:P,setBadges:I,updateXp:L,updateLevel:V,refetch:()=>{w.invalidateQueries({queryKey:["dynamicUserData"]}),w.invalidateQueries({queryKey:["staticUserData"]})},forceRefresh:()=>{w.invalidateQueries({queryKey:["dynamicUserData"]}),w.invalidateQueries({queryKey:["staticUserData"]})}}),[S,N,T,x,E,P,I,L,V,w,C]);return(0,r.jsx)(d.Provider,{value:R,children:t})},m=()=>{let e=(0,a.useContext)(d);if(!e)throw Error("useUserDataContext must be used within a UserDataProvider");return e}},19966:(e,t,s)=>{s.d(t,{Ac:()=>a,Rm:()=>i,cd:()=>l,jR:()=>o,kS:()=>n});let r=()=>"vibrate"in navigator,a=()=>{if(r())try{navigator.vibrate(100)}catch(e){console.warn("Haptic feedback failed:",e)}},i=()=>{if(r())try{navigator.vibrate([80,50,80,50,80])}catch(e){console.warn("Haptic feedback failed:",e)}},o=()=>{if(r())try{navigator.vibrate(15)}catch(e){}},n=()=>{if(r())try{navigator.vibrate(30)}catch(e){}},l=()=>{if(r())try{navigator.vibrate([20,30,20])}catch(e){}}},98312:(e,t,s)=>{s.d(t,{z:()=>n});var r=s(11094),a=s(2818);let i=s.g,o={log:["error"],datasources:{db:{url:a.env.DATABASE_URL}}},n=i.prisma||new r.PrismaClient(o),l=async()=>{try{await n.$disconnect()}catch(e){console.error("Error during Prisma Client disconnect:",e)}};i.prismaListenersAdded||(i.prismaListenersAdded=!0,a.on("beforeExit",l),a.on("SIGINT",l),a.on("SIGTERM",l),a.on("uncaughtException",async e=>{console.error(e),await l(),a.exit(1)}),a.on("unhandledRejection",async e=>{console.error(e),await l(),a.exit(1)}))},46482:(e,t,s)=>{s.d(t,{o:()=>o});var r=s(75556),a=s(19966);class i{static getInstance(){return i.instance||(i.instance=new i),i.instance}initialize(){if(!this.isInitialized){for(let[e,t]of(this.correctSound=new r.Howl({src:["/sounds/correct.mp3"],volume:this.uiVolume,html5:!1}),this.wrongSound=new r.Howl({src:["/sounds/wrong.mp3"],volume:this.uiVolume,html5:!1}),this.badgeSound=new r.Howl({src:["/sounds/badge.mp3"],volume:this.uiVolume,html5:!1}),this.completeSound=new r.Howl({src:["/sounds/complete.mp3"],volume:this.uiVolume,html5:!1}),[["levelUpSound","levelup"],["confettiSound","confetti"],["streakSound","streak"],["coinSound","coin"]]))this[e]=new r.Howl({src:["/sounds/".concat(t,".mp3")],volume:this.uiVolume,html5:!1});this.isInitialized=!0,this.loadVolumeSettings()}}setUIVolume(e){this.uiVolume=Math.max(0,Math.min(1,e)),this.correctSound&&this.correctSound.volume(this.uiVolume),this.wrongSound&&this.wrongSound.volume(this.uiVolume),this.badgeSound&&this.badgeSound.volume(this.uiVolume),this.completeSound&&this.completeSound.volume(this.uiVolume),this.saveVolumeSettings()}setMusicVolume(e){this.musicVolume=Math.max(0,Math.min(1,e)),this.saveVolumeSettings()}setExerciseVolume(e){this.setMusicVolume(e)}setUserVolume(e){this.setMusicVolume(e)}getUIVolume(){return this.uiVolume}getMusicVolume(){return this.musicVolume}getExerciseVolume(){return this.musicVolume}getUserVolume(){return this.musicVolume}saveVolumeSettings(){{let e={uiVolume:this.uiVolume,musicVolume:this.musicVolume};localStorage.setItem("soundVolumeSettings",JSON.stringify(e))}}loadVolumeSettings(){{let e=localStorage.getItem("soundVolumeSettings");if(e)try{let t=JSON.parse(e);void 0!==t.uiVolume&&(this.uiVolume=t.uiVolume),void 0!==t.musicVolume?this.musicVolume=t.musicVolume:void 0!==t.exerciseVolume&&(this.musicVolume=t.exerciseVolume),this.correctSound&&this.correctSound.volume(this.uiVolume),this.wrongSound&&this.wrongSound.volume(this.uiVolume),this.badgeSound&&this.badgeSound.volume(this.uiVolume),this.completeSound&&this.completeSound.volume(this.uiVolume)}catch(e){}}}playCorrect(){this.isInitialized||this.initialize(),this.correctSound&&(this.correctSound.stop(),this.correctSound.volume(this.uiVolume),this.correctSound.play()),(0,a.Ac)()}playWrong(){this.isInitialized||this.initialize(),this.wrongSound&&(this.wrongSound.stop(),this.wrongSound.volume(this.uiVolume),this.wrongSound.play()),(0,a.Rm)()}playBadge(){this.isInitialized||this.initialize(),this.badgeSound&&(this.badgeSound.stop(),this.badgeSound.volume(this.uiVolume),this.badgeSound.play())}playComplete(){this.isInitialized||this.initialize(),this.completeSound&&(this.completeSound.stop(),this.completeSound.volume(this.uiVolume),this.completeSound.play())}playCelebration(e){this.isInitialized||this.initialize();let t={levelup:this.levelUpSound,confetti:this.confettiSound,streak:this.streakSound,coin:this.coinSound}[e];t&&(t.stop(),t.volume(this.uiVolume),t.play())}cleanup(){this.correctSound&&(this.correctSound.stop(),this.correctSound.unload(),this.correctSound=null),this.wrongSound&&(this.wrongSound.stop(),this.wrongSound.unload(),this.wrongSound=null),this.badgeSound&&(this.badgeSound.stop(),this.badgeSound.unload(),this.badgeSound=null),this.completeSound&&(this.completeSound.stop(),this.completeSound.unload(),this.completeSound=null),this.isInitialized=!1}constructor(){this.correctSound=null,this.wrongSound=null,this.badgeSound=null,this.completeSound=null,this.levelUpSound=null,this.confettiSound=null,this.streakSound=null,this.coinSound=null,this.uiVolume=.5,this.musicVolume=.5,this.isInitialized=!1}}i.instance=null;let o=i.getInstance()},69483:(e,t,s)=>{s.d(t,{m:()=>n});var r=s(39556),a=s(98312),i=s(76196);let o=async e=>{let t=await a.z.user.findUnique({where:{id:parseInt(e)},select:{id:!0,xp:!0,level:!0,streak:!0,maxStreak:!0,dailyCorrectAnswers:!0,lastDailyReset:!0,earCoins:!0,userBadges:{select:{badge:{select:{id:!0,name:!0,description:!0,imageUrl:!0,xpRequired:!0}}}}}});if(!t)throw Error("User not found");let s=new Date,r=t.dailyCorrectAnswers,o=t.lastDailyReset;if(!o||(0,i.m)(s,o)>
10){let e=await a.z.user.update({where:{id:t.id},data:{dailyCorrectAnswers:0,lastDailyReset:s},select:{dailyCorrectAnswers:!0,lastDailyReset:!0}});r=e.dailyCorrectAnswers,o=e.lastDailyReset}return{...t,dailyCorrectAnswers:r,lastDailyReset:o,badges:t.userBadges.map(e=>e.badge)}},n=e=>(0,r.I)({queryKey:["user","dynamic",e],queryFn:()=>{if(!e)throw Error("Missing user ID");return o(e)},enabled:!!e})},19223:(e,t,s)=>{s.d(t,{X:()=>i});var r=s(39556),a=s(41580);let i=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,r.I)({queryKey:["user","static",e],queryFn:()=>{if(!e)throw Error("Missing user ID");return(0,a.m)("/api/user/static")},enabled:!!e&&!t,staleTime:864e5})}},41580:(e,t,s)=>{s.d(t,{j:()=>a,m:()=>r});let r=async(e,t)=>{let s=await fetch(e,t);if(!s.ok){let e=await s.text();throw Error("API error: ".concat(e))}return s.json()},a=async e=>{}},27148:(e,t,s)=>{s.d(t,{G:()=>i});var r=s(92337),a=s(57209);let i={onLessonComplete:(e,t,s)=>{e.invalidateQueries({queryKey:r.E.lessons.byLevel(t)}),e.invalidateQueries({queryKey:r.E.lessons.progress}),e.invalidateQueries({queryKey:r.E.exercises.initBase,exact:!1}),e.invalidateQueries({queryKey:r.E.stats.dashboard})},onLevelComplete:async(e,t,s,i)=>{e.invalidateQueries({queryKey:r.E.levels.progress}),s&&await e.prefetchQuery({queryKey:r.E.lessons.byLevel(s),queryFn:()=>(0,a.m)("/api/lessons?levelId=".concat(s)),staleTime:3e5}),i||e.invalidateQueries({queryKey:r.E.subscription.base,exact:!1}),e.invalidateQueries({queryKey:r.E.stats.dashboard}),e.invalidateQueries({queryKey:r.E.exercises.initBase,exact:!1})},onSubscriptionChange:e=>{e.invalidateQueries({queryKey:r.E.subscription.base,exact:!1}),e.invalidateQueries({queryKey:r.E.user.base}),e.invalidateQueries({queryKey:r.E.levels.base})},onExerciseStart:e=>{e.invalidateQueries({queryKey:r.E.subscription.info,exact:!1})},onUserProfileUpdate:(e,t)=>{e.invalidateQueries({queryKey:r.E.user.base}),t&&e.invalidateQueries({queryKey:r.E.user.dynamic(t)})},onStatsUpdate:(e,t)=>{e.invalidateQueries({queryKey:r.E.stats.dashboard}),t&&e.invalidateQueries({queryKey:r.E.stats.percentile(t)}),t&&e.invalidateQueries({queryKey:r.E.user.dynamic(t)})},onTestOutComplete:(e,t)=>{e.invalidateQueries({queryKey:r.E.levels.progress}),t.forEach(t=>{e.invalidateQueries({queryKey:r.E.lessons.byLevel(t)})}),e.invalidateQueries({queryKey:r.E.exercises.initBase,exact:!1}),e.invalidateQueries({queryKey:r.E.subscription.base,exact:!1})},onDevModeToggle:(e,t)=>{t&&e.invalidateQueries({queryKey:r.E.user.dynamic(t)}),e.invalidateQueries({queryKey:r.E.levels.base}),e.invalidateQueries({queryKey:r.E.levels.progress}),e.invalidateQueries({queryKey:r.E.exercises.initBase,exact:!1})},onTrainingPathChange:(e,t)=>
1{e.invalidateQueries({queryKey:r.E.levels.base}),t&&e.invalidateQueries({queryKey:r.E.levels.byPath(t)})},onEmailPreferencesUpdate:e=>{e.invalidateQueries({queryKey:r.E.user.emailPreferences})},onLogout:e=>{e.clear()},onProgressReset:(e,t)=>{e.invalidateQueries({queryKey:r.E.user.base}),e.invalidateQueries({queryKey:r.E.levels.progress}),e.invalidateQueries({queryKey:r.E.lessons.progress}),e.invalidateQueries({queryKey:r.E.stats.base}),e.invalidateQueries({queryKey:r.E.exercises.initBase,exact:!1}),e.invalidateQueries({queryKey:r.E.exercises.streak})}}},92337:(e,t,s)=>{s.d(t,{E:()=>r});let r={user:{base:["user"],dynamic:e=>e?["user","dynamic",e]:["user","dynamic"],allData:["user","all"],emailPreferences:["user","emailPreferences"]},subscription:{base:["subscription"],info:["subscription","info"]},levels:{base:["levels"],byPath:e=>e?["levels","path",e]:["levels"],progress:["levels","progress"],single:e=>["levels",e]},lessons:{base:["lessons"],byLevel:e=>["lessons",e],batch:e=>["lessons","batch",...e.sort()],progress:["lessons","progress"],allProgress:["lessons","progress","all"]},stats:{base:["stats"],dashboard:["stats","dashboard"],percentile:e=>["stats","percentile",e],report:["stats","report"]},exercises:{initBase:["exercisesInitData"],init:e=>["exercisesInitData",e],streak:["exercises","streak"]},harmonicQuest:{base:["harmonicQuestExercises"],filtered:(e,t)=>["harmonicQuestExercises",e,t],categories:["harmonicQuestCategories"]},trainingPaths:{base:["trainingPaths"],single:e=>["trainingPaths",e]},testOut:{base:["testOut"],session:e=>["testOut","session",e],results:e=>["testOut","results",e]},admin:{emailStats:e=>e?["admin","emails","stats",e]:["admin","emails","stats"],emailLogs:(e,t)=>["admin","emails","logs",e,t],emailTemplates:["admin","emails","templates"],emailCampaigns:["admin","emails","campaigns"]},scaleTypes:{base:["scaleTypes"]},voicings:{byLevel:e=>["voicings","level",e],categories:["voicingCategories"]}}},57209:(e,t,s)=>{s.d(t,{m:()=>r});async function r(e,t){let s=await fetch(e,t);if(!s.ok){let e=await s.json().catch(()=>({error:"HTTP Error ".concat(s.status),details:s.statusText,status:s.status}));throw Error("API error (".concat(e.status,"): ").concat(e.error||e.details))}return await s.json()}},14402:(e,t,s)=>{s.d(t,{$Y:()=>d,queueMutation:()=>o,r9:()=>l,xU:()=>c});let r="offline-mutations",a=null;function i(){return a||(a=new Promise((e,t)=>{if("undefined"==typeof indexedDB){t(Error("IndexedDB not available"));return}let s=indexedDB.open("earonman-offline",1);s.onupgradeneeded=()=>{let e=s.result;e.objectStoreNames.contains(r)||e.createObjectStore(r,{keyPath:"id"}).createIndex("createdAt","createdAt",{unique:!1})},s.onsuccess=()=>e(s.result),s.onerror=()=>{a=null,t(s.error)}}))}async function o(e,t,s,a){let o=await i(),n={id:"".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,9)),url:e,method:t,headers:{"Content-Type":"application/json"},body:s?JSON.stringify(s):null,createdAt:Date.now(),label:a};return new Promise((e,t)=>{let s=o.transaction(r,"readwrite").objectStore(r).put(n);s.onsuccess=()=>e(n.id),s.onerror=()=>t(s.error)})}async function n(){let e=await i();return new Promise((t,s)=>{let a=e.transaction(r,"readonly").objectStore(r).index("createdAt").getAll();a.onsuccess=()=>t(a.result),a.onerror=()=>s(a.error)})}async function l(){let e=await i();return new Promise((t,s)=>{let a=e.transaction(r,"readonly").objectStore(r).count();a.onsuccess=()=>t(a.result),a.onerror=()=>s(a.error)})}async function u(e){let t=await i();return new Promise((s,a)=>{let i=t.transaction(r,"readwrite").objectStore(r).delete(e);i.onsuccess=()=>s(),i.onerror=()=>a(i.error)})}async function d(){let e=await n(),t=0,s=0;for(let r of e)try{let e=await fetch(r.url,{method:r.method,headers:r.headers,body:r.body,credentials:"include"});e.ok?(await u(r.id),t++):(e.status>=400&&e.status<500&&await u(r.id),s++)}catch(e){break}return{synced:t,failed:s,remaining:await l()}}async function c(){if("undefined"!=typeof navigator&&"serviceWorker"in navigator)try{let e=await navigator.serviceWorker.ready;"sync"in e&&await e.sync.register("sync-offline-mutations")}catch(e){}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.