(function(){"use strict";const K=`https://fonts.googleapis.com/css2?family=${["Rajdhani:wght@700"].join("&family=")}&display=swap`;function z(){return new Promise((t,e)=>{if(document.querySelector('link[href*="fonts.googleapis.com"]')){L().then(t).catch(e);return}const i=document.createElement("link");i.rel="stylesheet",i.href=K,i.onload=()=>{L().then(t).catch(e)},i.onerror=()=>{console.warn("[SDK] Failed to load Google Fonts, proceeding with fallback"),t()},document.head.appendChild(i)})}function L(){return"fonts"in document?document.fonts.ready.then(()=>new Promise(t=>setTimeout(t,50))):new Promise(t=>setTimeout(t,300))}const _='#arealme-stats-widget{--ar-bg: #1e293b;--ar-text: #ffffff;--ar-subtext: #94a3b8;--ar-border: #334155;--widget-bg: var(--ar-bg);--widget-border: var(--ar-border);--widget-text: var(--ar-text);--widget-muted: var(--ar-subtext);--widget-accent: 5, 150, 105;--widget-font: "Rajdhani", "Segoe UI", system-ui, sans-serif;container-type:inline-size;height:100%;display:flex;flex-direction:column;text-decoration:none;position:relative;overflow:hidden;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;font-family:var(--widget-font);background-color:var(--ar-bg);border:1px solid var(--ar-border);border-radius:8px;padding:16px;color:var(--ar-text);box-sizing:border-box;opacity:0;transition:opacity .3s ease-in-out,transform .15s ease-out,filter .15s ease-out}#arealme-stats-widget.ar-theme-light{--ar-bg: #ffffff;--ar-text: #0f172a;--ar-subtext: #64748b;--ar-border: #e2e8f0}#arealme-stats-widget.widget-ready{opacity:1}#arealme-stats-widget *{box-sizing:border-box;margin:0;padding:0}#arealme-stats-widget:active{transform:scale(.98);filter:brightness(1.2) blur(.5px)}#arealme-stats-widget:active .widget-dimensions{transform:scale(.95);transition:transform .1s ease-out}#arealme-stats-widget .widget-ghost-footer{position:absolute;bottom:0;left:0;right:0;padding:12px 0;background:linear-gradient(to top,#0f172af2,#0f172a00);color:rgb(var(--widget-accent));font-size:11px;font-weight:700;letter-spacing:1px;text-transform:uppercase;text-align:center;transform:translateY(100%);transition:transform .25s cubic-bezier(.2,0,0,1);backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);pointer-events:none}#arealme-stats-widget.ar-theme-light .widget-ghost-footer{background:linear-gradient(to top,#fffffff2,#fff0)}#arealme-stats-widget:hover .widget-ghost-footer{transform:translateY(0)}#arealme-stats-widget .widget-loading{display:flex;align-items:center;justify-content:center;min-height:200px;font-family:system-ui,-apple-system,sans-serif;font-size:12px;font-weight:600;letter-spacing:2px;color:var(--widget-muted);text-transform:uppercase;animation:widget-pulse 1.5s ease-in-out infinite}@keyframes widget-pulse{0%,to{opacity:.5}50%{opacity:1}}#arealme-stats-widget .widget-header{flex-shrink:0;display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:12px;padding-bottom:12px;border-bottom:1px solid var(--widget-border)}#arealme-stats-widget .widget-cp-section{display:flex;flex-direction:column}#arealme-stats-widget .widget-cp-label{font-size:10px;font-weight:700;letter-spacing:1.5px;color:var(--widget-muted);text-transform:uppercase}#arealme-stats-widget .widget-cp-value{font-size:32px;font-weight:700;letter-spacing:-1px;color:var(--widget-text);line-height:1;margin-top:2px}#arealme-stats-widget .widget-rank-section{display:flex;flex-direction:column;align-items:flex-end;text-align:right}#arealme-stats-widget .widget-rank-stars{font-size:14px;letter-spacing:2px;line-height:1}#arealme-stats-widget .widget-rank-name{font-size:12px;font-weight:700;letter-spacing:1px;text-transform:uppercase;margin-top:4px}#arealme-stats-widget .widget-dimensions{flex-grow:1;align-content:center;display:grid;grid-template-columns:repeat(3,1fr);gap:8px;transition:transform .1s ease-out}#arealme-stats-widget .widget-dimension{background:#1e293b99;border-radius:4px;padding:8px 6px;text-align:center}#arealme-stats-widget.ar-theme-light .widget-dimension{background:#f1f5f9cc}#arealme-stats-widget .widget-dimension-label{font-size:9px;font-weight:700;letter-spacing:.5px;color:var(--widget-muted);text-transform:uppercase;margin-bottom:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#arealme-stats-widget .widget-dimension-value{font-size:16px;font-weight:700;color:rgb(var(--widget-accent));line-height:1}#arealme-stats-widget .widget-dimension-max{font-size:9px;color:var(--widget-muted);margin-top:2px}@container (min-width: 640px){#arealme-stats-widget .widget-dimensions{grid-template-columns:repeat(6,1fr)}#arealme-stats-widget .widget-dimension{padding:10px 8px}#arealme-stats-widget .widget-dimension-label{font-size:10px}#arealme-stats-widget .widget-dimension-value{font-size:18px}#arealme-stats-widget .widget-dimension-max{font-size:10px}}#arealme-stats-widget .widget-empty{text-align:center;padding:24px 16px}#arealme-stats-widget .widget-empty-title{font-size:14px;font-weight:700;color:var(--widget-text);margin-bottom:8px}#arealme-stats-widget .widget-empty-text{font-size:12px;color:var(--widget-muted);margin-bottom:16px}#arealme-stats-widget .widget-empty-cta{display:inline-block;font-size:11px;font-weight:700;letter-spacing:1px;color:rgb(var(--widget-accent));text-transform:uppercase}';function V(t,e,a,i="linear"){if(e===a)return 0;const n=Math.max(0,(t-e)/(a-e));let s;return i==="log"?s=Math.log(1+4*n)/Math.log(5)*100:s=n*100,Math.min(100,s)}function $(t,e){const a=["Reflex","Speed","Precision","Coordination","Cognition","Timing"],i=t.map(r=>{const o=e[r.slug],d=o===null,c=d?0:V(o,r.valFor0Pts,r.valFor100Pts,r.algorithm);return{config:r,rawValue:o,normalizedScore:c,cp:c,isMissing:d}}),n=a.map(r=>{const o=r.toLowerCase();let d=0,c=0;return i.forEach(u=>{const f=u.config.weights[o];d+=u.normalizedScore*f,c+=100*f}),{name:r,cp:Math.round(d),maxCP:Math.round(c)}}),s=n.reduce((r,o)=>r+o.cp,0),l=n.reduce((r,o)=>r+o.maxCP,0);return{testResults:i,dimensionScores:n,totalCP:s,maxPossibleCP:l}}const w=[{minCP:4e4,tierKey:"eternal",color:{dark:"#22d3ee",light:"#0891b2"},stars:5},{minCP:35e3,tierKey:"champion",color:{dark:"#f43f5e",light:"#e11d48"},stars:5},{minCP:3e4,tierKey:"legend",color:{dark:"#f43f5e",light:"#e11d48"},stars:5},{minCP:27e3,tierKey:"grandmaster",color:{dark:"#a855f7",light:"#7c3aed"},stars:4},{minCP:24e3,tierKey:"master",color:{dark:"#a855f7",light:"#7c3aed"},stars:4},{minCP:22e3,tierKey:"elite",color:{dark:"#fbbf24",light:"#d97706"},stars:4},{minCP:15e3,tierKey:"captain",color:{dark:"#fbbf24",light:"#d97706"},stars:3},{minCP:12e3,tierKey:"veteran",color:{dark:"#a1a1aa",light:"#475569"},stars:3},{minCP:1e4,tierKey:"specialist",color:{dark:"#a1a1aa",light:"#475569"},stars:3},{minCP:8e3,tierKey:"vanguard",color:{dark:"#b45309",light:"#78350f"},stars:2},{minCP:7e3,tierKey:"scout",color:{dark:"#b45309",light:"#78350f"},stars:2},{minCP:5e3,tierKey:"recruit",color:{dark:"#94a3b8",light:"#475569"},stars:1},{minCP:0,tierKey:"trainee",color:{dark:"#94a3b8",light:"#475569"},stars:1}],U=(t,e="dark")=>{const a=w.find(i=>t>=i.minCP)||w[w.length-1];return{tierKey:a.tierKey,color:a.color[e],stars:a.stars}},G=t=>"★".repeat(t),m=["&","2.up.61","LDBM","bjn.uftu","bqn","bqn.bdujpot.qfs.njovuf.uftu","bsn.dvqdblf.3159.nby","bsn.nuu","bsn`sftvmut/bjn.uftu","bsn`sftvmut/bqn.bdujpot.qfs.njovuf.uftu","bsn`sftvmut/csbjo.nfnpsz.hbnf","bsn`sftvmut/dboopo.efgfotf","bsn`sftvmut/dpmpst","bsn`sftvmut/esbx.b.djsdmf","bsn`sftvmut/ftdbqb","bsn`sftvmut/fzf.iboe.dppsejobujpo.uftu","bsn`sftvmut/npvtf.uftu","bsn`sftvmut/ovncfs.nfnpsz.uftu","bsn`sftvmut/sfbdujpo.uftu","bsn`sftvmut/ujnf.qfsdfqujpo.uftu","csbjo.nfnpsz.hbnf","dboopo.efgfotf","dmjdl.tqffe.uftu","dmjdl.tqffe.uftu;291t","dmjdl.tqffe.uftu;41t","dmjdl.tqffe.uftu;6t","dmjdl.tqffe.uftu;71t","dmjdl.tqffe.uftu`upqt/s21/d","dmjdl.tqffe.uftu`upqt/s291/d","dmjdl.tqffe.uftu`upqt/s41/d","dmjdl.tqffe.uftu`upqt/s6/d","dmjdl.tqffe.uftu`upqt/s71/d","dpmpst","dpsf.cbmm/nby","dpsfcbmm","dqt","dvqdblf.3159","esbx.b.djsdmf","ftdbqb","fzf.iboe.dppsejobujpo.uftu","g2.sfbdujpo.uftu","g2.sfbdujpo.uftu.21/1/t","g2.sfbdujpo.uftu.4/1/t","g2.sfbdujpo.uftu.6/1/t","g2.sfbdujpo.uftu;21t","g2.sfbdujpo.uftu;4t","ijut","mjofbs","mph","mw","npvtf.uftu","nt","nvmujubtljoh.uftu","ovncfs.nfnpsz.uftu","pee.pof.pvu","qut","sfbdujpo.uftu","sfbdujpo.uftu;26t","sfbdujpo.uftu;41t","sfbdujpo.uftu`26/1/t","sfbdujpo.uftu`41/1/t","sizuin.uftu","t","tqbdfcbs.uftu","tqbdfcbs.uftu`upqt/s21/d","ujnf.qfsdfqujpo.uftu","uzqjoh.uftu","uzqjoh.uftu/s231/d","xqn"],W=[[63,1,8,0,0,0,3,3,14,46,64,47],[66,3,8,6,7,5,2,20,120,68,67,47],[3,7,5,9,8,2,4,200,800,55,8,47],[50,1,3,9,6,2,1,5,75,55,16,48],[5,4,9,5,3,7,2,60,600,4,9,48],[52,6,2,5,9,8,4,20,150,55,7,47],[39,2,3,7,9,3,5,0,100,55,15,47],[65,0,0,0,0,4,9,0,100,55,19,47],[20,1,0,1,0,9,2,0,100,55,10,47],[53,1,0,3,0,9,1,0,15,55,17,48],[61,3,1,2,4,2,9,0,100,0,61,47],[1,4,9,9,2,2,1,80,15,62,1,47],[34,5,6,6,0,0,8,0,91,49,33,47],[37,0,0,9,0,0,0,0,100,55,13,47],[32,2,2,0,0,5,0,0,100,49,12,47],[54,2,0,0,0,5,0,800,120,62,54,47],[21,5,3,8,6,2,8,1e3,2e6,55,11,48],[36,0,0,0,0,9,0,0,15e5,2,6,48],[38,7,2,5,0,0,0,0,60,62,14,48],[25,0,9,0,0,0,0,4,15,35,30,47],[22,0,9,0,0,0,0,3,14,35,27,47],[24,0,9,0,0,0,0,3,11,35,29,47],[26,0,9,0,0,3,0,2,9,35,31,48],[23,0,9,0,0,6,3,0,8,35,28,48],[45,9,0,0,0,0,2,400,150,51,42,47],[40,9,0,0,0,0,2,420,160,51,43,48],[44,9,0,0,0,0,2,440,180,51,41,48],[56,9,2,1,0,3,2,600,190,51,18,47],[57,3,0,0,0,0,2,660,210,51,59,48],[58,3,0,0,0,0,2,680,220,51,60,48]],p=t=>t.split("").map(e=>String.fromCharCode(e.charCodeAt(0)-1)).join("");function B(){return W.map(t=>({slug:p(m[t[0]]),weights:{reflex:t[1],speed:t[2],precision:t[3],coordination:t[4],cognition:t[5],timing:t[6]},valFor0Pts:t[7],valFor100Pts:t[8],unit:p(m[t[9]]),localStorageKey:p(m[t[10]]),algorithm:p(m[t[11]])}))}let h=null;function H(){return h===null&&(h=B()),h}var E={trainee:"IRON",recruit:"BRONZE",scout:"SILVER",vanguard:"GOLD",specialist:"PLATINUM",veteran:"EMERALD",captain:"DIAMOND",elite:"ASCENDANT",master:"IMMORTAL",grandmaster:"RADIANT",legend:"PREDATOR",champion:"CHALLENGER",eternal:"G.O.A.T."},P={heroLabel:"AREALME战力值 / ACP",operator:"玩家代号",footer:"Arealme.com 数据分析",back:"返回",meta:{title:"AREALME电竞战力值综合评估",description:"测试你的反应、速度、精准、协同、认知和时机。获取你的战力值评分,与全球玩家对比!AREALME独家推出",keywords:"cps测试, 反应时间测试, 瞄准测试, 打字测试, 电竞技能, 游戏能力, moba技能, fps技能",ogTitle:"AREALME电竞战力值综合评估 - 你的总战力值是多少?",ogDescription:"六维度测试你的游戏能力,获取专属战力值评分和可分享的玩家卡片!"},radar:{REFLEX:"反应",SPEED:"速度",PRECISION:"精准",COORDINATION:"协同",COGNITION:"认知",TIMING:"时机"},radarShort:{REFLEX:"反应",SPEED:"速度",PRECISION:"精准",COORDINATION:"协同",COGNITION:"认知",TIMING:"时机"},tabs:{overview:"总览",reflex:"反应",speed:"速度",precision:"精准",coordination:"协同",cognition:"认知",timing:"时机"},ranks:{trainee:"学员",recruit:"新兵",scout:"斥候",vanguard:"先锋",specialist:"专家",veteran:"老兵",captain:"队长",elite:"精英",master:"大师",grandmaster:"宗师",legend:"传奇",champion:"冠军",eternal:"永恒"},loading:{initializing:"正在初始化神经链接...",error:"连接错误",errorDescription:"无法建立连接"},dashboard:{rankWidget:{title:"前 5%",subtitle:"钻石段位",menuTitle:"对战模式",modes:{standard:"标准视图",global:"全球平均",fps:"FPS 神枪手",moba:"MOBA 核心位",rhythm:"节奏大师"},descriptions:{standard:"查看你的分数,不进行比较。",global:"与全球平均玩家比较(55% 潜力)。",fps:"顶级反应 + 顶级精准。典型狙击型玩家。",moba:"顶级认知 + 顶级协同。战术指挥型玩家。",rhythm:"神级时机 + 神级速度。节奏型天赋玩家。",occupation:"与职业玩家基准比较。",region:"与地区玩家平均水平比较。"},groups:{occupation:"职业玩家",region:"地区标准"},benchmarks:{fps_pro:"FPS 职业选手",moba_pro:"MOBA 职业选手"}},testList:{start:"开始",improve:"提升",challenge:"挑战",noData:"暂无数据",contribution:"贡献值",target:"目标",reward:"奖励",moduleListTitle:"/// MODULE_LIST_V2.0",total:"总计",forMaxScore:"冲击满分"},actions:{save:"保存玩家卡",share:"分享战绩",saveDescription:"保存你的数据,或分享给朋友!"},embedWidget:{title:"嵌入组件",livePreview:"实时预览",layout:"布局",layouts:{standard:"标准",compact:"紧凑",wide:"宽幅",ticker:"横幅"},theme:"主题",options:"选项",showOperatorId:"显示玩家 ID",showRankBadge:"显示段位徽章",embedCode:"嵌入代码",copyCode:"复制代码",copied:"已复制!",widgetPreview:"组件预览",checkStats:"查看更多数据"},shareModal:{title:"分享你的战绩",tabShare:"分享",tabEmbed:"嵌入",preview:"预览",socialCardPreview:"社交卡片预览",generatingPreview:"正在生成预览...",previewHint:"这是你分享链接时,其他人在社交媒体上看到的样子。",shareLink:"分享链接",copyLink:"复制链接",linkCopied:"已复制链接!",discordCopied:"已复制!",shareOn:"分享到",twitterText:"我刚在 Arealme 测试了电竞战力值!我的战力:{score}。来挑战我吧!#电竞 #反应测试",shareDescription:"分享你的战力值给朋友,挑战他们超越你!"},operatorId:"玩家 ID",operatorPlaceholder:"输入你的代号",detailView:{systemPrefix:"/// 系统:",moduleSuffix:"_模块",secLevel:"安全等级_01",syncStatus:"同步状态: 在线",capacity:"能力值:",maxPotential:"最大潜力"}},callsignModal:{title:"身份卡",subtitle:"玩家代号设置",operatorLabel:"代号",inputLabel:"输入你的代号",formatHint:"仅支持 A-Z、0-9,最多 12 个字符。",restrictedCallsign:"代号受限",cancel:"取消",confirm:"确认",footerLeft:"AREALME 战术中心",footerRight:"已验证"},testNames:{"reaction-test":"反应时间测试","reaction-test:15s":"反应时间测试 (15秒)","reaction-test:30s":"反应时间测试 (30秒)","click-speed-test":"点击速度测试(10 秒)","click-speed-test:5s":"CPS测试 (5秒爆发)","click-speed-test:30s":"CPS测试 (30秒耐力)","click-speed-test:60s":"CPS测试 (60秒挑战)","click-speed-test:180s":"CPS测试 (180秒马拉松)","spacebar-test":"空格键测试(10 秒)","typing-test":"打字测试(2 分钟)","aim-test":"瞄准测试","mouse-test":"鼠标精准度测试","apm-actions-per-minute-test":"APM 每分钟操作数测试","multitasking-test":"多任务处理测试","eye-hand-coordination-test":"手眼协调测试","time-perception-test":"时间感知测试","brain-memory-game":"记忆测试","number-memory-test":"黑猩猩记忆测试","rhythm-test":"节奏感测试","1-to-50":"1 到 50挑战",coreball:"见缝插针","draw-a-circle":"画圆测试",colors:"颜色识别","odd-one-out":"找不同","cannon-defense":"炮塔防御","cupcake-2048":"蛋糕2048","f1-reaction-test:3s":"F1起步测试 (3灯)","f1-reaction-test":"F1起步测试 (5灯 / 标准)","f1-reaction-test:10s":"F1起步测试 (10灯 / 困难)",escapa:"Escapa! (红块大逃亡)"},protocol:{title:"数据协议",version:"协议版本",lastUpdated:"最近同步",description:"评分算法是动态的。随着新战斗模块的部署,总战力上限将持续提升。",headers:{testModule:"测试模块",statDistribution:"属性分布",maxCP:"最高 CP"},footer:{totalModules:"模块总数",maxPotential:"最大潜能"}},acpIndex:{title:"ACP 索引",recommendations:"战术推荐",database:"全量题库",noData:"暂无数据",score:"得分"},comments:{title:"评论",placeholder:"分享你的想法",join:"加入 {count} 人的讨论"}};const k=H();function Y(t){if(typeof window=="undefined")return null;const e=t.split(".");if(e.length===0)return null;const a=e[0],i=localStorage.getItem(a);if(i===null)return null;if(e.length===1)return i;let n;try{n=JSON.parse(i)}catch(s){return null}for(let s=1;s{const a=Y(e.localStorageKey);if(a!=null&&a!==""){const i=Number(a);if(!isNaN(i)){t[e.slug]=i;return}}t[e.slug]=null}),t}function J(){var t;if(typeof window!="undefined"){const e=window;if((t=e.test)!=null&&t.lang)return e.test.lang}return"en"}function X(){if(typeof P!="undefined")return P;throw new Error("[SDK] No translation available. Build may be misconfigured.")}const Z=typeof E!="undefined"?E:{trainee:"TRAINEE",recruit:"RECRUIT",scout:"SCOUT",vanguard:"VANGUARD",specialist:"SPECIALIST",veteran:"VETERAN",captain:"CAPTAIN",elite:"ELITE",master:"MASTER",grandmaster:"GRANDMASTER",legend:"LEGEND",champion:"CHAMPION",eternal:"ETERNAL"};function v(){var O,F;const t=J(),e=X(),a=T(),{dimensionScores:i,totalCP:n,maxPossibleCP:s}=$(k,a),l=U(n),r=G(l.stars),d=((O=e.ranks)!=null?O:Z)[l.tierKey],c=e.radar,u=t==="en"?"/stats/":`/stats/${t}/`,f=e.heroLabel,A=(F=e.viewFullStats)!=null?F:"VIEW FULL STATS";return{totalCP:n,maxPossibleCP:s,tierKey:l.tierKey,tierColor:l.color,stars:l.stars,starString:r,rankName:d,dimensions:i,radarLabels:c,lang:t,statsUrl:u,heroLabel:f,viewFullStatsLabel:A}}function Q(){const t=T();return Object.values(t).some(e=>e!==null)}const tt="arealme-stats-widget",I="arealme-stats-widget-styles";function x(){if(document.getElementById(I))return;const t=document.createElement("style");t.id=I,t.textContent=_,document.head.appendChild(t)}function et(t){return t.toLocaleString("en-US")}function y(t){if(t<1e3)return t.toString();const e=(t/1e3).toFixed(1);return`${e.endsWith(".0")?e.slice(0,-2):e}K`}function at(t,e){const a=t.toUpperCase();return e.radarLabels[a]||t}function it(){return'
LOADING...
'}function nt(t){const e=t.dimensions.map((a,i)=>`
${at(a.name,t)}
${et(a.cp)}
/ ${y(a.maxCP)}
`).join("");return`
${t.heroLabel}
${y(t.totalCP)}
${t.starString}
${t.rankName}
${e}
`}function N(){return document.getElementById(tt)}function b(t){const e=v();t.setAttribute("href",e.statsUrl);const i=window.matchMedia&&window.matchMedia("(pointer: coarse)").matches?"_self":"acp_index";t.setAttribute("target",i),t.removeAttribute("rel"),t.onclick=null,t.innerHTML=nt(e)}function j(t){requestAnimationFrame(()=>{t.classList.add("widget-ready")})}function st(t){return Array.from(t.querySelectorAll("[data-animate-value]"))}function rt(t){const e=t.getAttribute("data-animate-value");return e?parseInt(e,10):0}function M(t){const e=t.querySelector("[data-total-cp]")!==null,a=t.querySelector(".widget-header")!==null;return e&&a}function ot(t,e){if(!M(t))return!1;const a=t.querySelector("[data-total-cp]");a&&a.setAttribute("data-animate-value",e.totalCP.toString()),e.dimensions.forEach((s,l)=>{var o;const r=t.querySelector(`[data-dimension="${l}"]`);if(r){r.setAttribute("data-animate-value",s.cp.toString());const d=(o=r.parentElement)==null?void 0:o.querySelector(".widget-dimension-max");d&&(d.textContent=`/ ${y(s.maxCP)}`)}});const i=t.querySelector(".widget-rank-stars");i&&(i.textContent=e.starString,i.style.color=e.tierColor);const n=t.querySelector(".widget-rank-name");return n&&(n.textContent=e.rankName,n.style.color=e.tierColor),t.setAttribute("href",e.statsUrl),!0}function lt(t,e,a,i,n=s=>s.toLocaleString("en-US")){return new Promise(s=>{if(e===a){t.innerText=n(a),s();return}let l=null;const r=a-e;function o(d){l===null&&(l=d);const c=d-l,u=Math.min(c/i,1),f=1-Math.pow(1-u,3),A=Math.round(e+r*f);t.innerText=n(A),u<1?requestAnimationFrame(o):(t.innerText=n(a),s())}requestAnimationFrame(o)})}function dt(t,e){let a=null;return function(...i){a!==null&&clearTimeout(a),a=setTimeout(()=>{t.apply(this,i),a=null},e)}}const ct=dt(()=>{S()},500);let q=!1;function ut(){if(q||typeof window=="undefined"||!window.localStorage)return;const t=localStorage.setItem.bind(localStorage);localStorage.setItem=function(e,a){t(e,a),ct()},q=!0}const ft=300;function gt(t){t.innerHTML=it(),t.classList.add("widget-ready")}function mt(t){const e=t.innerText.trim();if(!e)return 0;if(e.toUpperCase().endsWith("K")){const n=e.slice(0,-1).replace(/,/g,""),s=parseFloat(n);return isNaN(s)?0:Math.round(s*1e3)}const a=e.replace(/,/g,""),i=parseInt(a,10);return isNaN(i)?0:i}async function g(t){const a=st(t).map(i=>{const n=rt(i),s=mt(i);return i.innerText.trim()===""&&(i.innerText="0"),lt(i,s,n,ft)});await Promise.all(a)}async function R(t){try{const e=Q();e||gt(t);const a=z();e?(b(t),requestAnimationFrame(()=>{j(t),setTimeout(()=>g(t),50)}),await a):(await Promise.all([a,Promise.resolve(v())]),t.classList.remove("widget-ready"),b(t),requestAnimationFrame(()=>{j(t),setTimeout(()=>{g(t)},50)})),console.log("[SDK] Arealme Stats Widget initialized")}catch(e){console.error("[SDK] Failed to initialize widget:",e),t.innerHTML='
Failed to load
'}}function pt(t){if(!("IntersectionObserver"in window)){R(t);return}const e=new IntersectionObserver(a=>{a.forEach(i=>{i.isIntersecting&&(e.unobserve(t),R(t))})},{threshold:.1,rootMargin:"50px"});e.observe(t)}function D(){const t=N();if(!t)return;x(),ut();const e=t.getAttribute("data-theme");e?C(t,e):C(t,"dark"),pt(t)}function S(){const t=N();if(!t)return;x();const e=v();M(t)?(ot(t,e),t.classList.add("widget-ready"),g(t)):(b(t),t.classList.add("widget-ready"),g(t))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",D):D();function C(t,e){t.classList.remove("ar-theme-light"),(e==="light"||e==="auto"&&window.matchMedia("(prefers-color-scheme: light)").matches)&&t.classList.add("ar-theme-light")}function bt(t,e,a={}){const i=a.theme||"dark";x(),C(t,i),b(t),t.classList.add("widget-ready"),g(t)}window.ArealmeSDK={refresh:S},window.ArealmeStatsSDK={render:bt},window.addEventListener("storage",()=>{S()})})();