1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3392],{3392:(e,t,r)=>{r.r(t),r.d(t,{default:()=>p});var s=r(95155),a=r(12115),n=r(76741),i=r(55635),l=r(13538),c=r(35906),o=r(76046),d=r(17008),x=r(68308),u=r(25571),m=r(89227),h=r(24224);let p=e=>{var t;let{currentLevel:r,handleLevelComplete:p,onEarCoinsEarned:g,setResultMessage:f,onBackToMap:y,testOutProgressId:b,...j}=e,[v,N]=(0,a.useState)(0),[w,k]=(0,a.useState)(null),C=(0,a.useRef)(Date.now()),S=(0,a.useRef)(0),D=(0,a.useRef)(0),E=(0,a.useRef)([]);(0,a.useEffect)(()=>{let e=m.JD.ensureCompatibleForSequential();e&&(0,h.notify)({description:"Switched to Piano - ".concat(e," blurs chord sequences"),variant:"warning",duration:4e3})},[]);let A=(0,l.GR)(),T=(0,l.Dz)(),q=(0,c.jE)(),I=(0,o.useRouter)(),P=!!b,[L,M]=(0,a.useState)(0),[O,R]=(0,a.useState)(5),[B,J]=(0,a.useState)(!1),[Q,F]=(0,a.useState)([]),{exercises:U,isLoading:H,error:K}=(0,i.i)();(0,a.useEffect)(()=>{if(!U)return;let e={57:"Barry Harris Exercise 1",58:"Basic Triad Recognition"}[r.id];if(!e){f("Exercise mapping not found");return}let t=U.find(t=>t.name===e);t?k(t):f("Exercise not found")},[U,r.id,f]);let Y=(0,a.useCallback)(e=>{N(e)},[]),_=(0,a.useCallback)(e=>{if(P&&b){let t="correct"===e;(async()=>{try{var e,r;let s=await A.mutateAsync({progressId:b,isCorrect:t});if(s.requiredAttempts&&R(s.requiredAttempts),M(s.attemptsCount),!t||"failed"===s.status){f("Test-out failed. Redirecting to the level map..."),alert("Test-out failed! One wrong answer ends the challenge.\nAttempt ".concat(s.attemptsCount,"/").concat(null!==(e=s.requiredAttempts)&&void 0!==e?e:O,".")),I.push("/exercises?refresh=".concat(Date.now()));return}if("completed"===s.status){let e=await T.mutateAsync({progressId:b});F(e.unlockedLevels||[]),J(!0),f("\uD83C\uDF89 Challenge complete! Unlocking your next levels...");return}f("Great progress! ".concat(s.attemptsCount,"/").concat(null!==(r=s.requiredAttempts)&&void 0!==r?r:O))}catch(e){console.error("[TEST-OUT] Harmonic quest error:",e),alert("Test-out error: ".concat(e instanceof Error?e.message:String(e))),I.push("/exercises?refresh=".concat(Date.now()))}})();return}D.current++,"correct"===e&&S.current++;{let r="";try{var t;let e=((null==w?void 0:w.steps)?JSON.parse(w.steps):[])[v],s=null==e?void 0:e.notes;r=Array.isArray(s)?s.map(e=>String(e)).join(" "):String(null!==(t=null!=s?s:null==e?void 0:e.id)&&void 0!==t?t:"")}catch(e){r=""}E.current.push({isCorrect:"correct"===e,item:String(r)})}if("correct"===e){if(f("Correct!"),w&&w.steps)try{let e=JSON.parse(w.steps);if(v>=e.length-1){let e=(Date.now()-C.current)/1e3,t=Math.max(D.current,1),s=e/t,a=e<=60?Math.floor((60-e)*10):0;(0,u.$)({questType:"harmonic-quest",levelId:r.id,totalScore:10*S.current,correctAnswers:S.current,totalQuestions:D.current,averageTime:s,quickestTime:s,slowestTime:s,totalTime:e,timeBonus:a,skipsPenalty:0,attempts:E.current.slice(0,200)}).then(e=>{e.earCoinsEarned&&(null==g||g(e.earCoinsEarned,e.earCoinsBreakdown))}).catch(()=>{}),setTimeout(()=>{p()},1500)}}catch(e){}}else"partial"===e?f("Partially correct! Try again."):f("Incorrect. Try again!")},[P,b,A,T,I,O,w,v,p,f]);return H?(0,s.jsx)("div",{className:"flex items-center justify-center min-h-[400px]",children:(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),(0,s.jsx)("p",{children:"Loading HarmonicQuest exercise..."})]})}):K?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:[(0,s.jsxs)("p",{className:"text-destructive mb-4",children:["Error loading exercise: ",K.message]}),(0,s.jsx)("button",{onClick:y,className:"px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90",children:"Back to Level Map"})]}):w?(0,s.jsxs)("div",{className:"w-full max-w-6xl mx-auto",children:[P&&(0,s.jsxs)("div",{className:"bg-gradient-to-r from-amber-600 to-orange-600 text-white px-6 py-4 mb-6 rounded-lg shadow-xl",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("h3",{className:"text-lg font-bold flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-2xl",children:"\uD83D\uDE80"}),"Jump to Next Section Challenge"]}),(0,s.jsxs)("div",{className:"text-xl font-bold",children:[L,"/",O]})]}),(0,s.jsx)("div",{className:"w-full bg-amber-900/50 rounded-full h-3 mb-2",children:(0,s.jsx)("div",{className:"bg-white h-3 rounded-full transition-all duration-300",style:{width:"".concat(L/O*100,"%")}})}),(0,s.jsxs)("p",{className:"text-sm text-amber-100",children:[(0,s.jsx)("strong",{children:"Zero mistakes allowed!"})," One wrong answer fails the test."]})]}),(0,s.jsxs)("div",{className:"text-center mb-6",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold mb-2 ear-title",children:r.name}),(0,s.jsx)("p",{className:"text-muted-foreground",children:r.description})]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("div",{className:"text-sm text-muted-foreground mb-1",children:"Exercise Progress"}),(0,s.jsx)("div",{className:"w-full bg-secondary rounded-full h-2",children:(0,s.jsx)("div",{className:"bg-primary h-2 rounded-full transition-all duration-300",style:{width:w.steps?"".concat(v/(JSON.parse(w.steps).length-1)*100,"%"):"0%"}})})]}),(0,s.jsx)("div",{className:"mb-4",children:(0,s.jsx)(x.$,{onClick:y,variant:"secondary",children:"â Back to Level Map"})}),j.resultMessage&&(0,s.jsx)("div",{className:"text-center mb-4",children:(0,s.jsx)("div",{className:"inline-block px-4 py-2 rounded ".concat(j.resultMessage.includes("Correct")?"bg-success/10 text-success border border-success":j.resultMessage.includes("Incorrect")?"bg-destructive/10 text-destructive border border-destructive":"bg-warning/10 text-warning border border-warning"),children:j.resultMessage})}),(0,s.jsx)(n.default,{xmlInput:w.musicXml,onStepChange:Y,onValidation:_,initialStep:0,allowMouseInput:!0,previewMode:!1,mode:"exercise"}),P&&(0,s.jsx)(d.f,{isOpen:B,onClose:async()=>{J(!1),await q.refetchQueries({queryKey:["exercisesInitData"],exact:!1}),I.push("/exercises?refresh=".concat(Date.now()))},onContinue:async()=>{J(!1),await q.refetchQueries({queryKey:["exercisesInitData"],exact:!1}),I.push("/exercises?refresh=".concat(Date.now()))},sectionName:"string"==typeof r.sectionBreak?r.sectionBreak:(null===(t=r.sectionBreak)||void 0===t?void 0:t.t
1itle)||"Section",unlockedLevelsCount:Q.length,nextSectionAvailable:Q.length>0})]}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[400px] text-center",children:[(0,s.jsxs)("p",{className:"text-destructive mb-4",children:["HarmonicQuest exercise not found (Level ID: ",r.id,")"]}),(0,s.jsx)("button",{onClick:y,className:"px-4 py-2 bg-primary text-primary-foreground rounded hover:bg-primary/90",children:"Back to Level Map"})]})}},17008:(e,t,r)=>{r.d(t,{f:()=>l});var s=r(95155);r(12115);var a=r(70734),n=r(43226),i=r(2178);function l(e){let{isOpen:t,onClose:r,onContinue:l,sectionName:c,unlockedLevelsCount:o,nextSectionAvailable:d}=e;return(0,s.jsx)(a.lG,{open:t,onOpenChange:e=>!e&&r(),children:(0,s.jsxs)(a.Cf,{className:"sm:max-w-[500px]",children:[(0,s.jsxs)(a.c7,{children:[(0,s.jsx)(i.P.div,{initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:260,damping:20},children:(0,s.jsx)(a.L3,{className:"text-3xl text-center mb-4",children:(0,s.jsx)(i.P.span,{animate:{rotate:[0,10,-10,10,0]},transition:{duration:.5,repeat:2},className:"inline-block text-6xl",children:"\uD83C\uDF89"})})}),(0,s.jsx)(a.L3,{className:"text-2xl text-center",children:"Test-Out Complete!"}),(0,s.jsxs)(a.rr,{className:"text-center text-base mt-2",children:["Congratulations! You've mastered ",(0,s.jsx)("strong",{children:c})]})]}),(0,s.jsxs)(i.P.div,{className:"space-y-4 my-6",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},children:[(0,s.jsxs)("div",{className:"bg-gradient-to-r from-green-50 to-emerald-50 dark:from-green-950/30 dark:to-emerald-950/30 border-2 border-green-300 dark:border-green-700 rounded-lg p-6",children:[(0,s.jsx)("h4",{className:"font-bold text-green-900 dark:text-green-100 mb-3 text-center text-lg",children:"Your Rewards"}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)(i.P.div,{className:"flex items-center gap-3 bg-white/50 dark:bg-black/20 rounded-lg p-3",initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.3},children:[(0,s.jsx)("div",{className:"flex-shrink-0 w-8 h-8 bg-green-500 rounded-full flex items-center justify-center",children:(0,s.jsx)("span",{className:"text-white text-lg",children:"\uD83D\uDD13"})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsxs)("p",{className:"font-semibold text-green-900 dark:text-green-100",children:[o," Levels Unlocked"]}),(0,s.jsxs)("p",{className:"text-sm text-green-700 dark:text-green-300",children:["All ",c," levels are now available"]})]})]}),d&&(0,s.jsxs)(i.P.div,{className:"flex items-center gap-3 bg-white/50 dark:bg-black/20 rounded-lg p-3",initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.4},children:[(0,s.jsx)("div",{className:"flex-shrink-0 w-8 h-8 bg-action rounded-full flex items-center justify-center",children:(0,s.jsx)("span",{className:"text-white text-lg",children:"\uD83D\uDE80"})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("p",{className:"font-semibold text-green-900 dark:text-green-100",children:"Next Section Unlocked"}),(0,s.jsx)("p",{className:"text-sm text-green-700 dark:text-green-300",children:"Ready to continue your journey!"})]})]}),(0,s.jsxs)(i.P.div,{className:"flex items-center gap-3 bg-white/50 dark:bg-black/20 rounded-lg p-3",initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.5},children:[(0,s.jsx)("div",{className:"flex-shrink-0 w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center",children:(0,s.jsx)("span",{className:"text-white text-lg",children:"â"})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("p",{className:"font-semibold text-green-900 dark:text-green-100",children:"Perfect Score!"}),(0,s.jsx)("p",{className:"text-sm text-green-700 dark:text-green-300",children:"50/50 correct answers - incredible!"})]})]})]})]}),(0,s.jsx)("div",{className:"text-center text-sm text-muted-foreground",children:(0,s.jsx)("p",{children:"You've proven your mastery. Keep up the amazing work! \uD83C\uDFB5"})})]}),(0,s.jsx)(a.Es,{children:(0,s.jsx)(n.$,{variant:"default",onClick:l,className:"w-full bg-gradient-to-r from-green-500 to-emerald-500 hover:from-green-600 hover:to-emerald-600",children:"Continue Your Journey â"})})]})})}},55635:(e,t,r)=>{r.d(t,{i:()=>n});var s=r(35906),a=r(39556);let n=(e,t)=>{(0,s.jE)();let{data:r,isLoading:n,error:i,refetch:l}=(0,a.I)({queryKey:["harmonicQuestExercises",e,t],queryFn:async()=>{let r="/api/harmonic-quest",s=new URLSearchParams;e&&s.append("levelId",e.toString()),t&&s.append("categoryId",t.toString()),s.toString()&&(r+="?".concat(s.toString()));let a=await fetch(r);if(!a.ok)throw Error("Failed to fetch harmonic quest data");let n=await a.json(),i="object"==typeof n.exercises&&null!==n.exercises&&0===Object.keys(n.exercises).length?[]:n.exercises;if(!Array.isArray(i))throw console.error("API returned unexpected data structure for exercises:",n),Error("Expected exercises to be an array, but received ".concat(typeof i,". Value: ").concat(JSON.stringify(i)));return{exercises:i,categories:Array.isArray(n.categories)?n.categories:[]}},staleTime:3e5});return{exercises:null==r?void 0:r.exercises,categories:null==r?void 0:r.categories,isLoading:n,error:i,refetch:l}}}}]);
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.