"undefined"==typeof GeniusSportsExposureHandler&&(GeniusSportsExposureHandler={}); (function(){function g(){MarketExposureObj.eventId=null;MarketExposureObj.marketId=null;MarketExposureObj.numberOfWinner=0;MarketExposureObj.numberOfActiveRunners=0;MarketExposureObj.marketExposure=0;MarketExposureObj.betSelections={};SelectionExposureObj.minExposure=0;SelectionExposureObj.selectionWinPL=0;SelectionExposureObj.selectionLossPL=0}function l(a){let d=a.selectionId;MarketExposureObj.betSelections[d]=MarketExposureObj.betSelections[d]||JSON.parse(JSON.stringify(MarketExposureObj.betSelections[0])); let b=Object.keys(MarketExposureObj.betSelections).length-1;b>MarketExposureObj.numberOfActiveRunners&&(MarketExposureObj.numberOfActiveRunners=b);let e=b==MarketExposureObj.numberOfActiveRunners,c=0;$j.each(MarketExposureObj.betSelections,function(h,k){let f=k.minExposure;f=d==h?MathUtil.decimal.add(f,a.selectionWinPL):MathUtil.decimal.add(f,a.selectionLossPL);k.minExposure=f;e&&0==h||(c=c>f?f:c)});MarketExposureObj.marketExposure=c}MarketExposureObj={eventId:null,marketId:null,numberOfWinner:0, numberOfActiveRunners:0,marketExposure:0,betSelections:{}};SelectionExposureObj={minExposure:0,selectionWinPL:0,selectionLossPL:0};GeniusSportsExposureHandler.getMarketExposure=function(){return JSON.parse(JSON.stringify(MarketExposureObj))};GeniusSportsExposureHandler.setMarketExposure=function(a){g();MarketExposureObj=JSON.parse(JSON.stringify(a))};GeniusSportsExposureHandler.initMarketInfo=function(a,d,b,e){g();MarketExposureObj.eventId=a;MarketExposureObj.marketId=d;MarketExposureObj.numberOfWinner= b;MarketExposureObj.numberOfActiveRunners=e;1==b&&(MarketExposureObj.betSelections[0]=JSON.parse(JSON.stringify(SelectionExposureObj)))};GeniusSportsExposureHandler.generatorBetTicketObj=function(a,d,b,e,c){e=MathUtil.decimal.multiply(1,MathUtil.decimal.multiply(MathUtil.decimal.subtract(e,1),c));c=MathUtil.decimal.multiply(-1,c);return{eventId:a,marketId:d,selectionId:b,selectionWinPL:e,selectionLossPL:c}};GeniusSportsExposureHandler.calculateExposure=function(a){if(!$j.isArray(a))throw"betTickets must bet array type.[betTicketObj....]"; if(1!=MarketExposureObj.numberOfWinner)throw"not support multiple winner.";$j.each(a,function(d,b){l(b)})}})();