/*! For license information please see dll.LearnDiceThrowing.js.LICENSE.txt */
(window.webpackJsonp_name_dll=window.webpackJsonp_name_dll||[]).push([[69],{872:function(e,t,a){"use strict";a.r(t);var n=a(14),r=a.n(n),l=a(13),i=a.n(l),u=a(10),c=a.n(u),s=a(15),o=a.n(s),d=a(16),f=a.n(d),m=a(8),h=a.n(m),y=a(7),E=a.n(y),w=a(0),b=a.n(w),v=a(77),p=a(1010),k=a(69),T=a(968),g=a(990),S=a(87),D=a(1504),C=a.n(D),P=a(208),R=a.n(P),x=a(1023),A=a.n(x),_=a(1063),N=a.n(_),B=a(1067),G=a.n(B),H=a(206),J=a(147);function V(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var a,n=h()(e);if(t){var r=h()(this).constructor;a=Reflect.construct(n,arguments,r)}else a=n.apply(this,arguments);return f()(this,a)}}var j=function(e){o()(a,e);var t=V(a);function a(e){var n;return r()(this,a),n=t.call(this,e),E()(c()(n),"chooseNSides",(function(e){var t=new Array(e),a=new Array(e);C()(a,(function(t){return 1/e})),C()(t,(function(e){return 0})),n.setState({sides:new Array(e),sideProbs:a,tally:t,valid:!0,draw:null,nThrows:0})})),E()(c()(n),"throwDice",(function(e){for(var t=G()(1,n.state.sides.length+1,1),a=A()(t,{probs:n.state.sideProbs,size:e}),r=n.state.tally.slice(),l=0;l<a.length;l++)r[a[l]-1]+=1;n.setState({draw:a,tally:r,nThrows:n.state.nThrows+e})})),n.state={sides:new Array(6),tally:[0,0,0,0,0,0],nThrows:0,sideProbs:[1/6,1/6,1/6,1/6,1/6,1/6],valid:!0},n}return i()(a,[{key:"renderGrid",value:function(){var e=this;return b.a.createElement(g.default,{fluid:!0},b.a.createElement(T.default,null,b.a.createElement(k.default,{md:5},b.a.createElement("h3",null,"Probabilities:"),C()(this.state.sides,(function(t,a){return b.a.createElement(H.default,{key:a,legend:"Side ".concat(a+1),defaultValue:1/e.state.sides.length,step:"any",max:1,min:0,width:100,numbersOnly:!1,onChange:function(t){var n=e.state.sideProbs.slice();n[a]=t;for(var r=0,l=0;l<n.length;l++)r+=n[l];var i=new Array(n.length);C()(i,(function(e){return 0})),e.setState({sideProbs:n,valid:N()(r,1)<=15e-9,tally:i,draw:null})}})})),b.a.createElement(v.default,{onClick:function(){e.setState({tally:e.state.tally.map((function(e){return 0})),nThrows:0})}},"Reset")),b.a.createElement(k.default,{md:6},this.renderDice()),b.a.createElement(k.default,{md:1},b.a.createElement(J.default,{id:"loaded_dice",vertical:!0}))))}},{key:"renderDice",value:function(){var e=this;return this.state.valid?b.a.createElement(S.default,{fluid:!0},b.a.createElement(S.default.Header,null,"Dice"),b.a.createElement(S.default.Body,null,b.a.createElement(S.default,{body:!0},this.state.draw?this.state.draw.join(" - "):"X"),b.a.createElement(p.default,null,b.a.createElement(v.default,{onClick:function(){e.throwDice(1)}},"Throw ⚅ 1x"),b.a.createElement(v.default,{onClick:function(){e.throwDice(5)}},"Throw ⚅ 5x"),b.a.createElement(v.default,{onClick:function(){e.throwDice(10)}},"Throw ⚅ 10x")))):b.a.createElement(S.default,{body:!0},b.a.createElement("h3",null,"Please make sure that all probabilities add up to one"))}},{key:"renderTable",value:function(){var e=this;return b.a.createElement("table",{className:"table table-bordered table-responsive-sm"},b.a.createElement("tbody",null,b.a.createElement("tr",null,b.a.createElement("th",null,"Side:"),this.state.tally.map((function(e,t){return b.a.createElement("td",{key:t},t+1)}))),b.a.createElement("tr",null,b.a.createElement("th",null,"Count:"),this.state.tally.map((function(e,t){return b.a.createElement("td",{key:t},e)}))),b.a.createElement("tr",null,b.a.createElement("th",null,"Relative Frequency:"),this.state.tally.map((function(t,a){return b.a.createElement("td",{key:a},R()(t/e.state.tally.reduce((function(e,t){return e+t})),-3)||"0.000")})))))}},{key:"render",value:function(){return b.a.createElement(S.default,{id:"diceThrowingModule",style:{maxWidth:1200,margin:"0 auto"}},b.a.createElement(S.default.Header,{as:"h4"},"Simulate Random Dice Throws"),b.a.createElement(S.default.Body,null,b.a.createElement(H.default,{legend:"Number of Sides",defaultValue:6,step:1,max:20,min:2,onChange:this.chooseNSides}),b.a.createElement("p",null,"Choose custom probabilities for the sides and then throw some dice!"),this.renderGrid(),this.renderTable(),b.a.createElement("p",null,"Total number of throws: ",this.state.nThrows)))}}]),a}(w.Component);t.default=j}}]);