/*! For license information please see main.js.LICENSE.txt */ (()=>{var t={885:t=>{function e(t){"function"!=typeof t&&(t=e.defunct);var i=[],n=[],s=0;function a(){for(var t=[],e=0,i=this.state,s=this.index,a=this.input,r=0,o=n.length;r=0||i%2&&1===d&&!c[0]){var u=l.pattern;u.lastIndex=s;var h=u.exec(a);if(h&&h.index===s){var f=t.push({result:h,action:l.action,length:h[0].length});for(l.global&&(e=f);--f>e;){var p=f-1;if(t[f].length>t[p].length){var g=t[f];t[f]=t[p],t[p]=g}}}}}return t}this.state=0,this.index=0,this.input="",this.addRule=function(t,e,i){var s=t.global;if(!s){var a="g";t.multiline&&(a+="m"),t.ignoreCase&&(a+="i"),t=new RegExp(t.source,a)}return"[object Array]"!==Object.prototype.toString.call(i)&&(i=[0]),n.push({pattern:t,global:s,action:e,start:i}),this},this.setInput=function(t){return s=0,this.state=0,this.index=0,i.length=0,this.input=t,this},this.lex=function(){if(i.length)return i.shift();for(this.reject=!0;this.index<=this.input.length;){for(var e=a.call(this).splice(s),n=this.index;e.length&&this.reject;){var r=e.shift(),o=r.result,l=r.length;this.index+=l,this.reject=!1,s++;var c=r.action.apply(this,o);if(this.reject)this.index=o.index;else if(void 0!==c)return"[object Array]"===Object.prototype.toString.call(c)&&(i=c.slice(1),c=c[0]),l&&(s=0),c}var d=this.input;if(n{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";function t(t,e,i,n){return new(i||(i=Promise))((function(s,a){function r(t){try{l(n.next(t))}catch(t){a(t)}}function o(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}l((n=n.apply(t,e||[])).next())}))}i.r(n),i.d(n,{default:()=>ie}),Object.create,Object.create;const e=require("obsidian");var s=i(885),a=i.n(s),r={prefix:"fas",iconName:"dice",icon:[640,512,[],"f522","M592 192H473.26c12.69 29.59 7.12 65.2-17 89.32L320 417.58V464c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48V240c0-26.51-21.49-48-48-48zM480 376c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm-46.37-186.7L258.7 14.37c-19.16-19.16-50.23-19.16-69.39 0L14.37 189.3c-19.16 19.16-19.16 50.23 0 69.39L189.3 433.63c19.16 19.16 50.23 19.16 69.39 0L433.63 258.7c19.16-19.17 19.16-50.24 0-69.4zM96 248c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm128 128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm0-128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm0-128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm128 128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"]},o={prefix:"far",iconName:"copy",icon:[448,512,[],"f0c5","M433.941 65.941l-51.882-51.882A48 48 0 0 0 348.118 0H176c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48v-48h80c26.51 0 48-21.49 48-48V99.882a48 48 0 0 0-14.059-33.941zM266 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h74v224c0 26.51 21.49 48 48 48h96v42a6 6 0 0 1-6 6zm128-96H182a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h106v88c0 13.255 10.745 24 24 24h88v202a6 6 0 0 1-6 6zm6-256h-64V48h9.632c1.591 0 3.117.632 4.243 1.757l48.368 48.368a6 6 0 0 1 1.757 4.243V112z"]};function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function c(t,e){for(var i=0;i0;)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[62*Math.random()|0];return e}function it(t){return"".concat(t).replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")}function nt(t){return Object.keys(t||{}).reduce((function(e,i){return e+"".concat(i,": ").concat(t[i],";")}),"")}function st(t){return t.size!==tt.size||t.x!==tt.x||t.y!==tt.y||t.rotate!==tt.rotate||t.flipX||t.flipY}function at(t){var e=t.transform,i=t.containerWidth,n=t.iconWidth,s={transform:"translate(".concat(i/2," 256)")},a="translate(".concat(32*e.x,", ").concat(32*e.y,") "),r="scale(".concat(e.size/16*(e.flipX?-1:1),", ").concat(e.size/16*(e.flipY?-1:1),") "),o="rotate(".concat(e.rotate," 0 0)");return{outer:s,inner:{transform:"".concat(a," ").concat(r," ").concat(o)},path:{transform:"translate(".concat(n/2*-1," -256)")}}}var rt={x:0,y:0,width:"100%",height:"100%"};function ot(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t.attributes&&(t.attributes.fill||e)&&(t.attributes.fill="black"),t}function lt(t){var e=t.icons,i=e.main,n=e.mask,s=t.prefix,a=t.iconName,r=t.transform,o=t.symbol,l=t.title,c=t.maskId,d=t.titleId,h=t.extra,f=t.watchable,p=void 0!==f&&f,g=n.found?n:i,m=g.width,v=g.height,y="fak"===s,w=y?"":"fa-w-".concat(Math.ceil(m/v*16)),b=[M.replacementClass,a?"".concat(M.familyPrefix,"-").concat(a):"",w].filter((function(t){return-1===h.classes.indexOf(t)})).filter((function(t){return""!==t||!!t})).concat(h.classes).join(" "),x={children:[],attributes:u({},h.attributes,{"data-prefix":s,"data-icon":a,class:b,role:h.attributes.role||"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 ".concat(m," ").concat(v)})},k=y&&!~h.classes.indexOf("fa-fw")?{width:"".concat(m/v*16*.0625,"em")}:{};p&&(x.attributes["data-fa-i2svg"]=""),l&&x.children.push({tag:"title",attributes:{id:x.attributes["aria-labelledby"]||"title-".concat(d||et())},children:[l]});var E=u({},x,{prefix:s,iconName:a,main:i,mask:n,maskId:c,transform:r,symbol:o,styles:u({},k,h.styles)}),C=n.found&&i.found?function(t){var e,i=t.children,n=t.attributes,s=t.main,a=t.mask,r=t.maskId,o=t.transform,l=s.width,c=s.icon,d=a.width,h=a.icon,f=at({transform:o,containerWidth:d,iconWidth:l}),p={tag:"rect",attributes:u({},rt,{fill:"white"})},g=c.children?{children:c.children.map(ot)}:{},m={tag:"g",attributes:u({},f.inner),children:[ot(u({tag:c.tag,attributes:u({},c.attributes,f.path)},g))]},v={tag:"g",attributes:u({},f.outer),children:[m]},y="mask-".concat(r||et()),w="clip-".concat(r||et()),b={tag:"mask",attributes:u({},rt,{id:y,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse"}),children:[p,v]},x={tag:"defs",children:[{tag:"clipPath",attributes:{id:w},children:(e=h,"g"===e.tag?e.children:[e])},b]};return i.push(x,{tag:"rect",attributes:u({fill:"currentColor","clip-path":"url(#".concat(w,")"),mask:"url(#".concat(y,")")},rt)}),{children:i,attributes:n}}(E):function(t){var e=t.children,i=t.attributes,n=t.main,s=t.transform,a=nt(t.styles);if(a.length>0&&(i.style=a),st(s)){var r=at({transform:s,containerWidth:n.width,iconWidth:n.width});e.push({tag:"g",attributes:u({},r.outer),children:[{tag:"g",attributes:u({},r.inner),children:[{tag:n.icon.tag,children:n.icon.children,attributes:u({},n.icon.attributes,r.path)}]}]})}else e.push(n.icon);return{children:e,attributes:i}}(E),S=C.children,R=C.attributes;return E.children=S,E.attributes=R,o?function(t){var e=t.prefix,i=t.iconName,n=t.children,s=t.attributes,a=t.symbol;return[{tag:"svg",attributes:{style:"display: none;"},children:[{tag:"symbol",attributes:u({},s,{id:!0===a?"".concat(e,"-").concat(M.familyPrefix,"-").concat(i):a}),children:n}]}]}(E):function(t){var e=t.children,i=t.main,n=t.mask,s=t.attributes,a=t.styles,r=t.transform;if(st(r)&&i.found&&!n.found){var o={x:i.width/i.height/2,y:.5};s.style=nt(u({},a,{"transform-origin":"".concat(o.x+r.x/16,"em ").concat(o.y+r.y/16,"em")}))}return[{tag:"svg",attributes:s,children:e}]}(E)}var ct=(M.measurePerformance&&x&&x.mark&&x.measure,function(t,e,i,n){var s,a,r,o=Object.keys(t),l=o.length,c=void 0!==n?function(t,e){return function(i,n,s,a){return t.call(e,i,n,s,a)}}(e,n):e;for(void 0===i?(s=1,r=t[o[0]]):(s=0,r=i);s2&&void 0!==arguments[2]?arguments[2]:{},n=i.skipHooks,s=void 0!==n&&n,a=Object.keys(e).reduce((function(t,i){var n=e[i];return n.icon?t[n.iconName]=n.icon:t[i]=n,t}),{});"function"!=typeof N.hooks.addPack||s?N.styles[t]=u({},N.styles[t]||{},a):N.hooks.addPack(t,a),"fas"===t&&dt("fa",e)}var ut=N.styles,ht=N.shims,ft=function(){var t=function(t){return ct(ut,(function(e,i,n){return e[n]=ct(i,t,{}),e}),{})};t((function(t,e,i){return e[3]&&(t[e[3]]=i),t})),t((function(t,e,i){var n=e[2];return t[i]=i,n.forEach((function(e){t[e]=i})),t}));var e="far"in ut;ct(ht,(function(t,i){var n=i[0],s=i[1],a=i[2];return"far"!==s||e||(s="fas"),t[n]={prefix:s,iconName:a},t}),{})};function pt(t,e,i){if(t&&t[e]&&t[e][i])return{prefix:e,iconName:i,icon:t[e][i]}}function gt(t){var e=t.tag,i=t.attributes,n=void 0===i?{}:i,s=t.children,a=void 0===s?[]:s;return"string"==typeof t?it(t):"<".concat(e," ").concat(function(t){return Object.keys(t||{}).reduce((function(e,i){return e+"".concat(i,'="').concat(it(t[i]),'" ')}),"").trim()}(n),">").concat(a.map(gt).join(""),"")}function mt(t){this.name="MissingIcon",this.message=t||"Icon unavailable",this.stack=(new Error).stack}ft(),N.styles,mt.prototype=Object.create(Error.prototype),mt.prototype.constructor=mt;var vt={fill:"currentColor"},yt={attributeType:"XML",repeatCount:"indefinite",dur:"2s"},wt=(u({},vt,{d:"M156.5,447.7l-12.6,29.5c-18.7-9.5-35.9-21.2-51.5-34.9l22.7-22.7C127.6,430.5,141.5,440,156.5,447.7z M40.6,272H8.5 c1.4,21.2,5.4,41.7,11.7,61.1L50,321.2C45.1,305.5,41.8,289,40.6,272z M40.6,240c1.4-18.8,5.2-37,11.1-54.1l-29.5-12.6 C14.7,194.3,10,216.7,8.5,240H40.6z M64.3,156.5c7.8-14.9,17.2-28.8,28.1-41.5L69.7,92.3c-13.7,15.6-25.5,32.8-34.9,51.5 L64.3,156.5z M397,419.6c-13.9,12-29.4,22.3-46.1,30.4l11.9,29.8c20.7-9.9,39.8-22.6,56.9-37.6L397,419.6z M115,92.4 c13.9-12,29.4-22.3,46.1-30.4l-11.9-29.8c-20.7,9.9-39.8,22.6-56.8,37.6L115,92.4z M447.7,355.5c-7.8,14.9-17.2,28.8-28.1,41.5 l22.7,22.7c13.7-15.6,25.5-32.9,34.9-51.5L447.7,355.5z M471.4,272c-1.4,18.8-5.2,37-11.1,54.1l29.5,12.6 c7.5-21.1,12.2-43.5,13.6-66.8H471.4z M321.2,462c-15.7,5-32.2,8.2-49.2,9.4v32.1c21.2-1.4,41.7-5.4,61.1-11.7L321.2,462z M240,471.4c-18.8-1.4-37-5.2-54.1-11.1l-12.6,29.5c21.1,7.5,43.5,12.2,66.8,13.6V471.4z M462,190.8c5,15.7,8.2,32.2,9.4,49.2h32.1 c-1.4-21.2-5.4-41.7-11.7-61.1L462,190.8z M92.4,397c-12-13.9-22.3-29.4-30.4-46.1l-29.8,11.9c9.9,20.7,22.6,39.8,37.6,56.9 L92.4,397z M272,40.6c18.8,1.4,36.9,5.2,54.1,11.1l12.6-29.5C317.7,14.7,295.3,10,272,8.5V40.6z M190.8,50 c15.7-5,32.2-8.2,49.2-9.4V8.5c-21.2,1.4-41.7,5.4-61.1,11.7L190.8,50z M442.3,92.3L419.6,115c12,13.9,22.3,29.4,30.5,46.1 l29.8-11.9C470,128.5,457.3,109.4,442.3,92.3z M397,92.4l22.7-22.7c-15.6-13.7-32.8-25.5-51.5-34.9l-12.6,29.5 C370.4,72.1,384.4,81.5,397,92.4z"}),u({},yt,{attributeName:"opacity"}));function bt(t){var e=t[0],i=t[1],n=h(t.slice(4),1)[0];return{found:!0,width:e,height:i,icon:Array.isArray(n)?{tag:"g",attributes:{class:"".concat(M.familyPrefix,"-").concat(R.GROUP)},children:[{tag:"path",attributes:{class:"".concat(M.familyPrefix,"-").concat(R.SECONDARY),fill:"currentColor",d:n[0]}},{tag:"path",attributes:{class:"".concat(M.familyPrefix,"-").concat(R.PRIMARY),fill:"currentColor",d:n[1]}}]}:{tag:"path",attributes:{fill:"currentColor",d:n}}}}u({},vt,{cx:"256",cy:"364",r:"28"}),u({},yt,{attributeName:"r",values:"28;14;28;28;14;28;"}),u({},wt,{values:"1;0;1;1;0;1;"}),u({},vt,{opacity:"1",d:"M263.7,312h-16c-6.6,0-12-5.4-12-12c0-71,77.4-63.9,77.4-107.8c0-20-17.8-40.2-57.4-40.2c-29.1,0-44.3,9.6-59.2,28.7 c-3.9,5-11.1,6-16.2,2.4l-13.1-9.2c-5.6-3.9-6.9-11.8-2.6-17.2c21.2-27.2,46.4-44.7,91.2-44.7c52.3,0,97.4,29.8,97.4,80.2 c0,67.6-77.4,63.5-77.4,107.8C275.7,306.6,270.3,312,263.7,312z"}),u({},wt,{values:"1;0;0;0;0;1;"}),u({},vt,{opacity:"0",d:"M232.5,134.5l7,168c0.3,6.4,5.6,11.5,12,11.5h9c6.4,0,11.7-5.1,12-11.5l7-168c0.3-6.8-5.2-12.5-12-12.5h-23 C237.7,122,232.2,127.7,232.5,134.5z"}),u({},wt,{values:"0;0;1;1;0;0;"}),N.styles,N.styles;var xt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.definitions={}}var e,i;return e=t,i=[{key:"add",value:function(){for(var t=this,e=arguments.length,i=new Array(e),n=0;n-1;s--){var a=i[s],r=(a.tagName||"").toUpperCase();["STYLE","LINK"].indexOf(r)>-1&&(n=a)}b.head.insertBefore(e,n)}}(function(){var t="fa",e=E,i=M.familyPrefix,n=M.replacementClass,s='svg:not(:root).svg-inline--fa {\n overflow: visible;\n}\n\n.svg-inline--fa {\n display: inline-block;\n font-size: inherit;\n height: 1em;\n overflow: visible;\n vertical-align: -0.125em;\n}\n.svg-inline--fa.fa-lg {\n vertical-align: -0.225em;\n}\n.svg-inline--fa.fa-w-1 {\n width: 0.0625em;\n}\n.svg-inline--fa.fa-w-2 {\n width: 0.125em;\n}\n.svg-inline--fa.fa-w-3 {\n width: 0.1875em;\n}\n.svg-inline--fa.fa-w-4 {\n width: 0.25em;\n}\n.svg-inline--fa.fa-w-5 {\n width: 0.3125em;\n}\n.svg-inline--fa.fa-w-6 {\n width: 0.375em;\n}\n.svg-inline--fa.fa-w-7 {\n width: 0.4375em;\n}\n.svg-inline--fa.fa-w-8 {\n width: 0.5em;\n}\n.svg-inline--fa.fa-w-9 {\n width: 0.5625em;\n}\n.svg-inline--fa.fa-w-10 {\n width: 0.625em;\n}\n.svg-inline--fa.fa-w-11 {\n width: 0.6875em;\n}\n.svg-inline--fa.fa-w-12 {\n width: 0.75em;\n}\n.svg-inline--fa.fa-w-13 {\n width: 0.8125em;\n}\n.svg-inline--fa.fa-w-14 {\n width: 0.875em;\n}\n.svg-inline--fa.fa-w-15 {\n width: 0.9375em;\n}\n.svg-inline--fa.fa-w-16 {\n width: 1em;\n}\n.svg-inline--fa.fa-w-17 {\n width: 1.0625em;\n}\n.svg-inline--fa.fa-w-18 {\n width: 1.125em;\n}\n.svg-inline--fa.fa-w-19 {\n width: 1.1875em;\n}\n.svg-inline--fa.fa-w-20 {\n width: 1.25em;\n}\n.svg-inline--fa.fa-pull-left {\n margin-right: 0.3em;\n width: auto;\n}\n.svg-inline--fa.fa-pull-right {\n margin-left: 0.3em;\n width: auto;\n}\n.svg-inline--fa.fa-border {\n height: 1.5em;\n}\n.svg-inline--fa.fa-li {\n width: 2em;\n}\n.svg-inline--fa.fa-fw {\n width: 1.25em;\n}\n\n.fa-layers svg.svg-inline--fa {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.fa-layers {\n display: inline-block;\n height: 1em;\n position: relative;\n text-align: center;\n vertical-align: -0.125em;\n width: 1em;\n}\n.fa-layers svg.svg-inline--fa {\n -webkit-transform-origin: center center;\n transform-origin: center center;\n}\n\n.fa-layers-counter, .fa-layers-text {\n display: inline-block;\n position: absolute;\n text-align: center;\n}\n\n.fa-layers-text {\n left: 50%;\n top: 50%;\n -webkit-transform: translate(-50%, -50%);\n transform: translate(-50%, -50%);\n -webkit-transform-origin: center center;\n transform-origin: center center;\n}\n\n.fa-layers-counter {\n background-color: #ff253a;\n border-radius: 1em;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n color: #fff;\n height: 1.5em;\n line-height: 1;\n max-width: 5em;\n min-width: 1.5em;\n overflow: hidden;\n padding: 0.25em;\n right: 0;\n text-overflow: ellipsis;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right;\n}\n\n.fa-layers-bottom-right {\n bottom: 0;\n right: 0;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom right;\n transform-origin: bottom right;\n}\n\n.fa-layers-bottom-left {\n bottom: 0;\n left: 0;\n right: auto;\n top: auto;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: bottom left;\n transform-origin: bottom left;\n}\n\n.fa-layers-top-right {\n right: 0;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top right;\n transform-origin: top right;\n}\n\n.fa-layers-top-left {\n left: 0;\n right: auto;\n top: 0;\n -webkit-transform: scale(0.25);\n transform: scale(0.25);\n -webkit-transform-origin: top left;\n transform-origin: top left;\n}\n\n.fa-lg {\n font-size: 1.3333333333em;\n line-height: 0.75em;\n vertical-align: -0.0667em;\n}\n\n.fa-xs {\n font-size: 0.75em;\n}\n\n.fa-sm {\n font-size: 0.875em;\n}\n\n.fa-1x {\n font-size: 1em;\n}\n\n.fa-2x {\n font-size: 2em;\n}\n\n.fa-3x {\n font-size: 3em;\n}\n\n.fa-4x {\n font-size: 4em;\n}\n\n.fa-5x {\n font-size: 5em;\n}\n\n.fa-6x {\n font-size: 6em;\n}\n\n.fa-7x {\n font-size: 7em;\n}\n\n.fa-8x {\n font-size: 8em;\n}\n\n.fa-9x {\n font-size: 9em;\n}\n\n.fa-10x {\n font-size: 10em;\n}\n\n.fa-fw {\n text-align: center;\n width: 1.25em;\n}\n\n.fa-ul {\n list-style-type: none;\n margin-left: 2.5em;\n padding-left: 0;\n}\n.fa-ul > li {\n position: relative;\n}\n\n.fa-li {\n left: -2em;\n position: absolute;\n text-align: center;\n width: 2em;\n line-height: inherit;\n}\n\n.fa-border {\n border: solid 0.08em #eee;\n border-radius: 0.1em;\n padding: 0.2em 0.25em 0.15em;\n}\n\n.fa-pull-left {\n float: left;\n}\n\n.fa-pull-right {\n float: right;\n}\n\n.fa.fa-pull-left,\n.fas.fa-pull-left,\n.far.fa-pull-left,\n.fal.fa-pull-left,\n.fab.fa-pull-left {\n margin-right: 0.3em;\n}\n.fa.fa-pull-right,\n.fas.fa-pull-right,\n.far.fa-pull-right,\n.fal.fa-pull-right,\n.fab.fa-pull-right {\n margin-left: 0.3em;\n}\n\n.fa-spin {\n -webkit-animation: fa-spin 2s infinite linear;\n animation: fa-spin 2s infinite linear;\n}\n\n.fa-pulse {\n -webkit-animation: fa-spin 1s infinite steps(8);\n animation: fa-spin 1s infinite steps(8);\n}\n\n@-webkit-keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes fa-spin {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n.fa-rotate-90 {\n -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";\n -webkit-transform: rotate(90deg);\n transform: rotate(90deg);\n}\n\n.fa-rotate-180 {\n -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n}\n\n.fa-rotate-270 {\n -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";\n -webkit-transform: rotate(270deg);\n transform: rotate(270deg);\n}\n\n.fa-flip-horizontal {\n -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";\n -webkit-transform: scale(-1, 1);\n transform: scale(-1, 1);\n}\n\n.fa-flip-vertical {\n -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";\n -webkit-transform: scale(1, -1);\n transform: scale(1, -1);\n}\n\n.fa-flip-both, .fa-flip-horizontal.fa-flip-vertical {\n -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";\n -webkit-transform: scale(-1, -1);\n transform: scale(-1, -1);\n}\n\n:root .fa-rotate-90,\n:root .fa-rotate-180,\n:root .fa-rotate-270,\n:root .fa-flip-horizontal,\n:root .fa-flip-vertical,\n:root .fa-flip-both {\n -webkit-filter: none;\n filter: none;\n}\n\n.fa-stack {\n display: inline-block;\n height: 2em;\n position: relative;\n width: 2.5em;\n}\n\n.fa-stack-1x,\n.fa-stack-2x {\n bottom: 0;\n left: 0;\n margin: auto;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.svg-inline--fa.fa-stack-1x {\n height: 1em;\n width: 1.25em;\n}\n.svg-inline--fa.fa-stack-2x {\n height: 2em;\n width: 2.5em;\n}\n\n.fa-inverse {\n color: #fff;\n}\n\n.sr-only {\n border: 0;\n clip: rect(0, 0, 0, 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n}\n\n.sr-only-focusable:active, .sr-only-focusable:focus {\n clip: auto;\n height: auto;\n margin: 0;\n overflow: visible;\n position: static;\n width: auto;\n}\n\n.svg-inline--fa .fa-primary {\n fill: var(--fa-primary-color, currentColor);\n opacity: 1;\n opacity: var(--fa-primary-opacity, 1);\n}\n\n.svg-inline--fa .fa-secondary {\n fill: var(--fa-secondary-color, currentColor);\n opacity: 0.4;\n opacity: var(--fa-secondary-opacity, 0.4);\n}\n\n.svg-inline--fa.fa-swap-opacity .fa-primary {\n opacity: 0.4;\n opacity: var(--fa-secondary-opacity, 0.4);\n}\n\n.svg-inline--fa.fa-swap-opacity .fa-secondary {\n opacity: 1;\n opacity: var(--fa-primary-opacity, 1);\n}\n\n.svg-inline--fa mask .fa-primary,\n.svg-inline--fa mask .fa-secondary {\n fill: black;\n}\n\n.fad.fa-inverse {\n color: #fff;\n}';if(i!==t||n!==e){var a=new RegExp("\\.".concat(t,"\\-"),"g"),r=new RegExp("\\--".concat(t,"\\-"),"g"),o=new RegExp("\\.".concat(e),"g");s=s.replace(a,".".concat(i,"-")).replace(r,"--".concat(i,"-")).replace(o,".".concat(n))}return s}()),Tt=!0)}function Et(t,e){return Object.defineProperty(t,"abstract",{get:e}),Object.defineProperty(t,"html",{get:function(){return t.abstract.map((function(t){return gt(t)}))}}),Object.defineProperty(t,"node",{get:function(){if(k){var e=b.createElement("div");return e.innerHTML=t.html,e.children}}}),t}function Ct(t){var e=t.prefix,i=void 0===e?"fa":e,n=t.iconName;if(n)return pt(Rt.definitions,i,n)||pt(N.styles,i,n)}var St,Rt=new xt,Tt=!1,_t=(St=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.transform,n=void 0===i?tt:i,s=e.symbol,a=void 0!==s&&s,r=e.mask,o=void 0===r?null:r,l=e.maskId,c=void 0===l?null:l,d=e.title,h=void 0===d?null:d,f=e.titleId,p=void 0===f?null:f,g=e.classes,m=void 0===g?[]:g,v=e.attributes,y=void 0===v?{}:v,w=e.styles,b=void 0===w?{}:w;if(t){var x=t.prefix,k=t.iconName,E=t.icon;return Et(u({type:"icon"},t),(function(){return kt(),M.autoA11y&&(h?y["aria-labelledby"]="".concat(M.replacementClass,"-title-").concat(p||et()):(y["aria-hidden"]="true",y.focusable="false")),lt({icons:{main:bt(E),mask:o?bt(o.icon):{found:!1,width:null,height:null,icon:{}}},prefix:x,iconName:k,transform:u({},tt,n),symbol:a,title:h,maskId:c,titleId:p,extra:{attributes:y,styles:b,classes:m}})}))}},function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=(t||{}).icon?t:Ct(t||{}),n=e.mask;return n&&(n=(n||{}).icon?n:Ct(n||{})),St(i,u({},e,{mask:n}))});class Mt{constructor(t){this.table=t}parse(t){for(var e=t.length,i=this.table,n=[],s=[],a=0;ac||l===c&&"right"===o.associativity)break;n.push(s.shift())}s.unshift(d)}else n.push(d)}for(;s.length;){var d;if("("===(d=s.shift()).data)throw new Error("Mismatched parentheses.");n.push(d)}return n}}const Ot=/(?:(?\d+)[Dd])?#(?[\p{Letter}\p{Emoji_Presentation}\w/-]+)(?:\|(?[\+-]))?(?:\|(?[^\+-]+))?/u,Nt=/(?:(?\d+)[Dd])?\[\[(?[\s\S]+?)#?\^(?[\s\S]+?)\]\]\|?(?
[\s\S]+)?/,At=/(?:(?\d+)[Dd])?\[\[(?[\s\S]+)\]\]\|?(?[\s\S]+)?/,Dt=/[\(\^\+\-\*\/\)]/,jt=/(?(?\d+)(?:[Dd]?\[?(?:-?\d+\s?,)?\s?(?:-?\d+|%|F)\]?)?)(?(?:(?:=|=!|<|>|<=|>=|=<|=>|\-=|=\-)\d+)*)?/,Ft=/(?\d+)?[Dd](?\[?(?:-?\d+\s?,)?\s?(?:-?\d+|%|F)\]?)?(?(?:(?:=|=!|<|>|<=|>=|=<|=>|\-=|=\-)\d+)*)?/,It=/(?:(?=|=!|<|>|<=|>=|=<|=>|\-=|=\-)(?\d+))/g,Pt="dice-roller-icon",Lt="dice-roller-copy";function zt(t,e,i){[...t].slice(e).reverse().forEach((([e,i])=>{t.set(e+1,i)})),t.set(e,i)}class qt extends e.Events{constructor(t,i,n){super(),this.plugin=t,this.original=i,this.lexemes=n,this.containerEl=createDiv({cls:"dice-roller",attr:{"aria-label-position":"top","data-dice":this.original}}),this.resultEl=this.containerEl.createDiv("dice-roller-result");const s=this.containerEl.createDiv({cls:"dice-roller-button"});(0,e.setIcon)(s,Pt),this.containerEl.onclick=this.onClick.bind(this),s.onclick=this.onClick.bind(this)}setTooltip(){this.plugin.data.displayResultsInline||this.containerEl.setAttrs({"aria-label":this.tooltip})}getRandomBetween(t,e){return Math.floor(Math.random()*(e-t+1))+t}render(){return t(this,void 0,void 0,(function*(){this.setTooltip(),yield this.build()}))}get inlineText(){return`${this.tooltip.split("\n").join(" -> ")} -> `}onClick(e){var i;return t(this,void 0,void 0,(function*(){e.stopPropagation(),e.stopImmediatePropagation(),(null===(i=window.getSelection())||void 0===i?void 0:i.isCollapsed)&&(yield this.roll())}))}}class Bt extends qt{}class $t extends Bt{constructor(t,e,i,n){super(t,e,[i]),this.plugin=t,this.original=e,this.lexeme=i,this.source=n,this.getPath(),this.getFile()}getFile(){return t(this,void 0,void 0,(function*(){if(this.file=this.plugin.app.metadataCache.getFirstLinkpathDest(this.path,this.source),!(this.file&&this.file instanceof e.TFile))throw new Error("Could not load file.");yield this.load(),this.registerFileWatcher()}))}registerFileWatcher(){this.plugin.registerEvent(this.plugin.app.vault.on("modify",(e=>t(this,void 0,void 0,(function*(){e===this.file&&(yield this.getOptions())})))))}}class Vt{constructor(t,e={original:t,conditionals:[],type:"dice",data:t}){var i;if(this.lexeme=e,this.modifiers=new Map,this.modifiersAllowed=!0,this.static=!1,this.conditions=[],!/(\-?\d+)[dD]?(\d+|%|\[\d+,\s?\d+\])?/.test(t))throw new Error("Non parseable dice string passed to DiceRoll.");this.dice=t.split(" ").join(""),/^-?\d+$/.test(this.dice)&&(this.static=!0,this.modifiersAllowed=!1);let[,n,s=null,a=1]=this.dice.match(/(\-?\d+)[dD]\[?(?:(-?\d+)\s?,)?\s?(-?\d+|%|F)\]?/)||[,1,null,1];this.multiplier=n<0?-1:1,this.rolls=Math.abs(Number(n))||1,Number(a)<0&&!s&&(s=-1),"%"===a&&(a=100),"F"===a&&(a=1,s=-1),Number(a)[e,{usable:!0,value:t,display:`${t}`,modifiers:new Set}])))}get text(){return`${this.result}`}get result(){return this.static?Number(this.dice):[...this.results].map((([,{usable:t,value:e}])=>t?e:0)).reduce(((t,e)=>t+e),0)}get display(){return this.static?`${this.result}`:`[${[...this.results].map((([,{modifiers:t,display:e}])=>`${e}${[...t].join("")}`)).join(", ")}]`}keepLow(t=1){this.modifiersAllowed?[...this.results].sort(((t,e)=>t[1].value-e[1].value)).slice(t-this.results.size).forEach((([t])=>{const e=this.results.get(t);e.usable=!1,e.modifiers.add("d"),this.results.set(t,Object.assign({},e))})):new e.Notice("Modifiers are only allowed on dice rolls.")}keepHigh(t=1){this.modifiersAllowed?[...this.results].sort(((t,e)=>e[1].value-t[1].value)).slice(t).forEach((([t])=>{const e=this.results.get(t);e.usable=!1,e.modifiers.add("d"),this.results.set(t,Object.assign({},e))})):new e.Notice("Modifiers are only allowed on dice rolls.")}reroll(t,i){if(!this.modifiersAllowed)return void new e.Notice("Modifiers are only allowed on dice rolls.");i.length||i.push({operator:"=",comparer:this.faces.min});let n=0,s=[...this.results].filter((([,{value:t}])=>this.checkCondition(t,i)));for(;nthis.checkCondition(t,i))).length>0;)n++,s.map((([,t])=>{t.modifiers.add("r"),t.value=this.getRandomBetween(this.faces.min,this.faces.max)}));s.forEach((([t,e])=>{this.results.set(t,e)}))}explodeAndCombine(t,i){if(!this.modifiersAllowed)return void new e.Notice("Modifiers are only allowed on dice rolls.");i.length||i.push({operator:"=",comparer:this.faces.max});let n=0;[...this.results].filter((([,{value:t}])=>this.checkCondition(t,i))).forEach((([e,s])=>{let a=this.getRandomBetween(this.faces.min,this.faces.max);for(n++,s.modifiers.add("!"),s.value+=a,s.display=`${s.value}`,this.results.set(e,s);nthis.multiplier*this.getRandomBetween(this.faces.min,this.faces.max)))}roll(){var t;const e=this._roll();this.results=new Map([...e].map(((t,e)=>[e,{usable:!0,value:t,display:`${t}`,modifiers:new Set}])));for(let[t,e]of this.modifiers)this.applyModifier(t,e);return(null===(t=this.conditions)||void 0===t?void 0:t.length)&&this.applyConditions(),e}applyConditions(){for(let[t,e]of this.results){const t=this.conditions.find((({operator:t})=>"-="===t||"=-"===t));t&&e.value===t.comparer?(e.value=-1,e.modifiers.add("-")):this.checkCondition(e.value,this.conditions)?(e.modifiers.add("*"),e.value=1):e.usable=!1}}applyModifier(t,e){switch(t){case"kh":this.keepHigh(e.data);break;case"kl":this.keepLow(e.data);break;case"!":this.explode(e.data,e.conditionals);break;case"!!":this.explodeAndCombine(e.data,e.conditionals);break;case"r":this.reroll(e.data,e.conditionals)}}checkCondition(t,e){return e&&e.length?e.some((({operator:e,comparer:i})=>{if(Number.isNaN(t)||Number.isNaN(i))return!1;let n=!1;switch(e){case"=":n=t===i;break;case"!=":case"=!":n=t!==i;break;case"<":n=t":n=t>i;break;case">=":n=t>=i}return n})):t}getRandomBetween(t,e){return Math.floor(Math.random()*(e-t+1))+t}}class Ht extends Vt{constructor(t,e){super("3d6",e),this.lexeme=e,this.dice=t}get doubles(){return new Set([...this.results].map((([,{usable:t,value:e}])=>t?e:0))).size<3}get result(){return this.static?Number(this.dice):[...this.results].map((([,{usable:t,value:e}])=>t?e:0)).reduce(((t,e)=>t+e),0)}get display(){let t=[];for(let e of this.results)0==e[0]&&this.doubles?t.push(`${e[1].value}S`):t.push(`${e[1].value}`);return`[${t.join(", ")}]`}}class Zt extends Bt{constructor(t,e,i){super(t,e,i),this.plugin=t,this.original=e,this.lexemes=i,this.stunted="",this.operators={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"^":(t,e)=>Math.pow(t,e)},this.stack=[],this.dice=[]}get resultText(){let t=this.original;return this.dice.forEach((e=>{t=t.replace(e.lexeme.original,e.display)})),t}get tooltip(){return this._tooltip?this._tooltip:`${this.original}\n${this.resultText}`}build(){return t(this,void 0,void 0,(function*(){const t=[this.result.toLocaleString(navigator.language,{maximumFractionDigits:2})];this.plugin.data.displayResultsInline&&t.unshift(this.inlineText),this.resultEl.setText(t.join("")+this.stunted)}))}roll(){return t(this,void 0,void 0,(function*(){let t=0;this.stunted="";for(const e of this.lexemes)switch(e.type){case"+":case"-":case"*":case"/":case"^":case"math":let i=this.stack.pop(),n=this.stack.pop();if(!n){"-"===e.data&&(i=new Vt(`-${i.dice}`,i.lexeme)),this.stack.push(i);continue}i.roll(),i instanceof Ht&&i.doubles&&(this.stunted=` - ${i.results.get(0).value} Stunt Points`),n.roll(),n instanceof Ht&&n.doubles&&(this.stunted=` - ${n.results.get(0).value} Stunt Points`);const s=this.operators[e.data](n.result,i.result);this.stack.push(new Vt(`${s}`,e));break;case"kh":{let i=this.dice[t-1],n=e.data?Number(e.data):1;i.modifiers.set("kh",{data:n,conditionals:[]});break}case"dl":{let i=this.dice[t-1],n=e.data?Number(e.data):1;n=i.results.size-n,i.modifiers.set("kh",{data:n,conditionals:[]});break}case"kl":{let i=this.dice[t-1],n=e.data?Number(e.data):1;i.modifiers.set("kl",{data:n,conditionals:[]});break}case"dh":{let i=this.dice[t-1],n=e.data?Number(e.data):1;n=i.results.size-n,i.modifiers.set("kl",{data:n,conditionals:[]});break}case"!":{let i=this.dice[t-1],n=Number(e.data)||1;i.modifiers.set("!",{data:n,conditionals:e.conditionals});break}case"!!":{let i=this.dice[t-1],n=Number(e.data)||1;i.modifiers.set("!!",{data:n,conditionals:e.conditionals});break}case"r":{let i=this.dice[t-1],n=Number(e.data)||1;i.modifiers.set("r",{data:n,conditionals:e.conditionals});break}case"dice":this.dice[t]||(this.dice[t]=new Vt(e.data,e)),this.stack.push(this.dice[t]),t++;break;case"stunt":this.dice[t]||(this.dice[t]=new Ht(e.original,e)),this.stack.push(this.dice[t]),t++}const e=this.stack.pop();return e.roll(),e instanceof Ht&&e.doubles&&(this.stunted=` - ${e.results.get(0).value} Stunt Points`),this.result=e.result,this._tooltip=null,this.render(),this.trigger("new-result"),this.result}))}toResult(){return{type:"dice",result:this.result,tooltip:this.tooltip}}applyResult(e){return t(this,void 0,void 0,(function*(){"dice"===e.type&&(e.result&&(this.result=e.result),e.tooltip&&(this._tooltip=e.tooltip),yield this.render())}))}}class Wt extends $t{constructor(i,n,s,a,r=!0){super(i,n,s,a),this.plugin=i,this.original=n,this.lexeme=s,this.inline=r,this.containerEl.addClasses(["has-embed","markdown-embed"]),this.resultEl.addClass("internal-embed"),this.resultEl.setAttrs({src:a}),this.copy=this.containerEl.createDiv({cls:"dice-content-copy dice-roller-button no-show",attr:{"aria-label":"Copy Contents"}}),this.copy.addEventListener("click",(i=>{i.stopPropagation(),navigator.clipboard.writeText(this.displayFromCache(...this.results).trim()).then((()=>t(this,void 0,void 0,(function*(){new e.Notice("Result copied to clipboard.")}))))})),(0,e.setIcon)(this.copy,Lt)}get tooltip(){return`${this.original}\n${this.path}`}build(){return t(this,void 0,void 0,(function*(){if(this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.inline&&this.resultEl.createSpan({text:this.inlineText}),this.results&&this.results.length){this.plugin.data.copyContentButton&&this.copy.removeClass("no-show");for(const i of this.results){this.resultEl.onclick=e=>t(this,void 0,void 0,(function*(){(e&&e.getModifierState("Control")||e.getModifierState("Meta"))&&e.stopPropagation()}));const n=this.resultEl.createDiv({cls:"markdown-embed"});if(this.plugin.data.displayResultsInline||n.setAttrs({"aria-label":`${this.file.basename}: ${i.type}`}),i){if(e.MarkdownRenderer.renderMarkdown(this.displayFromCache(i),n.createDiv(),this.source,null),this.plugin.data.copyContentButton&&this.results.length>1){let s=n.createDiv({cls:"dice-content-copy dice-roller-button",attr:{"aria-label":"Copy Contents"}});s.addEventListener("click",(n=>{n.stopPropagation(),navigator.clipboard.writeText(this.displayFromCache(i).trim()).then((()=>t(this,void 0,void 0,(function*(){new e.Notice("Result copied to clipboard.")}))))})),(0,e.setIcon)(s,Lt)}}else n.createDiv({cls:"dice-no-results",text:"No results."})}}else this.resultEl.createDiv({cls:"dice-no-results",text:"No results."})}))}load(){return t(this,void 0,void 0,(function*(){yield this.getOptions()}))}displayFromCache(...t){let e=[];for(let i of t)e.push(this.content.slice(i.position.start.offset,i.position.end.offset));return e.join("\n\n")}getPath(){var t;const{groups:e}=this.lexeme.data.match(At),{roll:i=1,link:n,types:s}=e;if(!n)throw new Error("Could not parse link.");this.rolls=null!==(t=i&&!isNaN(Number(i))&&Number(i))&&void 0!==t?t:1,this.path=n.replace(/(\[|\])/g,""),this.types=null==s?void 0:s.split(",")}getOptions(){return t(this,void 0,void 0,(function*(){if(this.cache=this.plugin.app.metadataCache.getFileCache(this.file),!this.cache||!this.cache.sections)throw new Error("Could not read file cache.");this.content=yield this.plugin.app.vault.cachedRead(this.file),this.options=this.cache.sections.filter((({type:t})=>this.types?this.types.includes(t):!["yaml","thematicBreak"].includes(t))),this.loaded=!0,this.trigger("loaded")}))}roll(){return t(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{if(this.loaded){const e=[...this.options];this.results=[...Array(this.rolls)].map((()=>{let t=e[this.getRandomBetween(0,e.length-1)];return e.splice(e.indexOf(t),1),t})).filter((t=>t)),this.render(),this.trigger("new-result"),t(this.results[0])}else this.on("loaded",(()=>{const e=[...this.options];this.results=[...Array(this.rolls)].map((()=>{let t=e[this.getRandomBetween(0,e.length-1)];return e.splice(e.indexOf(t),1),t})).filter((t=>t)),this.render(),this.trigger("new-result"),t(this.results[0])}))}))}))}toResult(){return{type:"section",result:this.results}}applyResult(e){return t(this,void 0,void 0,(function*(){"section"===e.type&&(e.result&&(this.results=e.result),yield this.render())}))}}class Yt extends Bt{constructor(t,e,i,n){super(t,e,[i]),this.plugin=t,this.original=e,this.lexeme=i,this.source=n,this.loaded=!1,this.containerEl.addClasses(["has-embed","markdown-embed"]);const{roll:s=1,tag:a,collapse:r,types:o}=i.data.match(Ot).groups;this.collapse="-"===r||"+"!==r&&!this.plugin.data.returnAllTags,this.tag=`#${a}`,this.rolls=Number(s),this.types=o,this.getFiles()}get typeText(){var t;return(null===(t=this.types)||void 0===t?void 0:t.length)?`|${this.types}`:""}getFiles(){return t(this,void 0,void 0,(function*(){const t=this.plugin.app.plugins.plugins.dataview.index.tags.invMap.get(this.tag);if(t&&t.delete(this.source),!t||!t.size)throw new Error("No files found with that tag. Is the tag correct?\n\n"+this.tag);const e=Array.from(t).map((t=>`${this.rolls}d[[${t}]]${this.typeText}`));this.results=e.map((t=>new Wt(this.plugin,t,{data:t,original:t,conditionals:null,type:"section"},this.source,!1))),this.loaded=!0,this.trigger("loaded")}))}build(){var e;return t(this,void 0,void 0,(function*(){if(this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.resultEl.createSpan({text:this.inlineText}),this.collapse){this.chosen=null!==(e=this.random)&&void 0!==e?e:this.getRandomBetween(0,this.results.length-1);let t=this.results[this.chosen];this.random=null;const i=this.resultEl.createDiv();i.createEl("h5",{cls:"dice-file-name",text:t.file.basename}),i.appendChild(t.containerEl)}else for(let t of this.results){const e=this.resultEl.createDiv();e.createEl("h5",{cls:"dice-file-name",text:t.file.basename}),e.appendChild(t.containerEl)}}))}roll(){return t(this,void 0,void 0,(function*(){return new Promise(((e,i)=>{this.loaded?(this.results.forEach((e=>t(this,void 0,void 0,(function*(){return yield e.roll()})))),this.render(),this.trigger("new-result"),e(this.result)):this.on("loaded",(()=>{this.results.forEach((e=>t(this,void 0,void 0,(function*(){return yield e.roll()})))),this.render(),this.trigger("new-result"),e(this.result)}))}))}))}get tooltip(){return this.original}toResult(){return{type:"tag",random:this.chosen,result:Object.fromEntries(this.results.map((t=>[t.path,t.toResult()])))}}applyResult(e){return t(this,void 0,void 0,(function*(){if("tag"===e.type){if(e.result)for(let t in e.result){const i=this.results.find((e=>e.path===t));i&&i.applyResult(e.result[t])}e.random&&(this.random=e.random),yield this.render()}}))}}class Ut extends Bt{constructor(t,e,i,n){var s;super(t,e,[i]),this.plugin=t,this.original=e,this.lexeme=i,this.source=n;const{roll:a=1,tag:r}=i.data.match(Ot).groups;this.tag=`#${r}`,this.rolls=null!==(s=a&&!isNaN(Number(a))&&Number(a))&&void 0!==s?s:1,this.getFiles()}get tooltip(){return`${this.original}\n${this.result.basename}`}roll(){return t(this,void 0,void 0,(function*(){return this.result=this.links[this.getRandomBetween(0,this.links.length-1)],yield this.render(),this.trigger("new-result"),this.result}))}build(){return t(this,void 0,void 0,(function*(){this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.resultEl.createSpan({text:this.inlineText});const e=this.resultEl.createEl("a",{cls:"internal-link",text:this.result.basename});e.onclick=e=>t(this,void 0,void 0,(function*(){var t;e.stopPropagation(),this.plugin.app.workspace.openLinkText(this.result.path,null===(t=this.plugin.app.workspace.getActiveFile())||void 0===t?void 0:t.path,!0)})),e.onmouseenter=i=>t(this,void 0,void 0,(function*(){var t;this.plugin.app.workspace.trigger("link-hover",this,e,this.result.path,null===(t=this.plugin.app.workspace.getActiveFile())||void 0===t?void 0:t.path)}))}))}getFiles(){return t(this,void 0,void 0,(function*(){const t=this.plugin.app.plugins.plugins.dataview.index.tags.invMap.get(this.tag);if(t&&t.delete(this.source),!t||!t.size)throw new Error("No files found with that tag. Is the tag correct?\n\n"+this.tag);this.links=Array.from(t).map((t=>this.plugin.app.metadataCache.getFirstLinkpathDest(t,this.source)))}))}toResult(){return{type:"link",result:this.result.path}}applyResult(i){return t(this,void 0,void 0,(function*(){if("link"===i.type){if(i.result){const t=this.plugin.app.vault.getAbstractFileByPath(i.result);t&&t instanceof e.TFile&&(this.result=t)}yield this.render()}}))}}class Xt extends $t{getPath(){var t;const{groups:e}=this.lexeme.data.match(Nt),{roll:i=1,link:n,block:s,header:a}=e;if(!n||!s)throw new Error("Could not parse link.");this.rolls=null!==(t=i&&!isNaN(Number(i))&&Number(i))&&void 0!==t?t:1,this.path=n.replace(/(\[|\])/g,""),this.block=s.replace(/(\^|#)/g,"").trim().toLowerCase(),this.header=a}get tooltip(){return`${this.original}\n${this.path} > ${this.block}${this.header?" | "+this.header:""}`}build(){return t(this,void 0,void 0,(function*(){this.resultEl.empty();const e=[this.result];this.plugin.data.displayResultsInline&&e.unshift(this.inlineText);const i=e.join("").split(/(\[\[(?:[\s\S]+?)\]\])/);for(let e of i)if(/\[\[(?:[\s\S]+?)\]\]/.test(e)){const[,i]=e.match(/\[\[([\s\S]+?)\]\]/),n=this.resultEl.createEl("a",{cls:"internal-link",text:i});n.onmouseover=()=>{var t;this.plugin.app.workspace.trigger("link-hover",this,n,i.replace("^","#^").split("|").shift(),null===(t=this.plugin.app.workspace.getActiveFile())||void 0===t?void 0:t.path)},n.onclick=e=>t(this,void 0,void 0,(function*(){var t;e.stopPropagation(),yield this.plugin.app.workspace.openLinkText(i.replace("^","#^").split(/\|/).shift(),null===(t=this.plugin.app.workspace.getActiveFile())||void 0===t?void 0:t.path,e.getModifierState("Control"))}))}else this.resultEl.createSpan({text:e})}))}roll(){return t(this,void 0,void 0,(function*(){return new Promise((t=>{if(this.loaded){const e=[...this.options];this.result=[...Array(this.rolls)].map((()=>{let t=e[this.getRandomBetween(0,e.length-1)];return e.splice(e.indexOf(t),1),t})).join("||"),this.render(),this.trigger("new-result"),t(this.result)}else this.on("loaded",(()=>{const e=[...this.options];this.result=[...Array(this.rolls)].map((()=>{let t=e[this.getRandomBetween(0,e.length-1)];return e.splice(e.indexOf(t),1),t})).join("||"),this.render(),this.trigger("new-result"),t(this.result)}))}))}))}load(){return t(this,void 0,void 0,(function*(){yield this.getOptions()}))}getOptions(){var e;return t(this,void 0,void 0,(function*(){if(this.cache=this.plugin.app.metadataCache.getFileCache(this.file),!this.cache||!this.cache.blocks||!(this.block in this.cache.blocks))throw new Error(`Could not read file cache. Does the block reference exist?\n\n${this.path} > ${this.block}`);this.position=this.cache.blocks[this.block].position,this.content=null===(e=yield this.plugin.app.vault.cachedRead(this.file))||void 0===e?void 0:e.slice(this.position.start.offset,this.position.end.offset);let t=function(t){const e=t.split("\n"),i=e.map((t=>{var e;return(null!==(e=t.trim().match(Gt))&&void 0!==e?e:[,t.trim()])[1]})),n=i[0].split(Qt),s=[],a=[];for(let t in n){let e=n[t];e.trim().length||(e=t),a.push([e.trim(),[]])}for(let t of e.slice(2)){const e=t.trim().split(Qt).map((t=>t.trim())).filter((t=>t.length));s.push(e.join(" | "));for(let t in e){const i=e[t].trim();i.length&&a[t]&&a[t][1].push(i)}}return{columns:Object.fromEntries(a),rows:s}}(this.content);if(this.header&&t.columns[this.header])this.options=t.columns[this.header];else{if(this.header)throw new Error(`Header ${this.header} was not found in table ${this.path} > ${this.block}.`);this.options=t.rows}this.loaded=!0,this.trigger("loaded")}))}toResult(){return{type:"table",result:this.result}}applyResult(e){return t(this,void 0,void 0,(function*(){"table"===e.type&&(e.result&&(this.result=e.result),yield this.render())}))}}const Gt=/^\|?([\s\S]+?)\|?$/,Qt=/\|/;class Kt extends e.PluginSettingTab{constructor(t,e){super(t,e),this.plugin=e,this.plugin=e}display(){return t(this,void 0,void 0,(function*(){let{containerEl:i}=this;i.empty(),i.addClass("dice-roller-settings"),i.createEl("h2",{text:"Dice Roller Settings"}),new e.Setting(i).setName("Roll All Files for Tags").setDesc("Return a result for each file when rolling tags.").addToggle((e=>{e.setValue(this.plugin.data.returnAllTags),e.onChange((e=>t(this,void 0,void 0,(function*(){this.plugin.data.returnAllTags=e,yield this.plugin.saveSettings()}))))})),new e.Setting(i).setName("Always Return Links for Tags").setDesc("Enables random link rolling with the link parameter. Override by specifying a section type.").addToggle((e=>{e.setValue(this.plugin.data.rollLinksForTags),e.onChange((e=>t(this,void 0,void 0,(function*(){this.plugin.data.rollLinksForTags=e,yield this.plugin.saveSettings()}))))})),new e.Setting(i).setName("Add Copy Button to Section Results").setDesc("Randomly rolled sections will have a copy-content button to easy add result to clipboard.").addToggle((e=>{e.setValue(this.plugin.data.copyContentButton),e.onChange((e=>t(this,void 0,void 0,(function*(){this.plugin.data.copyContentButton=e,yield this.plugin.saveSettings()}))))})),new e.Setting(i).setName("Display Formula With Results").setDesc("Both the formula and the results will both be displayed in preview mode.").addToggle((e=>{e.setValue(this.plugin.data.displayResultsInline),e.onChange((e=>t(this,void 0,void 0,(function*(){this.plugin.data.displayResultsInline=e,yield this.plugin.saveSettings()}))))}));const n=new e.Setting(i).setName("Globally Save Results").setDesc("Dice results will be saved by default. This can be overridden using ").addToggle((e=>{e.setValue(this.plugin.data.persistResults),e.onChange((e=>t(this,void 0,void 0,(function*(){this.plugin.data.persistResults=e,yield this.plugin.saveSettings()}))))}));new e.Setting(i).setName("Default Roll").setDesc("Use this as the number of rolls when it is omitted.").addText((i=>{i.setValue(`${this.plugin.data.defaultRoll}`),i.inputEl.onblur=()=>t(this,void 0,void 0,(function*(){isNaN(Number(i.inputEl.value))&&new e.Notice("The default roll must be a number."),this.plugin.data.defaultRoll=Number(i.inputEl.value),yield this.plugin.saveSettings()}))})),new e.Setting(i).setName("Default Face").setDesc("Use this as the number of faces when it is omitted.").addText((i=>{i.setValue(`${this.plugin.data.defaultFace}`),i.inputEl.onblur=()=>t(this,void 0,void 0,(function*(){isNaN(Number(i.inputEl.value))&&new e.Notice("The default face must be a number."),this.plugin.data.defaultFace=Number(i.inputEl.value),yield this.plugin.saveSettings()}))})),n.descEl.createEl("code",{text:"dice-: formula"}),n.descEl.createEl("p",{text:"Please note that the plugin will attempt to save the result but may not be able to."}),this.additionalContainer=i.createDiv("dice-roller-setting-additional-container"),this.buildFormulaSettings(),i.createDiv("coffee").createEl("a",{href:"https://www.buymeacoffee.com/valentine195"}).createEl("img",{attr:{src:"https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=☕&slug=valentine195&button_colour=e3e7ef&font_colour=262626&font_family=Inter&outline_colour=262626&coffee_colour=ff0000"}})}))}buildFormulaSettings(){this.additionalContainer.empty();const i=this.additionalContainer.createDiv();new e.Setting(i).setName("Add Formula").setDesc("Add a new formula shortcut.").addButton((e=>e.setTooltip("Add Formula").setButtonText("+").onClick((()=>t(this,void 0,void 0,(function*(){const t=yield this.buildFormulaForm(i);t&&(this.plugin.data.formulas[t.alias]=t.formula,this.buildFormulaSettings(),yield this.plugin.saveSettings())}))))));const n=this.additionalContainer.createDiv("additional"),s=this.plugin.data.formulas;for(const[a,r]of Object.entries(s)){const s=new e.Setting(n).setName(a);s.controlEl.createSpan({text:r}),s.addExtraButton((e=>e.setIcon("pencil").setTooltip("Edit").onClick((()=>t(this,void 0,void 0,(function*(){const t=yield this.buildFormulaForm(i,{alias:a,formula:r});t&&(delete this.plugin.data.formulas[a],this.plugin.data.formulas[t.alias]=t.formula,this.buildFormulaSettings(),yield this.plugin.saveSettings())})))))).addExtraButton((e=>e.setIcon("trash").setTooltip("Delete").onClick((()=>t(this,void 0,void 0,(function*(){delete this.plugin.data.formulas[a],yield this.plugin.saveSettings(),this.buildFormulaSettings()}))))))}Object.values(s).length||n.createSpan({text:"Create a formula to see it here!",cls:"no-formulas"})}buildFormulaForm(i,n={alias:null,formula:null}){return t(this,void 0,void 0,(function*(){return new Promise((s=>{const a=i.createDiv("add-new-formula"),r=a.createDiv("formula-data");new e.Setting(r).setName("Alias").addText((t=>{t.setValue(n.alias).onChange((t=>n.alias=t))})),new e.Setting(r).setName("Formula").addText((t=>{t.setValue(n.formula).onChange((t=>n.formula=t))}));const o=a.createDiv("formula-buttons");new e.Setting(o).addButton((e=>e.setCta().setButtonText("Save").onClick((()=>t(this,void 0,void 0,(function*(){a.detach(),s(n)})))))).addExtraButton((t=>t.setIcon("cross").setTooltip("Cancel").onClick((()=>{a.detach(),s(null)}))))}))}))}}const Jt="DICE_ROLLER_VIEW";(0,e.addIcon)("d4",''),(0,e.addIcon)("d6",''),(0,e.addIcon)("d8",''),(0,e.addIcon)("d10",''),(0,e.addIcon)("d12",''),(0,e.addIcon)("d20",''),(0,e.addIcon)("d100",''),(0,e.addIcon)("dice-roller-save",''),(0,e.addIcon)("dice-roller-plus",''),(0,e.addIcon)("dice-roller-minus",'');class te extends e.ItemView{constructor(t,e){super(e),this.plugin=t,this.leaf=e,this.dice=te.DICE(),this.custom="",this.adv=!1,this.dis=!1,this.add=0,this.contentEl.addClass("dice-roller-view")}static DICE(){return{d4:0,d6:0,d8:0,d10:0,d12:0,d20:0,d100:0}}onOpen(){return t(this,void 0,void 0,(function*(){this.display()}))}display(){return t(this,void 0,void 0,(function*(){this.contentEl.empty(),this.gridEl=this.contentEl.createDiv("dice-roller-grid"),this.formulaEl=this.contentEl.createDiv("dice-roller-formula");const t=this.contentEl.createDiv("dice-roller-results-container");t.createEl("h4",{text:"Results"}),this.resultEl=t.createDiv("dice-roller-results"),this.noResultsEl=this.resultEl.createSpan({text:"No results yet! Roll some dice to get started :)"}),this.buildButtons(),this.buildFormula()}))}buildButtons(){this.gridEl.empty();const t=this.gridEl.createDiv("dice-buttons");for(let i in this.dice)new e.ExtraButtonComponent(t.createDiv("dice-button")).setIcon(i).extraSettingsEl.onclick=t=>{let e=t.getModifierState("Shift")?-1:1;this.dice[i]+=e,this.setFormula()};const i=this.gridEl.createDiv("advantage-disadvantage"),n=new e.ButtonComponent(i).setButtonText("ADV").onClick((()=>{this.adv=!this.adv,this.dis=!1,this.adv?(n.setCta(),s.removeCta()):n.removeCta(),this.setFormula()})),s=new e.ButtonComponent(i).setButtonText("DIS").onClick((()=>{this.dis=!this.dis,this.dis?(s.setCta(),n.removeCta()):s.removeCta(),this.adv=!1,this.setFormula()})),a=this.gridEl.createDiv("dice-context").createDiv("add-subtract");new e.ExtraButtonComponent(a).setIcon("dice-roller-minus").onClick((()=>{this.add-=1,r.setValue(`${this.add}`),this.setFormula()}));const r=new e.TextComponent(a).setValue(`${this.add?this.add:""}`).onChange((t=>{isNaN(Number(t))||(this.add=Number(t)),this.setFormula()}));new e.ExtraButtonComponent(a).setIcon("dice-roller-plus").onClick((()=>{this.add+=1,r.setValue(`${this.add}`),this.setFormula()}))}buildFormula(){this.formulaEl.empty(),this.formulaComponent=new e.TextAreaComponent(this.formulaEl).setPlaceholder("Dice Formula"),this.formulaComponent.onChange((0,e.debounce)((e=>t(this,void 0,void 0,(function*(){}))),500,!0)),new e.ButtonComponent(this.formulaEl).setIcon(Pt).setCta().setTooltip("Roll").onClick((()=>t(this,void 0,void 0,(function*(){const t=yield this.plugin.getRoller(this.formulaComponent.inputEl.value,"view");t instanceof Zt?(yield t.roll(),this.addResult(t),this.dice=te.DICE(),this.add=null,this.adv=!1,this.dis=!1,this.buildButtons(),this.setFormula()):new e.Notice("The Dice View only supports dice rolls.")}))))}addResult(i){this.noResultsEl&&this.noResultsEl.detach();const n=createDiv("view-result");n.createSpan({text:i.original}),n.createEl("strong",{text:`${i.result}`,attr:{"aria-label":i.resultText}});const s=n.createDiv("result-context");s.createEl("em",{text:(new Date).toLocaleString()}),new e.ExtraButtonComponent(s).setIcon("trash").onClick((()=>{n.detach(),0===this.resultEl.children.length&&this.resultEl.prepend(this.noResultsEl)})),new e.ExtraButtonComponent(s).setIcon(Lt).setTooltip("Copy Result").onClick((()=>t(this,void 0,void 0,(function*(){yield navigator.clipboard.writeText(`${i.result}`)})))).extraSettingsEl.addClass("dice-content-copy"),this.resultEl.prepend(n)}get formulaString(){const t=[],e=Object.entries(this.dice).filter((([t,e])=>0!=e));if(!e.length)return"";e.sort(((t,e)=>Number(e[0].slice(1))-Number(t[0].slice(1))));const i=e.shift();return t.push(`${i[1]}${i[0]}`),this.adv?t.push("kh"):this.dis&&t.push("dh"),e.length&&t.push(...e.map((([t,e])=>`${e>0?"+":"-"}${Math.abs(e)}${t}`))),this.add&&0!=this.add&&(t.push(this.add>0?"+":"-"),t.push(Math.abs(this.add))),t.join("")}setFormula(){this.formulaComponent.setValue(this.formulaString)}getDisplayText(){return"Dice Roller"}getViewType(){return Jt}getIcon(){return Pt}}String.prototype.matchAll=String.prototype.matchAll||function*(t){const e=t.global?t.flags:t.flags+"g",i=new RegExp(t,e);let n;for(;n=i.exec(this);)yield n};const ee={returnAllTags:!0,rollLinksForTags:!1,copyContentButton:!0,displayResultsInline:!1,formulas:{},persistResults:!1,results:{},defaultRoll:1,defaultFace:100};class ie extends e.Plugin{constructor(){super(...arguments),this.persistingFiles=new Set,this.operators={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"^":(t,e)=>Math.pow(t,e)}}get view(){const t=this.app.workspace.getLeavesOfType(Jt),e=t.length?t[0]:null;if(e&&e.view&&e.view instanceof te)return e.view}addDiceView(){return t(this,void 0,void 0,(function*(){this.app.workspace.getLeavesOfType(Jt).length||(yield this.app.workspace.getRightLeaf(!1).setViewState({type:Jt}))}))}onload(){return t(this,void 0,void 0,(function*(){console.log("DiceRoller plugin loaded"),this.data=Object.assign(ee,yield this.loadData()),this.addSettingTab(new Kt(this.app,this)),this.registerView(Jt,(t=>new te(this,t))),this.addCommand({id:"open-view",name:"Open Dice View",checkCallback:t=>{if(!this.view)return t||this.addDiceView(),!0}});const i=_t(r).html[0];(0,e.addIcon)(Pt,i);const n=_t(o).html[0];(0,e.addIcon)(Lt,n),this.registerMarkdownPostProcessor(((i,n)=>t(this,void 0,void 0,(function*(){var s,a,r,o,l;let c=i.querySelectorAll("code");if(!c.length)return;const d=n.sourcePath,u=n.getSectionInfo(i),h=null===(s=n.getSectionInfo(i))||void 0===s?void 0:s.lineStart,f=this.app.vault.getAbstractFileByPath(n.sourcePath);if(!(f&&f instanceof e.TFile&&u))return;const p={};for(let t=0;tfunction(t,e,i){const n=t[e],s=t.hasOwnProperty(e);let a=i(n);return n&&Object.setPrototypeOf(a,n),Object.setPrototypeOf(r,a),t[e]=r,o;function r(...i){return a===n&&t[e]===r&&o(),a.apply(this,i)}function o(){t[e]===r&&(s?t[e]=n:delete t[e]),a!==n&&(a=n,Object.setPrototypeOf(r,n||Function))}}(t,i,e[i])));return 1===i.length?i[0]:function(){i.forEach((t=>t()))}}(s,{onUnloadFile:function(s){return function(r){var o,l,c,u;return t(this,void 0,void 0,(function*(){if(r=f){e.persistingFiles.has(d)&&(e.persistingFiles.delete(d),e.data.results[d]={});for(let t in p){const s=p[t],a=null===(o=n.getSectionInfo(i))||void 0===o?void 0:o.lineStart;if(null==a)continue;const r={[a]:Object.assign(Object.assign({},null!==(c=null===(l=e.data.results[d])||void 0===l?void 0:l[a])&&void 0!==c?c:{}),{[t]:s.toResult()})};e.data.results[d]=Object.assign(Object.assign({},null!==(u=e.data.results[d])&&void 0!==u?u:{}),r),yield e.saveSettings()}}return a(),yield s.call(this,r)}))}}});s.register(a),s.register((()=>t(this,void 0,void 0,(function*(){var t,e,s,a;this.persistingFiles.has(d)&&(this.persistingFiles.delete(d),this.data.results[d]={});for(let r in p){const o=p[r],l=null===(t=n.getSectionInfo(i))||void 0===t?void 0:t.lineStart;if(null==l)continue;const c={[l]:Object.assign(Object.assign({},null!==(s=null===(e=this.data.results[d])||void 0===e?void 0:e[l])&&void 0!==s?s:{}),{[r]:o.toResult()})};this.data.results[d]=Object.assign(Object.assign({},null!==(a=this.data.results[d])&&void 0!==a?a:{}),c),yield this.saveSettings()}}))))}}})))),this.lexer=new(a()),this.addLexerRules();var s={precedence:2,associativity:"left"},l={precedence:1,associativity:"left"};this.parser=new Mt({"+":l,"-":l,"*":s,"/":s,"^":{precedence:3,associativity:"right"}})}))}parseDice(e,i){return t(this,void 0,void 0,(function*(){const t=this.getRoller(e,i);return{result:yield t.roll(),roller:t}}))}clearEmpties(t){for(var e in t)t[e]&&"object"==typeof t[e]&&(this.clearEmpties(t[e]),0===Object.keys(t[e]).length&&delete t[e])}saveSettings(){return t(this,void 0,void 0,(function*(){this.clearEmpties(this.data.results),yield this.saveData(this.data)}))}getRoller(t,e){t in this.data.formulas&&(t=this.data.formulas[t]);const i=this.parse(t);switch(this.getTypeFromLexemes(i)){case"dice":return new Zt(this,t,i);case"table":return new Xt(this,t,i[0],e);case"section":return new Wt(this,t,i[0],e);case"tag":if(!this.app.plugins.plugins.dataview)throw new Error("Tags are only supported with the Dataview plugin installed.");return new Yt(this,t,i[0],e);case"link":return new Ut(this,t,i[0],e)}}getTypeFromLexemes(t){return t.some((({type:t})=>"table"===t))?"table":t.some((({type:t})=>"section"===t))?"section":t.some((({type:t})=>"tag"===t))?"tag":t.some((({type:t})=>"link"===t))?"link":"dice"}addLexerRules(){this.lexer.addRule(/\s+/,(function(){})),this.lexer.addRule(/[{}]+/,(function(){})),this.lexer.addRule(Nt,(function(t){return{type:"table",data:t,original:t,conditionals:null}})),this.lexer.addRule(At,(function(t){return{type:"section",data:t,original:t,conditionals:null}})),this.lexer.addRule(Ot,(t=>{var e;const{groups:i}=t.match(Ot);let n="tag";return("link"===i.types||this.data.rollLinksForTags&&!(null===(e=i.types)||void 0===e?void 0:e.length))&&(n="link"),{type:n,data:t,original:t,conditionals:null}})),this.lexer.addRule(jt,(function(t){const{dice:e,conditional:i}=t.match(jt).groups;let n=[];if(i){let t=i.matchAll(It);if(t)for(let e of t){if(!e)continue;const{comparer:t,operator:i}=e.groups;n.push({comparer:Number(t),operator:i})}}return{type:"dice",data:e,original:t,conditionals:n}})),this.lexer.addRule(Ft,(t=>{const{roll:e=this.data.defaultRoll,faces:i=this.data.defaultFace,conditional:n}=t.match(Ft).groups;let s=[];if(n){let t=n.matchAll(It);if(t)for(let e of t){if(!e)continue;const{comparer:t,operator:i}=e.groups;s.push({comparer:Number(t),operator:i})}}return{type:"dice",data:`${e}d${i}`,original:t,conditionals:s}})),this.lexer.addRule(Dt,(function(t){return{type:"math",data:t,original:t,conditionals:null}})),this.lexer.addRule(/1[Dd]S/,(function(t){var e;const[,i]=null!==(e=t.match(/1[Dd]S/))&&void 0!==e?e:[,"1"];return{type:"stunt",data:i,original:t,conditionals:[]}})),this.lexer.addRule(/kh?(?!:l)(\d*)/,(function(t){return{type:"kh",data:t.replace(/^\D+/g,""),original:t,conditionals:null}})),this.lexer.addRule(/dl?(?!:h)\d*/,(function(t){return{type:"dl",data:t.replace(/^\D+/g,""),original:t,conditionals:null}})),this.lexer.addRule(/kl\d*/,(function(t){return{type:"kl",data:t.replace(/^\D+/g,""),original:t,conditionals:null}})),this.lexer.addRule(/dh\d*/,(function(t){return{type:"dh",data:t.replace(/^\D+/g,""),original:t,conditionals:null}})),this.lexer.addRule(/!!(i|\d+)?(?:(!?=|=!|>=?|<=?)(-?\d+))*/,(function(t){let[,e="1"]=t.match(/!!(i|\d+)?(?:(!?=|=!|>=?|<=?)(-?\d+))*/),i=[];if(/(?:(!?=|=!|>=?|<=?)(-?\d+))+/.test(t))for(const[,e,n]of t.matchAll(/(?:(!?=|=!|>=?|<=?)(-?\d+))/g))i.push({operator:e,comparer:Number(n)});return/!!i/.test(t)&&(e="100"),{type:"!!",data:e,original:t,conditionals:i}})),this.lexer.addRule(/!(i|\d+)?(?:(!?=|=!?|>=?|<=?)(-?\d+))*/,(function(t){let[,e="1"]=t.match(/!(i|\d+)?(?:(!?=|=!?|>=?|<=?)(-?\d+))*/),i=[];if(/(?:(!?=|=!|>=?|<=?)(\d+))+/.test(t))for(const[,e,n]of t.matchAll(/(?:(!?=|=!?|>=?|<=?)(-?\d+))/g))i.push({operator:e,comparer:Number(n)});return/!i/.test(t)&&(e="100"),{type:"!",data:e,original:t,conditionals:i}})),this.lexer.addRule(/r(i|\d+)?(?:(!?=|=!|>=?|<=?)(-?\d+))*/,(function(t){let[,e="1"]=t.match(/r(i|\d+)?(?:(!?=|=!|>=?|<=?)(-?\d+))*/),i=[];if(/(?:(!?={1,2}|>=?|<=?)(-?\d+))+/.test(t))for(const[,e,n]of t.matchAll(/(?:(!?=|=!|>=?|<=?)(-?\d+))/g))i.push({operator:e,comparer:Number(n)});return/ri/.test(t)&&(e="100"),{type:"r",data:e,original:t,conditionals:i}}))}onunload(){console.log("DiceRoller unloaded"),this.app.workspace.getLeavesOfType(Jt).forEach((t=>t.detach()))}parse(t){this.lexer.setInput(t);for(var e,i=[];e=this.tryLex();)i.push(e);return this.parser.parse(i)}tryLex(){try{return this.lexer.lex()}catch(t){}}}})();var s=exports;for(var a in n)s[a]=n[a];n.__esModule&&Object.defineProperty(s,"__esModule",{value:!0})})();