import"../chunk-DP4DOSJU.js";import{B as p}from"../chunk-IRFDE6LX.js";import"../chunk-FW4363Y4.js";var l=s=>{let a=Object.values(p),c=s.split("@"),d=/\s*(\d*)d(\d+)((k[hl])(\d+))?(\s*(\+|\-)\s*(\d+)){0,1}\s*(\+|$)/gi,e={constant:0,set:[]},n;if(!isNaN(Number(s)))return e.constant=Number(s),e;for(;n=d.exec(c[0]);){let t={count:n[1],dieType:n[2],opModifier:n[4],opConstant:n[5],constantOperation:n[7],constant:n[8]},r=parseInt(t.count);t.count===""&&(r=1);let i=p["d"+t.dieType];if(a.indexOf(i)===-1)throw`Unknown die type ${i}`;let o={count:r,dieType:i,operation:0,operand:0,dice:[]};t.opModifier==="kh"?o.operation=2:t.opModifier==="kl"&&(o.operation=1),t.opConstant&&(o.operand=parseInt(t.opConstant)),e.set.push(o),t.constant&&t.constantOperation&&(t.constantOperation==="+"?e.constant+=parseInt(t.constant):e.constant-=parseInt(t.constant))}if(e.set.length<1)throw"No dice specified";return e};export{l as parseDiceNotation};
//# sourceMappingURL=parseDiceNotation.js.map
