/* Scordemy v5 — Path Finder: Dynamic WordPress-controlled question sequence & rules with fallback */ (() => { const D = window.SC; const { useState, useEffect } = React; const { Ic, rupee, months, useUI, Img, useLang } = window; const { examInfo, ExamStatus, CareerCard, Price } = window; const HUE = { apsc: 'sun', govt: 'sky', police: 'coral', teacher: 'mint', ssc: 'grape', neet: 'rose', judiciary: 'slate' }; const STAGE_HUE = { c10: 'sun', c12: 'mint', ug: 'sky', job: 'coral' }; const DEFAULT_TIME = [['2', '1–2 hrs', 'Up to 2 hours', 'Alongside work or college', 'sky'], ['3', '3 hrs', 'About 3 hours', 'Steady, serious preparation', 'mint'], ['5', '4–5 hrs', '4–5 hours', 'Most of the evening', 'sun'], ['7', '6+ hrs', '6 hours or more', 'Full-time aspirant', 'coral']]; const DEFAULT_LANG = [['as', 'অ', 'Assamese', 'অসমীয়া মাধ্যম', 'sun'], ['en', 'EN', 'English', 'English medium', 'sky'], ['both', 'অ+E', 'Both', 'Concepts in Assamese, terms in English', 'mint']]; function PathFinder({ q }) { const langHook = useLang ? useLang() : { lang: 0 }; const curLang = (langHook.lang === 1) ? 'as' : 'en'; // Helper for bilingual translation const t = (val, fallback = '') => { if (!val) return fallback; if (typeof val === 'string') return val; return val[curLang] || val.en || fallback; }; const [remoteConfig, setRemoteConfig] = useState(() => { return (window.ScordemyPathFinderService && window.ScordemyPathFinderService.getConfig()) || null; }); useEffect(() => { if (window.ScordemyPathFinderService) { const unsub = window.ScordemyPathFinderService.subscribe(cfg => { if (cfg) setRemoteConfig(cfg); }); window.ScordemyPathFinderService.fetchPublishedConfig(); return unsub; } }, []); // Determine active questions sequence const configuredQuestions = (remoteConfig && Array.isArray(remoteConfig.questions) && remoteConfig.questions.length > 0) ? remoteConfig.questions.filter(item => item && item.enabled !== false).sort((x, y) => (x.order || 0) - (y.order || 0)) : null; const defaultSteps = ['stage', 'goal', 'lang', 'time']; const steps = configuredQuestions ? configuredQuestions.map(item => item.id) : defaultSteps; const [a, setA] = useState(() => { const s = {}; if (q.stage && D.stages.find(x => x.id === q.stage)) s.stage = q.stage; if (q.goal && D.goals[q.goal]) s.goal = q.goal; return s; }); const cur = steps.find(k => !a[k]) || 'done'; const idx = cur === 'done' ? steps.length : steps.indexOf(cur); const set = (k, v) => setA(p => ({ ...p, [k]: v })); const back = () => { const k = steps[Math.max(0, idx - 1)]; setA(p => { const n = { ...p }; delete n[k]; return n; }); }; if (cur === 'done') { return setA({})} edit={k => setA(p => { const n = { ...p }; delete n[k]; return n; })} remoteConfig={remoteConfig} curLang={curLang} t={t} />; } // Active question metadata const activeQuestionObj = configuredQuestions ? configuredQuestions.find(item => item.id === cur) : null; const defaultQ = { stage: [ t({ en: 'What are you studying now?', as: 'আপুনি বৰ্তমান কি পঢ়ি আছে?' }), t({ en: 'We only show exams you can actually sit for.', as: 'আপুনি যিবোৰ পৰীক্ষাত বহিব পাৰে সেইবোৰহে দেখুওৱা হ\'ব।' }) ], goal: [ t({ en: 'Which kind of job do you want?', as: 'আপুনি কোন বিভাগৰ চাকৰি বিচাৰে?' }), t({ en: 'Each card shows the starting salary. Greyed cards need a higher qualification.', as: 'প্ৰতিখন কাৰ্ডত আৰম্ভণি দৰমহা দিয়া আছে।' }) ], lang: [ t({ en: 'Which language do you learn best in?', as: 'আপুনি কোনটো ভাষাত সহজে বুজি পায়?' }), t({ en: 'Every Scordemy batch is taught in Assamese and English.', as: 'সকলো স্কৰডেমি পাঠ্যক্ৰম অসমীয়া আৰু ইংৰাজী দুয়োটা ভাষাত শিকোৱা হয়।' }) ], time: [ t({ en: 'How many hours can you study a day?', as: 'দিনটোত কিমান সময় অধ্যয়ন কৰিব পাৰিব?' }), t({ en: 'Be honest. We will tell you how many months it will take.', as: 'সঠিক তথ্য দিয়ক। আমি কিমান মাহ লাগিব নিৰ্ধাৰণ কৰিম।' }) ] }; const qTitle = activeQuestionObj ? t(activeQuestionObj.title, defaultQ[cur] ? defaultQ[cur][0] : 'Choose an option') : (defaultQ[cur] ? defaultQ[cur][0] : 'Choose an option'); const qSub = activeQuestionObj ? t(activeQuestionObj.subtitle, defaultQ[cur] ? defaultQ[cur][1] : '') : (defaultQ[cur] ? defaultQ[cur][1] : ''); const badgeText = t(remoteConfig && remoteConfig.content && remoteConfig.content.badge_text, 'Path Finder'); const backText = t(remoteConfig && remoteConfig.content && remoteConfig.content.back_button_text, 'Back'); const customOptions = (activeQuestionObj && Array.isArray(activeQuestionObj.options) && activeQuestionObj.options.length > 0) ? activeQuestionObj.options.filter(o => o && o.enabled !== false) : null; return (
{idx > 0 ? ( ) : ( Home )} Question {idx + 1} of {steps.length}
{steps.map((s, i) => )}
{badgeText}

{qTitle}

{qSub &&

{qSub}

} {/* 1. Stage Question */} {cur === 'stage' && (
{customOptions ? ( customOptions.map(opt => ( )) ) : ( D.stages.map(s => ( )) )}
)} {/* 2. Goal Question */} {cur === 'goal' && (
{customOptions ? ( customOptions.map(opt => { const val = opt.value || opt.id; const g = D.goals[val]; const ok = g ? g.stages.includes(a.stage) : true; const k = g ? D.career[g.id] : null; return ( ); }) ) : ( Object.values(D.goals).map(g => { const ok = g.stages.includes(a.stage); const k = D.career[g.id]; return ( ); }) )}
)} {/* 3. Language Question */} {cur === 'lang' && (
{customOptions ? ( customOptions.map(opt => ( )) ) : ( DEFAULT_LANG.map(([v, b, l, s, h]) => ( )) )}
)} {/* 4. Time Question */} {cur === 'time' && (
{customOptions ? ( customOptions.map(opt => { const v = opt.value || opt.id; const m = a.goal && D.monthsAt ? D.monthsAt(a.goal, +v || 3) : null; return ( ); }) ) : ( DEFAULT_TIME.map(([v, b, l, s, h]) => { const m = a.goal ? D.monthsAt(a.goal, +v) : null; return ( ); }) )}
)} {/* 5. Any other dynamic questions */} {cur !== 'stage' && cur !== 'goal' && cur !== 'lang' && cur !== 'time' && (
{customOptions && customOptions.map(opt => ( ))}
)}
); } function Result({ a, reset, edit, remoteConfig, curLang, t }) { const { openTalk } = useUI(); // Evaluate recommendation rule const matchedRule = (window.ScordemyPathFinderService && window.ScordemyPathFinderService.evaluateAnswers) ? window.ScordemyPathFinderService.evaluateAnswers(a) : null; const g = D.goals[a.goal] || D.goals.govt || Object.values(D.goals)[0]; const st = D.stages.find(s => s.id === a.stage) || D.stages[0]; const ok = g.stages ? g.stages.includes(a.stage) : true; const e = examInfo(g.id); const h = +a.time || 3; const m = D.monthsAt(g.id, h); // Ladder Resolution: Use Rule Actions if present, otherwise default to goal ladder let full = []; let start = []; let practice = []; let displayTitle = g.exam; let displayLead = D.career[g.id] ? D.career[g.id].line : g.line; if (matchedRule && matchedRule.actions) { const act = matchedRule.actions; if (act.title) displayTitle = t(act.title, displayTitle); if (act.lead_line) displayLead = t(act.lead_line, displayLead); if (act.ladder_full && act.ladder_full.length) { full = act.ladder_full.map(s => D.courses[s]).filter(Boolean); } if (act.ladder_start && act.ladder_start.length) { start = act.ladder_start.map(s => D.courses[s]).filter(Boolean); } if (act.ladder_practice && act.ladder_practice.length) { practice = act.ladder_practice.map(s => D.courses[s]).filter(Boolean); } } // Fallback ladder if empty if (!full.length && g.ladder) { full = g.ladder.full.map(s => D.courses[s]).filter(Boolean); if (g.id === 'apsc') { const f = full.filter(c => a.lang === 'as' ? c.medium === 'Assamese' : a.lang === 'en' ? c.medium === 'English' : true); if (f.length) full = f; } } if (!start.length && g.ladder) { start = g.ladder.start.map(s => D.courses[s]).filter(Boolean); } if (!practice.length && g.ladder) { practice = g.ladder.practice.map(s => D.courses[s]).filter(Boolean); } const best = full[0] || (D.courses['adre-3-b2'] || Object.values(D.courses)[0]); const rungs = [ ['sky', t({ en: 'This week', as: 'এই সপ্তাহত' }), t({ en: 'Start free and build the habit', as: 'বিনামূলীয়া ক্লাছৰে আৰম্ভ কৰক' }), start.length ? start : [D.courses['apsc-daily-ca'] || best]], ['sun', t({ en: 'Month 1 onward', as: 'প্ৰথম মাহৰ পৰা' }), t({ en: 'Join the full batch and follow the plan', as: 'সম্পূৰ্ণ বেচত যোগদান কৰক' }), full.length ? full : [best]], ['mint', t({ en: 'Before the exam', as: 'পৰীক্ষাৰ পূৰ্বে' }), t({ en: 'Mock tests and revision', as: 'মক টেষ্ট আৰু পুনৰালোচনা' }), practice.length ? practice : [D.courses['saat-26'] || best]], ]; const resDisplay = (remoteConfig && remoteConfig.results_display) || {}; const showKpis = resDisplay.show_kpis !== false; const showWarning = resDisplay.show_warning_on_unqualified !== false; const showLadder = resDisplay.show_3_step_ladder !== false; const showCareer = resDisplay.show_career_card !== false; const showChecklist = resDisplay.show_who_can_apply !== false; const showMentor = resDisplay.show_mentor_cta !== false; const lbl = { stage: st ? st.label : a.stage, goal: g ? g.short : a.goal, lang: { as: 'Assamese', en: 'English', both: 'Assamese + English' }[a.lang] || a.lang, time: h + ' hrs/day' }; const mentorCtaText = t(remoteConfig && remoteConfig.content && remoteConfig.content.final_cta_text, 'Talk to a mentor'); return (
Your best fit

{displayTitle}

{displayLead}

{Object.entries(lbl).map(([k, l]) => ( ))}
{showKpis && (
Time to finish syllabus {m} months at {h} hrs a day
{e.state === 'scheduled' ? 'Exam date' : 'Expected exam'} {e.state === 'scheduled' ? D.fmtDate(e.date) : e.expect} {e.state === 'scheduled' ? e.days + ' days left' : 'tentative'}
Starting salary {D.career[g.id] ? D.career[g.id].pay[0][1] : '—'} {D.career[g.id] ? D.career[g.id].pay[0][0] : ''}
)}
{showWarning && !ok && (
Most {g.short} posts need a higher qualification than {st.label}. Start with the free courses below and talk to a mentor about when to begin.
)}
{showLadder && ( <>

Your plan in 3 steps

    {rungs.map(([hue, w, s, cs], i) => (
  1. {i + 1}
  2. ))}
)} {showCareer && ( <>

What you get after clearing it

)}
); } Object.assign(window, { PathFinder }); })();