You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
77 KiB

/*! 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<o;r++){var l=n[r],c=l.start,d=c.length;if(!d||c.indexOf(i)>=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<d.length)if(this.reject){if(s=0,void 0!==(c=t.call(this,d.charAt(this.index++))))return"[object Array]"===Object.prototype.toString.call(c)?(i=c.slice(1),c[0]):c}else this.index!==n&&(s=0),this.reject=!0;else{if(!e.length)break;this.reject=!0}}}}"object"==typeof t.exports&&(t.exports=e),e.defunct=function(t){throw new Error("Unexpected character at index "+(this.index-1)+": "+t)}}},e={};function i(n){var s=e[n];if(void 0!==s)return s.exports;var a=e[n]={exports:{}};return t[n](a,a.exports,i),a.exports}i.n=t=>{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;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function d(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function u(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{},n=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(i).filter((function(t){return Object.getOwnPropertyDescriptor(i,t).enumerable})))),n.forEach((function(e){d(t,e,i[e])}))}return t}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=[],n=!0,s=!1,a=void 0;try{for(var r,o=t[Symbol.iterator]();!(n=(r=o.next()).done)&&(i.push(r.value),!e||i.length!==e);n=!0);}catch(t){s=!0,a=t}finally{try{n||null==o.return||o.return()}finally{if(s)throw a}}return i}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var f=function(){},p={},g={},m={mark:f,measure:f};try{"undefined"!=typeof window&&(p=window),"undefined"!=typeof document&&(g=document),"undefined"!=typeof MutationObserver&&MutationObserver,"undefined"!=typeof performance&&(m=performance)}catch(t){}var v=(p.navigator||{}).userAgent,y=void 0===v?"":v,w=p,b=g,x=m,k=(w.document,!!b.documentElement&&!!b.head&&"function"==typeof b.addEventListener&&"function"==typeof b.createElement),E=(~y.indexOf("MSIE")||y.indexOf("Trident/"),"svg-inline--fa"),C=[1,2,3,4,5,6,7,8,9,10],S=C.concat([11,12,13,14,15,16,17,18,19,20]),R={GROUP:"group",SWAP_OPACITY:"swap-opacity",PRIMARY:"primary",SECONDARY:"secondary"},T=(["xs","sm","lg","fw","ul","li","border","pull-left","pull-right","spin","pulse","rotate-90","rotate-180","rotate-270","flip-horizontal","flip-vertical","flip-both","stack","stack-1x","stack-2x","inverse","layers","layers-text","layers-counter",R.GROUP,R.SWAP_OPACITY,R.PRIMARY,R.SECONDARY].concat(C.map((function(t){return"".concat(t,"x")}))).concat(S.map((function(t){return"w-".concat(t)}))),w.FontAwesomeConfig||{});b&&"function"==typeof b.querySelector&&[["data-family-prefix","familyPrefix"],["data-replacement-class","replacementClass"],["data-auto-replace-svg","autoReplaceSvg"],["data-auto-add-css","autoAddCss"],["data-auto-a11y","autoA11y"],["data-search-pseudo-elements","searchPseudoElements"],["data-observe-mutations","observeMutations"],["data-mutate-approach","mutateApproach"],["data-keep-original-source","keepOriginalSource"],["data-measure-performance","measurePerformance"],["data-show-missing-icons","showMissingIcons"]].forEach((function(t){var e=h(t,2),i=e[0],n=e[1],s=function(t){return""===t||"false"!==t&&("true"===t||t)}(function(t){var e=b.querySelector("script["+t+"]");if(e)return e.getAttribute(t)}(i));null!=s&&(T[n]=s)}));var _=u({},{familyPrefix:"fa",replacementClass:E,autoReplaceSvg:!0,autoAddCss:!0,autoA11y:!0,searchPseudoElements:!1,observeMutations:!0,mutateApproach:"async",keepOriginalSource:!0,measurePerformance:!1,showMissingIcons:!0},T);_.autoReplaceSvg||(_.observeMutations=!1);var M=u({},_);w.FontAwesomeConfig=M;var O=w||{};O.___FONT_AWESOME___||(O.___FONT_AWESOME___={}),O.___FONT_AWESOME___.styles||(O.___FONT_AWESOME___.styles={}),O.___FONT_AWESOME___.hooks||(O.___FONT_AWESOME___.hooks={}),O.___FONT_AWESOME___.shims||(O.___FONT_AWESOME___.shims=[]);var N=O.___FONT_AWESOME___,A=[];k&&((b.documentElement.doScroll?/^loaded|^c/:/^loaded|^i|^c/).test(b.readyState)||b.addEventListener("DOMContentLoaded",(function t(){b.removeEventListener("DOMContentLoaded",t),A.map((function(t){return t()}))})));var D,j="pending",F="settled",I="fulfilled",P="rejected",L=function(){},z="undefined"!=typeof global&&void 0!==global.process&&"function"==typeof global.process.emit,q="undefined"==typeof setImmediate?setTimeout:setImmediate,B=[];function $(){for(var t=0;t<B.length;t++)B[t][0](B[t][1]);B=[],D=!1}function V(t,e){B.push([t,e]),D||(D=!0,q($,0))}function H(t){var e=t.owner,i=e._state,n=e._data,s=t[i],a=t.then;if("function"==typeof s){i=I;try{n=s(n)}catch(t){U(a,t)}}Z(a,n)||(i===I&&W(a,n),i===P&&U(a,n))}function Z(t,e){var i;try{if(t===e)throw new TypeError("A promises callback cannot return that same promise.");if(e&&("function"==typeof e||"object"===l(e))){var n=e.then;if("function"==typeof n)return n.call(e,(function(n){i||(i=!0,e===n?Y(t,n):W(t,n))}),(function(e){i||(i=!0,U(t,e))})),!0}}catch(e){return i||U(t,e),!0}return!1}function W(t,e){t!==e&&Z(t,e)||Y(t,e)}function Y(t,e){t._state===j&&(t._state=F,t._data=e,V(G,t))}function U(t,e){t._state===j&&(t._state=F,t._data=e,V(Q,t))}function X(t){t._then=t._then.forEach(H)}function G(t){t._state=I,X(t)}function Q(t){t._state=P,X(t),!t._handled&&z&&global.process.emit("unhandledRejection",t._data,t)}function K(t){global.process.emit("rejectionHandled",t)}function J(t){if("function"!=typeof t)throw new TypeError("Promise resolver "+t+" is not a function");if(this instanceof J==0)throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._then=[],function(t,e){function i(t){U(e,t)}try{t((function(t){W(e,t)}),i)}catch(t){i(t)}}(t,this)}J.prototype={constructor:J,_state:j,_then:null,_data:void 0,_handled:!1,then:function(t,e){var i={owner:this,then:new this.constructor(L),fulfilled:t,rejected:e};return!e&&!t||this._handled||(this._handled=!0,this._state===P&&z&&V(K,this)),this._state===I||this._state===P?V(H,i):this._then.push(i),i.then},catch:function(t){return this.then(null,t)}},J.all=function(t){if(!Array.isArray(t))throw new TypeError("You must pass an array to Promise.all().");return new J((function(e,i){var n=[],s=0;function a(t){return s++,function(i){n[t]=i,--s||e(n)}}for(var r,o=0;o<t.length;o++)(r=t[o])&&"function"==typeof r.then?r.then(a(o),i):n[o]=r;s||e(n)}))},J.race=function(t){if(!Array.isArray(t))throw new TypeError("You must pass an array to Promise.race().");return new J((function(e,i){for(var n,s=0;s<t.length;s++)(n=t[s])&&"function"==typeof n.then?n.then(e,i):e(n)}))},J.resolve=function(t){return t&&"object"===l(t)&&t.constructor===J?t:new J((function(e){e(t)}))},J.reject=function(t){return new J((function(e,i){i(t)}))};var tt={size:16,x:0,y:0,rotate:0,flipX:!1,flipY:!1};function et(){for(var t=12,e="";t-- >0;)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[62*Math.random()|0];return e}function it(t){return"".concat(t).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}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);s<l;s++)r=c(r,t[a=o[s]],a,t);return r});function dt(t,e){var i=arguments.length>2&&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(""),"</").concat(e,">")}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<e;n++)i[n]=arguments[n];var s=i.reduce(this._pullDefinitions,{});Object.keys(s).forEach((function(e){t.definitions[e]=u({},t.definitions[e]||{},s[e]),dt(e,s[e]),ft()}))}},{key:"reset",value:function(){this.definitions={}}},{key:"_pullDefinitions",value:function(t,e){var i=e.prefix&&e.iconName&&e.icon?{0:e}:e;return Object.keys(i).map((function(e){var n=i[e],s=n.prefix,a=n.iconName,r=n.icon;t[s]||(t[s]={}),t[s][a]=r})),t}}],i&&c(e.prototype,i),t}();function kt(){M.autoAddCss&&!Tt&&(function(t){if(t&&k){var e=b.createElement("style");e.setAttribute("type","text/css"),e.innerHTML=t;for(var i=b.head.childNodes,n=null,s=i.length-1;s>-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;a<e;)switch((d=t[a++]).data){case"(":s.unshift(d);break;case")":for(;s.length&&"("!==(d=s.shift()).data;)n.push(d);if("("!==d.data)throw new Error("Mismatched parentheses.");break;default:if(i.hasOwnProperty(d.data)){for(;s.length;){var r=s[0];if("("===r.data)break;var o=i[d.data],l=o.precedence,c=i[r.data].precedence;if(l>c||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=/(?:(?<roll>\d+)[Dd])?#(?<tag>[\p{Letter}\p{Emoji_Presentation}\w/-]+)(?:\|(?<collapse>[\+-]))?(?:\|(?<types>[^\+-]+))?/u,Nt=/(?:(?<roll>\d+)[Dd])?\[\[(?<link>[\s\S]+?)#?\^(?<block>[\s\S]+?)\]\]\|?(?<header>[\s\S]+)?/,At=/(?:(?<roll>\d+)[Dd])?\[\[(?<link>[\s\S]+)\]\]\|?(?<types>[\s\S]+)?/,Dt=/[\(\^\+\-\*\/\)]/,jt=/(?<dice>(?<roll>\d+)(?:[Dd]?\[?(?:-?\d+\s?,)?\s?(?:-?\d+|%|F)\]?)?)(?<conditional>(?:(?:=|=!|<|>|<=|>=|=<|=>|\-=|=\-)\d+)*)?/,Ft=/(?<roll>\d+)?[Dd](?<faces>\[?(?:-?\d+\s?,)?\s?(?:-?\d+|%|F)\]?)?(?<conditional>(?:(?:=|=!|<|>|<=|>=|=<|=>|\-=|=\-)\d+)*)?/,It=/(?:(?<operator>=|=!|<|>|<=|>=|=<|=>|\-=|=\-)(?<comparer>\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)<Number(s)&&([a,s]=[s,a]),this.faces={max:a?Number(a):1,min:s?Number(s):1},this.conditions=null!==(i=this.lexeme.conditionals)&&void 0!==i?i:[],this.results=new Map([...this.roll()].map(((t,e)=>[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(;n<t&&s.filter((([,{value:t}])=>this.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);n<t&&this.checkCondition(a,i);)n++,a=this.getRandomBetween(this.faces.min,this.faces.max),s.value+=a,s.display=`${s.value}`,this.results.set(e,s)}))}explode(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=[...this.results].filter((([,{value:t}])=>this.checkCondition(t,i))),s=0;n.forEach((([e,n])=>{let a=n.value,r=0;for(;r<t&&this.checkCondition(a,i);)this.results.get(e+s+r).modifiers.add("!"),a=this.getRandomBetween(this.faces.min,this.faces.max),zt(this.results,e+s+r+1,{usable:!0,value:a,display:`${a}`,modifiers:new Set}),r++;s+=r}))}_roll(){return this.static?[Number(this.dice)]:[...Array(this.rolls)].map((()=>this.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<i;break;case"<=":n=t<=i;break;case">":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",'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px;}</style></defs><g id="Shapes"><path class="cls-1" d="M244.62,49.31,40.31,403.19a6.21,6.21,0,0,0,5.38,9.31H454.31a6.21,6.21,0,0,0,5.38-9.31L255.38,49.31A6.21,6.21,0,0,0,244.62,49.31Z"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M270.21,278.16h21.7v16.22h-21.7v36.31h-20V294.38H179V282.67l70-108.39h21.16Zm-68.64,0h48.66v-76.7l-2.36,4.3Z"/></g></svg>'),(0,e.addIcon)("d6",'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px;}</style></defs><g id="Shapes"><rect class="cls-1" x="87.5" y="87.5" width="325" height="325" rx="10"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M279.22,174.18V191h-3.65q-23.2.44-37,13.75t-15.9,37.49q12.36-14.17,33.74-14.18,20.4,0,32.6,14.4t12.19,37.17q0,24.16-13.16,38.67t-35.29,14.5q-22.46,0-36.41-17.24t-14-44.42v-7.63q0-43.19,18.42-66t54.84-23.36Zm-26.1,70.47a33.41,33.41,0,0,0-30.73,21.48v7.31q0,19.33,8.7,31.15t21.7,11.81q13.43,0,21.11-9.88t7.68-25.89q0-16.11-7.79-26A25,25,0,0,0,253.12,244.65Z"/></g></svg>'),(0,e.addIcon)("d8",'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px;}</style></defs><g id="Shapes"><rect class="cls-1" x="102.75" y="102.75" width="294.51" height="294.51" rx="9.8" transform="translate(-103.55 250) rotate(-45)"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M292.08,215.1a36.35,36.35,0,0,1-6.17,20.84,42.05,42.05,0,0,1-16.71,14.29,44.8,44.8,0,0,1,19.39,15.36,38.7,38.7,0,0,1,7.15,22.88q0,20.31-13.7,32.34t-36,12q-22.56,0-36.15-12.09t-13.59-32.28a39.84,39.84,0,0,1,6.93-22.88,43.14,43.14,0,0,1,19.18-15.47,40.88,40.88,0,0,1-16.44-14.28,36.85,36.85,0,0,1-6-20.74q0-19.75,12.67-31.36T246,172.14q20.63,0,33.35,11.6T292.08,215.1ZM275.86,288q0-13.1-8.32-21.37t-21.75-8.27q-13.44,0-21.54,8.16T216.14,288q0,13.33,7.89,20.95t22,7.63q14,0,21.91-7.68T275.86,288ZM246,188.46q-11.72,0-19,7.26t-7.25,19.71q0,11.92,7.14,19.28T246,242.07q11.92,0,19.07-7.36t7.14-19.28q0-11.93-7.41-19.45T246,188.46Z"/></g></svg>'),(0,e.addIcon)("d10",'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px;}</style></defs><g id="Shapes"><rect class="cls-1" x="102.75" y="102.75" width="294.51" height="294.51" rx="9.8" transform="translate(-103.55 250) rotate(-45)"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M219,330.69H199V198.24L158.92,213V194.91l56.93-21.38H219Z"/><path d="M344.47,264q0,34.92-11.93,51.89t-37.27,17q-25,0-37.06-16.6t-12.46-49.57V240.13q0-34.47,11.92-51.24t37.38-16.75q25.24,0,37.17,16.16t12.25,49.9ZM324.59,236.8q0-25.23-7.09-36.79t-22.45-11.55q-15.26,0-22.23,11.5t-7.2,35.34v31.8q0,25.35,7.36,37.43t22.29,12.09q14.72,0,21.86-11.39t7.46-35.88Z"/></g></svg>'),(0,e.addIcon)("d12",'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px;}</style></defs><g id="Shapes"><path class="cls-1" d="M244.31,29.14,52,168.87a9.72,9.72,0,0,0-3.52,10.84l73.47,226.1a9.69,9.69,0,0,0,9.21,6.69H368.87a9.69,9.69,0,0,0,9.21-6.69l73.47-226.1A9.72,9.72,0,0,0,448,168.87L255.69,29.14A9.66,9.66,0,0,0,244.31,29.14Z"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M208,330.69H188V198.24L147.93,213V194.91l56.93-21.38H208Z"/><path d="M342.28,330.69H239.8V316.4l54.14-60.15q12-13.65,16.6-22.19a37,37,0,0,0,4.56-17.67q0-12.24-7.41-20.08t-19.77-7.85q-14.82,0-23,8.44t-8.22,23.47H236.79q0-21.6,13.91-34.91t37.22-13.32q21.81,0,34.49,11.44T335.08,214q0,23.1-29.43,55l-41.9,45.44h78.53Z"/></g></svg>'),(0,e.addIcon)("d20",'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px;}</style></defs><g id="Shapes"><path class="cls-1" d="M55.14,143.27V356.73a10,10,0,0,0,5,8.66L245,472.11a10,10,0,0,0,10,0L439.86,365.39a10,10,0,0,0,5-8.66V143.27a10,10,0,0,0-5-8.66L255,27.89a10,10,0,0,0-10,0L60.14,134.61A10,10,0,0,0,55.14,143.27Z"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M251.34,330.69H148.86V316.4L203,256.25q12-13.65,16.6-22.19a37,37,0,0,0,4.57-17.67q0-12.24-7.42-20.08T197,188.46q-14.82,0-23,8.44t-8.22,23.47H145.86q0-21.6,13.91-34.91T197,172.14q21.81,0,34.48,11.44T244.15,214q0,23.1-29.44,55l-41.89,45.44h78.52Z"/><path d="M361.67,264q0,34.92-11.92,51.89t-37.27,17q-25,0-37.06-16.6T263,266.67V240.13q0-34.47,11.93-51.24t37.38-16.75q25.25,0,37.17,16.16t12.24,49.9ZM341.8,236.8q0-25.23-7.09-36.79t-22.45-11.55Q297,188.46,290,200t-7.19,35.34v31.8q0,25.35,7.36,37.43t22.29,12.09q14.72,0,21.86-11.39t7.46-35.88Z"/></g></svg>'),(0,e.addIcon)("d100",'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px;}</style></defs><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M172.54,194.88q0-15.7,10.19-25.49t26.72-9.79q16.76,0,27,9.67t10.19,26.19v8.44q0,15.82-10.19,25.43t-26.72,9.61q-16.65,0-26.9-9.67T172.54,203.2Zm22.5,9.17q0,7.06,4,11.37a13.88,13.88,0,0,0,10.61,4.3,13.24,13.24,0,0,0,10.43-4.36Q224,211,224,203.69V195c0-4.71-1.28-8.53-3.86-11.43s-6.14-4.36-10.67-4.36a13.56,13.56,0,0,0-10.43,4.3q-4,4.31-4,12Zm21.33,115.87L199.84,311l83.32-133.36,16.53,8.91Zm37.73-29.06q0-15.83,10.31-25.49t26.72-9.67q16.65,0,26.9,9.55t10.25,26.31V300q0,15.71-10.08,25.37T291.37,335q-16.87,0-27.07-9.73t-10.2-25.78Zm22.5,9.28a15.82,15.82,0,0,0,4.22,11.08,13.71,13.71,0,0,0,10.55,4.6q14.29,0,14.29-15.92V291q0-7.08-4-11.38a15.08,15.08,0,0,0-21.09,0q-4,4.31-4,11.73Z"/><circle class="cls-1" cx="246.23" cy="250" r="189.38"/></g></svg>'),(0,e.addIcon)("dice-roller-save",'<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" data-prefix="far" data-icon="save" class="svg-inline--fa fa-save fa-w-14" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM272 80v80H144V80h128zm122 352H54a6 6 0 0 1-6-6V86a6 6 0 0 1 6-6h42v104c0 13.255 10.745 24 24 24h176c13.255 0 24-10.745 24-24V83.882l78.243 78.243a6 6 0 0 1 1.757 4.243V426a6 6 0 0 1-6 6zM224 232c-48.523 0-88 39.477-88 88s39.477 88 88 88 88-39.477 88-88-39.477-88-88-88zm0 128c-22.056 0-40-17.944-40-40s17.944-40 40-40 40 17.944 40 40-17.944 40-40 40z"/></svg>'),(0,e.addIcon)("dice-roller-plus",'<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" data-prefix="far" data-icon="plus-square" class="svg-inline--fa fa-plus-square fa-w-14" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M352 240v32c0 6.6-5.4 12-12 12h-88v88c0 6.6-5.4 12-12 12h-32c-6.6 0-12-5.4-12-12v-88h-88c-6.6 0-12-5.4-12-12v-32c0-6.6 5.4-12 12-12h88v-88c0-6.6 5.4-12 12-12h32c6.6 0 12 5.4 12 12v88h88c6.6 0 12 5.4 12 12zm96-160v352c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V80c0-26.5 21.5-48 48-48h352c26.5 0 48 21.5 48 48zm-48 346V86c0-3.3-2.7-6-6-6H54c-3.3 0-6 2.7-6 6v340c0 3.3 2.7 6 6 6h340c3.3 0 6-2.7 6-6z"/></svg>'),(0,e.addIcon)("dice-roller-minus",'<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" data-prefix="far" data-icon="minus-square" class="svg-inline--fa fa-minus-square fa-w-14" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M108 284c-6.6 0-12-5.4-12-12v-32c0-6.6 5.4-12 12-12h232c6.6 0 12 5.4 12 12v32c0 6.6-5.4 12-12 12H108zM448 80v352c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V80c0-26.5 21.5-48 48-48h352c26.5 0 48 21.5 48 48zm-48 346V86c0-3.3-2.7-6-6-6H54c-3.3 0-6 2.7-6 6v340c0 3.3 2.7 6 6 6h340c3.3 0 6-2.7 6-6z"/></svg>');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;t<c.length;t++){const i=c.item(t);if(/^dice\-mod:\s*([\s\S]+)\s*?/.test(i.innerText))try{let[t,s]=i.innerText.match(/^dice\-mod:\s*([\s\S]+)\s*?/);if(s in this.data.formulas&&(s=this.data.formulas[s]),!jt.test(s)){new e.Notice("Replacing note content may only be done with Dice Rolls.");continue}const a=this.getRoller(s,n.sourcePath);yield a.roll();const r=(yield this.app.vault.cachedRead(f)).split("\n");let o=r.slice(u.lineStart,u.lineEnd+1);o=o.join("\n").replace(`\`${t}\``,`${a.inlineText} **${a.result}**`).split("\n"),r.splice(u.lineStart,u.lineEnd-u.lineStart+1,...o),yield this.app.vault.modify(f,r.join("\n"))}catch(t){console.error(t)}if(/^dice(?:\+|\-)?:\s*([\s\S]+)\s*?/.test(i.innerText))try{let[,e]=i.innerText.match(/^dice(?:\+|\-)?:\s*([\s\S]+)\s*?/);const s=this.getRoller(e,n.sourcePath);if(yield s.roll(),this.data.persistResults&&!/dice\-/.test(i.innerText)||/dice\+/.test(i.innerText)){this.persistingFiles.add(n.sourcePath),p[t]=s;const e=null!==(l=null===(o=null===(r=null===(a=this.data.results)||void 0===a?void 0:a[d])||void 0===r?void 0:r[h])||void 0===o?void 0:o[t])&&void 0!==l?l:null;e&&(yield s.applyResult(e))}i.replaceWith(s.containerEl)}catch(t){console.error(t),new e.Notice(`There was an error parsing the dice string: ${i.innerText}.\n\n${t}`,5e3);continue}}if(d in this.data.results&&(this.data.results[d][h]={}),Object.entries(p).length){const s=this.app.workspace.getActiveViewOfType(e.MarkdownView);if(s){const e=this;let a=function(t,e){const i=Object.keys(e).map((i=>function(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})})();