import{k as te,j as B,t as V,m as I,n as o,p as n,f as ne,q as N,v as W,A as q,s as le,B as ie,i as U,z as re,w as oe,x as ae,F as se}from"./web.Os7kOAdY.js";import{g as X,t as ce}from"./i18n-runtime._BAkvU05.js";var ge=q("<div class=tool-container><p style=font-size:14px;color:var(--text-2);margin-bottom:16px></p><div style=display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;margin-bottom:16px></div><div style=display:flex;gap:12px;flex-wrap:wrap><button class=tool-btn></button><button class=tool-btn></button></div><!$><!/>"),de=q('<div style="border:1px solid var(--border);border-radius:8px;padding:12px;text-align:center"><canvas width=200 height=200 style="width:180px;height:180px;border-radius:50%;margin:0 auto 10px;display:block"></canvas><p style="font-size:12px;color:var(--text-2);margin:0 0 8px"><!$><!/><!$><!/> <!$><!/></p><input class=tool-input maxlength=3 style=width:80px;text-align:center><!$><!/>'),xe=q("<p>"),$e=q('<div style="margin-top:16px;border:1px solid var(--border);border-radius:8px;padding:16px"><h4 style="margin:0 0 8px"></h4><p style=margin:0;font-size:14px><!$><!/><!$><!/>/<!$><!/> <!$><!/><!$><!/>');const x=[{number:12,bgColor:"#cd853f",fgColor:"#228b22",description:"正常视力可见数字12"},{number:8,bgColor:"#228b22",fgColor:"#cd853f",description:"正常视力可见数字8"},{number:6,bgColor:"#4169e1",fgColor:"#ff6347",description:"正常视力可见数字6"},{number:29,bgColor:"#ff6347",fgColor:"#32cd32",description:"正常视力可见数字29"},{number:5,bgColor:"#daa520",fgColor:"#2e8b57",description:"正常视力可见数字5"}];function Y(E,u){const e=E.getContext("2d"),l=E.width,a=l/2,f=l/2-10;e.clearRect(0,0,l,l),e.beginPath(),e.arc(a,a,f,0,Math.PI*2),e.fillStyle="#f5f5f5",e.fill(),e.clip();const g=8,S=u.number.toString(),v=document.createElement("canvas");v.width=l,v.height=l;const $=v.getContext("2d");$.font=`bold ${l*.4}px Arial`,$.textAlign="center",$.textBaseline="middle",$.fillText(S,a,a);for(let _=10;_<l-10;_+=g*1.5)for(let d=10;d<l-10;d+=g*1.5){const t=_-a,i=d-a;if(t*t+i*i>f*f)continue;const r=_+(Math.random()-.5)*g*.6,C=d+(Math.random()-.5)*g*.6,y=g*(.6+Math.random()*.6),j=$.getImageData(Math.round(r),Math.round(C),1,1).data[3]>128;e.beginPath(),e.arc(r,C,y/2,0,Math.PI*2),j?(e.fillStyle=u.fgColor,e.globalAlpha=.7+Math.random()*.3):(e.fillStyle=u.bgColor,e.globalAlpha=.6+Math.random()*.4),e.fill()}e.globalAlpha=1}function ue(){const[E,u]=B(X(),{equals:!1}),e=t=>ce(t,E());V(()=>{const t=i=>{const r=i.detail?.locale;r&&u(r)};window.addEventListener("taitan:locale-change",t),u(X()),le(()=>window.removeEventListener("taitan:locale-change",t))}),B(0);const[l,a]=B(new Array(x.length).fill(null)),[f,g]=B(!1);let S=[];V(()=>{S.forEach((t,i)=>{t&&Y(t,x[i])})});function v(){S.forEach((t,i)=>{t&&Y(t,x[i])}),a(new Array(x.length).fill(null)),g(!1)}function $(t,i){const r=[...l()];r[t]=i,a(r)}function _(){g(!0)}function d(){return l().filter((t,i)=>t===x[i].number.toString()).length}return(()=>{var t=I(ge),i=t.firstChild,r=i.nextSibling,C=r.nextSibling,y=C.firstChild,F=y.nextSibling,j=C.nextSibling,[Z,ee]=o(j.nextSibling);return n(i,()=>e("请辨认下方每张图片中隐藏的数字。色觉正常者可清晰辨认所有数字。 本测试仅供娱乐参考，不能替代专业医学检查。")),n(r,ne(se,{each:x,children:(w,s)=>(()=>{var m=I(de),c=m.firstChild,b=c.nextSibling,z=b.firstChild,[k,D]=o(z.nextSibling),P=k.nextSibling,[R,H]=o(P.nextSibling),G=R.nextSibling,L=G.nextSibling,[J,K]=o(L.nextSibling),h=b.nextSibling,T=h.nextSibling,[O,Q]=o(T.nextSibling);return ie(p=>{S[s()]=p},c),n(b,()=>e("第"),k,D),n(b,()=>s()+1,R,H),n(b,()=>e("题"),J,K),h.$$input=p=>$(s(),p.currentTarget.value),n(m,(()=>{var p=N(()=>!!f());return()=>p()&&(()=>{var A=I(xe);return n(A,(()=>{var M=N(()=>l()[s()]===w.number.toString());return()=>M()?"正确!":`答案: ${w.number}`})()),U(M=>re(A,`margin:6px 0 0;font-size:12px;color:${l()[s()]===w.number.toString()?"#38a169":"#e53e3e"};`,M)),A})()})(),O,Q),U(()=>oe(h,"placeholder",e("数字?"))),U(()=>ae(h,"value",l()[s()]||"")),W(),m})()})),y.$$click=_,n(y,()=>e("查看结果")),F.$$click=v,n(F,()=>e("重新生成")),n(t,(()=>{var w=N(()=>!!f());return()=>w()&&(()=>{var s=I($e),m=s.firstChild,c=m.nextSibling,b=c.firstChild,[z,k]=o(b.nextSibling),D=z.nextSibling,[P,R]=o(D.nextSibling),H=P.nextSibling,G=H.nextSibling,[L,J]=o(G.nextSibling),K=L.nextSibling,h=K.nextSibling,[T,O]=o(h.nextSibling),Q=T.nextSibling,[p,A]=o(Q.nextSibling);return n(m,()=>e("测试结果")),n(c,()=>e("正确"),z,k),n(c,d,P,R),n(c,()=>x.length,L,J),n(c,()=>e("题。"),T,O),n(c,(()=>{var M=N(()=>d()===x.length);return()=>M()?" 色觉正常！所有测试图都正确辨认。":d()>=3?" 基本正常，部分图片可能因屏幕色差影响。":" 建议到专业医疗机构进行详细检查。"})(),p,A),s})()})(),Z,ee),W(),t})()}te(["click","input"]);export{ue as default};
