pvgttm-web/src/assets/scripts/lib/dice-v2.0.0.min.js

10 lines
38 KiB
JavaScript

// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT
/*
dice.js v2.0 (minified)
https://github.com/lordnull/dice.js/
Copyright (c) 2013 - 2015 Micah Warren
Released under the MIT license
*/
!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).dice=e()}(function(){return function n(i,s,o){function a(t,e){if(!s[t]){if(!i[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(u)return u(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}r=s[t]={exports:{}},i[t][0].call(r.exports,function(e){return a(i[t][1][e]||e)},r,r.exports,n,i,s,o)}return s[t].exports}for(var u="function"==typeof require&&require,e=0;e<o.length;e++)a(o[e]);return a}({1:[function(e,t,r){t.exports={name:"dice.js",version:"2.0.0",description:"A parser and evaluator for a useful rpg dice syntax.",main:"build/dice.js",directories:{test:"tests"},devDependencies:{"@types/node":"^20.5.6",browserify:"^17.0.0",jasmine:"^5.1.0","jasmine-browser-runner":"^2.1.0","jasmine-core":"^5.1.0",peggy:"^3.0.2",typescript:"^5.2.2","uglify-js":"^3.17.4"},scripts:{test:"make test"},repository:{type:"git",url:"https://github.com/lordnull/dice.js.git"},keywords:["rpg","dice","parser","roll","peg"],author:"Micah Warren (Lord Null)",license:"MIT",bugs:{url:"https://github.com/lordnull/dice.js/issues"},homepage:"https://github.com/lordnull/dice.js"}},{}],2:[function(e,t,r){var n,i={parse:e("./parser").parse,eval:e("./evaluate").eval,stringify:e("./stringify").stringify,ops:e("./evaluate").ops,version:e("../package").version,grammer:e("./grammerAST"),statistics:e("./statistics").analyse};for(n in i.roll=function(e,t){return e=i.parse(e),i.eval(e,t)},i)r[n]=i[n]},{"../package":1,"./evaluate":3,"./grammerAST":4,"./parser":5,"./statistics":6,"./stringify":7}],3:[function(P,j,e){"use strict";var r,s,o,a,u,l,n,i,f,c,h,d,p,v,w,m,g,M,x,R,k,y,b,A,W,S=this&&this.__classPrivateFieldSet||function(e,t,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e===t&&i:t.has(e))return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r;throw new TypeError("Cannot write private member to an object whose class did not declare it")},O=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e===t&&n:t.has(e))return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e);throw new TypeError("Cannot read private member from an object whose class did not declare it")};Object.defineProperty(e,"__esModule",{value:!0}),e.eval_default=e.ParensR=e.MathSeqR=e.MathOpListR=e.MathOpR=e.RounderR=e.ExplodeModifier=e.RerollModifier=e.KeepDropModifier=e.RollSetModifiersR=e.DiceRollR=e.LookupR=e.StaticR=e.Resolver=void 0;let T=P("./grammerAST");class t extends Number{constructor(e,t){super(e),this.ast=t}get rolls(){return[]}}class E extends(e.Resolver=t){constructor(e){super(e,new T.Static(e))}}e.StaticR=E;class C extends t{constructor(e,t){super(C.deepSeek(e,t),new T.Lookup(e)),r.set(this,void 0),S(this,r,e,"f")}static deepSeek(e,t){var r;return t.hasOwnProperty(e)?t[e]:(r=e.split("."))[0]!==e&&void 0!==(e=r.reverse().reduceRight((e,t,r)=>{if(void 0!==e){e=e[t],t="object"==typeof e,r=0!==r;if(!r||t)return e}},t))&&"number"==typeof e?e:void 0}}e.LookupR=C,r=new WeakMap;let F=[];class D extends t{get min(){return O(this,s,"f")}get max(){return O(this,o,"f")}get rolls(){var e=this.min.rolls,t=this.max.rolls,r=this.x.rolls,n=this.modifiers.rolls,i=O(this,l,"f");return new Array(r,e,t,n,i).flatMap(e=>e)}get modifiers(){return O(this,u,"f")}get x(){return O(this,a,"f")}constructor(e,t,r,n,i){super(D.initVal(e,t,r,n),i),s.set(this,void 0),o.set(this,void 0),a.set(this,void 0),u.set(this,void 0),l.set(this,void 0),S(this,a,e,"f"),S(this,s,t,"f"),S(this,o,r,"f"),S(this,u,n,"f"),S(this,l,F,"f")}static rand(e,t){var r=Math.random();return r*=t.valueOf()-e.valueOf(),Math.round(r+e.valueOf())}static resultSet(t,r,n){var i=[];for(let e=0;e<t.valueOf();e++)i.push(new Number(D.rand(r,n)));return i}static applyModifiers(e,t,r){return t.modify(e,r)}static sum(e){return e.reduce((e,t)=>e+t.valueOf(),0)}static initVal(e,t,r,n){var i=D.resultSet(null!=e?e:new E(1),null!=t?t:new E(1),r),i=D.applyModifiers(i,n,{x:e,min:t,max:r});return F=i,D.sum(i)}}e.DiceRollR=D,s=new WeakMap,o=new WeakMap,a=new WeakMap,u=new WeakMap,l=new WeakMap;class N extends t{constructor(e,t){super(NaN,t),n.set(this,[]),S(this,n,e,"f")}get rolls(){return O(this,n,"f").map(e=>e.rolls).flatMap(e=>e)}get mods(){return O(this,n,"f")}modify(e,r){return O(this,n,"f").reduce((e,t)=>t.modify(e,r),e)}}e.RollSetModifiersR=N,n=new WeakMap;class K extends t{constructor(e,t,r,n){super(NaN,n),i.set(this,void 0),f.set(this,void 0),c.set(this,void 0),S(this,i,null!=e?e:"keep","f"),S(this,f,null!=t?t:"highest","f"),S(this,c,null!=r?r:new E(1),"f")}get rolls(){return O(this,c,"f").rolls}modify(e){e=e.sort();if("keep"===O(this,i,"f")&&"highest"===O(this,f,"f"))return e.slice(-1*O(this,c,"f").valueOf());if("drop"===O(this,i,"f")&&"highest"===O(this,f,"f"))return e.reverse().slice(O(this,c,"f").valueOf());if("keep"===O(this,i,"f")&&"lowest"===O(this,f,"f"))return e.reverse().slice(-1*O(this,c,"f").valueOf());if("drop"===O(this,i,"f")&&"lowest"===O(this,f,"f"))return e.slice(O(this,c,"f").valueOf());throw"impossible, but no action or direction matches"}}e.KeepDropModifier=K,i=new WeakMap,f=new WeakMap,c=new WeakMap;let q={"=":(e,t)=>e===t,"!=":(e,t)=>e!==t,"<":(e,t)=>t<e,"<=":(e,t)=>t<=e,">":(e,t)=>e<t,">=":(e,t)=>e<=t};function V(e,t){let r=q[e];return e=>r(t,e)}class I extends t{constructor(e,t,r,n){super(NaN,n),h.set(this,void 0),d.set(this,void 0),p.set(this,void 0),S(this,h,null!=e?e:"=","f"),S(this,d,t,"f"),S(this,p,null!=r?r:new E(1),"f")}get rolls(){let e=[];return void 0!==O(this,d,"f")&&(e=O(this,d,"f").rolls),O(this,p,"f").rolls.concat(e)}modify(t,r){var e;S(this,d,null!=(e=O(this,d,"f"))?e:r.min,"f");let n=V(O(this,h,"f"),O(this,d,"f"));for(let e=O(this,p,"f").valueOf();0<e;e--){var i,s,o=t.length,a=t.filter(e=>!n(e)),o=o-a.length;0!=o&&(o=new E(o),i=new N([],new T.RollSetModifiers),s=new T.DiceRoll(1,1,1,[]),o=new D(o,r.min,r.max,i,s).rolls,t=a.concat(o))}return t}}e.RerollModifier=I,h=new WeakMap,d=new WeakMap,p=new WeakMap;class G extends t{constructor(e,t,r,n){super(NaN,n),v.set(this,void 0),w.set(this,void 0),m.set(this,void 0),S(this,v,null!=e?e:"=","f"),S(this,w,t,"f"),S(this,m,null!=r?r:new E(1e4),"f")}get rolls(){let e=[];return void 0!==O(this,w,"f")&&(e=O(this,w,"f").rolls),O(this,m,"f").rolls.concat(e)}modify(e,t){let r=0;var n=null!=(n=O(this,w,"f"))?n:t.max;let i=V(O(this,v,"f"),n),s=e.filter(e=>i(e)),o=0===s.length;for(;!o;){var a=s.length,a=new D(new E(a),new E(t.min.valueOf()),new E(t.max.valueOf()),new N([],new T.RollSetModifiers([])),new T.DiceRoll(1,1,1,[])).rolls;e=e.concat(a),s=a.filter(e=>i(e)),o=(o=null!==O(this,m,"f")&&(r++,O(this,m,"f").valueOf()===r)?!0:o)||0===s.length}return e}}e.ExplodeModifier=G,v=new WeakMap,w=new WeakMap,m=new WeakMap;class _ extends t{constructor(e,t,r){super(_.modeToFunc(e)(t.valueOf()),r),g.set(this,void 0),M.set(this,void 0),S(this,g,e,"f"),S(this,M,t,"f")}get mode(){return O(this,g,"f")}get thingRounded(){return O(this,M,"f")}get rolls(){return O(this,M,"f").rolls}static modeToFunc(e){if("f"===e)return Math.floor;if("c"===e)return Math.ceil;if("r"===e)return Math.round;throw"invalid round mode"}}e.RounderR=_,g=new WeakMap,M=new WeakMap;class L extends t{constructor(e,t,r){if(super(NaN,r),x.set(this,void 0),R.set(this,void 0),k.set(this,void 0),S(this,x,e,"f"),S(this,k,t,"f"),"+"===e)S(this,R,e=>e+O(this,k,"f").valueOf(),"f");else if("-"===e)S(this,R,e=>e-O(this,k,"f").valueOf(),"f");else if("*"===e)S(this,R,e=>e*O(this,k,"f").valueOf(),"f");else{if("/"!==e)throw"invalid math operation";S(this,R,e=>e/O(this,k,"f").valueOf(),"f")}}get op(){return O(this,x,"f")}get operand(){return O(this,k,"f")}get commute(){return"-"===this.op?new L("+",new E(-1*O(this,k,"f").valueOf()),this.ast):"/"===this.op?new L("*",new E(1/O(this,k,"f").valueOf()),this.ast):new L(this.op,O(this,k,"f"),this.ast)}get rolls(){return O(this,k,"f").rolls}eval(e){return O(this,R,"f").call(this,e.valueOf())}}e.MathOpR=L,x=new WeakMap,R=new WeakMap,k=new WeakMap;class U extends t{constructor(e,t){super(NaN,t),y.set(this,[]),S(this,y,e,"f")}get ops(){return O(this,y,"f")}get rolls(){return O(this,y,"f").map(e=>e.rolls).flatMap(e=>e)}eval(e){var t=O(this,y,"f").map(e=>e.commute),e={number:e.valueOf(),opList:[]},t=t.reduce((e,t)=>("*"===t.op?e.number=t.eval(e.number):(e.opList.push(new L(t.op,new E(e.number),this.ast)),e.number=t.operand.valueOf()),e),e);return t.opList.reduce((e,t)=>t.eval(e),t.number)}}e.MathOpListR=U,y=new WeakMap;class H extends t{constructor(e,t,r){super(t.eval(e).valueOf(),r),b.set(this,void 0),A.set(this,void 0),S(this,A,e,"f"),S(this,b,t,"f")}get head(){return O(this,A,"f")}get ops(){return O(this,b,"f")}get rolls(){return O(this,A,"f").rolls.concat(O(this,b,"f").rolls)}}e.MathSeqR=H,b=new WeakMap,A=new WeakMap;class z extends t{constructor(e,t){super(e.valueOf(),t),W.set(this,void 0),S(this,W,e,"f")}get expression(){return O(this,W,"f")}get rolls(){return O(this,W,"f").rolls}}function Y(e,t,r){if(e instanceof T.Static)return n=e.value,new E(n);var n,i,s,o,a,u;if(e instanceof T.Lookup)return n=e.lookupName,r=r,new C(n,r);if(e instanceof T.RollSetModifiers)return i=t,s=(s=(r=e).children()).reduce((e,t)=>(void 0===i[t]||e.push(i[t]),e),[]),new N(s,r);if(e instanceof T.KeepDrop)return s=t,a=(r=e).action,o=r.direction,s=t.howMany,new K(a,o,s,r);if(e instanceof T.ReRoll)return a=t,r=(o=e).comparisonStr,new I(r,a.compareToVal,a.limit,o);if(e instanceof T.Explode)return r=e,l=t,new G(r.comparisonStr,l.compareToVal,l.limit,r);if(e instanceof T.MathOp){var l=e,r=t;if(void 0!==r.val)return new L(l.op,r.val,l);throw"a mathop needs something to op on"}if(e instanceof T.MathOpList)return u=t,f=(f=(r=e).children()).reduce((e,t)=>(void 0===u[t]||e.push(u[t]),e),[]),new U(f,r);if(e instanceof T.MathSeq){var f=e,r=t;if(void 0===r.head)throw"need a start up for mathseq";var c=null!=(c=r.ops)?c:new U([],f.ops);return new H(r.head,c,f)}if(e instanceof T.Rounder){r=e,c=t;if(void 0!==c.thingToRound)return new _(r.roundType,c.thingToRound,r);throw"cannot round/ceiling/floor undefined"}if(e instanceof T.Parens){var r=e,h=t;if(void 0!==h.expression)return new z(h.expression,r);throw"parens somehow ended up with undefined expression"}if(e instanceof T.DiceRoll){h=e,r=t;if(void 0===r.max)throw"dice rolls _must_ have at least a max defined";e=null!=(e=r.modifiers)?e:new N([],new T.RollSetModifers([]));return new D(null!=(t=r.x)?t:new E(1),null!=(t=r.min)?t:new E(1),r.max,e,h)}throw"invalid ast"}function B(e,t){if(t instanceof T.KeepDrop&&"howMany"===e)return new E(1);if(t instanceof T.ReRoll&&"limit"===e)return new E(1);if(t instanceof T.ReRoll&&"compareToVal"===e)return new E(1);if(t instanceof T.Explode&&"limit"===e)return new E(1e4);if(t instanceof T.Explode&&"compareToVal"===e)return new E(1);if(t instanceof T.DiceRoll&&"x"===e)return new E(1);if(t instanceof T.DiceRoll&&"min"===e)return new E(1);if(t instanceof T.DiceRoll&&"modifiers"===e)return new N([],new T.RollSetModifiers([]));throw"If you got here, somehow parsing allowed things that should not be null to be null"}e.ParensR=z,W=new WeakMap,e.eval_default=B,e.eval=function(e,t){return e=e,r=t=null!=t?t:{},T.walk_ast(e,void 0,(e,t,r)=>{return B(r,t).ast},(e,t)=>Y(e,t,r));var r}},{"./grammerAST":4}],4:[function(P,j,e){"use strict";var t,r,i,s,n,o,a,u,l,f,c,h,d,p,v,w,m,g,M,x,R,k,y,b,A,W,S,O,T,E,C,D=this&&this.__classPrivateFieldSet||function(e,t,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e===t&&i:t.has(e))return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r;throw new TypeError("Cannot write private member to an object whose class did not declare it")},N=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e===t&&n:t.has(e))return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e);throw new TypeError("Cannot read private member from an object whose class did not declare it")};Object.defineProperty(e,"__esModule",{value:!0}),e.walk_ast=e.TreeWalkerStep=e.Parens=e.MathSeq=e.MathOpList=e.MathOp=e.Rounder=e.DiceRoll=e.Explode=e.ReRoll=e.KeepDrop=e.RollSetModifiers=e.Lookup=e.Static=void 0;e.Static=class F{constructor(e){t.set(this,void 0),D(this,t,e,"f")}get value(){return N(this,t,"f")}children(){return[]}static is(e){return e instanceof F}},t=new WeakMap;e.Lookup=class K{get lookupName(){return N(this,r,"f")}constructor(e){r.set(this,void 0),D(this,r,e,"f")}children(){return[]}static is(e){return e instanceof K}},r=new WeakMap;e.RollSetModifiers=class q{constructor(t){i.set(this,[]),s.set(this,[]);var r=[];for(let e=0;e<t.length;e++)r.push(e);D(this,s,r,"f"),D(this,i,t,"f");let n=this;var e=r.reduce((e,t)=>(e[t]={get:function(){return n.mods[t]},set:function(e){n.mods[t]=e}},e),{});Object.defineProperties(this,e),N(this,s,"f").map(e=>({key:e,val:N(this,i,"f")[e]}))}get mods(){return N(this,i,"f")}children(){return N(this,s,"f").map(e=>e)}static is(e){return e instanceof q}},i=new WeakMap,s=new WeakMap;e.KeepDrop=class V{constructor(e,t,r){n.set(this,"keep"),o.set(this,"highest"),a.set(this,void 0),D(this,n,e,"f"),D(this,o,t,"f"),D(this,a,r,"f")}get action(){return N(this,n,"f")}get direction(){return N(this,o,"f")}get howMany(){return N(this,a,"f")}children(){return["howMany"]}static is(e){return e instanceof V}},n=new WeakMap,o=new WeakMap,a=new WeakMap;e.ReRoll=class I{constructor(e,t,r){u.set(this,void 0),l.set(this,void 0),f.set(this,void 0),D(this,l,t,"f"),N(this,u,"f"),D(this,f,r,"f")}get comparisonStr(){return N(this,u,"f")}get compareToVal(){return N(this,l,"f")}get limit(){return N(this,f,"f")}children(){return["limit","compareToVal"]}static is(e){return e instanceof I}},u=new WeakMap,l=new WeakMap,f=new WeakMap;e.Explode=class G{constructor(e,t,r){c.set(this,void 0),h.set(this,void 0),d.set(this,void 0),D(this,c,e,"f"),D(this,d,r,"f"),D(this,h,t,"f")}get comparisonStr(){return N(this,c,"f")}get compareToVal(){return N(this,h,"f")}get limit(){return N(this,d,"f")}children(){return["limit","compareToVal"]}static is(e){return e instanceof G}},c=new WeakMap,h=new WeakMap,d=new WeakMap;e.DiceRoll=class U{constructor(e,t,r,n){p.set(this,void 0),v.set(this,void 0),w.set(this,void 0),m.set(this,void 0),D(this,p,e,"f"),D(this,v,t,"f"),D(this,w,r,"f"),D(this,m,n,"f")}get x(){return N(this,p,"f")}get min(){return N(this,v,"f")}get max(){return N(this,w,"f")}get modifiers(){return N(this,m,"f")}children(){return["x","min","max","modifiers"]}static is(e){return e instanceof U}},p=new WeakMap,v=new WeakMap,w=new WeakMap,m=new WeakMap;e.Rounder=class H{constructor(e,t){g.set(this,"r"),M.set(this,void 0),D(this,g,e,"f"),D(this,M,t,"f")}get roundType(){return N(this,g,"f")}get thingToRound(){return N(this,M,"f")}children(){return["thingToRound"]}static is(e){return e instanceof H}},g=new WeakMap,M=new WeakMap;e.MathOp=class z{constructor(e,t){x.set(this,"+"),R.set(this,void 0),D(this,x,e,"f"),D(this,R,t,"f")}get op(){return N(this,x,"f")}get val(){return N(this,R,"f")}children(){return["val"]}static is(e){return e instanceof z}},x=new WeakMap,R=new WeakMap;class _{constructor(t){k.set(this,[]),y.set(this,[]);var r=[];for(let e=0;e<t.length;e++)r.push(e);D(this,k,t,"f"),D(this,y,r,"f");let n=this;var e=r.reduce((e,t)=>{return e[t]={get:function(){return N(n,k,"f")[t]},set:function(e){N(n,k,"f")[t]=e}},e},{});Object.defineProperties(this,e)}get ops(){return N(this,k,"f")}children(){return N(this,y,"f").map(e=>e)}static is(e){return e instanceof _}}e.MathOpList=_,k=new WeakMap,y=new WeakMap;e.MathSeq=class Y{constructor(e,t){b.set(this,new _([])),A.set(this,void 0),D(this,A,e,"f"),D(this,b,t,"f")}get head(){return N(this,A,"f")}get ops(){return N(this,b,"f")}children(){return["head","ops"]}static is(e){return e instanceof Y}},b=new WeakMap,A=new WeakMap;e.Parens=class B{constructor(e){W.set(this,void 0),D(this,W,e,"f")}get expression(){return N(this,W,"f")}children(){return["expression"]}static is(e){return e instanceof B}},W=new WeakMap;class L{constructor(e){S.set(this,void 0),O.set(this,[]),T.set(this,void 0),E.set(this,void 0),C.set(this,{}),D(this,S,e,"f"),D(this,O,e.children(),"f"),D(this,T,N(this,O,"f").values(),"f")}get currentKey(){if(void 0===N(this,E,"f"))throw"No current key; may need to reset the iteration and call 'next'";return N(this,E,"f")}get currentValue(){if(void 0!==N(this,E,"f"))return N(this,S,"f")[N(this,E,"f")]}get currentNode(){return N(this,S,"f")}get keymapSoFar(){return N(this,C,"f")}get keymap(){N(this,O,"f").forEach(e=>{if(void 0===N(this,C,"f")[e])throw String(e)+" is not yet set";return!0});var e=N(this,C,"f");return e}get allKeys(){return N(this,O,"f")}resetItor(){D(this,T,N(this,O,"f").values(),"f"),D(this,E,void 0,"f")}next(){var e=N(this,T,"f").next(),e=(D(this,E,e.value,"f"),{key:N(this,E,"f"),value:this.currentValue,done:e.done});return e}setKey(e,t){N(this,C,"f")[e]=t}setCurrent(e){if(void 0===this.currentKey)throw"No current key. You either never called next, called next too often, or called next but didn't check the 'done' property.";N(this,C,"f")[this.currentKey]=e}}e.TreeWalkerStep=L,S=new WeakMap,O=new WeakMap,T=new WeakMap,E=new WeakMap,C=new WeakMap,e.walk_ast=function(e,t,r,n){var i=[];let s=new L(e),o=!1,a=t;for(;!o;){var u,l=s.next();l.done?(a=n(s.currentNode,s.keymap),void 0===(u=i.pop())?o=!0:(u.setCurrent(a),s=u)):s=void 0===l.value?(u=r(i.map(e=>e.currentNode),s.currentNode,s.currentKey),i.push(s),new L(u)):(i.push(s),new L(l.value))}return a}},{}],5:[function(e,t,r){"use strict";let St=e("./grammerAST");function Ot(e,t,r,n){e=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(e,Ot.prototype),e.expected=t,e.found=r,e.location=n,e.name="SyntaxError",e}function n(){this.constructor=i}var i;function f(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,e+(r+=r.repeat(t)).slice(0,t))}i=Ot,e=Error,n.prototype=e.prototype,i.prototype=new n,Ot.prototype.format=function(e){var t="Error: "+this.message;if(this.location){for(var r=null,n=0;n<e.length;n++)if(e[n].source===this.location.source){r=e[n].text.split(/\r\n|\n|\r/g);break}var i,s,o,a=this.location.start,u=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(a):a,l=this.location.source+":"+u.line+":"+u.column;r?(o=this.location.end,i=f("",u.line.toString().length," "),s=r[a.line-1],o=(a.line===o.line?o.column:s.length+1)-a.column||1,t+="\n --\x3e "+l+"\n"+i+" |\n"+u.line+" | "+s+"\n"+i+" | "+f("",a.column-1," ")+f("",o,"^")):t+="\n at "+l}return t},Ot.buildMessage=function(e,t){var r={literal:function(e){return'"'+i(e.text)+'"'},class:function(e){var t=e.parts.map(function(e){return Array.isArray(e)?s(e[0])+"-"+s(e[1]):s(e)});return"["+(e.inverted?"^":"")+t.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function i(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}function s(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}function o(e){return r[e.type](e)}return"Expected "+function(e){var t,r,n=e.map(o);if(n.sort(),0<n.length){for(r=t=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+((e=t)?'"'+i(e)+'"':"end of input")+" found."},t.exports={SyntaxError:Ot,parse:function(l,e){function P(e){return new St.RollSetModifiers([e])}function j(e,t){return t.unshift(e),new St.RollSetModifiers(t)}function F(e,t,r){return r=(r??[void 0,void 0])[1]??void 0,t=t[1],new St.KeepDrop(e,t,r)}function K(e,t,r){return new St.Explode(e,t,r)}function q(e,t){return new St.Explode(e,t,void 0)}function V(e,t){return new St.Explode(e,void 0,t)}function I(e,t){return new St.Explode(void 0,e,t)}function G(e){return new St.Explode(void 0,void 0,e)}function U(){return new St.Explode(void 0,void 0,void 0)}function H(e,t,r){return new St.ReRoll(e,t,r)}function z(e,t){return new St.ReRoll(void 0,e,t)}function Y(e,t){return new St.ReRoll(e,t)}function B(e){return new St.ReRoll(void 0,void 0,e)}function J(e){return new St.ReRoll(void 0,e)}function Q(){return new St.ReRoll}function X(e){return new St.Parens(e)}function Z(e){return e.join("")}function $(){return parseInt(l.substring(M,g))}var f={},s=(e=void 0!==e?e:{}).grammarSource,t={start:yt},r=yt,ee="*",te="/",re="+",ne="-",a="..",o=":",u=":rr",ie="{",se="}",oe=";",ae="keep",ue="drop",le="highest",fe="lowest",c="explode",h="x",d="reroll",ce=">=",he="<=",de="!=",pe="(",ve=")",we="[",me="]",ge=/^[dD]/,Me=/^[wW]/,xe=/^[kKdD]/,Re=/^[hHlL]/,ke=/^[>=<]/,ye=/^[cCfFrR]/,be=/^[^[\]]/,Ae=/^[\-]/,We=/^[0-9]/,n=/^[\n\r\t ]/,Se=b("*",!1),Oe=b("/",!1),Te=b("+",!1),Ee=b("-",!1),Ce=A(["d","D"],!1,!1),p=b("..",!1),De=A(["w","W"],!1,!1),Ne=b(":",!1),_e=A(["k","K","d","D"],!1,!1),Le=A(["h","H","l","L"],!1,!1),Pe=b(":rr",!1),je=b("{",!1),Fe=b("}",!1),Ke=b(";",!1),qe=b("keep",!1),Ve=b("drop",!1),Ie=b("highest",!1),Ge=b("lowest",!1),v=b("explode",!1),w=b("x",!1),m=b("reroll",!1),Ue=W("comparison operator"),He=b(">=",!1),ze=b("<=",!1),Ye=b("!=",!1),Be=A([">","=","<"],!1,!1),Je=b("(",!1),Qe=b(")",!1),Xe=W("integer or rounded expression"),Ze=A(["c","C","f","F","r","R"],!1,!1),$e=b("[",!1),et=A(["[","]"],!0,!1),tt=b("]",!1),rt=A(["-"],!1,!1),nt=A([["0","9"]],!1,!1),it=W("whitespace"),i=A(["\n","\r","\t"," "],!1,!1),st=W("required whitespace"),ot=function(e,t){return 0==t.length?e:(t=t.map(e=>{var t=e[0],e=e[1];return new St.MathOp(t,e)}),t=new St.MathOpList(t),new St.MathSeq(e,t))},at=function(e,t,r,n){return new St.DiceRoll(e??void 0,t,r,n??void 0)},ut=function(e,t,r){return new St.DiceRoll(e??void 0,void 0,t,r??void 0)},lt=function(e,t,r,n){n=(n??new St.RollSetModifiers([])).mods;var i=new St.Explode("=",r,void 0,t,r),i=(n.unshift(i),new St.RollSetModifiers(n));return new St.DiceRoll(e??void 0,t,r,i)},ft=function(e,t,r){var r=(r??new St.RollSetModifiers([])).mods,n=new St.Explode("=",t,void 0,1,t),n=(r.unshift(n),new St.RollSetModifiers(r));return new St.DiceRoll(e??void 0,void 0,t,n)},ct=function(e,t,r){return new St.DiceRoll(void 0,e,t,r??void 0)},ht=function(e,t,r){let n="highest",i="keep",s=("d"===e.toLowerCase()&&(i="drop",n="lowest"),n);t&&(s="l"===t.toLowerCase()?"lowest":"highest");e=r??void 0;return new St.KeepDrop(i,s,e)},dt=function(e,t){let r="keep",n="highest";n="h"===e.toLowerCase()?(r="keep","highest"):(r="drop","lowest");e=t??void 0;return new St.KeepDrop(r,n,e)},pt=function(e){return new St.ReRoll("=",void 0,void 0)},vt=function(e){return e},wt=function(e,t){return e?new St.Rounder(e,t):t},mt=function(e,t){t=new St.Lookup(t);return e?new St.Rounder(e,t):t},gt=function(e,t){return new St.Rounder(e,t)},Mt=function(e){return new St.Static(e)},g=0,M=0,x=[{line:1,column:1}],R=0,k=[],y=0;if("startRule"in e){if(!(e.startRule in t))throw new Error("Can't start parsing from rule \""+e.startRule+'".');r=t[e.startRule]}function b(e,t){return{type:"literal",text:e,ignoreCase:t}}function A(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function W(e){return{type:"other",description:e}}function xt(e){var t,r=x[e];if(r)return r;for(t=e-1;!x[t];)t--;for(r={line:(r=x[t]).line,column:r.column};t<e;)10===l.charCodeAt(t)?(r.line++,r.column=1):r.column++,t++;return x[e]=r}function Rt(e,t,r){var n=xt(e),i=xt(t),e={source:s,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:i.line,column:i.column}};return r&&s&&"function"==typeof s.offset&&(e.start=s.offset(e.start),e.end=s.offset(e.end)),e}function S(e){g<R||(R<g&&(R=g,k=[]),k.push(e))}function kt(e,t,r){return new Ot(Ot.buildMessage(e,t),e,t,r)}function yt(){return bt()}function bt(){var e,t,r,n,i=g,s=(_(),O());if(s!==f){for(e=[],t=g,_(),t=(r=At())!==f&&(_(),(n=O())!==f)?[r,n]:(g=t,f);t!==f;)e.push(t),t=g,_(),t=(r=At())!==f&&(_(),(n=O())!==f)?[r,n]:(g=t,f);t=_(),M=i,i=ot(s,e)}else g=i,i=f;return i}function At(){var e;return 42===l.charCodeAt(g)?(e=ee,g++):(e=f,0===y&&S(Se)),e===f&&(47===l.charCodeAt(g)?(e=te,g++):(e=f,0===y&&S(Oe)),e===f)&&(43===l.charCodeAt(g)?(e=re,g++):(e=f,0===y&&S(Te)),e===f)&&(45===l.charCodeAt(g)?(e=ne,g++):(e=f,0===y&&S(Ee))),e}function O(){var e=function(){var e,t,r,n,i,s,o;e=g,(t=D())===f&&(t=null);ge.test(l.charAt(g))?(r=l.charAt(g),g++):(r=f,0===y&&S(Ce));e=r!==f&&(n=D(),n!==f)&&(l.substr(g,2)===a?(i=a,g+=2):(i=f,0===y&&S(p)),i!==f)&&(s=D())!==f?(o=T(),M=e,at(t,n,s,o=o===f?null:o)):(g=e,f);e===f&&(e=g,(t=D())===f&&(t=null),ge.test(l.charAt(g))?(r=l.charAt(g),g++):(r=f,0===y&&S(Ce)),(e=r!==f&&(n=D())!==f?(i=T(),M=e,ut(t,n,i=i===f?null:i)):(g=e,f))===f)&&(e=g,(t=D())===f&&(t=null),Me.test(l.charAt(g))?(r=l.charAt(g),g++):(r=f,0===y&&S(De)),(e=r!==f&&(n=D())!==f&&(l.substr(g,2)===a?(i=a,g+=2):(i=f,0===y&&S(p)),i!==f)&&(s=D())!==f?(o=T(),M=e,lt(t,n,s,o=o===f?null:o)):(g=e,f))===f)&&(e=g,(t=D())===f&&(t=null),Me.test(l.charAt(g))?(r=l.charAt(g),g++):(r=f,0===y&&S(De)),(e=r!==f&&(n=D())!==f?(i=T(),M=e,ft(t,n,i=i===f?null:i)):(g=e,f))===f)&&(e=g,t=D(),e=t!==f&&(l.substr(g,2)===a?(r=a,g+=2):(r=f,0===y&&S(p)),r!==f)&&(n=D())!==f?(i=T(),M=e,ct(t,n,i=i===f?null:i)):(g=e,f));return e}();return e=e===f&&(e=function(){var e,t,r;e=g,(t=N())===f&&(t=null);e=(r=Wt())!==f?(M=e,wt(t,r)):(g=e,f);return e}())===f?D():e}function T(){var e=g,t=function(){var e,t,r,n,i;e=g,58===l.charCodeAt(g)?(t=o,g++):(t=f,0===y&&S(Ne));e=t!==f&&(xe.test(l.charAt(g))?(r=l.charAt(g),g++):(r=f,0===y&&S(_e)),r!==f)?(Re.test(l.charAt(g))?(n=l.charAt(g),g++):(n=f,0===y&&S(Le)),n===f&&(n=null),i=D(),M=e,ht(r,n,i=i===f?null:i)):(g=e,f);e===f&&(e=g,58===l.charCodeAt(g)?(t=o,g++):(t=f,0===y&&S(Ne)),(e=t!==f&&(Re.test(l.charAt(g))?(r=l.charAt(g),g++):(r=f,0===y&&S(Le)),r!==f)?(n=D(),M=e,dt(r,n=n===f?null:n)):(g=e,f))===f)&&(e=g,l.substr(g,3)===u?(t=u,g+=3):(t=f,0===y&&S(Pe)),e=t!==f?(r=D(),M=e,pt(r=r===f?null:r)):(g=e,f));return e}();return t!==f&&(M=e,t=P(t)),e=(e=t)===f?function(){var e,t,r;e=g,_(),123===l.charCodeAt(g)?(t=ie,g++):(t=f,0===y&&S(je));e=t!==f&&(_(),t=function(){var e,t,r,n,i,s;if(e=g,(t=E())!==f){for(r=[],n=g,_(),59===l.charCodeAt(g)?(i=oe,g++):(i=f,0===y&&S(Ke)),n=i!==f&&(_(),(s=E())!==f)?s:(g=n,f);n!==f;)r.push(n),n=g,_(),59===l.charCodeAt(g)?(i=oe,g++):(i=f,0===y&&S(Ke)),n=i!==f&&(_(),(s=E())!==f)?s:(g=n,f);M=e,e=j(t,r)}else g=e,e=f;return e}(),t!==f)&&(_(),125===l.charCodeAt(g)?(r=se,g++):(r=f,0===y&&S(Fe)),r!==f)?(M=e,vt(t)):(g=e,f);return e}():e}function E(){var e=function(){var e,t,r,n,i,s;e=g,l.substr(g,4)===ae?(t=ae,g+=4):(t=f,0===y&&S(qe));t===f&&(l.substr(g,4)===ue?(t=ue,g+=4):(t=f,0===y&&S(Ve)));e=t!==f&&(r=g,n=L(),(r=n!==f&&(l.substr(g,7)===le?(i=le,g+=7):(i=f,0===y&&S(Ie)),i!==f)?n=[n,i]:(g=r,f))===f&&(r=g,n=L(),r=n!==f&&(l.substr(g,6)===fe?(i=fe,g+=6):(i=f,0===y&&S(Ge)),i!==f)?n=[n,i]:(g=r,f)),r!==f)?(n=g,i=L(),n=i!==f&&(s=D())!==f?i=[i,s]:(g=n,f),M=e,F(t,r,n=n===f?null:n)):(g=e,f);return e}();return e=e===f&&(e=function(){var e,t,r,n,i,s,o,a,u;e=g,l.substr(g,7)===c?(t=c,g+=7):(t=f,0===y&&S(v));e=t!==f&&(r=L(),r!==f)&&(n=C())!==f&&(i=_(),(s=D())!==f)&&(o=L())!==f&&(a=D())!==f&&(120===l.charCodeAt(g)?(u=h,g++):(u=f,0===y&&S(w)),u!==f)?(M=e,K(n,s,a)):(g=e,f);e===f&&(e=g,l.substr(g,7)===c?(t=c,g+=7):(t=f,0===y&&S(v)),(e=t!==f&&(r=L())!==f&&(n=C())!==f&&(i=_(),(s=D())!==f)?(M=e,q(n,s)):(g=e,f))===f)&&(e=g,l.substr(g,7)===c?(t=c,g+=7):(t=f,0===y&&S(v)),(e=t!==f&&(r=L())!==f&&(n=C())!==f&&(i=L())!==f&&(s=D())!==f&&(120===l.charCodeAt(g)?(o=h,g++):(o=f,0===y&&S(w)),o!==f)?(M=e,V(n,s)):(g=e,f))===f)&&(e=g,l.substr(g,7)===c?(t=c,g+=7):(t=f,0===y&&S(v)),(e=t!==f&&(r=L())!==f&&(n=D())!==f&&(i=L())!==f&&(s=D())!==f&&(120===l.charCodeAt(g)?(o=h,g++):(o=f,0===y&&S(w)),o!==f)?(M=e,I(n,s)):(g=e,f))===f)&&(e=g,l.substr(g,7)===c?(t=c,g+=7):(t=f,0===y&&S(v)),(e=t!==f&&(r=L())!==f&&(n=D())!==f&&(120===l.charCodeAt(g)?(i=h,g++):(i=f,0===y&&S(w)),i!==f)?(M=e,G(n)):(g=e,f))===f)&&(e=g,l.substr(g,7)===c?(t=c,g+=7):(t=f,0===y&&S(v)),t!==f&&(M=e,t=U()),e=t);return e}())===f?function(){var e,t,r,n,i,s,o,a;e=g,l.substr(g,6)===d?(t=d,g+=6):(t=f,0===y&&S(m));e=t!==f&&(_(),r=C(),r!==f)&&(n=_(),(i=D())!==f)&&(s=L())!==f&&(o=D())!==f&&(120===l.charCodeAt(g)?(a=h,g++):(a=f,0===y&&S(w)),a!==f)?(M=e,H(r,i,o)):(g=e,f);e===f&&(e=g,l.substr(g,6)===d?(t=d,g+=6):(t=f,0===y&&S(m)),(e=t!==f&&L()!==f&&(r=D())!==f&&(n=L())!==f&&(i=D())!==f&&(120===l.charCodeAt(g)?(s=h,g++):(s=f,0===y&&S(w)),s!==f)?(M=e,z(r,i)):(g=e,f))===f)&&(e=g,l.substr(g,6)===d?(t=d,g+=6):(t=f,0===y&&S(m)),(e=t!==f&&(_(),(r=C())!==f)&&(n=_(),(i=D())!==f)?(M=e,Y(r,i)):(g=e,f))===f)&&(e=g,l.substr(g,6)===d?(t=d,g+=6):(t=f,0===y&&S(m)),(e=t!==f&&L()!==f&&(r=D())!==f&&(120===l.charCodeAt(g)?(n=h,g++):(n=f,0===y&&S(w)),n!==f)?(M=e,B(r)):(g=e,f))===f)&&(e=g,l.substr(g,6)===d?(t=d,g+=6):(t=f,0===y&&S(m)),(e=t!==f&&L()!==f&&(r=D())!==f?(M=e,J(r)):(g=e,f))===f)&&(e=g,l.substr(g,6)===d?(t=d,g+=6):(t=f,0===y&&S(m)),t!==f&&(M=e,t=Q()),e=t);return e}():e}function C(){var e;return y++,l.substr(g,2)===ce?(e=ce,g+=2):(e=f,0===y&&S(He)),e===f&&(l.substr(g,2)===he?(e=he,g+=2):(e=f,0===y&&S(ze)),e===f)&&(l.substr(g,2)===de?(e=de,g+=2):(e=f,0===y&&S(Ye)),e===f)&&(ke.test(l.charAt(g))?(e=l.charAt(g),g++):(e=f,0===y&&S(Be))),y--,e===f&&0===y&&S(Ue),e}function Wt(){var e,t,r=g;return 40===l.charCodeAt(g)?(e=pe,g++):(e=f,0===y&&S(Je)),r=e!==f&&(_(),(e=bt())!==f)&&(_(),41===l.charCodeAt(g)?(t=ve,g++):(t=f,0===y&&S(Qe)),t!==f)?(M=r,X(e)):(g=r,f)}function D(){var e,t,r;return y++,e=g,(t=N())===f&&(t=null),(e=(r=function(){var e,t,r,n;e=g,91===l.charCodeAt(g)?(t=we,g++):(t=f,0===y&&S($e));if(t!==f){if(r=[],be.test(l.charAt(g))?(n=l.charAt(g),g++):(n=f,0===y&&S(et)),n!==f)for(;n!==f;)r.push(n),be.test(l.charAt(g))?(n=l.charAt(g),g++):(n=f,0===y&&S(et));else r=f;e=r!==f&&(93===l.charCodeAt(g)?(n=me,g++):(n=f,0===y&&S(tt)),n!==f)?(M=e,Z(r)):(g=e,f)}else g=e,e=f;return e}())!==f?(M=e,mt(t,r)):(g=e,f))===f&&(e=g,(e=(t=N())!==f&&(r=Wt())!==f?(M=e,gt(t,r)):(g=e,f))===f)&&(e=g,(t=function(){var e,t,r,n;e=g,Ae.test(l.charAt(g))?(t=l.charAt(g),g++):(t=f,0===y&&S(rt));t===f&&(t=null);r=[],We.test(l.charAt(g))?(n=l.charAt(g),g++):(n=f,0===y&&S(nt));if(n!==f)for(;n!==f;)r.push(n),We.test(l.charAt(g))?(n=l.charAt(g),g++):(n=f,0===y&&S(nt));else r=f;e=r!==f?(M=e,$()):(g=e,f);return e}())!==f&&(M=e,t=Mt(t)),e=t),y--,e===f&&(t=f,0===y)&&S(Xe),e}function N(){var e;return ye.test(l.charAt(g))?(e=l.charAt(g),g++):(e=f,0===y&&S(Ze)),e}function _(){var e,t;for(y++,e=[],n.test(l.charAt(g))?(t=l.charAt(g),g++):(t=f,0===y&&S(i));t!==f;)e.push(t),n.test(l.charAt(g))?(t=l.charAt(g),g++):(t=f,0===y&&S(i));return t=f,0===--y&&S(it),e}function L(){var e,t;if(y++,e=[],n.test(l.charAt(g))?(t=l.charAt(g),g++):(t=f,0===y&&S(i)),t!==f)for(;t!==f;)e.push(t),n.test(l.charAt(g))?(t=l.charAt(g),g++):(t=f,0===y&&S(i));else e=f;return y--,e===f&&(t=f,0===y)&&S(st),e}if((t=r())!==f&&g===l.length)return t;throw t!==f&&g<l.length&&S({type:"end"}),kt(k,R<l.length?l.charAt(R):null,R<l.length?Rt(R,R+1):Rt(R,R))}}},{"./grammerAST":4}],6:[function(e,t,r){"use strict";var n,i,s,o,a,u,l,f,c,h,d,p,v=this&&this.__classPrivateFieldSet||function(e,t,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e===t&&i:t.has(e))return"a"===n?i.call(e,r):i?i.value=r:t.set(e,r),r;throw new TypeError("Cannot write private member to an object whose class did not declare it")},w=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e===t&&n:t.has(e))return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e);throw new TypeError("Cannot read private member from an object whose class did not declare it")};Object.defineProperty(r,"__esModule",{value:!0}),r.analyse=void 0;let m=e("./grammerAST"),g=e("./parser"),M=e("./evaluate");function x(e,t,r){return M.eval_default(r,t).ast}r.analyse=function(e,t,r){"number"==typeof t&&(r=t,t={}),t=t||{},r=r||1e3;for(var n,i,s=[],o=0;o<r;o++)s.push((n=e,i=t,n=g.parse(n),M.eval(n,i)));var a=s.reduce(function(e,t){return e+t},0)/r,u=s.reduce(function(e,t){return e<t?e:t},s[0]),l=s.reduce(function(e,t){return t<e?e:t},s[0]),f=function(e,t){t=function(d){return(n,i)=>{var e,s=d;if(m.Static.is(n))return t=n.value,new k(t);if(m.Lookup.is(n)){var t=n.lookupName,s=M.LookupR.deepSeek(t,s);if(void 0===s)throw"scope lacked a value for "+t;return new k(s)}if(m.MathOp.is(n))return s=n,o=i,new y(s.op,o.val);if(m.MathOpList.is(n)){let r=i;var s=(e,t)=>{t=r[t];return t instanceof y&&e.push(t),e},o=n.children().reduce(s,[]);return new b(o)}if(m.MathSeq.is(n))return s=i,new A(s.head,s.ops);if(m.KeepDrop.is(n))return s=n,e=i,new W(s,e.howMany);if(m.Explode.is(n))return s=n,e=i,new S(s,e.compareToVal,e.limit);if(m.ReRoll.is(n))return s=n,l=i,new O(s,l.compareToVal,l.limit);if(m.RollSetModifiers.is(n)){let t=i;s=n.children().map(e=>t[e]);return new T(s)}if(m.DiceRoll.is(n)){var r=i.x,a=i.min,u=i.max,l=i.modifiers,f=[];for(let e=0;e<r.min;e++)f.push(a.min);var s=l.evalMin(f),c=[];for(let e=0;e<r.max;e++)c.push(u.max);var h=l.evalMax(c),s=s.reduce((e,t)=>e+t,0),h=h.reduce((e,t)=>e+t,0);return new R(s,h)}if(m.Parens.is(n))return i.expression;if(m.Rounder.is(n)){s=n,h=i;let e=Math.floor;return"c"===s.roundType?e=Math.ceil:"r"===s.roundType&&(e=Math.round),new R(e(h.thingToRound.min),e(h.thingToRound.max))}throw console.log("the node",n),{message:"unknown node type",node:n}}}(t);return m.walk_ast(e,{min:0,max:0},x,t)}(g.parse(e),t);return{results:s,mean:a,min:parseInt(u.toFixed()),max:parseInt(l.toFixed()),min_possible:f.min,max_possible:f.max}};class R{constructor(e,t){this.min=e,this.max=t}}class k extends R{constructor(e){super(e,e)}}class y extends R{constructor(e,t){super(t.min,t.max),"-"===e?(this.op="+",this.min=-1*t.max,this.max=-1*t.min):"/"===e?(this.op="*",this.min=1/t.max,this.max=1/t.min):this.op=e}eval(e){let t=0,r=0;return"+"===this.op?(t=e.min+this.min,r=e.max+this.max):"*"===this.op&&(t=e.min*this.min,r=e.max*this.max),new R(t,r)}}class b extends R{constructor(e){super(NaN,NaN),n.set(this,void 0),v(this,n,e,"f")}get ops(){return w(this,n,"f")}eval(e){e={range:e,opList:[]},e=w(this,n,"f").reduce((e,t)=>("*"===t.op?e.range=t.eval(e.range):(e.opList.push(new y(t.op,e.range)),e.range=new R(t.min,t.max)),e),e);return e.opList.reduce((e,t)=>t.eval(e),e.range)}}n=new WeakMap;class A extends R{constructor(e,t){super(e.min,e.max),i.set(this,void 0),s.set(this,void 0);var r=t.eval(e);this.min=r.min,this.max=r.max,v(this,i,e,"f"),v(this,s,t,"f")}get ops(){return w(this,s,"f")}get head(){return w(this,i,"f")}}i=new WeakMap,s=new WeakMap;class W extends R{constructor(e,t){super(t.min,t.max),o.set(this,void 0),a.set(this,void 0),v(this,o,t,"f"),v(this,a,e,"f")}evalMin(e){var t=w(this,o,"f").min;return new M.KeepDropModifier(w(this,a,"f").action,w(this,a,"f").direction,t,w(this,a,"f")).modify(e)}evalMax(e){var t=w(this,o,"f").max;return new M.KeepDropModifier(w(this,a,"f").action,w(this,a,"f").direction,t,w(this,a,"f")).modify(e)}}o=new WeakMap,a=new WeakMap;class S extends R{constructor(e,t,r){super(t.min,t.max),u.set(this,void 0),l.set(this,void 0),f.set(this,void 0),v(this,l,t,"f"),v(this,u,r,"f"),v(this,f,e,"f")}evalMin(e,t,r){return e}evalMax(e,t,r){return e}}u=new WeakMap,l=new WeakMap,f=new WeakMap;class O extends R{constructor(e,t,r){super(t.min,t.max),c.set(this,void 0),h.set(this,void 0),d.set(this,void 0),v(this,h,t,"f"),v(this,c,r,"f"),v(this,d,e,"f")}evalMin(e,t,r){return e}evalMax(e,t,r){return e}}c=new WeakMap,h=new WeakMap,d=new WeakMap;class T extends R{constructor(e){super(NaN,NaN),p.set(this,void 0),v(this,p,e,"f")}evalMin(e){return w(this,p,"f").reduce((e,t)=>t.evalMin(e),e)}evalMax(e){return w(this,p,"f").reduce((e,t)=>t.evalMax(e),e)}}p=new WeakMap},{"./evaluate":3,"./grammerAST":4,"./parser":5}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.stringify_loop=r.stringify=void 0;let n=e("./grammerAST"),i=e("./evaluate");function s(t){if(t instanceof n.Static)return[t.value.toString()];if(t instanceof n.Lookup)return["[",t.lookupName,"]"];if(t instanceof n.RollSetModifiers)return["oh god modifiers..."];if(t instanceof n.KeepDrop)return["keep lowest 33"];if(t instanceof n.ReRoll)return["reroll >10 55x"];if(t instanceof n.Explode)return["explode =3 1x"];if(t instanceof n.DiceRoll){let e=t;return[()=>(e,["12"]),()=>(e,["z"]),()=>(e,["99..-12"]),()=>(e,["no mods!"])]}if(t instanceof n.Rounder){let e=t;return[e.roundType,()=>s(e.thingToRound)]}if(t instanceof n.MathOp){let e=t;return[e.op,()=>s(e.val)]}if(t instanceof n.MathOpList)return t.ops.map(e=>()=>s(e));if(t instanceof n.MathSeq);if(t instanceof n.Parens){let e=t;return["( ",()=>s(e.expression)," )"]}throw"cannot format the thing"}function o(e,t){var r=[];let n=t(e);for(;0<n.length;){var i=n.shift();void 0!==i&&("string"==typeof i?r.push(i):(i=i(),n=i.concat(n)))}return r.join("")}function a(r){if(r instanceof i.StaticR)return[()=>s(r.ast)];if(r instanceof i.LookupR)return[r.valueOf().toString(),":",()=>s(r.ast)];if(r instanceof i.ParensR){let e=r;return["( ",()=>a(e.expression)," )"]}if(r instanceof i.RounderR){let e=r;return[e.mode,()=>a(e.thingRounded)]}if(r instanceof i.DiceRollR){let t=r;return[()=>{return(e=t).ast.x?[()=>a(e.x)]:[];var e},()=>{return 0!==t.modifiers.mods.length?["q"]:["d"]},()=>{return void 0===(e=t).ast.min?[()=>a(e.max)]:[()=>a(e.min),"..",()=>a(e.max)];var e},()=>u(t.modifiers),()=>{return e=t,[":[",()=>[e.rolls.join(", ")],"]"];var e}]}if(r instanceof i.RollSetModifiersR)return u(r);if(r instanceof i.KeepDropModifier)return["keep highest 27"];if(r instanceof i.RerollModifier)return["reroll <12 78x"];if(r instanceof i.ExplodeModifier)return["explode =7 8x"];if(r instanceof i.MathOpR){let e=r;return[e.op," ",()=>a(e.operand)]}if(r instanceof i.MathOpListR)return r.ops.map(e=>()=>a(e));if(r instanceof i.MathSeqR){let e=r;return[()=>a(e.head),()=>0===e.ops.ops.length?[]:[" "],()=>a(e.ops)]}throw"unformatabled!"}function u(e){return void 0===e.ast.mods||0===e.mods.length?[]:["!!!mods listing not yet complete!!!"]}r.stringify=function(e){return void 0!==e.children?o(e,s):o(e,a)},r.stringify_loop=o},{"./evaluate":3,"./grammerAST":4}]},{},[2])(2)});
// @license-end