const LANG={zh:{title:"2026\u5E74\u804C\u4E1A\u57FA\u672C\u9002\u5E94\u6027\u6A21\u62DF\u68C0\u6D4B\u7CFB\u7EDF",badge:"",mainTitle:"\u804C\u4E1A\u57FA\u672C\u9002\u5E94\u6027\u68C0\u6D4B",subtitle:"\u672C\u7CFB\u7EDF\u5305\u542B\u591A\u9879\u4E13\u4E1A\u6D4B\u8BC4\u6A21\u5757\uFF0C\u5168\u9762\u8BC4\u4F30\u60A8\u7684\u7EFC\u5408\u80FD\u529B",desc:"\u57FA\u4E8EMMPI\u5FC3\u7406\u6D4B\u8BC4\u6807\u51C6\u548C\u8BED\u8A00\u80FD\u529B\u8BC4\u4F30\u4F53\u7CFB\u5F00\u53D1\uFF0C\u6DB5\u76D6\u4EBA\u683C\u6D4B\u9A8C\u3001\u8BED\u8A00\u80FD\u529B\u3001\u6570\u5B66\u63A8\u7406\u3001\u9002\u5E94\u80FD\u529B\u7B49\u591A\u4E2A\u6838\u5FC3\u7EF4\u5EA6\u3002\u4E3A\u519B\u65C5\u751F\u6DAF\u9009\u62D4\u63D0\u4F9B\u79D1\u5B66\u3001\u5168\u9762\u7684\u53C2\u8003\u4F9D\u636E\u3002",login:"\u767B\u5F55",register:"\u6CE8\u518C",logout:"\u9000\u51FA",footerAuthor:"",footerResource:"",footerTool:"",copyright:"\xA9 2026 \u7248\u6743\u6240\u6709"},en:{title:"2026 Career Adaptability Simulation Test System",badge:"",mainTitle:"Career Adaptability Test",subtitle:"Multiple professional assessment modules to evaluate your comprehensive abilities",desc:"Developed based on MMPI psychological assessment standards and language ability evaluation systems, covering personality tests, language ability, math reasoning, and adaptability. Providing scientific reference for military career selection.",login:"Login",register:"Register",logout:"Logout",footerAuthor:"",footerResource:"",footerTool:"",copyright:"\xA9 2026 All Rights Reserved"},"zh-tw":{title:"2026\u5E74\u8077\u696D\u57FA\u672C\u9069\u61C9\u6027\u6A21\u64EC\u6AA2\u6E2C\u7CFB\u7D71",badge:"",mainTitle:"\u8077\u696D\u57FA\u672C\u9069\u61C9\u6027\u6AA2\u6E2C",subtitle:"\u672C\u7CFB\u7D71\u5305\u542B\u591A\u9805\u5C08\u696D\u6E2C\u8A55\u6A21\u7D44\uFF0C\u5168\u9762\u8A55\u4F30\u60A8\u7684\u7D9C\u5408\u80FD\u529B",desc:"\u57FA\u65BCMMPI\u5FC3\u7406\u6E2C\u8A55\u6A19\u6E96\u548C\u8A9E\u8A00\u80FD\u529B\u8A55\u4F30\u9AD4\u7CFB\u958B\u767C\uFF0C\u6DB5\u84CB\u4EBA\u683C\u6E2C\u9A57\u3001\u8A9E\u8A00\u80FD\u529B\u3001\u6578\u5B78\u63A8\u7406\u3001\u9069\u61C9\u80FD\u529B\u7B49\u591A\u500B\u6838\u5FC3\u7DAD\u5EA6\u3002\u70BA\u8ECD\u65C5\u751F\u6DAF\u9078\u62D4\u63D0\u4F9B\u79D1\u5B78\u3001\u5168\u9762\u7684\u53C3\u8003\u4F9D\u64DA\u3002",login:"\u767B\u9304",register:"\u8A3B\u518A",logout:"\u9000\u51FA",footerAuthor:"",footerResource:"",footerTool:"",copyright:"\xA9 2026 \u7248\u6B0A\u6240\u6709"}};let currentLang=localStorage.getItem("miltest_lang")||"zh";function setLang(e){currentLang=e,localStorage.setItem("miltest_lang",e),document.documentElement.lang=e==="en"?"en":"zh-CN",updatePageText()}function t(e){return LANG[currentLang]?.[e]||LANG.zh[e]||e}function updatePageText(){document.querySelectorAll("[data-i18n]").forEach(e=>{const n=e.dataset.i18n;e.textContent=t(n)})}function escapeHtml(e){return e?String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):""}function renderUserMenu(){const e=Auth.getCurrentUser(),n=document.getElementById("userNav");if(n)if(e){const o=(e.username||"?").charAt(0).toUpperCase(),a=escapeHtml(e.username||""),i=e.account_type==="trial"?"\u4F53\u9A8C":e.account_type==="formal"?"\u6B63\u5F0F":"--",s=e.role==="admin"?"\u7BA1\u7406\u5458":i+"\u7528\u6237";let r="";e.role==="admin"&&(r='\u2699\uFE0F\u7BA1\u7406\u540E\u53F0'),n.innerHTML=`
`}else n.innerHTML=` \u767B\u5F55 \u6CE8\u518C `}function toggleUserMenu(e){e.stopPropagation();const n=document.getElementById("userDropdown");if(!n)return;n.classList.toggle("show");const o=document.getElementById("menuArrow");o&&o.classList.toggle("open",n.classList.contains("show"))}document.addEventListener("click",function(e){const n=document.getElementById("userDropdown");if(n&&!e.target.closest(".user-menu")){n.classList.remove("show");const o=document.getElementById("menuArrow");o&&o.classList.remove("open")}});function toggleLangMenu(){document.getElementById("languageDropdown")?.classList.toggle("show")}function selectLang(e){setLang(e),document.getElementById("languageDropdown")?.classList.remove("show");const n={zh:"\u4E2D\u6587",en:"English","zh-tw":"\u7E41\u9AD4"},o=document.getElementById("langToggle");o&&(o.textContent=n[e]||"\u4E2D\u6587"),document.querySelectorAll(".lang-option").forEach(a=>a.classList.remove("active")),document.getElementById("lang-"+e)?.classList.add("active"),localStorage.setItem("miltest_lang",e)}document.addEventListener("click",function(e){const n=document.getElementById("languageDropdown");n&&!n.parentElement.contains(e.target)&&n.classList.remove("show")});var NoticeBar={_elSys:null,_elAct:null,_timer:0,init:function(){if(this._elSys=document.getElementById("noticeTrackSys"),this._elAct=document.getElementById("noticeTrackAct"),!(!this._elSys||!this._elAct)){var e=this;this.refresh(),this._timer=setInterval(function(){e.refresh()},3e4),document.addEventListener("visibilitychange",function(){document.hidden||e.refresh()})}},refresh:async function(){try{var e=await Promise.all([fetch(API_BASE+"/notifications/active").then(function(s){return s.json()}).catch(function(){return{}}),fetch(API_BASE+"/notices").then(function(s){return s.json()}).catch(function(){return{}})]),n=[],o=[],a=e[0].notifications||[];a.forEach(function(s){var r=escapeHtml(s.content),c=''+r;s.link?n.push(''+c+""):n.push(''+c+"")});var i=e[1].notices||[];i.forEach(function(s){var r=s.grade?' '+escapeHtml(s.grade)+"":"";o.push(''+s.icon+" "+escapeHtml(s.user)+s.action+r+' '+escapeHtml(s.time)+"")}),this._render(n,o)}catch(s){console.error("NoticeBar:",s)}},_render:function(e,n){e.length?this._elSys.innerHTML=e.join("")+e.join(""):this._elSys.innerHTML='\u6682\u65E0\u7CFB\u7EDF\u901A\u77E5',n.length?this._elAct.innerHTML=n.join("")+n.join(""):this._elAct.innerHTML='\u6682\u65E0\u505A\u9898\u52A8\u6001'}};window.addEventListener("beforeunload",function(){NoticeBar._timer&&(clearInterval(NoticeBar._timer),NoticeBar._timer=0)});async function loadUserStats(){var e=document.getElementById("userStats");if(!(!e||!Auth.isLoggedIn()))try{var n=Auth.getToken(),o=await fetch("/api/practice/report",{headers:{Authorization:"Bearer "+n}}),a=await o.json();if(a.success){var i=a.report;e.style.display="inline-flex",e.innerHTML=''+i.passRate+'%\u901A\u8FC7\u7387'+(i.estimatedScore>0?i.estimatedScore:"--")+'\u8BC4\u5206'}}catch{}}async function initPage(){setLang(currentLang),renderUserMenu(),NoticeBar.init(),await loadUserStats()}function checkLogin(e){return Auth.isLoggedIn()?(e&&(location.href=e),!0):(location.href="login.html?redirect="+encodeURIComponent(e||"index.html"),!1)}(function(){window.addEventListener("error",function(e){try{const n=JSON.stringify({message:e.message,url:e.filename||location.href,line:e.lineno,col:e.colno,error:e.error?e.error.stack:"",type:"error"});navigator.sendBeacon("/api/log/client-error",n)}catch{}}),window.addEventListener("unhandledrejection",function(e){try{const n=JSON.stringify({message:e.reason?.message||String(e.reason),type:"unhandledrejection",error:e.reason?.stack||""});navigator.sendBeacon("/api/log/client-error",n)}catch{}})})();function initTestWatermark(){const e=Auth.getCurrentUser();if(!e)return;const n=e.phone||e.email.split("@")[0]||"";if(!n)return;const o=location.hostname,a=n+" "+o;if(!document.querySelector(".test-watermark")){var i=document.createElement("div");i.className="test-watermark",i.style.cssText="position:fixed;top:0;left:0;right:0;bottom:0;pointer-events:none;z-index:9996;overflow:hidden";for(var s=0;s<5;s++)for(var r=0;r<4;r++){var c=document.createElement("div");c.style.cssText="position:absolute;left:"+(r*28+2)+"%;top:"+(s*22+1)+"%;transform:rotate(-25deg);color:rgba(0,0,0,0.035);font-size:12px;white-space:nowrap;user-select:none;font-family:Microsoft YaHei,sans-serif;font-weight:500;letter-spacing:1px",c.textContent=a,i.appendChild(c)}document.body.appendChild(i)}}window.A=Auth,window.toggleLangMenu=toggleLangMenu,window.selectLang=selectLang,window.checkLogin=checkLogin,window.toggleUserMenu=toggleUserMenu,window.initTestWatermark=initTestWatermark;