(window.webpackJsonp=window.webpackJsonp||[]).push([[31],{i4a2:function(t,e,n){"use strict";n.r(e);var a=n("KQm4"),c=n("q1tI"),r=n.n(c);e.default=function(){var t=Object(c.useState)([]),e=t[0],n=t[1],u=Object(c.useState)([]),i=u[0],o=u[1],l=Object(c.useState)([]),f=l[0],s=l[1],b=Object(c.useState)(0),m=b[0],v=b[1],j=Object(c.useState)(""),h=j[0],p=j[1],O=i.length>9||m>2,d=Object(c.useCallback)((function(){return 4!==h.length?alert("4자리 숫자를 입력해 주세요"):4!==new Set(h).size?alert("중복되지 않게 입력해 주세요."):!i.includes(h)||alert("이미 시도한 값입니다.")}),[h,i]);return Object(c.useEffect)((function(){for(var t=Array(9).fill(0).map((function(t,e){return e+1})),e=[],a=0;a<4;a++){var c=Math.floor(Math.random()*t.length);e.push(t[c]),t.splice(c,1)}console.log(e),n(e)}),[]),Object(c.useEffect)((function(){if(O){var t=e.join("");s((function(e){return[].concat(Object(a.a)(e),["패배하였습니다. 정답은 "+t+"입니다."])}))}}),[i,m]),r.a.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",height:"100vh"}},r.a.createElement("form",{onSubmit:function(t){if(t.preventDefault(),!O&&d()){p(""),o((function(t){return[].concat(Object(a.a)(t),[h])}));var n=e.join("");if(h!==n){var c=0,r=0;if(e.forEach((function(t,e){var n=h.indexOf(t.toString());n===e?c+=1:n>-1&&(r+=1)})),!c&&!r)return s((function(t){return[].concat(Object(a.a)(t),[h+" : 아웃"])})),void v((function(t){return t+1}));s((function(t){return[].concat(Object(a.a)(t),[h+" : "+c+"스트라이크, 볼 "+r])}))}else s((function(t){return[].concat(Object(a.a)(t),["홈런"])}))}}},r.a.createElement("input",{type:"text",value:h,minLength:4,maxLength:4,readOnly:O,pattern:"^(?!.*(.).*\\1)\\d{4}$",onChange:function(t){return p(t.target.value)},style:{marginRight:8}}),r.a.createElement("button",{type:"submit"},"확인")),r.a.createElement("div",null,r.a.createElement("div",null,"아웃 카운트 : ",m,f.map((function(t){return r.a.createElement("div",{key:t,style:{textAlign:"center"}},t)})))))}}}]);
//# sourceMappingURL=component---src-pages-number-baseball-tsx-52557f30a7ef14a5af97.js.map