/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ "use strict";var dm=Object.create;var Ui=Object.defineProperty;var hm=Object.getOwnPropertyDescriptor;var fm=Object.getOwnPropertyNames;var mm=Object.getPrototypeOf,gm=Object.prototype.hasOwnProperty;var Yl=n=>{throw TypeError(n)};var pm=(n,e,t)=>e in n?Ui(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Jl=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),bm=(n,e)=>{for(var t in e)Ui(n,t,{get:e[t],enumerable:!0})},Xl=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of fm(e))!gm.call(n,a)&&a!==t&&Ui(n,a,{get:()=>e[a],enumerable:!(i=hm(e,a))||i.enumerable});return n};var La=(n,e,t)=>(t=n!=null?dm(mm(n)):{},Xl(e||!n||!n.__esModule?Ui(t,"default",{value:n,enumerable:!0}):t,n)),ym=n=>Xl(Ui({},"__esModule",{value:!0}),n);var We=(n,e,t)=>pm(n,typeof e!="symbol"?e+"":e,t),ar=(n,e,t)=>e.has(n)||Yl("Cannot "+t);var Q=(n,e,t)=>(ar(n,e,"read from private field"),t?t.call(n):e.get(n)),Le=(n,e,t)=>e.has(n)?Yl("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),nn=(n,e,t,i)=>(ar(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),Oe=(n,e,t)=>(ar(n,e,"access private method"),t);var Zl=Jl((Ql,sr)=>{(function(n){"use strict";var e=S(),t=C(),i=M(),a=w(),s={imagePlaceholder:void 0,cacheBust:!1},r={toSvg:o,toPng:c,toJpeg:d,toBlob:u,toPixelData:l,impl:{fontFaces:i,images:a,util:e,inliner:t,options:{}}};typeof sr<"u"?sr.exports=r:n.domtoimage=r;function o(k,A){return A=A||{},h(A),Promise.resolve(k).then(function(L){return f(L,A.filter,!0)}).then(p).then(b).then(P).then(function(L){return _(L,A.width||e.width(k),A.height||e.height(k))});function P(L){return A.bgcolor&&(L.style.backgroundColor=A.bgcolor),A.width&&(L.style.width=A.width+"px"),A.height&&(L.style.height=A.height+"px"),A.style&&Object.keys(A.style).forEach(function(B){L.style[B]=A.style[B]}),L}}function l(k,A){return m(k,A||{}).then(function(P){return P.getContext("2d").getImageData(0,0,e.width(k),e.height(k)).data})}function c(k,A){return m(k,A||{}).then(function(P){return P.toDataURL()})}function d(k,A){return A=A||{},m(k,A).then(function(P){return P.toDataURL("image/jpeg",A.quality||1)})}function u(k,A){return m(k,A||{}).then(e.canvasToBlob)}function h(k){typeof k.imagePlaceholder>"u"?r.impl.options.imagePlaceholder=s.imagePlaceholder:r.impl.options.imagePlaceholder=k.imagePlaceholder,typeof k.cacheBust>"u"?r.impl.options.cacheBust=s.cacheBust:r.impl.options.cacheBust=k.cacheBust}function m(k,A){return o(k,A).then(e.makeImage).then(e.delay(100)).then(function(L){var B=P(k);return B.getContext("2d").drawImage(L,0,0),B});function P(L){var B=document.createElement("canvas");if(B.width=A.width||e.width(L),B.height=A.height||e.height(L),A.bgcolor){var O=B.getContext("2d");O.fillStyle=A.bgcolor,O.fillRect(0,0,B.width,B.height)}return B}}function f(k,A,P){if(!P&&A&&!A(k))return Promise.resolve();return Promise.resolve(k).then(L).then(function(q){return B(k,q,A)}).then(function(q){return O(k,q)});function L(q){return q instanceof HTMLCanvasElement?e.makeImage(q.toDataURL()):q.cloneNode(!1)}function B(q,Z,ee){var se=q.childNodes;if(se.length===0)return Promise.resolve(Z);return $(Z,e.asArray(se),ee).then(function(){return Z});function $(W,J,F){var ie=Promise.resolve();return J.forEach(function(Y){ie=ie.then(function(){return f(Y,F)}).then(function(de){de&&W.appendChild(de)})}),ie}}function O(q,Z){if(!(Z instanceof Element))return Z;return Promise.resolve().then(ee).then(se).then($).then(W).then(function(){return Z});function ee(){J(window.getComputedStyle(q),Z.style);function J(F,ie){F.cssText?ie.cssText=F.cssText:Y(F,ie);function Y(de,V){e.asArray(de).forEach(function(H){V.setProperty(H,de.getPropertyValue(H),de.getPropertyPriority(H))})}}}function se(){[":before",":after"].forEach(function(F){J(F)});function J(F){var ie=window.getComputedStyle(q,F),Y=ie.getPropertyValue("content");if(Y===""||Y==="none")return;var de=e.uid();Z.className=Z.className+" "+de;var V=document.createElement("style");V.appendChild(H(de,F,ie)),Z.appendChild(V);function H(fe,Ce,Ie){var et="."+fe+":"+Ce,At=Ie.cssText?mi(Ie):gi(Ie);return document.createTextNode(et+"{"+At+"}");function mi(Pt){var Rt=Pt.getPropertyValue("content");return Pt.cssText+" content: "+Rt+";"}function gi(Pt){return e.asArray(Pt).map(Rt).join("; ")+";";function Rt(gt){return gt+": "+Pt.getPropertyValue(gt)+(Pt.getPropertyPriority(gt)?" !important":"")}}}}}function $(){q instanceof HTMLTextAreaElement&&(Z.innerHTML=q.value),q instanceof HTMLInputElement&&Z.setAttribute("value",q.value)}function W(){Z instanceof SVGElement&&(Z.setAttribute("xmlns","http://www.w3.org/2000/svg"),Z instanceof SVGRectElement&&["width","height"].forEach(function(J){var F=Z.getAttribute(J);F&&Z.style.setProperty(J,F)}))}}}function p(k){return i.resolveAll().then(function(A){var P=document.createElement("style");return k.appendChild(P),P.appendChild(document.createTextNode(A)),k})}function b(k){return a.inlineAll(k).then(function(){return k})}function _(k,A,P){return Promise.resolve(k).then(function(L){return L.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),new XMLSerializer().serializeToString(L)}).then(e.escapeXhtml).then(function(L){return''+L+""}).then(function(L){return''+L+""}).then(function(L){return"data:image/svg+xml;charset=utf-8,"+L})}function S(){return{escape:W,parseExtension:A,mimeType:P,dataAsUrl:$,isDataUrl:L,canvasToBlob:O,resolveUrl:q,getAndEncode:se,uid:Z(),delay:J,asArray:F,escapeXhtml:ie,makeImage:ee,width:Y,height:de};function k(){var H="application/font-woff",fe="image/jpeg";return{woff:H,woff2:H,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:fe,jpeg:fe,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}}function A(H){var fe=/\.([^\.\/]*?)$/g.exec(H);return fe?fe[1]:""}function P(H){var fe=A(H).toLowerCase();return k()[fe]||""}function L(H){return H.search(/^(data:)/)!==-1}function B(H){return new Promise(function(fe){for(var Ce=window.atob(H.toDataURL().split(",")[1]),Ie=Ce.length,et=new Uint8Array(Ie),At=0;At{"use strict";var Bo=Object.defineProperty,Lb=Object.getOwnPropertyDescriptor,Bb=Object.getOwnPropertyNames,Fb=Object.prototype.hasOwnProperty,Wb=(n,e)=>{for(var t in e)Bo(n,t,{get:e[t],enumerable:!0})},Hb=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Bb(e))!Fb.call(n,a)&&a!==t&&Bo(n,a,{get:()=>e[a],enumerable:!(i=Lb(e,a))||i.enumerable});return n},zb=n=>Hb(Bo({},"__esModule",{value:!0}),n),Wd={};Wb(Wd,{FileInputSuggest:()=>jb,FolderInputSuggest:()=>qb,FuzzyInputSuggest:()=>Fo,createCollapsibleSection:()=>Gb,setNodeIcon:()=>Ub});Hd.exports=zb(Wd);var Lo=require("obsidian"),Fo=class extends Lo.AbstractInputSuggest{constructor(n,e,t){super(n,e.inputEl),this.items=t}getSuggestions(n){let e=(0,Lo.prepareSimpleSearch)(n),t=[];for(let i of this.items){let a=e(this.getItemText(i));a&&t.push({item:i,match:a})}return t}renderSuggestion(n,e){e.addClass("mod-complex");let t=e.createDiv({cls:"suggestion-content"});if(!n?.item){t.setText("No match found"),t.parentElement?.addClass("is-selected");return}this.renderTitle(t.createDiv("suggestion-title"),n),this.renderNote?.(t.createDiv("suggestion-note"),n),this.renderFlair?.(e.createDiv("suggestion-aux").createDiv("suggestion-flair"),n)}renderMatches(n,e,t,i){(0,Lo.renderMatches)(n,e,t,i)}},Ld=require("obsidian"),qb=class extends Fo{getItemText(n){return n.path}renderNote(n,e){let{item:t,match:i}=e;(0,Ld.renderMatches)(n,t.path,i.matches)}renderTitle(n,e){let{item:t,match:i}=e;(0,Ld.renderMatches)(n,t.name,i.matches,t.path.length-t.name.length)}},Bd=require("obsidian"),jb=class extends Fo{getItemText(n){return n.path}renderNote(n,e){let{item:t,match:i}=e;(0,Bd.renderMatches)(n,t.path,i.matches)}renderTitle(n,e){let{item:t,match:i}=e;(0,Bd.renderMatches)(n,t.name,i.matches,t.path.length-t.name.length)}},Vb=require("obsidian");function Ub(n,e){n.addClass("has-node-icon"),(0,Vb.setIcon)(n,e)}var Fd=require("obsidian");function Gb(n,e,t,i){let a=n.createEl("details",{cls:"javalent-nested-settings",attr:{...t??!0?{open:"open"}:{}}});a.ontoggle=async()=>{i&&i(a.open)};let s=a.createEl("summary");return new Fd.Setting(s).setHeading().setName(e),(0,Fd.setIcon)(s.createDiv("handle"),"chevron-right"),a}});var cv={};bm(cv,{DICE_ROLLER_SOURCE:()=>hi,default:()=>$s});module.exports=ym(cv);var qn=require("obsidian"),yf=La(Zl());var St=require("obsidian");var Sc=require("@codemirror/state"),Cc=require("@codemirror/view");var vm=Function.prototype.toString,rr=Object.create,km=Object.prototype.toString,wm=function(){function n(){this._keys=[],this._values=[]}return n.prototype.has=function(e){return!!~this._keys.indexOf(e)},n.prototype.get=function(e){return this._values[this._keys.indexOf(e)]},n.prototype.set=function(e,t){this._keys.push(e),this._values.push(t)},n}();function _m(){return new wm}function Sm(){return new WeakMap}var Cm=typeof WeakMap<"u"?Sm:_m;function lr(n){if(!n)return rr(null);var e=n.constructor;if(e===Object)return n===Object.prototype?{}:rr(n);if(e&&~vm.call(e).indexOf("[native code]"))try{return new e}catch{}return rr(n)}function xm(n){var e="";return n.global&&(e+="g"),n.ignoreCase&&(e+="i"),n.multiline&&(e+="m"),n.unicode&&(e+="u"),n.sticky&&(e+="y"),e}function Am(n){return n.flags}var Tm=/test/g.flags==="g"?Am:xm;function ec(n){var e=km.call(n);return e.substring(8,e.length-1)}function Dm(n){return n[Symbol.toStringTag]||ec(n)}var Em=typeof Symbol<"u"?Dm:ec,Mm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,tc=Object.getOwnPropertyNames,cr=Object.getOwnPropertySymbols,nc=Object.prototype,ic=nc.hasOwnProperty,Om=nc.propertyIsEnumerable,ac=typeof cr=="function";function Pm(n){return tc(n).concat(cr(n))}var Rm=ac?Pm:tc;function Fa(n,e,t){for(var i=Rm(n),a=0,s=i.length,r=void 0,o=void 0;a[(0,Nt.foldGutter)(),(0,an.drawSelection)(),(0,an.dropCursor)(),(0,Nt.indentOnInput)(),(0,Nt.syntaxHighlighting)(Nt.defaultHighlightStyle,{fallback:!0}),an.EditorView.lineWrapping,(0,Nt.bracketMatching)(),(0,Cn.closeBrackets)(),(0,Cn.autocompletion)(),(0,an.rectangularSelection)(),(0,Wa.highlightSelectionMatches)(),an.keymap.of([...Cn.closeBracketsKeymap,...yi.defaultKeymap,...Wa.searchKeymap,...yi.historyKeymap,yi.indentWithTab,...Nt.foldKeymap,...Cn.completionKeymap,...uc.lintKeymap])];var fc=require("@codemirror/view"),gv=require("@codemirror/state"),Ha=require("@codemirror/language"),je=require("@lezer/highlight"),Qm="#abb2bf",Zm="#7d8799",eg="#ffffff",tg="#21252b",dr="rgba(0, 0, 0, 0.5)",ng="#292d3e",hr="#353a42",ig="rgba(128, 203, 196, 0.2)",hc="#ffcc00",ag=fc.EditorView.theme({"&":{color:"#ffffff",backgroundColor:ng},".cm-content":{caretColor:hc},"&.cm-focused .cm-cursor":{borderLeftColor:hc},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ig},".cm-panels":{backgroundColor:tg,color:"#ffffff"},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:dr},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847",outline:"1px solid #515a6b"},".cm-gutters":{background:"#292d3e",color:"#676e95",border:"none"},".cm-activeLineGutter":{backgroundColor:dr},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:hr},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:hr,borderBottomColor:hr},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:dr,color:Qm}}},{dark:!0}),sg=Ha.HighlightStyle.define([{tag:je.tags.keyword,color:"#c792ea"},{tag:je.tags.operator,color:"#89ddff"},{tag:je.tags.special(je.tags.variableName),color:"#eeffff"},{tag:je.tags.typeName,color:"#f07178"},{tag:je.tags.atom,color:"#f78c6c"},{tag:je.tags.number,color:"#ff5370"},{tag:je.tags.definition(je.tags.variableName),color:"#82aaff"},{tag:je.tags.string,color:"#c3e88d"},{tag:je.tags.special(je.tags.string),color:"#f07178"},{tag:je.tags.comment,color:Zm},{tag:je.tags.variableName,color:"#f07178"},{tag:je.tags.tagName,color:"#ff5370"},{tag:je.tags.bracket,color:"#a2a1a4"},{tag:je.tags.meta,color:"#ffcb6b"},{tag:je.tags.attributeName,color:"#c792ea"},{tag:je.tags.propertyName,color:"#c792ea"},{tag:je.tags.className,color:"#decb6b"},{tag:je.tags.invalid,color:eg}]),mc=[ag,(0,Ha.syntaxHighlighting)(sg)];var _c=require("@codemirror/view"),yv=require("@codemirror/state"),qa=require("@codemirror/language"),he=require("@lezer/highlight"),gc="#2e3440",yr="#3b4252",pc="#434c5e",za="#4c566a";var bc="#e5e9f0",br="#eceff4",fr="#8fbcbb",yc="#88c0d0",rg="#81a1c1",qt="#5e81ac",og="#bf616a",vi="#d08770",mr="#ebcb8b",vc="#a3be8c",lg="#b48ead",kc="#d30102",vr=br,gr=vr,cg="#ffffff",pr=yr,ug=vr,wc=yr,kr=_c.EditorView.theme({"&":{color:gc,backgroundColor:cg},".cm-content":{caretColor:wc},".cm-cursor, .cm-dropCursor":{borderLeftColor:wc},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ug},".cm-panels":{backgroundColor:vr,color:za},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${za}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:bc},".cm-activeLine":{backgroundColor:gr},".cm-selectionMatch":{backgroundColor:bc},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${za}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:br},".cm-gutters":{backgroundColor:br,color:gc,border:"none"},".cm-activeLineGutter":{backgroundColor:gr},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:pr},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:pr,borderBottomColor:pr},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:gr,color:za}}},{dark:!1}),dg=qa.HighlightStyle.define([{tag:he.tags.keyword,color:qt},{tag:[he.tags.name,he.tags.deleted,he.tags.character,he.tags.propertyName,he.tags.macroName],color:vi},{tag:[he.tags.variableName],color:vi},{tag:[he.tags.function(he.tags.variableName)],color:qt},{tag:[he.tags.labelName],color:rg},{tag:[he.tags.color,he.tags.constant(he.tags.name),he.tags.standard(he.tags.name)],color:qt},{tag:[he.tags.definition(he.tags.name),he.tags.separator],color:vc},{tag:[he.tags.brace],color:fr},{tag:[he.tags.annotation],color:kc},{tag:[he.tags.number,he.tags.changed,he.tags.annotation,he.tags.modifier,he.tags.self,he.tags.namespace],color:yc},{tag:[he.tags.typeName,he.tags.className],color:mr},{tag:[he.tags.operator,he.tags.operatorKeyword],color:vc},{tag:[he.tags.tagName],color:lg},{tag:[he.tags.squareBracket],color:og},{tag:[he.tags.angleBracket],color:vi},{tag:[he.tags.attributeName],color:mr},{tag:[he.tags.regexp],color:qt},{tag:[he.tags.quote],color:yr},{tag:[he.tags.string],color:vi},{tag:he.tags.link,color:fr,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[he.tags.url,he.tags.escape,he.tags.special(he.tags.string)],color:vi},{tag:[he.tags.meta],color:yc},{tag:[he.tags.comment],color:pc,fontStyle:"italic"},{tag:he.tags.strong,fontWeight:"bold",color:qt},{tag:he.tags.emphasis,fontStyle:"italic",color:qt},{tag:he.tags.strikethrough,textDecoration:"line-through"},{tag:he.tags.heading,fontWeight:"bold",color:qt},{tag:he.tags.special(he.tags.heading1),fontWeight:"bold",color:qt},{tag:he.tags.heading1,fontWeight:"bold",color:qt},{tag:[he.tags.heading2,he.tags.heading3,he.tags.heading4],fontWeight:"bold",color:qt},{tag:[he.tags.heading5,he.tags.heading6],color:qt},{tag:[he.tags.atom,he.tags.bool,he.tags.special(he.tags.variableName)],color:vi},{tag:[he.tags.processingInstruction,he.tags.inserted],color:fr},{tag:[he.tags.contentSeparator],color:mr},{tag:he.tags.invalid,color:pc,borderBottom:`1px dotted ${kc}`}]),kv=[kr,(0,qa.syntaxHighlighting)(dg)];function jt(n,e,t="js"){let i=dc();document.body.hasClass("theme-dark")?i.push(mc):i.push(kr);let a=[...i];e&&a.push(e);let s=new Cc.EditorView({state:Sc.EditorState.create({doc:n.value,extensions:a})});return n.parentNode.appendChild(s.dom),n.style.display="none",n.form&&n.form.addEventListener("submit",()=>{n.value=s.state.doc.toString()}),s}function sn(n){return n?n.toLowerCase().replace(/[^A-Za-z0-9\s_-]/g,"").replace(/\s+/g,"-"):""}function Gi(n){return n[0].toUpperCase()+n.slice(1).toLowerCase()}function U(){return"xyxyxyxyxyxy".replace(/[xy]/g,function(n){let e=Math.random()*16|0;return(n=="x"?e:e&3|8).toString(16)})}function be(n,e=0,t=" ",i=!0){let a=[];if(e==5||n==null)return"";if(typeof n=="string")return n;if(typeof n=="number")return`${n}`;if(Array.isArray(n))a.push(`${i?"(":""}${n.map(s=>be(s,e+1)).join(t)}${i?")":""}`);else if(typeof n=="object")for(let s of Object.values(n))a.push(be(s,e+1));return a.join(" ")}function wr(n,e){if(!Array.isArray(n)&&typeof n!="string"||!Array.isArray(e)&&typeof e!="string")return e;let t=Ze(n);if(Array.isArray(t)){if(Array.isArray(e))return[...t,...e];if(typeof e=="string")return t.push(e),t}else if(typeof t=="string")return`${t} ${be(e)}`;return e}var hg=[{type:"inline",id:U(),properties:[],hasRule:!0,nested:[{type:"group",id:U(),properties:["name","size","type","subtype","alignment"],nested:[{type:"inline",id:U(),properties:[],hasRule:!1,nested:[{type:"heading",id:U(),properties:["name"],conditioned:!0,size:1},{type:"inline",id:U(),properties:[],hasRule:!1,nested:[{type:"action",id:U(),icon:"sword",callback:"try { InitiativeTracker.newEncounter({roll: true, creatures: [monster]}); } catch(e) {}"},{type:"action",id:U(),icon:"plus-with-circle",callback:"try { InitiativeTracker.addCreatures([monster]); } catch(e) {}"}]}]},{type:"subheading",id:U(),properties:["size","type","subtype","alignment"],conditioned:!0,separator:", "}],conditioned:!0},{type:"image",id:U(),properties:["image"]}]},{type:"group",id:U(),properties:["ac","hp","speed"],nested:[{type:"property",id:U(),properties:["ac"],display:"Armor Class",conditioned:!0,callback:'const ac = [monster.ac];if ("ac_class" in monster) {ac.push(`(${monster.ac_class})`);}return ac.join(" ");'},{type:"property",id:U(),properties:["hp"],display:"Hit Points",dice:!0,diceProperty:"hit_dice",diceCallback:`if ("hit_dice" in monster) { return [{ text: monster["hit_dice"] }]; } else { return property; }`,callback:`let str = [monster.hp]; if (monster.hit_dice?.length) { str.push(\`(\${monster.hit_dice})\`); } return str.join(" ");`,conditioned:!0},{type:"property",id:U(),display:"Speed",properties:["speed"],conditioned:!0}],hasRule:!0,conditioned:!0},{type:"table",id:U(),properties:["stats"],headers:["Str","Dex","Con","Int","Wis","Cha"],calculate:!0,hasRule:!0,conditioned:!0},{type:"table",id:U(),properties:["fage_stats"],headers:["Accuracy","Communication","Constitution","Dexterity","Fighting","Intelligence","Perception","Strength","Willpower"],calculate:!1,hasRule:!0,conditioned:!0},{type:"group",id:U(),properties:["saves","skillsaves","damage_immunities","damage_resistances","damage_vulnerabilities","condition_immunities","cr","languages","senses"],nested:[{type:"saves",id:U(),display:"Saves",properties:["saves"],conditioned:!0},{type:"saves",id:U(),display:"Skills",properties:["skillsaves"],conditioned:!0},{type:"property",id:U(),display:"Damage Resistances",properties:["damage_resistances"],conditioned:!0},{type:"property",id:U(),display:"Damage Immunities",properties:["damage_immunities"],conditioned:!0},{type:"property",id:U(),display:"Condition Immunities",properties:["condition_immunities"],conditioned:!0},{type:"property",id:U(),display:"Damage Vulnerabilities",properties:["damage_vulnerabilities"],conditioned:!0},{type:"property",id:U(),display:"Senses",properties:["senses"],conditioned:!0},{type:"property",id:U(),display:"Languages",properties:["languages"],fallback:"-"},{type:"inline",id:U(),properties:[],conditioned:!0,nested:[{type:"property",id:U(),display:"Challenge",properties:["cr"],callback:`const CR = { "0": { cr: "0", value: 0, xp: 10 }, "1/8": { cr: "1/8", value: 0.125, xp: 25 }, "1/4": { cr: "1/4", value: 0.25, xp: 50 }, "1/2": { cr: "1/2", value: 0.5, xp: 100 }, "0.125": { cr: "1/8", value: 0.125, xp: 25 }, "0.25": { cr: "1/4", value: 0.25, xp: 50 }, "0.5": { cr: "1/2", value: 0.5, xp: 100 }, "1": { cr: "1", value: 1, xp: 200 }, "2": { cr: "2", value: 2, xp: 450 }, "3": { cr: "3", value: 3, xp: 700 }, "4": { cr: "4", value: 4, xp: 1100 }, "5": { cr: "5", value: 5, xp: 1800 }, "6": { cr: "6", value: 6, xp: 2300 }, "7": { cr: "7", value: 7, xp: 2900 }, "8": { cr: "8", value: 8, xp: 3900 }, "9": { cr: "9", value: 9, xp: 5000 }, "10": { cr: "10", value: 10, xp: 5900 }, "11": { cr: "11", value: 11, xp: 7200 }, "12": { cr: "12", value: 12, xp: 8400 }, "13": { cr: "13", value: 13, xp: 10000 }, "14": { cr: "14", value: 14, xp: 11500 }, "15": { cr: "15", value: 15, xp: 13000 }, "16": { cr: "16", value: 16, xp: 15000 }, "17": { cr: "17", value: 17, xp: 18000 }, "18": { cr: "18", value: 18, xp: 20000 }, "19": { cr: "19", value: 19, xp: 22000 }, "20": { cr: "20", value: 20, xp: 25000 }, "21": { cr: "21", value: 21, xp: 33000 }, "22": { cr: "22", value: 22, xp: 41000 }, "23": { cr: "23", value: 23, xp: 50000 }, "24": { cr: "24", value: 24, xp: 62000 }, "25": { cr: "25", value: 25, xp: 75000 }, "26": { cr: "26", value: 26, xp: 90000 }, "27": { cr: "27", value: 27, xp: 105000 }, "28": { cr: "28", value: 28, xp: 120000 }, "29": { cr: "29", value: 29, xp: 135000 }, "30": { cr: "30", value: 30, xp: 155000 } }; if ("cr" in monster && monster.cr in CR) { return \`\${CR[ monster.cr ].cr} (\${CR[ monster.cr ].xp.toLocaleString()} XP)\`; } return "";`},{type:"property",id:U(),display:"Proficiency Bonus",properties:["cr"],callback:`const CR = { "0": { cr: "0", value: 0, xp: 0 }, "1/8": { cr: "1/8", value: 0.125, xp: 25 }, "1/4": { cr: "1/4", value: 0.25, xp: 50 }, "1/2": { cr: "1/2", value: 0.5, xp: 100 }, "0.125": { cr: "1/8", value: 0.125, xp: 25 }, "0.25": { cr: "1/4", value: 0.25, xp: 50 }, "0.5": { cr: "1/2", value: 0.5, xp: 100 }, "1": { cr: "1", value: 1, xp: 200 }, "2": { cr: "2", value: 2, xp: 450 }, "3": { cr: "3", value: 3, xp: 700 }, "4": { cr: "4", value: 4, xp: 1100 }, "5": { cr: "5", value: 5, xp: 1800 }, "6": { cr: "6", value: 6, xp: 2300 }, "7": { cr: "7", value: 7, xp: 2900 }, "8": { cr: "8", value: 8, xp: 3900 }, "9": { cr: "9", value: 9, xp: 5000 }, "10": { cr: "10", value: 10, xp: 5900 }, "11": { cr: "11", value: 11, xp: 7200 }, "12": { cr: "12", value: 12, xp: 8400 }, "13": { cr: "13", value: 13, xp: 10000 }, "14": { cr: "14", value: 14, xp: 11500 }, "15": { cr: "15", value: 15, xp: 13000 }, "16": { cr: "16", value: 16, xp: 15000 }, "17": { cr: "17", value: 17, xp: 18000 }, "18": { cr: "18", value: 18, xp: 20000 }, "19": { cr: "19", value: 19, xp: 22000 }, "20": { cr: "20", value: 20, xp: 25000 }, "21": { cr: "21", value: 21, xp: 33000 }, "22": { cr: "22", value: 22, xp: 41000 }, "23": { cr: "23", value: 23, xp: 50000 }, "24": { cr: "24", value: 24, xp: 62000 }, "25": { cr: "25", value: 25, xp: 75000 }, "26": { cr: "26", value: 26, xp: 90000 }, "27": { cr: "27", value: 27, xp: 105000 }, "28": { cr: "28", value: 28, xp: 120000 }, "29": { cr: "29", value: 29, xp: 135000 }, "30": { cr: "30", value: 30, xp: 155000 } }; if ("cr" in monster && monster.cr in CR) { return \`+\${Math.max( Math.floor(2 + ((CR[monster.cr]?.value ?? 0) - 1) / 4), 2 )}\`; } return "";`}]}],conditioned:!0,hasRule:!0},{type:"traits",id:U(),properties:["traits"],conditioned:!0,dice:!0},{type:"spells",id:U(),properties:["spells"],conditioned:!0,dice:!0},{type:"text",id:U(),properties:["spellsNotes"],conditioned:!0,text:null},{type:"traits",id:U(),properties:["actions"],heading:"Actions",conditioned:!0,dice:!0},{type:"traits",id:U(),properties:["bonus_actions"],heading:"Bonus Actions",conditioned:!0,dice:!0},{type:"group",id:U(),properties:["legendary_description","legendary_actions"],heading:"Legendary Actions",nested:[{type:"text",id:U(),properties:["legendary_description"],conditioned:!0,text:null},{type:"traits",id:U(),properties:["legendary_actions"],conditioned:!0,dice:!0}],conditioned:!0},{type:"group",id:U(),properties:["mythic_description","mythic_actions"],heading:"Mythic Actions",nested:[{type:"text",id:U(),properties:["mythic_description"],conditioned:!0,text:null},{type:"traits",id:U(),properties:["mythic_actions"],conditioned:!0,dice:!0}],conditioned:!0},{type:"traits",id:U(),properties:["reactions"],heading:"Reactions",conditioned:!0,dice:!0},{type:"traits",id:U(),properties:["lair_actions"],heading:"Lair Actions",conditioned:!0,dice:!0},{type:"traits",id:U(),properties:["regional_effects"],heading:"Regional Effects",conditioned:!0,dice:!0}],rn={blocks:hg,id:"basic-5e-layout",name:"Basic 5e Layout",edited:!1,version:9};var Ou=require("obsidian");function N(){}var on=n=>n;function at(n,e){for(let t in e)n[t]=e[t];return n}function xc(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function _r(n){return n()}function Va(){return Object.create(null)}function le(n){n.forEach(_r)}function Pe(n){return typeof n=="function"}function j(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}var ja;function Ac(n,e){return n===e?!0:(ja||(ja=document.createElement("a")),ja.href=e,n===ja.href)}function Tc(n){return Object.keys(n).length===0}function Tt(n,...e){if(n==null){for(let i of e)i(void 0);return N}let t=n.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function Se(n,e,t){n.$$.on_destroy.push(Tt(e,t))}function st(n,e,t,i){if(n){let a=Dc(n,e,t,i);return n[0](a)}}function Dc(n,e,t,i){return n[1]&&i?at(t.ctx.slice(),n[1](i(e))):t.ctx}function rt(n,e,t,i){if(n[2]&&i){let a=n[2](i(t));if(e.dirty===void 0)return a;if(typeof a=="object"){let s=[],r=Math.max(e.dirty.length,a.length);for(let o=0;o32){let e=[],t=n.ctx.length/32;for(let i=0;iwindow.performance.now():()=>Date.now(),Ki=Ec?n=>requestAnimationFrame(n):N;var ki=new Set;function Mc(n){ki.forEach(e=>{e.c(n)||(ki.delete(e),e.f())}),ki.size!==0&&Ki(Mc)}function Gn(n){let e;return ki.size===0&&Ki(Mc),{promise:new Promise(t=>{ki.add(e={c:n,f:t})}),abort(){ki.delete(e)}}}var $i=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var Ua=class n{constructor(e){We(this,"_listeners","WeakMap"in $i?new WeakMap:void 0);We(this,"_observer");We(this,"options");this.options=e}observe(e,t){return this._listeners.set(e,t),this._getObserver().observe(e,this.options),()=>{this._listeners.delete(e),this._observer.unobserve(e)}}_getObserver(){return this._observer??(this._observer=new ResizeObserver(e=>{for(let t of e)n.entries.set(t.target,t),this._listeners.get(t.target)?.(t)}))}};Ua.entries="WeakMap"in $i?new WeakMap:void 0;var Ic=!1;function Oc(){Ic=!0}function Pc(){Ic=!1}function y(n,e){n.appendChild(e)}function re(n,e,t){let i=Ga(n);if(!i.getElementById(e)){let a=v("style");a.id=e,a.textContent=t,Nc(i,a)}}function Ga(n){if(!n)return document;let e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Rc(n){let e=v("style");return e.textContent="/* empty */",Nc(Ga(n),e),e.sheet}function Nc(n,e){return y(n.head||n,e),e.sheet}function D(n,e,t){n.insertBefore(e,t||null)}function x(n){n.parentNode&&n.parentNode.removeChild(n)}function Ke(n,e){for(let t=0;tn.removeEventListener(e,t,i)}function Sr(n){return function(e){return e.preventDefault(),n.call(this,e)}}function ln(n){return function(e){return e.stopPropagation(),n.call(this,e)}}function Lc(n){return function(e){e.target===this&&n.call(this,e)}}function g(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}function cn(n,e){for(let t in e)g(n,t,e[t])}function Kn(n){return n===""?null:+n}function Bc(n){return Array.from(n.childNodes)}function we(n,e){e=""+e,n.data!==e&&(n.data=e)}function ct(n,e){n.value=e??""}function He(n,e,t,i){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,i?"important":"")}function oe(n,e,t){n.classList.toggle(e,!!t)}function Yi(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}var gn=class{constructor(e=!1){We(this,"is_svg",!1);We(this,"e");We(this,"n");We(this,"t");We(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,i=null){this.e||(this.is_svg?this.e=Ut(t.nodeName):this.e=v(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(i)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let t=0;t{e[t.slot||"default"]=!0}),e}function Cr(n,e){return new n(e)}var Ka=new Map,$a=0;function mg(n){let e=5381,t=n.length;for(;t--;)e=(e<<5)-e^n.charCodeAt(t);return e>>>0}function gg(n,e){let t={stylesheet:Rc(e),rules:{}};return Ka.set(n,t),t}function Ji(n,e,t,i,a,s,r,o=0){let l=16.666/i,c=`{ `;for(let b=0;b<=1;b+=l){let _=e+(t-e)*s(b);c+=b*100+`%{${r(_,1-_)}} `}let d=c+`100% {${r(t,1-t)}} }`,u=`__svelte_${mg(d)}_${o}`,h=Ga(n),{stylesheet:m,rules:f}=Ka.get(h)||gg(h,n);f[u]||(f[u]=!0,m.insertRule(`@keyframes ${u} ${d}`,m.cssRules.length));let p=n.style.animation||"";return n.style.animation=`${p?`${p}, `:""}${u} ${i}ms linear ${a}ms 1 both`,$a+=1,u}function Ya(n,e){let t=(n.style.animation||"").split(", "),i=t.filter(e?s=>s.indexOf(e)<0:s=>s.indexOf("__svelte")===-1),a=t.length-i.length;a&&(n.style.animation=i.join(", "),$a-=a,$a||pg())}function pg(){Ki(()=>{$a||(Ka.forEach(n=>{let{ownerNode:e}=n.stylesheet;e&&x(e)}),Ka.clear())})}function Tn(n,e,t,i){if(!e)return N;let a=n.getBoundingClientRect();if(e.left===a.left&&e.right===a.right&&e.top===a.top&&e.bottom===a.bottom)return N;let{delay:s=0,duration:r=300,easing:o=on,start:l=An()+s,end:c=l+r,tick:d=N,css:u}=t(n,{from:e,to:a},i),h=!0,m=!1,f;function p(){u&&(f=Ji(n,0,1,r,s,o,u)),s||(m=!0)}function b(){u&&Ya(n,f),h=!1}return Gn(_=>{if(!m&&_>=l&&(m=!0),m&&_>=c&&(d(1,0),b()),!h)return!1;if(m){let S=_-l,C=0+1*o(S/r);d(C,1-C)}return!0}),p(),d(0,1),b}function Dn(n){let e=getComputedStyle(n);if(e.position!=="absolute"&&e.position!=="fixed"){let{width:t,height:i}=e,a=n.getBoundingClientRect();n.style.position="absolute",n.style.width=t,n.style.height=i,bg(n,a)}}function bg(n,e){let t=n.getBoundingClientRect();if(e.left!==t.left||e.top!==t.top){let i=getComputedStyle(n),a=i.transform==="none"?"":i.transform;n.style.transform=`${a} translate(${e.left-t.left}px, ${e.top-t.top}px)`}}var En;function Dt(n){En=n}function Mn(){if(!En)throw new Error("Function called outside component initialization");return En}function pn(n){Mn().$$.on_mount.push(n)}function bn(n){Mn().$$.on_destroy.push(n)}function Me(){let n=Mn();return(e,t,{cancelable:i=!1}={})=>{let a=n.$$.callbacks[e];if(a){let s=Yi(e,t,{cancelable:i});return a.slice().forEach(r=>{r.call(n,s)}),!s.defaultPrevented}return!0}}function Et(n,e){return Mn().$$.context.set(n,e),e}function Ve(n){return Mn().$$.context.get(n)}function xr(){return Mn().$$.context}function Ue(n,e){let t=n.$$.callbacks[e.type];t&&t.slice().forEach(i=>i.call(this,e))}var $n=[];var Re=[],_i=[],Tr=[],Wc=Promise.resolve(),Dr=!1;function Er(){Dr||(Dr=!0,Wc.then(Xi))}function Ja(){return Er(),Wc}function Mt(n){_i.push(n)}function Lt(n){Tr.push(n)}var Ar=new Set,wi=0;function Xi(){if(wi!==0)return;let n=En;do{try{for(;wi<$n.length;){let e=$n[wi];wi++,Dt(e),yg(e.$$)}}catch(e){throw $n.length=0,wi=0,e}for(Dt(null),$n.length=0,wi=0;Re.length;)Re.pop()();for(let e=0;e<_i.length;e+=1){let t=_i[e];Ar.has(t)||(Ar.add(t),t())}_i.length=0}while($n.length);for(;Tr.length;)Tr.pop()();Dr=!1,Ar.clear(),Dt(n)}function yg(n){if(n.fragment!==null){n.update(),le(n.before_update);let e=n.dirty;n.dirty=[-1],n.fragment&&n.fragment.p(n.ctx,e),n.after_update.forEach(Mt)}}function Hc(n){let e=[],t=[];_i.forEach(i=>n.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),_i=e}var Qi;function vg(){return Qi||(Qi=Promise.resolve(),Qi.then(()=>{Qi=null})),Qi}function Mr(n,e,t){n.dispatchEvent(Yi(`${e?"intro":"outro"}${t}`))}var Xa=new Set,yn;function ce(){yn={r:0,c:[],p:yn}}function ue(){yn.r||le(yn.c),yn=yn.p}function E(n,e){n&&n.i&&(Xa.delete(n),n.i(e))}function I(n,e,t,i){if(n&&n.o){if(Xa.has(n))return;Xa.add(n),yn.c.push(()=>{Xa.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}var kg={duration:0};function Yn(n,e,t,i){let s=e(n,t,{direction:"both"}),r=i?0:1,o=null,l=null,c=null,d;function u(){c&&Ya(n,c)}function h(f,p){let b=f.b-r;return p*=Math.abs(b),{a:r,b:f.b,d:b,duration:p,start:f.start,end:f.start+p,group:f.group}}function m(f){let{delay:p=0,duration:b=300,easing:_=on,tick:S=N,css:C}=s||kg,M={start:An()+p,b:f};f||(M.group=yn,yn.r+=1),"inert"in n&&(f?d!==void 0&&(n.inert=d):(d=n.inert,n.inert=!0)),o||l?l=M:(C&&(u(),c=Ji(n,r,f,b,p,_,C)),f&&S(0,1),o=h(M,b),Mt(()=>Mr(n,f,"start")),Gn(w=>{if(l&&w>l.start&&(o=h(l,b),l=null,Mr(n,o.b,"start"),C&&(u(),c=Ji(n,r,o.b,o.duration,0,_,s.css))),o){if(w>=o.end)S(r=o.b,1-r),Mr(n,o.b,"end"),l||(o.b?u():--o.group.r||le(o.group.c)),o=null;else if(w>=o.start){let k=w-o.start;r=o.a+o.d*_(k/o.duration),S(r,1-r)}}return!!(o||l)}))}return{run(f){Pe(s)?vg().then(()=>{s=s({direction:f?"in":"out"}),m(f)}):m(f)},end(){u(),o=l=null}}}function zc(n,e){let t=e.token={};function i(a,s,r,o){if(e.token!==t)return;e.resolved=o;let l=e.ctx;r!==void 0&&(l=l.slice(),l[r]=o);let c=a&&(e.current=a)(l),d=!1;e.block&&(e.blocks?e.blocks.forEach((u,h)=>{h!==s&&u&&(ce(),I(u,1,1,()=>{e.blocks[h]===u&&(e.blocks[h]=null)}),ue())}):e.block.d(1),c.c(),E(c,1),c.m(e.mount(),e.anchor),d=!0),e.block=c,e.blocks&&(e.blocks[s]=c),d&&Xi()}if(xc(n)){let a=Mn();if(n.then(s=>{Dt(a),i(e.then,1,e.value,s),Dt(null)},s=>{if(Dt(a),i(e.catch,2,e.error,s),Dt(null),!e.hasCatch)throw s}),e.current!==e.pending)return i(e.pending,0),!0}else{if(e.current!==e.then)return i(e.then,1,e.value,n),!0;e.resolved=n}}function qc(n,e,t){let i=e.slice(),{resolved:a}=n;n.current===n.then&&(i[n.value]=a),n.current===n.catch&&(i[n.error]=a),n.block.p(i,t)}function ye(n){return n?.length!==void 0?n:Array.from(n)}function Ir(n,e){n.d(1),e.delete(n.key)}function Jn(n,e){I(n,1,1,()=>{e.delete(n.key)})}function jc(n,e){n.f(),Ir(n,e)}function Si(n,e){n.f(),Jn(n,e)}function bt(n,e,t,i,a,s,r,o,l,c,d,u){let h=n.length,m=s.length,f=h,p={};for(;f--;)p[n[f].key]=f;let b=[],_=new Map,S=new Map,C=[];for(f=m;f--;){let A=u(a,s,f),P=t(A),L=r.get(P);L?i&&C.push(()=>L.p(A,e)):(L=c(P,A),L.c()),_.set(P,b[f]=L),P in p&&S.set(P,Math.abs(f-p[P]))}let M=new Set,w=new Set;function k(A){E(A,1),A.m(o,d),r.set(A.key,A),d=A.first,m--}for(;h&&m;){let A=b[m-1],P=n[h-1],L=A.key,B=P.key;A===P?(d=A.first,h--,m--):_.has(B)?!r.has(L)||M.has(L)?k(A):w.has(B)?h--:S.get(L)>S.get(B)?(w.add(L),k(A)):(M.add(B),h--):(l(P,r),h--)}for(;h--;){let A=n[h];_.has(A.key)||l(A,r)}for(;m;)k(b[m-1]);return le(C),b}function In(n,e){let t={},i={},a={$$scope:1},s=n.length;for(;s--;){let r=n[s],o=e[s];if(o){for(let l in r)l in o||(i[l]=1);for(let l in o)a[l]||(t[l]=o[l],a[l]=1);n[s]=o}else for(let l in r)a[l]=1}for(let r in i)r in t||(t[r]=void 0);return t}var wg=["allowfullscreen","allowpaymentrequest","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"],_g=new Set([...wg]);function Bt(n,e,t){let i=n.$$.props[e];i!==void 0&&(n.$$.bound[i]=t,t(n.$$.ctx[i]))}function ae(n){n&&n.c()}function te(n,e,t){let{fragment:i,after_update:a}=n.$$;i&&i.m(e,t),Mt(()=>{let s=n.$$.on_mount.map(_r).filter(Pe);n.$$.on_destroy?n.$$.on_destroy.push(...s):le(s),n.$$.on_mount=[]}),a.forEach(Mt)}function ne(n,e){let t=n.$$;t.fragment!==null&&(Hc(t.after_update),le(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Cg(n,e){n.$$.dirty[0]===-1&&($n.push(n),Er(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{let f=m.length?m[0]:h;return c.ctx&&a(c.ctx[u],c.ctx[u]=f)&&(!c.skip_bound&&c.bound[u]&&c.bound[u](f),d&&Cg(n,u)),h}):[],c.update(),d=!0,le(c.before_update),c.fragment=i?i(c.ctx):!1,e.target){if(e.hydrate){Oc();let u=Bc(e.target);c.fragment&&c.fragment.l(u),u.forEach(x)}else c.fragment&&c.fragment.c();e.intro&&E(n.$$.fragment),te(n,e.target,e.anchor),Pc(),Xi()}Dt(l)}var xg;typeof HTMLElement=="function"&&(xg=class extends HTMLElement{constructor(e,t,i){super();We(this,"$$ctor");We(this,"$$s");We(this,"$$c");We(this,"$$cn",!1);We(this,"$$d",{});We(this,"$$r",!1);We(this,"$$p_d",{});We(this,"$$l",{});We(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,i&&this.attachShadow({mode:"open"})}addEventListener(e,t,i){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){let a=this.$$c.$on(e,t);this.$$l_u.set(t,a)}super.addEventListener(e,t,i)}removeEventListener(e,t,i){if(super.removeEventListener(e,t,i),this.$$c){let a=this.$$l_u.get(t);a&&(a(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(s){return()=>{let r;return{c:function(){r=v("slot"),s!=="default"&&g(r,"name",s)},m:function(c,d){D(c,r,d)},d:function(c){c&&x(r)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;let t={},i=Fc(this);for(let s of this.$$s)s in i&&(t[s]=[e(s)]);for(let s of this.attributes){let r=this.$$g_p(s.name);r in this.$$d||(this.$$d[r]=Or(r,s.value,this.$$p_d,"toProp"))}for(let s in this.$$p_d)!(s in this.$$d)&&this[s]!==void 0&&(this.$$d[s]=this[s],delete this[s]);this.$$c=new this.$$ctor({target:this.shadowRoot||this,props:{...this.$$d,$$slots:t,$$scope:{ctx:[]}}});let a=()=>{this.$$r=!0;for(let s in this.$$p_d)if(this.$$d[s]=this.$$c.$$.ctx[this.$$c.$$.props[s]],this.$$p_d[s].reflect){let r=Or(s,this.$$d[s],this.$$p_d,"toAttribute");r==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,r)}this.$$r=!1};this.$$c.$$.after_update.push(a),a();for(let s in this.$$l)for(let r of this.$$l[s]){let o=this.$$c.$on(s,r);this.$$l_u.set(r,o)}this.$$l={}}}attributeChangedCallback(e,t,i){this.$$r||(e=this.$$g_p(e),this.$$d[e]=Or(e,i,this.$$p_d,"toProp"),this.$$c?.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$c=void 0)})}$$g_p(e){return Object.keys(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Or(n,e,t,i){let a=t[n]?.type;if(e=a==="Boolean"&&typeof e!="boolean"?e!=null:e,!i||!t[n])return e;if(i==="toAttribute")switch(a){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(a){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}var G=class{constructor(){We(this,"$$");We(this,"$$set")}$destroy(){ne(this,1),this.$destroy=N}$on(e,t){if(!Pe(t))return N;let i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{let a=i.indexOf(t);a!==-1&&i.splice(a,1)}}$set(e){this.$$set&&!Tc(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var Vc="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Vc);var Kt=require("obsidian");var Ci=[];function Ag(n,e){return{subscribe:Be(n,e).subscribe}}function Be(n,e=N){let t,i=new Set;function a(o){if(j(n,o)&&(n=o,t)){let l=!Ci.length;for(let c of i)c[1](),Ci.push(c,n);if(l){for(let c=0;c{i.delete(c),i.size===0&&t&&(t(),t=null)}}return{set:a,update:s,subscribe:r}}function yt(n,e,t){let i=!Array.isArray(n),a=i?[n]:n;if(!a.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");let s=e.length<2;return Ag(t,(r,o)=>{let l=!1,c=[],d=0,u=N,h=()=>{if(d)return;u();let f=e(i?c[0]:c,r,o);s?r(f):u=Pe(f)?f:N},m=a.map((f,p)=>Tt(f,b=>{c[p]=b,d&=~(1<{d|=1<([\\s\\S]+?)<${Qa}>`),Za="STATBLOCK-MARKDOWN-LINK",ts=new RegExp(`<${Za}>([\\s\\S]+?)(?:\\|([\\s\\S]+?))?<${Za}>`),Nr=/([\s\S]+?)/,Ft=class n{static isStatblockLink(e){return Nr.test(e)}static replaceWikiLink(e){return`<${Qa}>${e}<${Qa}>`}static replaceMarkdownLink(e,t){return`<${Za}>${e}${t?"|"+t:""}<${Za}>`}static transformSource(e){return e.replace(/\[\[([^\]]+?)\]\]/g,(t,i)=>n.replaceWikiLink(i)).replace(/\[([^\]]*?)\]\(([^)]+?)\)/g,(t,i,a)=>n.replaceMarkdownLink(a,i))}static transformYamlSource(e){return n.transformSource(e)}static stringifyLinks(e){return e.replace(new RegExp(es,"g"),(t,i)=>`[[${i}]]`).replace(new RegExp(ts,"g"),(t,i,a)=>`[${a||""}](${i})`)}};var vn,Zi,Br,Lr=class extends xi.Component{constructor(){super(...arguments);Le(this,Zi);Le(this,vn,new Map)}buildCache(){setTimeout(()=>{let t=this.metadataCache.getLinkSuggestions();for(let{alias:i,file:a}of t)i&&Oe(this,Zi,Br).call(this,[i],a)},0)}getResolvedFile(t,i){t=t.trim();let a=Q(this,vn).get(t)??Q(this,vn).get(t.toLowerCase())??t;return{alias:Q(this,vn).has(t)||Q(this,vn).has(t.toLowerCase())?t:null,file:this.app.metadataCache.getFirstLinkpathDest(a,i)}}initialize(t,i){if(this.load(),this.app=i,this.metadataCache=t,t.initialized)this.buildCache();else{let a=i.metadataCache.on("resolved",()=>{this.buildCache(),this.metadataCache.offref(a)});this.registerEvent(a)}this.registerEvent(this.metadataCache.on("changed",a=>{let{frontmatter:s}=i.metadataCache.getFileCache(a)??{};if(!s)return;let r=(0,xi.parseFrontMatterAliases)(s)??[];Oe(this,Zi,Br).call(this,r,a)}))}linkify(t,i=""){let a=t.trim(),{file:s,alias:r}=this.getResolvedFile(a,i);return s!=null?t.replace(a,Ft.replaceWikiLink(`${s.basename}${r?"|"+r:""}`)):t}linkifySpells(t,i=""){return t.replace(/(.+?)(\*?,|\*?$)/g,(a,s,r)=>`${this.linkify(s,i)}${r}`)}transformSource(t){return Ft.transformSource(t)}transformYamlSource(t){return Ft.transformYamlSource(t)}stringifyLinks(t){return Ft.stringifyLinks(t)}splitByLinks(t,i,a){return be(t).split(Nr).filter(s=>s&&s.length).map(s=>{if(es.test(s)){let r=s.match(es)[1];return{isLink:a,text:`[[${(0,xi.normalizePath)(r)}]]`}}if(ts.test(s)){let[r,o,l]=s.match(ts);return{isLink:a,text:`[${l||""}](${o})`}}return{isLink:!1,text:s}})}};vn=new WeakMap,Zi=new WeakSet,Br=function(t,i){for(let a of t)Q(this,vn).set(a,i.name),Q(this,vn).set(a.toLowerCase(),i.name)};var ut=new Lr;function Uc(n,e,t){let i=new Map,a=new Map,s=n.diceParsing??ns();for(let o of s){i.set(o.id,new RegExp(o.regex));let l=` let anon = (original, matches, monster) => { if (!matches || !matches.length) return original; ${o.parser}; } let result; try { result = anon(original, matches, monster); } catch(e) { console.error(e); result = original; } finally { return result; } `,c=new Function("original","matches","monster",l);a.set(o.id,c)}for(let{id:o}of s){let l=i.get(o);e=e.replaceAll(new RegExp(l,"g"),c=>`${o}${c}`)}let r=[];for(let o of e.split(/(.+?)/)){if(!/.+?/.test(o)){r.push(o);continue}let[,l,c]=o.match(/(.+?)(.+)/)??[];if(!l||!c){r.push(o);continue}let d=i.get(l),u=a.get(l),h=c.match(d),m=u.call(void 0,c,h,t);!m||Array.isArray(m)&&!m.every(f=>typeof f=="string"||f?.text?.length)||!Array.isArray(m)&&typeof m=="object"&&!m.text?.length?r.push(c):Array.isArray(m)?r.push(...m):r.push(m)}return r}function ns(){return[{regex:/([\+\-])(\d+) to hit/.source,parser:`let [, sign, number] = matches; let mult = 1; if (sign === "-") { mult = -1; } if (!isNaN(Number(number))) { return { text: \`1d20+\${mult * Number(number)}\`, original } }`,id:U(),desc:"+10 to hit"},{regex:/(\d+)\s\((\d+d\d+(?:\s*[+\-]\s*\d+)?)\)/.source,parser:`let [, base, dice] = matches; let text; if (!isNaN(Number(base)) && dice) { text = dice; } return { text, original: dice ?? original };`,id:U(),desc:"4 (1d6 + 1)"},{regex:/([^\s]+) ([\+\-])(\d+)/.source,parser:` let [, save, sign, number] = matches; let mult = 1; if (sign === "-") { mult = -1; } let text; if (!isNaN(Number(number))) { text = \`1d20+\${mult * Number(number)}\`; original = \`\${save} \${sign}\${number}\`; } return { text, original };`,id:U(),desc:"+5"}]}function Eg(n){re(n,"svelte-1c3hzq4",".statblock-markdown.svelte-1c3hzq4{display:inline}.statblock-markdown.svelte-1c3hzq4 p{display:inline}.statblock-markdown.svelte-1c3hzq4 p ~ p{display:inline-block}")}function Mg(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","statblock-markdown svelte-1c3hzq4")},m(s,r){D(s,e,r),i||(a=X(t=n[1].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function Ig(n,e,t){let i,{property:a}=e;a=typeof a=="string"?ut.stringifyLinks(a):a;let s=Ve("context"),r=Ve("renderer"),o=Ve("item"),l=Ve("dice"),c=o.dice,d=Ve("monster");Se(n,d,b=>t(5,i=b));let u=i;d.subscribe(b=>u=b);let h=Ve("plugin"),m=Ve("layout"),f=[a];if(l&&c)if(o.diceProperty&&o.diceProperty in u&&typeof u[o.diceProperty]=="string")f=[{text:u[o.diceProperty]}];else{let b=Uc(m,be(a),u);Array.isArray(b)?f=b:f=[b]}if(l&&o.diceCallback)try{let b=document.body.createEl("iframe"),_=b.contentWindow.Function,C=new _("monster","property",o.diceCallback).call(void 0,u,a)??a;document.body.removeChild(b),Array.isArray(C)?f=C:f=[C]}catch(b){new is.Notice(`There was an error executing the provided dice callback for [${o.properties.join(", ")}] ${b.message}`),console.error(b)}a="";for(let b of f)if(l&&typeof b!="string"){let _,S=h.getRollerString(b.text);b.original?_=`${b.original} (\`dice: ${S}\`)`:_=`\`dice: ${S}\``,a+=_}else a+=b;let p=b=>{a==="-"&&t(2,a="\\-"),is.MarkdownRenderer.render(h.app,a,b,s,r)};return n.$$set=b=>{"property"in b&&t(2,a=b.property)},[d,p,a]}var Fr=class extends G{constructor(e){super(),K(this,e,Ig,Mg,j,{property:2},Eg)}},Gc=Fr;function Og(n){let e,t;return e=new Gc({props:{property:n[0]}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,[a]){let s={};a&1&&(s.property=i[0]),e.$set(s)},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function Pg(n,e,t){let{property:i=""}=e;return n.$$set=a=>{"property"in a&&t(0,i=a.property)},[i]}var Wr=class extends G{constructor(e){super(),K(this,e,Pg,Og,j,{property:0})}},vt=Wr;var Xc=require("obsidian");function Rg(n){re(n,"svelte-1d2gp4n",".trait.svelte-1d2gp4n{font-family:var(--active-traits-font);color:var(--active-traits-font-color);font-size:var(--active-traits-font-size);font-weight:var(--active-traits-font-weight);font-style:var(--active-traits-font-style)}.trait-name.svelte-1d2gp4n{font-family:var(--active-traits-name-font);color:var(--active-traits-name-font-color);font-size:var(--active-traits-name-font-size);font-weight:var(--active-traits-name-font-weight);font-style:var(--active-traits-name-font-style)}.property-name.svelte-1d2gp4n{margin:0;margin-right:0.25em;display:inline}.statblock-nested-traits.svelte-1d2gp4n{margin-left:1rem}")}function Kc(n,e,t){let i=n.slice();return i[7]=e[t],i}function $c(n){let e,t,i;return t=new vt({props:{property:n[2]}}),{c(){e=v("div"),ae(t.$$.fragment),g(e,"class","property-name trait-name svelte-1d2gp4n")},m(a,s){D(a,e,s),te(t,e,null),i=!0},p(a,s){let r={};s&4&&(r.property=a[2]),t.$set(r)},i(a){i||(E(t.$$.fragment,a),i=!0)},o(a){I(t.$$.fragment,a),i=!1},d(a){a&&x(e),ne(t)}}}function Yc(n){let e,t,i=ye(n[1].traits),a=[];for(let r=0;rI(a[r],1,1,()=>{a[r]=null});return{c(){e=v("div");for(let r=0;r{o=null}),ue());let u={};d&1&&(u.property=c[0]),i.$set(u),c[1]?.traits?l?(l.p(c,d),d&2&&E(l,1)):(l=Yc(c),l.c(),E(l,1),l.m(e,null)):l&&(ce(),I(l,1,1,()=>{l=null}),ue()),(!r||d&32&&s!==(s="property "+c[5]+" trait svelte-1d2gp4n"))&&g(e,"class",s)},i(c){r||(E(o),E(i.$$.fragment,c),E(l),r=!0)},o(c){I(o),I(i.$$.fragment,c),I(l),r=!1},d(c){c&&x(e),o&&o.d(),ne(i),l&&l.d()}}}function Lg(n,e,t){let i,{trait:a}=e,{name:s}=e,{desc:r}=e,{property:o=""}=e,{item:l}=e,{monster:c}=e;if(l.callback)try{let d=document.body.createEl("iframe"),u=d.contentWindow.Function;r=new u("monster","property",l.callback).call(void 0,c,a)??r,document.body.removeChild(d)}catch(d){new Xc.Notice(`There was an error executing the provided callback for [${l.properties.join(", ")}] ${d.message}`),console.error(d)}return n.$$set=d=>{"trait"in d&&t(1,a=d.trait),"name"in d&&t(2,s=d.name),"desc"in d&&t(0,r=d.desc),"property"in d&&t(3,o=d.property),"item"in d&&t(4,l=d.item),"monster"in d&&t(6,c=d.monster)},n.$$.update=()=>{n.$$.dirty&28&&t(5,i=l.doNotAddClass?[]:[sn(s),sn(o)].join(" "))},[r,a,s,o,l,i,c]}var as=class extends G{constructor(e){super(),K(this,e,Lg,Ng,j,{trait:1,name:2,desc:0,property:3,item:4,monster:6},Rg)}},ea=as;var ss=require("obsidian");function Bg(n){re(n,"svelte-1lnliuc",".inline.svelte-1lnliuc{display:inline}")}function Qc(n,e,t){let i=n.slice();return i[6]=e[t],i}function Fg(n){let e=n[6].text+"",t;return{c(){t=pe(e)},m(i,a){D(i,t,a)},p:N,d(i){i&&x(t)}}}function Wg(n){let e,t,i={ctx:n,current:null,token:null,hasCatch:!1,pending:qg,then:zg,catch:Hg,value:9};return zc(t=n[1](n[6].text),i),{c(){e=_e(),i.block.c()},m(a,s){D(a,e,s),i.block.m(a,i.anchor=s),i.mount=()=>e.parentNode,i.anchor=e},p(a,s){n=a,qc(i,n,s)},d(a){a&&x(e),i.block.d(a),i.token=null,i=null}}}function Hg(n){return{c:N,m:N,p:N,d:N}}function zg(n){let e,t=n[9]+"",i;return{c(){e=new gn(!1),i=_e(),e.a=i},m(a,s){e.m(t,a,s),D(a,i,s)},p:N,d(a){a&&(x(i),e.d())}}}function qg(n){return{c:N,m:N,p:N,d:N}}function Zc(n){let e;function t(s,r){return s[6].isLink?Wg:Fg}let a=t(n,-1)(n);return{c(){a.c(),e=_e()},m(s,r){a.m(s,r),D(s,e,r)},p(s,r){a.p(s,r)},d(s){s&&x(e),a.d(s)}}}function jg(n){let e,t=ye(n[0]),i=[];for(let a=0;a{let d=createDiv();return await ss.MarkdownRenderer.render(app,c,d,s,r),d.querySelector("a").outerHTML};return n.$$set=c=>{"textToRender"in c&&t(2,i=c.textToRender)},[o,l,i]}var Hr=class extends G{constructor(e){super(),K(this,e,Vg,jg,j,{textToRender:2},Bg)}},Gt=Hr;function Ug(n){re(n,"svelte-14k5qsm",".flex-container.svelte-14k5qsm{display:flex;justify-content:space-between;align-items:center}.heading.svelte-14k5qsm{font-family:var(--active-heading-font);color:var(--active-heading-font-color);font-weight:var(--active-heading-font-weight);font-variant:var(--active-heading-font-variant);font-size:var(--active-heading-font-size);line-height:var(--active-heading-line-height);margin:0px;letter-spacing:1px;display:flex;justify-content:space-between;align-items:center}")}function eu(n,e,t){let i=n.slice();return i[2]=e[t],i}function tu(n){let e,t,i,a,s=[Xg,Jg,Yg,$g,Kg,Gg],r=[];function o(l,c){return!l[1].size||l[1].size==1?0:l[1].size==2?1:l[1].size==3?2:l[1].size==4?3:l[1].size==5?4:5}return e=o(n,-1),t=r[e]=s[e](n),{c(){t.c(),i=_e()},m(l,c){r[e].m(l,c),D(l,i,c),a=!0},p(l,c){let d=e;e=o(l,c),e===d?r[e].p(l,c):(ce(),I(r[d],1,1,()=>{r[d]=null}),ue(),t=r[e],t?t.p(l,c):(t=r[e]=s[e](l),t.c()),E(t,1),t.m(i.parentNode,i))},i(l){a||(E(t),a=!0)},o(l){I(t),a=!1},d(l){l&&x(i),r[e].d(l)}}}function Gg(n){let e,t,i,a,s;return t=new Gt({props:{textToRender:be(n[0][n[2]])}}),{c(){e=v("h6"),ae(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+be(n[2])+" svelte-14k5qsm")},m(r,o){D(r,e,o),te(t,e,null),y(e,i),s=!0},p(r,o){let l={};o&3&&(l.textToRender=be(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+be(r[2])+" svelte-14k5qsm"))&&g(e,"class",a)},i(r){s||(E(t.$$.fragment,r),s=!0)},o(r){I(t.$$.fragment,r),s=!1},d(r){r&&x(e),ne(t)}}}function Kg(n){let e,t,i,a,s;return t=new Gt({props:{textToRender:be(n[0][n[2]])}}),{c(){e=v("h5"),ae(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+be(n[2])+" svelte-14k5qsm")},m(r,o){D(r,e,o),te(t,e,null),y(e,i),s=!0},p(r,o){let l={};o&3&&(l.textToRender=be(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+be(r[2])+" svelte-14k5qsm"))&&g(e,"class",a)},i(r){s||(E(t.$$.fragment,r),s=!0)},o(r){I(t.$$.fragment,r),s=!1},d(r){r&&x(e),ne(t)}}}function $g(n){let e,t,i,a,s;return t=new Gt({props:{textToRender:be(n[0][n[2]])}}),{c(){e=v("h4"),ae(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+be(n[2])+" svelte-14k5qsm")},m(r,o){D(r,e,o),te(t,e,null),y(e,i),s=!0},p(r,o){let l={};o&3&&(l.textToRender=be(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+be(r[2])+" svelte-14k5qsm"))&&g(e,"class",a)},i(r){s||(E(t.$$.fragment,r),s=!0)},o(r){I(t.$$.fragment,r),s=!1},d(r){r&&x(e),ne(t)}}}function Yg(n){let e,t,i,a,s;return t=new Gt({props:{textToRender:be(n[0][n[2]])}}),{c(){e=v("h3"),ae(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+be(n[2])+" svelte-14k5qsm")},m(r,o){D(r,e,o),te(t,e,null),y(e,i),s=!0},p(r,o){let l={};o&3&&(l.textToRender=be(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+be(r[2])+" svelte-14k5qsm"))&&g(e,"class",a)},i(r){s||(E(t.$$.fragment,r),s=!0)},o(r){I(t.$$.fragment,r),s=!1},d(r){r&&x(e),ne(t)}}}function Jg(n){let e,t,i,a,s;return t=new Gt({props:{textToRender:be(n[0][n[2]])}}),{c(){e=v("h2"),ae(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+be(n[2])+" svelte-14k5qsm")},m(r,o){D(r,e,o),te(t,e,null),y(e,i),s=!0},p(r,o){let l={};o&3&&(l.textToRender=be(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+be(r[2])+" svelte-14k5qsm"))&&g(e,"class",a)},i(r){s||(E(t.$$.fragment,r),s=!0)},o(r){I(t.$$.fragment,r),s=!1},d(r){r&&x(e),ne(t)}}}function Xg(n){let e,t,i,a,s;return t=new Gt({props:{textToRender:be(n[0][n[2]])}}),{c(){e=v("h1"),ae(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+be(n[2])+" svelte-14k5qsm")},m(r,o){D(r,e,o),te(t,e,null),y(e,i),s=!0},p(r,o){let l={};o&3&&(l.textToRender=be(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+be(r[2])+" svelte-14k5qsm"))&&g(e,"class",a)},i(r){s||(E(t.$$.fragment,r),s=!0)},o(r){I(t.$$.fragment,r),s=!1},d(r){r&&x(e),ne(t)}}}function nu(n){let e,t,i=n[2]in n[0]&&tu(n);return{c(){i&&i.c(),e=_e()},m(a,s){i&&i.m(a,s),D(a,e,s),t=!0},p(a,s){a[2]in a[0]?i?(i.p(a,s),s&3&&E(i,1)):(i=tu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(ce(),I(i,1,1,()=>{i=null}),ue())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function Qg(n){let e,t,i=ye(n[1].properties),a=[];for(let r=0;rI(a[r],1,1,()=>{a[r]=null});return{c(){e=v("div");for(let r=0;r{"monster"in s&&t(0,i=s.monster),"item"in s&&t(1,a=s.item)},[i,a]}var zr=class extends G{constructor(e){super(),K(this,e,Zg,Qg,j,{monster:0,item:1},Ug)}},iu=zr;var su=require("obsidian");function ep(n){re(n,"svelte-1rketb6",".line.svelte-1rketb6{line-height:var(--active-property-line-height);display:block;font-family:var(--active-property-font);color:var(--active-property-font-color);font-variant:var(--active-property-font-variant);font-size:var(--active-property-font-size);font-weight:var(--active-property-font-weight)}.property-name.svelte-1rketb6{margin:0;margin-right:0.25em;display:inline;font-family:var(--active-property-name-font);color:var(--active-property-name-font-color);font-variant:var(--active-property-name-font-variant);font-size:var(--active-property-name-font-size);font-weight:var(--active-property-name-font-weight)}")}function au(n){let e,t,i,a,s,r;return a=new vt({props:{property:n[1]}}),{c(){e=v("div"),t=v("span"),t.textContent=`${n[3]}`,i=R(),ae(a.$$.fragment),g(t,"class","property-name svelte-1rketb6"),g(e,"class",s="line "+n[2]+" svelte-1rketb6")},m(o,l){D(o,e,l),y(e,t),y(e,i),te(a,e,null),r=!0},p(o,l){let c={};l&2&&(c.property=o[1]),a.$set(c),(!r||l&4&&s!==(s="line "+o[2]+" svelte-1rketb6"))&&g(e,"class",s)},i(o){r||(E(a.$$.fragment,o),r=!0)},o(o){I(a.$$.fragment,o),r=!1},d(o){o&&x(e),ne(a)}}}function tp(n){let e,t,i=(!n[0].conditioned||n[0].conditioned&&`${n[1]}`.length)&&au(n);return{c(){i&&i.c(),e=_e()},m(a,s){i&&i.m(a,s),D(a,e,s),t=!0},p(a,[s]){!a[0].conditioned||a[0].conditioned&&`${a[1]}`.length?i?(i.p(a,s),s&3&&E(i,1)):(i=au(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(ce(),I(i,1,1,()=>{i=null}),ue())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function np(n,e,t){let i,{monster:a}=e,{item:s}=e,r=be(a[s.properties[0]],0,", ",!1),o=s.display??s.properties[0];if(s.callback)try{let l=document.body.createEl("iframe"),c=l.contentWindow.Function;r=new c("monster",s.callback).call(void 0,a)??r,document.body.removeChild(l)}catch(l){new su.Notice(`There was an error executing the provided callback for [${s.properties.join(", ")}] ${l.message}`),console.error(l)}return!s.conditioned&&!`${r}`.length&&(r=s.fallback??"-"),n.$$set=l=>{"monster"in l&&t(4,a=l.monster),"item"in l&&t(0,s=l.item)},n.$$.update=()=>{n.$$.dirty&1&&t(2,i=s.doNotAddClass?"":sn(s.properties[0]))},[s,r,i,o,a]}var qr=class extends G{constructor(e){super(),K(this,e,np,tp,j,{monster:4,item:0},ep)}},ru=qr;function ip(n){re(n,"svelte-k72li0",`.tapered-rule.svelte-k72li0{width:auto;margin:0.5em 0;height:5px;background:-webkit-linear-gradient( 0deg, var(--active-rule-color) 0%, var(--active-rule-color) 50%, var(--active-background-color) 95%, var(--active-background-color) 100% );clip-path:polygon(0 0, 0 100%, 95% 50%);-webkit-clip-path:polygon(0 0, 0 100%, 95% 50%)}`)}function ap(n){let e;return{c(){e=v("div"),g(e,"class","tapered-rule svelte-k72li0")},m(t,i){D(t,e,i)},p:N,i:N,o:N,d(t){t&&x(e)}}}var jr=class extends G{constructor(e){super(),K(this,e,null,ap,j,{},ip)}},rs=jr;function sp(n){re(n,"svelte-r9sicd",".line.svelte-r9sicd{line-height:var(--active-saves-line-height);display:block;color:var(--active-font-color)}.property-name.svelte-r9sicd{color:var(--active-property-name-font-color);margin:0;margin-right:0.25em;display:inline;font-weight:bold}.property-text.svelte-r9sicd{display:inline;margin:0}")}function rp(n){let e,t,i,a=(n[0].display??Gi(n[0].properties[0]))+"",s,r,o,l,c;return l=new vt({props:{render:n[0].markdown,property:n[1]}}),{c(){e=v("div"),t=v("div"),i=v("span"),s=pe(a),r=R(),o=v("div"),ae(l.$$.fragment),g(i,"class","property-name svelte-r9sicd"),g(o,"class","property-text svelte-r9sicd"),g(t,"class","line svelte-r9sicd"),g(e,"class","info")},m(d,u){D(d,e,u),y(e,t),y(t,i),y(i,s),y(t,r),y(t,o),te(l,o,null),c=!0},p(d,[u]){(!c||u&1)&&a!==(a=(d[0].display??Gi(d[0].properties[0]))+"")&&we(s,a);let h={};u&1&&(h.render=d[0].markdown),l.$set(h)},i(d){c||(E(l.$$.fragment,d),c=!0)},o(d){I(l.$$.fragment,d),c=!1},d(d){d&&x(e),ne(l)}}}function op(n){return`${n>=0?"+":""}${n}`}function lp(n,e,t){let{monster:i}=e,{item:a}=e,s=i[a.properties[0]];Array.isArray(s)||(s=[]);let r=s.map(o=>{if(typeof o!="object"||o==null)return null;let l=Object.keys(o)[0];if(!l)return null;let c=Object.values(o)[0];return typeof c=="string"&&isNaN(Number(c))?`${Gi(l)} ${c}`:c!=0&&(!c||isNaN(Number(c)))?null:`${Gi(l)} ${op(c)}`}).filter(o=>o).join(", ");return n.$$set=o=>{"monster"in o&&t(2,i=o.monster),"item"in o&&t(0,a=o.item)},[a,r,i]}var Vr=class extends G{constructor(e){super(),K(this,e,lp,rp,j,{monster:2,item:0},sp)}},ou=Vr;function cp(n){re(n,"svelte-1ascaxr",`.section-header.svelte-1ascaxr{border-bottom:var(--active-section-heading-border-size) solid var(--active-section-heading-border-color);color:var(--active-section-heading-font-color);font-size:var(--active-section-heading-font-size);font-variant:var(--active-section-heading-font-variant);font-weight:var(--active-section-heading-font-weight);font-family:var(--active-section-heading-font);letter-spacing:1px;margin:0;margin-bottom:0.3em;break-inside:avoid-column;break-after:avoid-column}`)}function lu(n){let e,t,i,a;return t=new Gt({props:{textToRender:n[0]}}),{c(){e=v("h3"),ae(t.$$.fragment),g(e,"class",i="section-header "+n[1](n[0])+" svelte-1ascaxr")},m(s,r){D(s,e,r),te(t,e,null),a=!0},p(s,r){let o={};r&1&&(o.textToRender=s[0]),t.$set(o),(!a||r&1&&i!==(i="section-header "+s[1](s[0])+" svelte-1ascaxr"))&&g(e,"class",i)},i(s){a||(E(t.$$.fragment,s),a=!0)},o(s){I(t.$$.fragment,s),a=!1},d(s){s&&x(e),ne(t)}}}function up(n){let e,t,i=n[0]&&n[0].length&&lu(n);return{c(){i&&i.c(),e=_e()},m(a,s){i&&i.m(a,s),D(a,e,s),t=!0},p(a,[s]){a[0]&&a[0].length?i?(i.p(a,s),s&1&&E(i,1)):(i=lu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(ce(),I(i,1,1,()=>{i=null}),ue())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function dp(n,e,t){let{monster:i}=e,{item:a}=e,s;if(a.headingProp){if(a.heading in i){let o=be(i[a.heading]);o.length&&(s=o)}}else a.heading?.length&&(s=a.heading);let r=o=>o.toLowerCase().replace(/[^A-Za-z0-9\s]/g,"").replace(/\s+/g,"-");return n.$$set=o=>{"monster"in o&&t(2,i=o.monster),"item"in o&&t(3,a=o.item)},[s,r,i,a]}var Ur=class extends G{constructor(e){super(),K(this,e,dp,up,j,{monster:2,item:3},cp)}},Ai=Ur;function hp(n){re(n,"svelte-1fyuyh",".subheading.svelte-1fyuyh{font-weight:var(--active-subheading-font-weight);font-style:var(--active-subheading-font-style);font-size:var(--active-subheading-font-size);font-family:var(--active-subheading-font-family);color:var(--active-subheading-font-color);margin:0}")}function fp(n){let e,t,i;return t=new Gt({props:{textToRender:n[1].join(n[0].separator)}}),{c(){e=v("div"),ae(t.$$.fragment),g(e,"class","subheading svelte-1fyuyh")},m(a,s){D(a,e,s),te(t,e,null),i=!0},p(a,s){let r={};s&1&&(r.textToRender=a[1].join(a[0].separator)),t.$set(r)},i(a){i||(E(t.$$.fragment,a),i=!0)},o(a){I(t.$$.fragment,a),i=!1},d(a){a&&x(e),ne(t)}}}function mp(n){let e,t,i=n[1].length&&fp(n);return{c(){i&&i.c(),e=_e()},m(a,s){i&&i.m(a,s),D(a,e,s),t=!0},p(a,[s]){a[1].length&&i.p(a,s)},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function gp(n,e,t){let{monster:i}=e,{item:a}=e,s=[];for(let r of a.properties)r in i&&s.push(`${be(i[r],0,", ",!1)}`);return n.$$set=r=>{"monster"in r&&t(2,i=r.monster),"item"in r&&t(0,a=r.item)},[a,s,i]}var Gr=class extends G{constructor(e){super(),K(this,e,gp,mp,j,{monster:2,item:0},hp)}},cu=Gr;function pp(n){re(n,"svelte-gjlmp0",".statblock-table-header.svelte-gjlmp0{font-weight:var(--active-table-header-font-weight)}.statblock-table.svelte-gjlmp0{display:flex;justify-content:space-evenly;align-items:center;flex-wrap:wrap}.table-item.svelte-gjlmp0{display:flex;justify-content:center;align-items:center;flex-flow:column nowrap}")}function uu(n,e,t){let i=n.slice();return i[6]=e[t][0],i[1]=e[t][1],i}function du(n,e,t){let i=n.slice();return i[9]=e[t],i}function hu(n){let e;return{c(){e=v("span"),e.textContent=`${n[2](n[9])}`},m(t,i){D(t,e,i)},p:N,d(t){t&&x(e)}}}function fu(n){let e,t,i,a;t=new vt({props:{property:be(n[9])}});let s=n[0].calculate&&hu(n);return{c(){e=v("span"),ae(t.$$.fragment),i=R(),s&&s.c()},m(r,o){D(r,e,o),te(t,e,null),y(e,i),s&&s.m(e,null),a=!0},p(r,o){r[0].calculate?s?s.p(r,o):(s=hu(r),s.c(),s.m(e,null)):s&&(s.d(1),s=null)},i(r){a||(E(t.$$.fragment,r),a=!0)},o(r){I(t.$$.fragment,r),a=!1},d(r){r&&x(e),ne(t),s&&s.d()}}}function mu(n){let e,t,i,a,s,r=ye(n[1]),o=[];for(let c=0;cI(o[c],1,1,()=>{o[c]=null});return{c(){e=v("div"),t=v("span"),t.textContent=`${n[4][n[6]]}`,i=R();for(let c=0;cI(a[r],1,1,()=>{a[r]=null});return{c(){e=v("div");for(let r=0;r=0?"+":"-"}${Math.abs(d)})`}let r=i[a.properties[0]];Array.isArray(r)||(r=[]);let o=new Map;for(let c=0;c0?r.length:1).keys()];return n.$$set=c=>{"monster"in c&&t(5,i=c.monster),"item"in c&&t(0,a=c.item)},[a,r,s,o,l,i]}var Kr=class extends G{constructor(e){super(),K(this,e,yp,bp,j,{monster:5,item:0},pp)}},gu=Kr;function pu(n){let e,t,i,a,s=n[1].heading&&bu(n);return i=new vt({props:{render:n[1].markdown,property:n[2]}}),{c(){s&&s.c(),e=R(),t=v("div"),ae(i.$$.fragment),g(t,"class","line")},m(r,o){s&&s.m(r,o),D(r,e,o),D(r,t,o),te(i,t,null),a=!0},p(r,o){r[1].heading?s?(s.p(r,o),o&2&&E(s,1)):(s=bu(r),s.c(),E(s,1),s.m(e.parentNode,e)):s&&(ce(),I(s,1,1,()=>{s=null}),ue());let l={};o&2&&(l.render=r[1].markdown),o&4&&(l.property=r[2]),i.$set(l)},i(r){a||(E(s),E(i.$$.fragment,r),a=!0)},o(r){I(s),I(i.$$.fragment,r),a=!1},d(r){r&&(x(e),x(t)),s&&s.d(r),ne(i)}}}function bu(n){let e,t;return e=new Ai({props:{item:n[1],monster:n[0]}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,a){let s={};a&2&&(s.item=i[1]),a&1&&(s.monster=i[0]),e.$set(s)},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function vp(n){let e,t,i=(!n[1].conditioned||n[1].conditioned&&`${n[2]}`.length)&&pu(n);return{c(){i&&i.c(),e=_e()},m(a,s){i&&i.m(a,s),D(a,e,s),t=!0},p(a,[s]){!a[1].conditioned||a[1].conditioned&&`${a[2]}`.length?i?(i.p(a,s),s&6&&E(i,1)):(i=pu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(ce(),I(i,1,1,()=>{i=null}),ue())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function kp(n,e,t){let{monster:i}=e,{item:a}=e,s=a.text&&a.text.length?a.text:be(i[a.properties[0]]);return!a.conditioned&&!`${s}`.length&&(s=a.fallback??"-"),n.$$set=r=>{"monster"in r&&t(0,i=r.monster),"item"in r&&t(1,a=r.item)},[i,a,s]}var $r=class extends G{constructor(e){super(),K(this,e,kp,vp,j,{monster:0,item:1})}},yu=$r;var vu=require("obsidian");function wp(n){re(n,"svelte-q1pj66",`.image.svelte-q1pj66{width:var(--active-image-width);height:var(--active-image-height)}.image.pointer.svelte-q1pj66{cursor:pointer}img.svelte-q1pj66{object-fit:cover;width:100%;height:100%;border-radius:100%;border:var(--active-image-border-size) solid var(--active-image-border-color);object-position:center}`)}function _p(n){let e,t,i,a,s,r;return{c(){e=v("div"),t=v("img"),Ac(t.src,i=n[2])||g(t,"src",i),g(t,"alt",a=n[0].name),g(t,"class","svelte-q1pj66"),g(e,"class","image svelte-q1pj66"),oe(e,"pointer",n[1]!=null)},m(o,l){D(o,e,l),y(e,t),s||(r=[z(e,"click",n[6]),z(e,"mouseenter",n[7])],s=!0)},p(o,l){l&1&&a!==(a=o[0].name)&&g(t,"alt",a),l&2&&oe(e,"pointer",o[1]!=null)},d(o){o&&x(e),s=!1,le(r)}}}function Sp(n){let e,t=n[2]&&_p(n);return{c(){t&&t.c(),e=_e()},m(i,a){t&&t.m(i,a),D(i,e,a)},p(i,[a]){i[2]&&t.p(i,a)},i:N,o:N,d(i){i&&x(e),t&&t.d(i)}}}function Cp(n,e,t){let{monster:i}=e,{item:a}=e,s=Ve("plugin"),r=Ve("context"),o;function l(b){b=decodeURIComponent(b);let _;try{if(/https?:/.test(b)){let[S]=ut.stringifyLinks(b).split("|");_=S}else{let[S]=ut.stringifyLinks(b).replace(/(^\[\[|\]\]$)/g,"").split("|");if(t(1,o=s.app.metadataCache.getFirstLinkpathDest(S,r)),!o)throw new Error;_=s.app.vault.getResourcePath(o)}}catch{console.warn("No image could be loaded")}return _}let d=(()=>{if(a.properties.length&&a.properties.some(b=>b in i&&typeof i[b]=="string")){let b=a.properties.filter(S=>S in i&&typeof i[S]=="string");b.length>1&&console.log("Fantasy Statblocks: Multiple image properties provided, using first.");let _=i[b[0]];return l(_)}})(),u=vu.Platform.isMacOS?"Meta":"Control";function h(b){if(!o)return;s.app.workspace.getLeaf(b.getModifierState(u)?"window":"split").openFile(o)}function m(b){o&&s.app.workspace.trigger("hover-link",{event:b,source:s.manifest.id,hoverParent:s.app.workspace.getMostRecentLeaf(),targetEl:b.currentTarget,linktext:o.path})}let f=b=>h(b),p=b=>m(b);return n.$$set=b=>{"monster"in b&&t(0,i=b.monster),"item"in b&&t(5,a=b.item)},[i,o,d,h,m,a,f,p]}var Yr=class extends G{constructor(e){super(),K(this,e,Cp,Sp,j,{monster:0,item:5},wp)}},ku=Yr;function xp(n){re(n,"svelte-1674zvq",`details.svelte-1674zvq>summary.svelte-1674zvq.svelte-1674zvq.svelte-1674zvq{outline:none;display:block !important;list-style:none !important;list-style-type:none !important;min-height:1rem;border-top-left-radius:0.1rem;border-top-right-radius:0.1rem;cursor:pointer;position:relative;margin-bottom:1rem}details.svelte-1674zvq>summary.svelte-1674zvq.svelte-1674zvq.svelte-1674zvq::-webkit-details-marker,details.svelte-1674zvq>summary.svelte-1674zvq.svelte-1674zvq.svelte-1674zvq::marker{display:none !important}details.svelte-1674zvq>summary.svelte-1674zvq>.collapser.svelte-1674zvq.svelte-1674zvq{position:absolute;top:50%;right:8px;transform:translateY(-50%);content:""}details.svelte-1674zvq>summary.svelte-1674zvq>.collapser.svelte-1674zvq>.handle.svelte-1674zvq{transform:rotate(0deg);transition:transform 0.25s;background-color:currentColor;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-image:url("data:image/svg+xml;charset=utf-8,");mask-image:url("data:image/svg+xml;charset=utf-8,");width:20px;height:20px}details[open].svelte-1674zvq>summary.svelte-1674zvq>.collapser.svelte-1674zvq>.handle.svelte-1674zvq{transform:rotate(90deg)}`)}function Ap(n){let e,t,i=(n[0].heading??"")+"",a,s,r,o,l;return{c(){e=v("details"),t=v("summary"),a=pe(i),s=R(),r=v("div"),r.innerHTML='
',g(r,"class","collapser svelte-1674zvq"),g(t,"class","svelte-1674zvq"),g(e,"class","svelte-1674zvq")},m(c,d){D(c,e,d),y(e,t),y(t,a),y(t,s),y(t,r),n[3](e),e.open=n[0].open,o||(l=z(e,"toggle",n[4]),o=!0)},p(c,[d]){d&1&&i!==(i=(c[0].heading??"")+"")&&we(a,i),d&1&&(e.open=c[0].open)},i:N,o:N,d(c){c&&x(e),n[3](null),o=!1,l()}}}function Tp(n,e,t){let{block:i}=e,{elements:a}=e,s;pn(()=>{for(let l of a)s.append(l)});function r(l){Re[l?"unshift":"push"](()=>{s=l,t(1,s)})}function o(){i.open=this.open,t(0,i)}return n.$$set=l=>{"block"in l&&t(0,i=l.block),"elements"in l&&t(2,a=l.elements)},[i,s,a,r,o]}var Jr=class extends G{constructor(e){super(),K(this,e,Tp,Ap,j,{block:0,elements:2},xp)}},wu=Jr;var t2=require("obsidian");function Dp(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","statblock-javascript")},m(s,r){D(s,e,r),i||(a=X(t=n[1].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function Ep(n,e,t){let i,{block:a}=e,s=Ve("monster");Se(n,s,c=>t(4,i=c));let r=i;s.subscribe(c=>r=c);let o=Ve("plugin"),l=c=>{if(a.code)try{let u=new Function("monster","property",a.code).call(void 0,r,o);u instanceof HTMLElement&&c.appendChild(u)}catch(d){console.error(d)}};return n.$$set=c=>{"block"in c&&t(2,a=c.block)},[s,l,a]}var Xr=class extends G{constructor(e){super(),K(this,e,Ep,Dp,j,{block:2})}},_u=Xr;function Mp(n){re(n,"svelte-420xq",`.statblock-content.svelte-420xq{font-family:var(--active-content-font);font-size:var(--active-content-font-size);color:var(--active-font-color);background-color:var(--active-background-color);padding:0.5em;border:var(--active-border-size) var(--active-border-color) solid;box-shadow:var(--active-box-shadow-x-offset) var(--active-box-shadow-y-offset) var(--active-box-shadow-blur) var(--active-box-shadow-color);margin-left:2px;margin-right:2px;display:flex;gap:1rem}.statblock-content.svelte-420xq>.column{width:var(--statblock-column-width)}@media screen and (max-width: 400px){.statblock-content.svelte-420xq>.column{width:75vw}}`)}function Ip(n){let e,t;return{c(){e=v("div"),t=v("div"),g(t,"class","statblock-content svelte-420xq"),g(e,"class","statblock-content-container"),He(e,"--statblock-column-width",n[0])},m(i,a){D(i,e,a),y(e,t),n[7](t)},p(i,[a]){a&1&&He(e,"--statblock-column-width",i[0])},i:N,o:N,d(i){i&&x(e),n[7](null)}}}function Op(n,e,t){let i=Me(),{columns:a=1}=e,{targets:s}=e,{columnWidth:r="400px"}=e,{heights:o=[]}=e,{split:l=1/0}=e,{classes:c}=e,d=l,u=f=>{f.empty();let p=[],b=document.body.createDiv({cls:"statblock-detached markdown-preview-view",attr:{style:`width: ${r}`}}),S=b.createDiv({cls:["statblock-detached","obsidian-statblock-plugin","statblock",...c]}).createDiv({cls:"statblock-content-container",attr:{style:`width: ${r}`}}).createDiv("statblock-content"),C=S.createDiv("column");p.push(C);for(let M=0;MA+P,0);p.lengthd&&kd&&(a<=2||p.length>1||k/((a-p.length-1)*C.scrollHeight)<1.5)&&(d=Math.max(d,C.scrollHeight),S.empty(),C=S.createDiv("column"),p.push(C))}for(let M of p)f.appendChild(M),M.querySelectorAll(".statblock-item-container:empty").forEach(w=>w.detach());b.detach()},h;pn(()=>{i("mounted"),h&&(u(h),i("built"))});function m(f){Re[f?"unshift":"push"](()=>{h=f,t(1,h)})}return n.$$set=f=>{"columns"in f&&t(2,a=f.columns),"targets"in f&&t(3,s=f.targets),"columnWidth"in f&&t(0,r=f.columnWidth),"heights"in f&&t(4,o=f.heights),"split"in f&&t(5,l=f.split),"classes"in f&&t(6,c=f.classes)},[r,h,a,s,o,l,c,m]}var Qr=class extends G{constructor(e){super(),K(this,e,Op,Ip,j,{columns:2,targets:3,columnWidth:0,heights:4,split:5,classes:6},Mp)}},Zr=Qr;function Pp(n){re(n,"svelte-1suaf4g","ul.spell-item.svelte-1suaf4g{margin:0}ul.spell-item.first.svelte-1suaf4g{margin-top:revert}ul.spell-item.last.svelte-1suaf4g{margin-bottom:revert}.spells.svelte-1suaf4g{font-style:italic}")}function Rp(n){let e,t,i,a,s,r,o;return i=new vt({props:{property:`${n[0].level}:`}}),r=new vt({props:{property:n[0].spells}}),{c(){e=v("li"),t=v("span"),ae(i.$$.fragment),a=R(),s=v("span"),ae(r.$$.fragment),g(t,"class","spell-level"),g(s,"class","spells svelte-1suaf4g"),g(e,"class","spell-line")},m(l,c){D(l,e,c),y(e,t),te(i,t,null),y(e,a),y(e,s),te(r,s,null),o=!0},p(l,c){let d={};c&1&&(d.property=`${l[0].level}:`),i.$set(d);let u={};c&1&&(u.property=l[0].spells),r.$set(u)},i(l){o||(E(i.$$.fragment,l),E(r.$$.fragment,l),o=!0)},o(l){I(i.$$.fragment,l),I(r.$$.fragment,l),o=!1},d(l){l&&x(e),ne(i),ne(r)}}}function Np(n){let e,t,i;return t=new vt({props:{property:n[0].spells}}),{c(){e=v("span"),ae(t.$$.fragment),g(e,"class","spell-line")},m(a,s){D(a,e,s),te(t,e,null),i=!0},p(a,s){let r={};s&1&&(r.property=a[0].spells),t.$set(r)},i(a){i||(E(t.$$.fragment,a),i=!0)},o(a){I(t.$$.fragment,a),i=!1},d(a){a&&x(e),ne(t)}}}function Lp(n){let e,t,i,a,s=[Np,Rp],r=[];function o(l,c){return l[0].level?1:0}return t=o(n,-1),i=r[t]=s[t](n),{c(){e=v("ul"),i.c(),g(e,"class","spell-item svelte-1suaf4g"),oe(e,"first",n[1]),oe(e,"last",n[2])},m(l,c){D(l,e,c),r[t].m(e,null),a=!0},p(l,[c]){let d=t;t=o(l,c),t===d?r[t].p(l,c):(ce(),I(r[d],1,1,()=>{r[d]=null}),ue(),i=r[t],i?i.p(l,c):(i=r[t]=s[t](l),i.c()),E(i,1),i.m(e,null)),(!a||c&2)&&oe(e,"first",l[1]),(!a||c&4)&&oe(e,"last",l[2])},i(l){a||(E(i),a=!0)},o(l){I(i),a=!1},d(l){l&&x(e),r[t].d()}}}function Bp(n,e,t){let{spell:i}=e,{first:a=!1}=e,{last:s=!1}=e;return n.$$set=r=>{"spell"in r&&t(0,i=r.spell),"first"in r&&t(1,a=r.first),"last"in r&&t(2,s=r.last)},[i,a,s]}var eo=class extends G{constructor(e){super(),K(this,e,Bp,Lp,j,{spell:0,first:1,last:2},Pp)}},Su=eo;var ta=require("obsidian");function Fp(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","action")},m(s,r){D(s,e,r),i||(a=X(t=n[0].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function Wp(n,e,t){let{block:i}=e,{monster:a}=e,s=r=>{new ta.ExtraButtonComponent(r).setIcon(i.icon).onClick(()=>{if(i.callback?.trim()?.length)try{new Function("monster",i.callback).call(void 0,a)}catch(o){new ta.Notice(`There was an error executing the provided callback for the action block. ${o.message}`),console.error(o)}else if(i.action)try{app.commands.executeCommandById(i.action)}catch(o){new ta.Notice(`There was an error executing the command for the action block. ${o.message}`),console.error(o)}})};return n.$$set=r=>{"block"in r&&t(1,i=r.block),"monster"in r&&t(2,a=r.monster)},[s,i,a]}var to=class extends G{constructor(e){super(),K(this,e,Wp,Fp,j,{block:1,monster:2})}},Cu=to;function xu(n){let e,t;return e=new Zr({props:{heights:n[7],targets:n[2],columns:n[1],columnWidth:n[3],split:n[5],classes:n[0]}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,a){let s={};a&2&&(s.columns=i[1]),a&8&&(s.columnWidth=i[3]),a&32&&(s.split=i[5]),a&1&&(s.classes=i[0]),e.$set(s)},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function Hp(n){let e,t,i=n[4]&&xu(n);return{c(){i&&i.c(),e=_e()},m(a,s){i&&i.m(a,s),D(a,e,s),t=!0},p(a,[s]){a[4]?i?(i.p(a,s),s&16&&E(i,1)):(i=xu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(ce(),I(i,1,1,()=>{i=null}),ue())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function zp(n,e,t){let i,a,s=Me(),{statblock:r}=e,{ready:o}=e,{classes:l}=e,{layout:c}=e,{columns:d}=e,u=d,h=!1,m=[],{plugin:f}=e,p=Ve("monster");Se(n,p,O=>t(16,a=O));let b=a;p.subscribe(O=>t(14,b=O));let _=O=>/[^a-zA-Z0-9]$/.test(O)?O:`${O}:`,S=O=>O.conditioned==null||!O.conditioned?!0:"nested"in O?O.nested.some(q=>S(q)):O.type=="ifelse"||O.type=="javascript"||O.type=="layout"||!("properties"in O)||!O.properties.length?!0:O.properties.some(q=>!!(q in b&&(Array.isArray(b[q])&&b[q].length||typeof b[q]=="string"&&b[q].length||typeof b[q]=="number"))),C=xr(),M=(O,q={})=>q.container?q.container.createDiv(`statblock-item-container ${sn(O.type)}-container ${(q.classes??[]).join(" ")}`):createDiv(`statblock-item-container ${sn(O.type)}-container ${(q.classes??[]).join(" ")}`),w=(O,q={})=>{if(!S(O))return[];let{container:Z,classes:ee}=q,se=[],$=M(O,{container:Z,classes:ee});switch(C.set("item",O),se.push($),O.type){case"group":{O.heading&&new Ai({target:$,props:{monster:b,item:O},context:C});for(let W of O.nested??[]){let J=w(W,{container:$,classes:O.cls?[...ee??[],O.cls]:ee??[]});se.push(...J)}break}case"action":{new Cu({target:$,props:{block:O,monster:b}});break}case"javascript":{new _u({target:$,props:{block:O}});break}case"collapse":{let W=[];for(let J of O.nested){let F=w(J);W.push(...F)}new wu({target:$,props:{block:O,elements:W}});break}case"heading":{let W=new iu({target:$,props:{monster:b,item:O},context:C});W.$on("save",J=>s("save",J.detail)),W.$on("export",J=>s("export",J.detail));break}case"ifelse":{for(let W=0;W{if(typeof ie=="string"&&(ie.charAt(ie.length-1)==":"||!ie.includes(":"))){let V={header:_(ie),spells:[]};return F.push(V),F}let Y=F[F.length-1],de;if(typeof ie=="string")de={spells:ut.linkifySpells(ie,C.get("context"))};else try{de={level:Object.keys(ie).shift(),spells:ut.linkifySpells(be(Object.values(ie).shift()),C.get("context"))}}catch{return F}if(Y)Y.spells.push(de);else{let V={header:`${b.name} knows the following spells:`,spells:[de]};F.push(V)}return F},[]);for(let F=0;F0){new ea({target:J.createDiv("statblock-item-container statblock-trait-prop"),props:{name:W[0].name,desc:W[0].desc,property:O.properties[0],item:O,monster:b,trait:W[0]},context:C});for(let F=1;FW.hasChildNodes())};if(!m.length)for(let O of r){let q=w(O);q?.length&&m.push(...q)}let k="400px";b.columnWidth?(typeof b.columnWidth=="number"&&(k=`${b.columnWidth}px`),typeof b.columnWidth=="string"&&(k=b.columnWidth)):c.columnWidth&&(k=`${c.columnWidth}px`);let A=!1,P=[],L,B=()=>{let O=document.body.createDiv({cls:"statblock-detached markdown-preview-view",attr:{style:`width: ${k}`}});new Zr({target:O.createDiv({cls:["obsidian-statblock-plugin","statblock",...l]}),props:{heights:P,targets:m,columns:1,columnWidth:k,classes:l}}).$on("built",()=>{let Z=O.querySelector(".column");for(let ee of m)P.push(ee.scrollHeight);b.forceColumns?t(5,L=Z.scrollHeight/u):b.columns&&b.columns>0?t(5,L=Math.max(Z.scrollHeight/b.columns,Z.scrollHeight/d)):t(5,L=Math.max(600,Math.min(Z.scrollHeight/d,i))),O.empty(),O.detach(),t(4,A=!0)})};return n.$$set=O=>{"statblock"in O&&t(8,r=O.statblock),"ready"in O&&t(9,o=O.ready),"classes"in O&&t(0,l=O.classes),"layout"in O&&t(10,c=O.layout),"columns"in O&&t(1,d=O.columns),"plugin"in O&&t(13,f=O.plugin)},n.$$.update=()=>{n.$$.dirty&16384&&(i=!isNaN(Number(b.columnHeight))&&b.columnHeight>0?b.columnHeight:1/0),n.$$.dirty&512&&o&&B()},[l,d,m,k,A,L,p,P,r,o,c,u,h,f,b]}var no=class extends G{constructor(e){super(),K(this,e,zp,Hp,j,{statblock:8,ready:9,classes:0,layout:10,columns:1,maxColumns:11,detached:12,targets:2,plugin:13})}get maxColumns(){return this.$$.ctx[11]}get detached(){return this.$$.ctx[12]}get targets(){return this.$$.ctx[2]}},Au=no;function qp(n){re(n,"svelte-1unaafm",`.statblock.svelte-1unaafm{--active-primary-color:var(--statblock-primary-color);--active-rule-color:var(--statblock-rule-color);--active-background-color:var(--statblock-background-color);--active-bar-color:var(--statblock-bar-color);--active-bar-border-size:var(--statblock-bar-border-size);--active-bar-border-color:var(--statblock-bar-border-color);--active-image-width:var(--statblock-image-width);--active-image-height:var(--statblock-image-height);--active-image-border-size:var(--statblock-image-border-size);--active-image-border-color:var( --statblock-image-border-color, --active-primary-color );--active-border-size:var(--statblock-border-size);--active-border-color:var(--statblock-border-color);--active-box-shadow-color:var(--statblock-box-shadow-color);--active-box-shadow-x-offset:var(--statblock-box-shadow-x-offset);--active-box-shadow-y-offset:var(--statblock-box-shadow-y-offset);--active-box-shadow-blur:var(--statblock-box-shadow-blur);--active-font-color:var( --statblock-font-color, --active-primary-color );--active-font-weight:var(--statblock-font-weight);--active-content-font:var(--statblock-content-font);--active-content-font-size:var(--statblock-content-font-size);--active-heading-font:var(--statblock-heading-font);--active-heading-font-color:var(--statblock-heading-font-color);--active-heading-font-size:var(--statblock-heading-font-size);--active-heading-font-variant:var(--statblock-heading-font-variant);--active-heading-font-weight:var(--statblock-heading-font-weight);--active-heading-line-height:var(--statblock-heading-line-height);--active-property-line-height:var(--statblock-property-line-height);--active-property-font:var(--statblock-property-font);--active-property-font-color:var(--statblock-property-font-color);--active-property-font-variant:var(--statblock-property-font-variant);--active-property-font-size:var(--statblock-property-font-size);--active-property-font-weight:var(--statblock-property-font-weight);--active-property-name-font:var(--statblock-property-name-font);--active-property-name-font-color:var( --statblock-property-name-font-color );--active-property-name-font-variant:var( --statblock-property-name-font-variant );--active-property-name-font-size:var( --statblock-property-name-font-size );--active-property-name-font-weight:var( --statblock-property-name-font-weight );--active-section-heading-border-size:var( --statblock-section-heading-border-size );--active-section-heading-border-color:var( --statblock-section-heading-border-color );--active-section-heading-font:var(--statblock-section-heading-font);--active-section-heading-font-color:var( --statblock-section-heading-font-color );--active-section-heading-font-size:var( --statblock-section-heading-font-size );--active-section-heading-font-variant:var( --statblock-section-heading-font-variant );--active-section-heading-font-weight:var( --statblock-section-heading-font-weight );--active-saves-line-height:var(--statblock-saves-line-height);--active-spells-font-style:var(--statblock-spells-font-style);--active-subheading-font:var(--statblock-subheading-font);--active-subheading-font-color:var(--statblock-subheading-font-color);--active-subheading-font-size:var(--statblock-subheading-font-size);--active-subheading-font-style:var(--statblock-subheading-font-style);--active-subheading-font-weight:var( --statblock-subheading-font-weight );--active-table-header-font-weight:var( --statblock-table-header-font-weight );--active-traits-font:var(--statblock-traits-font);--active-traits-font-color:var(--statblock-traits-font-color);--active-traits-font-size:var(--statblock-traits-font-size);--active-traits-font-weight:var(--statblock-traits-font-weight);--active-traits-font-style:var(--statblock-traits-font-style);--active-traits-name-font:var(--statblock-traits-name-font);--active-traits-name-font-color:var( --statblock-traits-name-font-color );--active-traits-name-font-size:var(--statblock-traits-name-font-size);--active-traits-name-font-weight:var( --statblock-traits-name-font-weight );--active-traits-name-font-style:var( --statblock-traits-name-font-style );--active-link-style:var(--statblock-link-style)}.statblock.svelte-1unaafm a{font-style:var(--statblock-link-style)}.container.svelte-1unaafm{display:flex;position:relative;width:100%;margin:0.25rem 0}.statblock.svelte-1unaafm{margin:0 auto;position:relative}.icons.svelte-1unaafm{position:absolute;left:var(--size-2-2)}`)}function Tu(n){let e,t=n[8],i,a,s,r,o=Eu(n),l=n[3]&&Mu(n);return{c(){e=v("div"),o.c(),a=R(),l&&l.c(),s=_e(),g(e,"class",i=xn(n[5].join(" "))+" svelte-1unaafm"),oe(e,"obsidian-statblock-plugin",!0),oe(e,"statblock",!0)},m(c,d){D(c,e,d),o.m(e,null),D(c,a,d),l&&l.m(c,d),D(c,s,d),r=!0},p(c,d){d[0]&256&&j(t,t=c[8])?(ce(),I(o,1,1,N),ue(),o=Eu(c),o.c(),E(o,1),o.m(e,null)):o.p(c,d),(!r||d[0]&32&&i!==(i=xn(c[5].join(" "))+" svelte-1unaafm"))&&g(e,"class",i),(!r||d[0]&32)&&oe(e,"obsidian-statblock-plugin",!0),(!r||d[0]&32)&&oe(e,"statblock",!0),c[3]?l?l.p(c,d):(l=Mu(c),l.c(),l.m(s.parentNode,s)):l&&(l.d(1),l=null)},i(c){r||(E(o),r=!0)},o(c){I(o),r=!1},d(c){c&&(x(e),x(a),x(s)),o.d(c),l&&l.d(c)}}}function jp(n){let e;return{c(){e=v("span"),e.textContent="Invalid monster."},m(t,i){D(t,e,i)},p:N,i:N,o:N,d(t){t&&x(e)}}}function Vp(n){let e,t,i=n[7],a,s,r;e=new Rr({});let o=Du(n);return s=new Rr({}),{c(){ae(e.$$.fragment),t=R(),o.c(),a=R(),ae(s.$$.fragment)},m(l,c){te(e,l,c),D(l,t,c),o.m(l,c),D(l,a,c),te(s,l,c),r=!0},p(l,c){c[0]&128&&j(i,i=l[7])?(ce(),I(o,1,1,N),ue(),o=Du(l),o.c(),E(o,1),o.m(a.parentNode,a)):o.p(l,c)},i(l){r||(E(e.$$.fragment,l),E(o),E(s.$$.fragment,l),r=!0)},o(l){I(e.$$.fragment,l),I(o),I(s.$$.fragment,l),r=!1},d(l){l&&(x(t),x(a)),ne(e,l),o.d(l),ne(s,l)}}}function Du(n){let e,t;return e=new Au({props:{columns:n[7],maxColumns:n[10],statblock:n[1],ready:n[6],classes:n[5],layout:n[2],plugin:n[0]}}),e.$on("save",n[19]),e.$on("export",n[20]),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,a){let s={};a[0]&128&&(s.columns=i[7]),a[0]&2&&(s.statblock=i[1]),a[0]&64&&(s.ready=i[6]),a[0]&32&&(s.classes=i[5]),a[0]&4&&(s.layout=i[2]),a[0]&1&&(s.plugin=i[0]),e.$set(s)},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function Eu(n){let e,t,i,a,s=[Vp,jp],r=[];function o(l,c){return l[8]?0:1}return e=o(n,[-1,-1]),t=r[e]=s[e](n),{c(){t.c(),i=_e()},m(l,c){r[e].m(l,c),D(l,i,c),a=!0},p(l,c){let d=e;e=o(l,c),e===d?r[e].p(l,c):(ce(),I(r[d],1,1,()=>{r[d]=null}),ue(),t=r[e],t?t.p(l,c):(t=r[e]=s[e](l),t.c()),E(t,1),t.m(i.parentNode,i))},i(l){a||(E(t),a=!0)},o(l){I(t),a=!1},d(l){l&&x(i),r[e].d(l)}}}function Mu(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","icons svelte-1unaafm")},m(s,r){D(s,e,r),i||(a=[X(t=n[11].call(null,e)),z(e,"click",n[12])],i=!0)},p:N,d(s){s&&x(e),i=!1,le(a)}}}function Up(n){let e,t,i=n[6]&&Tu(n);return{c(){e=v("div"),i&&i.c(),g(e,"class","container svelte-1unaafm")},m(a,s){D(a,e,s),i&&i.m(e,null),n[21](e),t=!0},p(a,s){a[6]?i?(i.p(a,s),s[0]&64&&E(i,1)):(i=Tu(a),i.c(),E(i,1),i.m(e,null)):i&&(ce(),I(i,1,1,()=>{i=null}),ue())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(),n[21](null)}}}function Gp(n,e,t){let i,a,s,r,o,l,c=Me(),{monster:d}=e,{context:u}=e,{plugin:h}=e,{statblock:m}=e,{renderer:f}=e,{layout:p}=e,{canSave:b=!0}=e,{icons:_=!0}=e,S=Be(d);Se(n,S,Y=>t(8,l=Y));let C=!isNaN(Number(d.columns??p.columns))&&Number(d.columns??p.columns)>0?Number(d.columns??p.columns):2,M=Number(`${d.columnWidth}`.replace(/\D/g,"")),w=!isNaN(M??p.columnWidth)&&(M??p.columnWidth)>0?M:400,k=h.canUseDiceRoller&&(d.dice??h.settings.useDice),A=d.render??h.settings.renderDice;Et("plugin",h),Et("tryToRenderLinks",h.settings.tryToRenderLinks),Et("context",u),Et("monster",S),Et("dice",k),Et("render",A),Et("renderer",f),Et("layout",p);let P=Be(!1);Et("reset",P);let L,B=()=>{if(d.forceColumns??p.forceColumns){t(7,i=C),q.disconnect();return}let Y=L.clientWidth;t(7,i=Math.min(Math.max(Math.floor(Y/w),1),C))},O=(0,Kt.debounce)(()=>{B(),a||t(6,a=!0)},100,!1),q=new ResizeObserver(O);pn(()=>{O(),q.observe(L)}),bn(()=>{q.disconnect()});let Z=Y=>{new Kt.ExtraButtonComponent(Y).setIcon("vertical-three-dots")},ee=new Kt.Menu;ee.addItem(Y=>Y.setIcon("save").setTitle("Save to Bestiary").setDisabled(!b).onClick(()=>c("save"))),ee.addItem(Y=>{Y.setTitle("Copy YAML").setIcon("code").onClick(async()=>{try{await navigator.clipboard.writeText((0,Kt.stringifyYaml)(d)),new Kt.Notice("Creature YAML copied to clipboard")}catch(de){new Kt.Notice(`There was an issue copying the yaml: ${de.message}`)}})}),ee.addItem(Y=>Y.setIcon("image-down").setTitle("Export as PNG").onClick(()=>c("export"))),k&&ee.addItem(Y=>Y.setIcon("reset").setTitle("Reset Dice").onClick(()=>{P.set(!0),P.set(!1)}));let se=Y=>{ee.showAtMouseEvent(Y)},$=(Y,de="")=>Y?.toLowerCase().replace(/\s+/g,"-")??de,W=Y=>{let de=[];for(let V of Y){if(V.type=="layout"){let H=h.manager.getAllLayouts().find(fe=>fe.id==V.layout);H&&de.push($(H.name))}"nested"in V&&de.push(...W(V.nested))}return de};function J(Y){Ue.call(this,n,Y)}function F(Y){Ue.call(this,n,Y)}function ie(Y){Re[Y?"unshift":"push"](()=>{L=Y,t(4,L)})}return n.$$set=Y=>{"monster"in Y&&t(13,d=Y.monster),"context"in Y&&t(14,u=Y.context),"plugin"in Y&&t(0,h=Y.plugin),"statblock"in Y&&t(1,m=Y.statblock),"renderer"in Y&&t(15,f=Y.renderer),"layout"in Y&&t(2,p=Y.layout),"canSave"in Y&&t(16,b=Y.canSave),"icons"in Y&&t(3,_=Y.icons)},n.$$.update=()=>{n.$$.dirty[0]&8192&&Ae(S,l=d,l),n.$$.dirty[0]&8192&&t(18,s=$(d.name??"","no-name")),n.$$.dirty[0]&4&&t(17,r=$(p.name,"no-layout")),n.$$.dirty[0]&393218&&t(5,o=[s,r,...W(m)].filter(Y=>Y?.length))},t(7,i=C),t(6,a=!1),[h,m,p,_,L,o,a,i,l,S,C,Z,se,d,u,f,b,r,s,J,F,ie]}var io=class extends G{constructor(e){super(),K(this,e,Gp,Up,j,{monster:13,context:14,plugin:0,statblock:1,renderer:15,layout:2,canSave:16,icons:3},qp,[-1,-1])}},Iu=io;var kt=require("obsidian");function na(n){let e=new Blob([n],{type:"text/javascript"}),t=URL.createObjectURL(e),i=new Worker(t,{name:"Fantasy Statblocks Creature Parser"});return URL.revokeObjectURL(t),i}function ao(){return na('var Bl=Object.defineProperty,uc=Object.defineProperties;var dc=Object.getOwnPropertyDescriptors;var Ll=Object.getOwnPropertySymbols;var pc=Object.prototype.hasOwnProperty,mc=Object.prototype.propertyIsEnumerable;var ur=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),gc=s=>{throw TypeError(s)};var Pl=(s,e,t)=>e in s?Bl(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Il=(s,e)=>{for(var t in e||(e={}))pc.call(e,t)&&Pl(s,t,e[t]);if(Ll)for(var t of Ll(e))mc.call(e,t)&&Pl(s,t,e[t]);return s},Rl=(s,e)=>uc(s,dc(e));var Fl=(s,e)=>{for(var t in e)Bl(s,t,{get:e[t],enumerable:!0})};var yc=function(s,e){this[0]=s,this[1]=e};var k=s=>{var e=s[ur("asyncIterator")],t=!1,i,n={};return e==null?(e=s[ur("iterator")](),i=r=>n[r]=o=>e[r](o)):(e=e.call(s),i=r=>n[r]=o=>{if(t){if(t=!1,r==="throw")throw o;return o}return t=!0,{done:!1,value:new yc(new Promise(l=>{var a=e[r](o);a instanceof Object||gc("Object expected"),l(a)}),1)}}),n[ur("iterator")]=()=>n,i("next"),"throw"in e?i("throw"):n.throw=r=>{throw r},"return"in e&&i("return"),n};var bc=Function.prototype.toString,dr=Object.create,wc=Object.prototype.toString,kc=function(){function s(){this._keys=[],this._values=[]}return s.prototype.has=function(e){return!!~this._keys.indexOf(e)},s.prototype.get=function(e){return this._values[this._keys.indexOf(e)]},s.prototype.set=function(e,t){this._keys.push(e),this._values.push(t)},s}();function Sc(){return new kc}function vc(){return new WeakMap}var xc=typeof WeakMap!="undefined"?vc:Sc;function mr(s){if(!s)return dr(null);var e=s.constructor;if(e===Object)return s===Object.prototype?{}:dr(s);if(e&&~bc.call(e).indexOf("[native code]"))try{return new e}catch(t){}return dr(s)}function Cc(s){var e="";return s.global&&(e+="g"),s.ignoreCase&&(e+="i"),s.multiline&&(e+="m"),s.unicode&&(e+="u"),s.sticky&&(e+="y"),e}function Ac(s){return s.flags}var Mc=/test/g.flags==="g"?Ac:Cc;function $l(s){var e=wc.call(s);return e.substring(8,e.length-1)}function Oc(s){return s[Symbol.toStringTag]||$l(s)}var Tc=typeof Symbol!="undefined"?Oc:$l,Ec=Object.defineProperty,Nc=Object.getOwnPropertyDescriptor,Vl=Object.getOwnPropertyNames,gr=Object.getOwnPropertySymbols,Hl=Object.prototype,_l=Hl.hasOwnProperty,Dc=Hl.propertyIsEnumerable,Kl=typeof gr=="function";function Lc(s){return Vl(s).concat(gr(s))}var Pc=Kl?Lc:Vl;function Ps(s,e,t){for(var i=Pc(s),n=0,r=i.length,o=void 0,l=void 0;nthis.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=ai(this,e,t);let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),ni.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ai(this,e,t);let i=[];return this.decompose(e,t,i,0),ni.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new $t(this),r=new $t(e);for(let o=t,l=t;;){if(n.next(o),r.next(o),o=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(l+=n.value.length,n.done||l>=i)return!0}}iter(e=1){return new $t(this,e)}iterRange(e,t=this.length){return new $s(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Vs(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?s.empty:e.length<=32?new ge(e):ni.from(ge.split(e,[]))}},ge=class s extends K{constructor(e,t=Xc(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.text[r],l=n+o.length;if((t?i:l)>=e)return new kr(n,l,i,o);n=l+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new s(Yl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=i.pop(),l=Rs(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new s(l,o.length+r.length));else{let a=l.length>>1;i.push(new s(l.slice(0,a)),new s(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof s))return super.replace(e,t,i);[e,t]=ai(this,e,t);let n=Rs(this.text,Rs(i.text,Yl(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new s(n,r):ni.from(s.split(n,[]),r)}sliceString(e,t=this.length,i=`\n`){[e,t]=ai(this,e,t);let n="";for(let r=0,o=0;r<=t&&oe&&o&&(n+=i),er&&(n+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,i.length==32&&(t.push(new s(i,n)),i=[],n=-1);return n>-1&&t.push(new s(i,n)),t}},ni=class s extends K{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let o=this.children[r],l=n+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,n);n=l+1,i=a+1}}decompose(e,t,i,n){for(let r=0,o=0;o<=t&&r=o){let h=n&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=ai(this,e,t),i.lines=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>h>>6){let f=this.children.slice();return f[n]=a,new s(f,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`\n`){[e,t]=ai(this,e,t);let n="";for(let r=0,o=0;re&&r&&(n+=i),eo&&(n+=l.sliceString(e-o,t-o,i)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof s))return 0;let i=0,[n,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==o||r==l)return i;let a=this.children[n],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new ge(d,t)}let n=Math.max(32,i>>5),r=n<<1,o=n>>1,l=[],a=0,h=-1,f=[];function c(d){let p;if(d.lines>r&&d instanceof s)for(let m of d.children)c(m);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof ge&&a&&(p=f[f.length-1])instanceof ge&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,f[f.length-1]=new ge(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>n&&u(),a+=d.lines,h+=d.length+1,f.push(d))}function u(){a!=0&&(l.push(f.length==1?f[0]:s.from(f,h)),h=-1,a=f.length=0)}for(let d of e)c(d);return u(),l.length==1?l[0]:new s(l,t)}};K.empty=new ge([""],0);function Xc(s){let e=-1;for(let t of s)e+=t.length+1;return e}function Rs(s,e,t=0,i=1e9){for(let n=0,r=0,o=!0;r=t&&(a>i&&(l=l.slice(0,i-n)),n0?1:(e instanceof ge?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],o=r>>1,l=n instanceof ge?n.text.length:n.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`\n`,this;e--}else if(n instanceof ge){let a=n.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ge?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},$s=class{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new $t(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Vs=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(K.prototype[Symbol.iterator]=function(){return this.iter()},$t.prototype[Symbol.iterator]=$s.prototype[Symbol.iterator]=Vs.prototype[Symbol.iterator]=function(){return this});var kr=class{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}};function ai(s,e,t){return e=Math.max(0,Math.min(s.length,e)),[e,Math.max(e,Math.min(s.length,t))]}var ri="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(s=>s?parseInt(s,36):1);for(let s=1;ss)return ri[e-1]<=s;return!1}function Gl(s){return s>=127462&&s<=127487}var Jl=8205;function Ke(s,e,t=!0,i=!0){return(t?ia:Zc)(s,e,i)}function ia(s,e,t){if(e==s.length)return e;e&&sa(s.charCodeAt(e))&&na(s.charCodeAt(e-1))&&e--;let i=Fs(s,e);for(e+=Sr(i);e=0&&Gl(Fs(s,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Zc(s,e,t){for(;e>0;){let i=ia(s,e-2,t);if(i=56320&&s<57344}function na(s){return s>=55296&&s<56320}function Fs(s,e){let t=s.charCodeAt(e);if(!na(t)||e+1==s.length)return t;let i=s.charCodeAt(e+1);return sa(i)?(t-55296<<10)+(i-56320)+65536:t}function Sr(s){return s<65536?1:2}var vr=/\\r\\n?|\\n/,ue=function(s){return s[s.Simple=0]="Simple",s[s.TrackDel=1]="TrackDel",s[s.TrackBefore=2]="TrackBefore",s[s.TrackAfter=3]="TrackAfter",s}(ue||(ue={})),Vt=class s{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-n);r+=l}else{if(i!=ue.Simple&&h>=e&&(i==ue.TrackDel&&ne||i==ue.TrackBefore&&ne))return null;if(h>e||h==e&&t<0&&!l)return e==n||t<0?r:r+a;r+=a}n=h}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i=0&&n<=t&&l>=e)return nt?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new s(e)}static create(e){return new s(e)}},ye=class s extends Vt{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return xr(this,(t,i,n,r,o)=>e=e.replace(n,n+(i-t),o),!1),e}mapDesc(e,t=!1){return Cr(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;i.length0&&yt(i,t,r.text),r.forward(f),l+=f}let h=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],o=0,l=null;function a(f=!1){if(!f&&!n.length)return;ou||c<0||u>t)throw new RangeError(`Invalid change range ${c} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?K.of(d.split(i||vr)):d:K.empty,m=p.length;if(c==u&&m==0)return;co&&le(n,c-o,-1),le(n,u-c,m),yt(r,n,p),o=u}}return h(e),a(!l),l}static empty(e){return new s(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;nl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length=0&&t<=0&&t==s[n+1]?s[n]+=e:e==0&&s[n]==0?s[n+1]+=t:i?(s[n]+=e,s[n+1]+=t):s.push(e,t)}function yt(s,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==s.sections.length||s.sections[o+1]<0);)l=s.sections[o++],a=s.sections[o++];e(n,h,r,f,c),n=h,r=f}}}function Cr(s,e,t,i=!1){let n=[],r=i?[]:null,o=new Ht(s),l=new Ht(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);le(n,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let h=0,f=o.len;for(;f;)if(l.ins==-1){let c=Math.min(f,l.len);h+=c,f-=c,l.forward(c)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}var Ht=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?K.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?K.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},si=class s{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new s(i,n,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return P.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return P.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return P.range(e.anchor,e.head)}static create(e,t,i){return new s(e,t,i)}},P=class s{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:s.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new s(e.ranges.map(t=>si.fromJSON(t)),e.main)}static single(e,t=e){return new s([s.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;ne?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((n,r)=>n.from-r.from),t=e.indexOf(i);for(let n=1;nr.head?s.range(a,l):s.range(l,a))}}return new s(e,t)}};function oa(s,e){for(let t of s.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var Br=0,R=class s{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.id=Br++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new s(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Ir),!!e.static,e.enables)}of(e){return new oi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can\'t compute a static facet");return new oi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can\'t compute a static facet");return new oi(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}};function Ir(s,e){return s==e||s.length==e.length&&s.every((t,i)=>t===e[i])}var oi=class{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=Br++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,f=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?h=!0:((t=e[c.id])!==null&&t!==void 0?t:1)&1||f.push(e[c.id]);return{create(c){return c.values[o]=i(c),1},update(c,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||Ar(c,f)){let d=i(c);if(l?!Xl(d,c.values[o],n):!n(d,c.values[o]))return c.values[o]=d,1}return 0},reconfigure:(c,u)=>{let d,p=u.config.address[r];if(p!=null){let m=Ws(u,p);if(this.dependencies.every(g=>g instanceof R?u.facet(g)===c.facet(g):g instanceof at?u.field(g,!1)==c.field(g,!1):!0)||(l?Xl(d=i(c),m,n):n(d=i(c),m)))return c.values[o]=m,0}else d=i(c);return c.values[o]=d,1}}}};function Xl(s,e,t){if(s.length!=e.length)return!1;for(let i=0;is[a.id]),n=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=s[e.id]>>1;function l(a){let h=[];for(let f=0;fi===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Ql).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,n)=>{let r=i.values[t],o=this.updateF(r,n);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,n)=>n.config.address[this.id]!=null?(i.values[t]=n.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,Ql.of({field:this,create:e})]}get extension(){return this}},Rt={lowest:4,low:3,default:2,high:1,highest:0};function Ri(s){return e=>new Hs(e,s)}var js={highest:Ri(Rt.highest),high:Ri(Rt.high),default:Ri(Rt.default),low:Ri(Rt.low),lowest:Ri(Rt.lowest)},Hs=class{constructor(e,t){this.inner=e,this.prec=t}},_s=class s{of(e){return new $i(this,e)}reconfigure(e){return s.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},$i=class{constructor(e,t){this.compartment=e,this.inner=t}},Ks=class s{constructor(e,t,i,n,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let n=[],r=Object.create(null),o=new Map;for(let u of tu(e,t,o))u instanceof at?n.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of n)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let f=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=f&&f[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Ir(m,d))a.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(y=>g.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(g=>eu(g,p,d))}}let c=h.map(u=>u(l));return new s(e,o,c,l,a,r)}};function tu(s,e,t){let i=[[],[],[],[],[]],n=new Map;function r(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof $i&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof $i){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Hs)r(o.inner,o.prec);else if(o instanceof at)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof oi)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Rt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(s,Rt.default),i.reduce((o,l)=>o.concat(l))}function Fi(s,e){if(e&1)return 2;let t=e>>1,i=s.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;s.status[t]=4;let n=s.computeSlot(s,s.config.dynamicSlots[t]);return s.status[t]=2|n}function Ws(s,e){return e&1?s.config.staticValues[e>>1]:s.values[e>>1]}var la=R.define(),Mr=R.define({combine:s=>s.some(e=>e),static:!0}),aa=R.define({combine:s=>s.length?s[0]:void 0,static:!0}),ha=R.define(),fa=R.define(),ca=R.define(),ua=R.define({combine:s=>s.length?s[0]:!1}),ht=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Or}},Or=class{of(e){return new ht(this,e)}},Tr=class{constructor(e){this.map=e}of(e){return new J(this,e)}},J=class s{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new s(this.type,t)}is(e){return this.type==e}static define(e={}){return new Tr(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let r=n.map(t);r&&i.push(r)}return i}};J.reconfigure=J.define();J.appendConfig=J.define();var de=class s{constructor(e,t,i,n,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&oa(i,t.newLength),r.some(l=>l.type==s.time)||(this.annotations=r.concat(s.time.of(Date.now())))}static create(e,t,i,n,r,o){return new s(e,t,i,n,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(s.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};de.time=ht.define();de.userEvent=ht.define();de.addToHistory=ht.define();de.remote=ht.define();function iu(s,e){let t=[];for(let i=0,n=0;;){let r,o;if(i=s[i]))r=s[i++],o=s[i++];else if(n=0;n--){let r=i[n](s);r instanceof de?s=r:Array.isArray(r)&&r.length==1&&r[0]instanceof de?s=r[0]:s=pa(e,li(r),!1)}return s}function nu(s){let e=s.startState,t=e.facet(ca),i=s;for(let n=t.length-1;n>=0;n--){let r=t[n](s);r&&Object.keys(r).length&&(i=da(i,Er(e,r,s.changes.newLength),!0))}return i==s?s:de.create(e,s.changes,s.selection,i.effects,i.annotations,i.scrollIntoView)}var ru=[];function li(s){return s==null?ru:Array.isArray(s)?s:[s]}var _e=function(s){return s[s.Word=0]="Word",s[s.Space=1]="Space",s[s.Other=2]="Other",s}(_e||(_e={})),ou=/[\\u00df\\u0587\\u0590-\\u05f4\\u0600-\\u06ff\\u3040-\\u309f\\u30a0-\\u30ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\uac00-\\ud7af]/,Nr;try{Nr=new RegExp("[\\\\p{Alphabetic}\\\\p{Number}_]","u")}catch(s){}function lu(s){if(Nr)return Nr.test(s);for(let e=0;e"\\x80"&&(t.toUpperCase()!=t.toLowerCase()||ou.test(t)))return!0}return!1}function au(s){return e=>{if(!/\\S/.test(e))return _e.Space;if(lu(e))return _e.Word;for(let t=0;t-1)return _e.Word;return _e.Other}}var X=class s{constructor(e,t,i,n,r,o){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;ln.set(h,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(J.reconfigure)?(t=null,i=l.value):l.is(J.appendConfig)&&(t=null,i=li(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Ks.resolve(i,n,this),r=new s(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Mr)?e.newSelection:e.newSelection.asSingle();new s(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:P.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],o=li(i.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return s.create({doc:e.doc,selection:P.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=Ks.resolve(e.extensions||[],new Map),i=e.doc instanceof K?e.doc:K.of((e.doc||"").split(t.staticFacet(s.lineSeparator)||vr)),n=e.selection?e.selection instanceof P?e.selection:P.single(e.selection.anchor,e.selection.head):P.single(0);return oa(n,i.length),t.staticFacet(Mr)||(n=n.asSingle()),new s(t,i,n,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(s.tabSize)}get lineBreak(){return this.facet(s.lineSeparator)||`\n`}get readOnly(){return this.facet(ua)}phrase(e,...t){for(let i of this.facet(s.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\\$(\\$|\\d*)/g,(i,n)=>{if(n=="$")return"$";let r=+(n||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let n=[];for(let r of this.facet(la))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){return au(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=Ke(t,o,!1);if(r(t.slice(a,o))!=_e.Word)break;o=a}for(;ls.length?s[0]:4});X.lineSeparator=aa;X.readOnly=ua;X.phrases=R.define({compare(s,e){let t=Object.keys(s),i=Object.keys(e);return t.length==i.length&&t.every(n=>s[n]==e[n])}});X.languageData=la;X.changeFilter=ha;X.transactionFilter=fa;X.transactionExtender=ca;_s.reconfigure=J.define();var ft=class{eq(e){return this==e}range(e,t=e){return Vi.create(e,t,this)}};ft.prototype.startSide=ft.prototype.endSide=0;ft.prototype.point=!1;ft.prototype.mapMode=ue.TrackDel;var Vi=class s{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new s(e,t,i)}};function Dr(s,e){return s.from-e.from||s.value.startSide-e.value.startSide}var Lr=class s{constructor(e,t,i,n){this.from=e,this.to=t,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,n=0){let r=i?this.to:this.from;for(let o=n,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,n){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);rd||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,d-u)),i.push(h),n.push(u-o),r.push(d-o))}return{mapped:i.length?new s(n,r,i,l):null,pos:o}}},Z=class s{constructor(e,t,i,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}static create(e,t,i,n){return new s(e,t,i,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(Dr)),this.isEmpty)return t.length?s.of(t):this;let l=new qs(this,null,-1).goto(0),a=0,h=[],f=new _t;for(;l.value||a=0){let c=t[a++];f.addInner(c.from,c.to,c.value)||h.push(c)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||rl.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Hi.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Hi.from(e).goto(t)}static compare(e,t,i,n,r=-1){let o=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),l=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=r),a=Zl(o,l,i),h=new Ft(o,a,r),f=new Ft(l,a,r);i.iterGaps((c,u,d)=>ea(h,c,f,u,d,n)),i.empty&&i.length==0&&ea(h,0,f,0,0,n)}static eq(e,t,i=0,n){n==null&&(n=999999999);let r=e.filter(f=>!f.isEmpty&&t.indexOf(f)<0),o=t.filter(f=>!f.isEmpty&&e.indexOf(f)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Zl(r,o),a=new Ft(r,l,0).goto(i),h=new Ft(o,l,0).goto(i);for(;;){if(a.to!=h.to||!Pr(a.active,h.active)||a.point&&(!h.point||!a.point.eq(h.point)))return!1;if(a.to>n)return!0;a.next(),h.next()}}static spans(e,t,i,n,r=-1){let o=new Ft(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let f=o.activeForPoint(o.to),c=o.pointFroml&&(n.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new _t;for(let n of e instanceof Vi?[e]:t?hu(e):e)i.add(n.from,n.to,n.value);return i.finish()}static join(e){if(!e.length)return s.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let n=e[i];n!=s.empty;n=n.nextLayer)t=new s(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}};Z.empty=new Z([],[],null,-1);function hu(s){if(s.length>1)for(let e=s[0],t=1;t0)return s.slice().sort(Dr);e=i}return s}Z.empty.nextLayer=Z.empty;var _t=class s{finishChunk(e){this.chunks.push(new Lr(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new s)).add(e,t,i)}addInner(e,t,i){let n=e-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return n<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(Z.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Z.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Zl(s,e,t){let i=new Map;for(let r of s)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&n.push(new qs(o,t,i,r));return n.length==1?n[0]:new s(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)wr(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)wr(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),wr(this.heap,0)}}};function wr(s,e){for(let t=s[e];;){let i=(e<<1)+1;if(i>=s.length)break;let n=s[i];if(i+1=0&&(n=s[i+1],i++),t.compare(n)<0)break;s[i]=t,s[e]=n,e=i}}var Ft=class{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Hi.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Bs(this.active,e),Bs(this.activeTo,e),Bs(this.activeRank,e),this.minActive=ta(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:r}=this.cursor;for(;t0;)t++;Is(this.active,t,i),Is(this.activeTo,t,n),Is(this.activeRank,t,r),e&&Is(e,t,this.cursor.from),this.minActive=ta(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Bs(i,n)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[n]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}};function ea(s,e,t,i,n,r){s.goto(e),t.goto(i);let o=i+n,l=i,a=i-e;for(;;){let h=s.to+a-t.to||s.endSide-t.endSide,f=h<0?s.to+a:t.to,c=Math.min(f,o);if(s.point||t.point?s.point&&t.point&&(s.point==t.point||s.point.eq(t.point))&&Pr(s.activeForPoint(s.to),t.activeForPoint(t.to))||r.comparePoint(l,c,s.point,t.point):c>l&&!Pr(s.active,t.active)&&r.compareRange(l,c,s.active,t.active),f>o)break;l=f,h<=0&&s.next(),h>=0&&t.next()}}function Pr(s,e){if(s.length!=e.length)return!1;for(let t=0;t=e;i--)s[i+1]=s[i];s[e]=t}function ta(s,e){let t=-1,i=1e9;for(let n=0;n=e)return n;if(n==s.length)break;r+=s.charCodeAt(n)==9?t-r%t:1,n=Ke(s,n)}return i===!0?-1:s.length}var Rr="\\u037C",ga=typeof Symbol=="undefined"?"__"+Rr:Symbol.for(Rr),Fr=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ya=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},ve=class{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\\s*/)}function r(o,l,a,h){let f=[],c=/^@(\\w+)\\b/.exec(o[0]),u=c&&c[1]=="keyframes";if(c&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!c)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(n(d),p,f,u)}else p!=null&&f.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(f.length||u)&&a.push((i&&!c&&!h?o.map(i):o).join(", ")+" {"+f.join(" ")+"}")}for(let o in e)r(n(o),e[o],this.rules)}getRules(){return this.rules.join(`\n`)}static newName(){let e=ya[ga]||1;return ya[ga]=e+1,Rr+e.toString(36)}static mount(e,t,i){let n=e[Fr],r=i&&i.nonce;n?r&&n.setNonce(r):n=new $r(e,r),n.mount(Array.isArray(t)?t:[t],e)}},ba=new Map,$r=class{constructor(e,t){let i=e.ownerDocument||e,n=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let r=ba.get(i);if(r)return e[Fr]=r;this.sheet=new n.CSSStyleSheet,ba.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Fr]=this}mount(e,t){let i=this.sheet,n=0,r=0;for(let o=0;o-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),i)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:\'"\'},Up=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Yp=typeof navigator!="undefined"&&/MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent);for(ee=0;ee<10;ee++)Kt[48+ee]=Kt[96+ee]=String(ee);var ee;for(ee=1;ee<=24;ee++)Kt[ee+111]="F"+ee;var ee;for(ee=65;ee<=90;ee++)Kt[ee]=String.fromCharCode(ee+32),Us[ee]=String.fromCharCode(ee);var ee;for(zs in Kt)Us.hasOwnProperty(zs)||(Us[zs]=Kt[zs]);var zs;function Ji(s){let e;return s.nodeType==11?e=s.getSelection?s:s.ownerDocument:e=s,e.getSelection()}function Wr(s,e){return e?s==e||s.contains(e.nodeType!=1?e.parentNode:e):!1}function uu(s){let e=s.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function tn(s,e){if(!e.anchorNode)return!1;try{return Wr(s,e.anchorNode)}catch(t){return!1}}function Xi(s){return s.nodeType==3?jt(s,0,s.nodeValue.length).getClientRects():s.nodeType==1?s.getClientRects():[]}function ji(s,e,t,i){return t?wa(s,e,t,i,-1)||wa(s,e,t,i,1):!1}function qt(s){for(var e=0;;e++)if(s=s.previousSibling,!s)return e}function rn(s){return s.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\\d|SECTION|PRE)$/.test(s.nodeName)}function wa(s,e,t,i,n){for(;;){if(s==t&&e==i)return!0;if(e==(n<0?0:ct(s))){if(s.nodeName=="DIV")return!1;let r=s.parentNode;if(!r||r.nodeType!=1)return!1;e=qt(s)+(n<0?0:1),s=r}else if(s.nodeType==1){if(s=s.childNodes[e+(n<0?-1:0)],s.nodeType==1&&s.contentEditable=="false")return!1;e=n<0?ct(s):0}else return!1}}function ct(s){return s.nodeType==3?s.nodeValue.length:s.childNodes.length}function gn(s,e){let t=e?s.left:s.right;return{left:t,right:t,top:s.top,bottom:s.bottom}}function du(s){let e=s.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:s.innerWidth,top:0,bottom:s.innerHeight}}function Ja(s,e){let t=e.width/s.offsetWidth,i=e.height/s.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-s.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-s.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function pu(s,e,t,i,n,r,o,l){let a=s.ownerDocument,h=a.defaultView||window;for(let f=s,c=!1;f&&!c;)if(f.nodeType==1){let u,d=f==a.body,p=1,m=1;if(d)u=du(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(f).position)&&(c=!0),f.scrollHeight<=f.clientHeight&&f.scrollWidth<=f.clientWidth){f=f.assignedSlot||f.parentNode;continue}let w=f.getBoundingClientRect();({scaleX:p,scaleY:m}=Ja(f,w)),u={left:w.left,right:w.left+f.clientWidth*p,top:w.top,bottom:w.top+f.clientHeight*m}}let g=0,y=0;if(n=="nearest")e.top0&&e.bottom>u.bottom+y&&(y=e.bottom-u.bottom+y+o)):e.bottom>u.bottom&&(y=e.bottom-u.bottom+o,t<0&&e.top-y0&&e.right>u.right+g&&(g=e.right-u.right+g+r)):e.right>u.right&&(g=e.right-u.right+r,t<0&&e.leftn.clientHeight&&(i=n),!t&&n.scrollWidth>n.clientWidth&&(t=n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;return{x:t,y:i}}var qr=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?ct(t):0),i,Math.min(e.focusOffset,i?ct(i):0))}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}},hi=null;function Xa(s){if(s.setActive)return s.setActive();if(hi)return s.focus(hi);let e=[];for(let t=s;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(s.focus(hi==null?{get preventScroll(){return hi={preventScroll:!0},!0}}:void 0),!hi){hi=!1;for(let t=0;tMath.max(1,s.scrollHeight-s.clientHeight-4)}function eh(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=ct(t)}else if(t.parentNode&&!rn(t))i=qt(t),t=t.parentNode;else return null}}function th(s,e){for(let t=s,i=e;;){if(t.nodeType==3&&it)return c.domBoundsAround(e,t,h);if(u>=e&&n==-1&&(n=a,r=h),h>t&&c.dom.parentNode==this.dom){o=a,l=f;break}f=u,h=u+c.breakAfter}return{from:r,to:l<0?i+this.length:l,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=ko){this.markDirty();for(let n=e;nthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}};function ih(s,e,t,i,n,r,o,l,a){let{children:h}=s,f=h.length?h[e]:null,c=r.length?r[r.length-1]:null,u=c?c.breakAfter:o;if(!(e==i&&f&&!o&&!u&&r.length<2&&f.merge(t,n,r.length?c:null,t==0,l,a))){if(i0&&(!o&&r.length&&f.merge(t,f.length,r[0],!1,l,0)?f.breakAfter=r.shift().breakAfter:(t2),T={mac:Ca||/Mac/.test(pe.platform),windows:/Win/.test(pe.platform),linux:/Linux|X11/.test(pe.platform),ie:yn,ie_version:nh?jr.documentMode||6:Ur?+Ur[1]:zr?+zr[1]:0,gecko:va,gecko_version:va?+(/Firefox\\/(\\d+)/.exec(pe.userAgent)||[0,0])[1]:0,chrome:!!Vr,chrome_version:Vr?+Vr[1]:0,ios:Ca,android:/Android\\b/.test(pe.userAgent),webkit:xa,safari:rh,webkit_version:xa?+(/\\bAppleWebKit\\/(\\d+)/.exec(pe.userAgent)||[0,0])[1]:0,tabSize:jr.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},bu=256,Ye=class s extends z{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return this.flags&8||i&&(!(i instanceof s)||this.length-(t-e)+i.length>bu||i.flags&8)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new s(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new fe(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return wu(this.dom,e,t)}},kt=class s extends z{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let n of t)n.setParent(this)}setAttrs(e){if(Qa(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,n,r,o){return i&&(!(i instanceof s&&i.mark.eq(this.mark))||e&&r<=0||te&&t.push(i=e&&(n=r),i=a,r++}let o=this.length-e;return this.length=e,n>-1&&(this.children.length=n,this.markDirty()),new s(this.mark,t,o)}domAtPos(e){return oh(this,e)}coordsAt(e,t){return ah(this,e,t)}};function wu(s,e,t){let i=s.nodeValue.length;e>i&&(e=i);let n=e,r=e,o=0;e==0&&t<0||e==i&&t>=0?T.chrome||T.gecko||(e?(n--,o=1):r=0)?0:l.length-1];return T.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?gn(a,o<0):a||null}var ln=class s extends z{static create(e,t,i){return new s(e,t,i)}constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}split(e){let t=s.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,i,n,r,o){return i&&(!(i instanceof s)||!this.widget.compare(i.widget)||e>0&&r<=0||t0)?fe.before(this.dom):fe.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let n=this.dom.getClientRects(),r=null;if(!n.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?n.length-1:0;r=n[l],!(e>0?l==0:l==n.length-1||r.top0?fe.before(this.dom):fe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return K.empty}get isHidden(){return!0}};Ye.prototype.children=ln.prototype.children=Qi.prototype.children=ko;function oh(s,e){let t=s.dom,{children:i}=s,n=0;for(let r=0;nr&&e0;r--){let o=i[r-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let r=n;r0&&e instanceof kt&&n.length&&(i=n[n.length-1])instanceof kt&&i.mark.eq(e.mark)?lh(i,e.children[0],t-1):(n.push(e),e.setParent(s)),s.length+=e.length}function ah(s,e,t){let i=null,n=-1,r=null,o=-1;function l(h,f){for(let c=0,u=0;c=f&&(d.children.length?l(d,f-u):(!r||r.isHidden&&t>0)&&(p>f||u==p&&d.getSide()>0)?(r=d,o=f-u):(u-1?1:0)!=n.length-(t&&n.indexOf(t)>-1?1:0))return!1;for(let r of i)if(r!=t&&(n.indexOf(r)==-1||s[r]!==e[r]))return!1;return!0}function Gr(s,e,t){let i=!1;if(e)for(let n in e)t&&n in t||(i=!0,n=="style"?s.style.cssText="":s.removeAttribute(n));if(t)for(let n in t)e&&e[n]==t[n]||(i=!0,n=="style"?s.style.cssText=t[n]:s.setAttribute(n,t[n]));return i}function Su(s){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new St(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,n;if(e.isBlockGap)i=-5e8,n=4e8;else{let{start:r,end:o}=hh(e,t);i=(r?t?-3e8:-1:5e8)-1,n=(o?t?2e8:1:-6e8)+1}return new St(e,i,n,t,e.widget||null,!0)}static line(e){return new es(e)}static set(e,t=!1){return Z.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Q.none=Z.empty;var Zi=class s extends Q{constructor(e){let{start:t,end:i}=hh(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,i;return this==e||e instanceof s&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((i=e.attrs)===null||i===void 0?void 0:i.class))&&an(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};Zi.prototype.point=!1;var es=class s extends Q{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof s&&this.spec.class==e.spec.class&&an(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};es.prototype.mapMode=ue.TrackBefore;es.prototype.point=!0;var St=class s extends Q{constructor(e,t,i,n,r,o){super(t,i,r,e),this.block=n,this.isReplace=o,this.mapMode=n?t<=0?ue.TrackBefore:ue.TrackAfter:ue.TrackDel}get type(){return this.startSide!=this.endSide?ze.WidgetRange:this.startSide<=0?ze.WidgetBefore:ze.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof s&&vu(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};St.prototype.point=!0;function hh(s,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=s;return t==null&&(t=s.inclusive),i==null&&(i=s.inclusive),{start:t!=null?t:e,end:i!=null?i:e}}function vu(s,e){return s==e||!!(s&&e&&s.compare(e))}function Jr(s,e,t,i=0){let n=t.length-1;n>=0&&t[n]+i>=s?t[n]=Math.max(t[n],e):t.push(s,e)}var re=class s extends z{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,n,r,o){if(i){if(!(i instanceof s))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),sh(this,e,t,i?i.children.slice():[],r,o),!0}split(e){let t=new s;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:n}=this.childPos(e);n&&(t.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let r=i;r0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){an(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){lh(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=Yr(t,this.attrs||{})),i&&(this.attrs=Yr({class:i},this.attrs||{}))}domAtPos(e){return oh(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var i;this.dom?this.flags&4&&(Qa(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Gr(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let n=this.dom.lastChild;for(;n&&z.get(n)instanceof kt;)n=n.lastChild;if(!n||!this.length||n.nodeName!="BR"&&((i=z.get(n))===null||i===void 0?void 0:i.isEditable)==!1&&(!T.ios||!this.children.some(r=>r instanceof Ye))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof Ye)||/[^ -~]/.test(i.text))return null;let n=Xi(i.dom);if(n.length!=1)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=ah(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:n}=this.parent.view.viewState,r=i.bottom-i.top;if(Math.abs(r-n.lineHeight)<2&&n.textHeight=t){if(r instanceof s)return r;if(o>t)break}n=o+r.breakAfter}return null}},Wt=class s extends z{constructor(e,t,i){super(),this.widget=e,this.length=t,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,n,r,o){return i&&(!(i instanceof s)||!this.widget.compare(i.widget)||e>0&&r<=0||t0}},ts=class extends ui{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},zi=class s{constructor(e,t,i,n){this.doc=e,this.pos=t,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Wt&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new re),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(Ys(new Qi(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Wt)&&this.getLine()}buildText(e,t,i){for(;e>0;){if(this.textOff==this.text.length){let{value:r,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=r,this.textOff=0}let n=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(Ys(new Ye(this.text.slice(this.textOff,this.textOff+n)),t),i),this.atCursorPos=!0,this.textOff+=n,e-=n,i=0}}span(e,t,i,n){this.buildText(t-e,i,n),this.pos=t,this.openStart<0&&(this.openStart=n)}point(e,t,i,n,r,o){if(this.disallowBlockEffectsFor[o]&&i instanceof St){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof St)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Wt(i.widget||vt.block,l,i));else{let a=ln.create(i.widget||vt.inline,l,l?0:i.startSide),h=this.atCursorPos&&!a.isEditable&&r<=n.length&&(e0),f=!a.isEditable&&(en.length||i.startSide<=0),c=this.getLine();this.pendingBuffer==2&&!h&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(n),h&&(c.append(Ys(new Qi(1),n),r),r=n.length+Math.max(0,r-n.length)),c.append(Ys(a,n),r),this.atCursorPos=f,this.pendingBuffer=f?en.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,i,n,r){let o=new s(e,t,i,r);return o.openEnd=Z.spans(n,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function Ys(s,e){for(let t of e)s=new kt(t,[s],s.length);return s}var vt=class extends ui{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};vt.inline=new vt("span");vt.block=new vt("div");var ie=function(s){return s[s.LTR=0]="LTR",s[s.RTL=1]="RTL",s}(ie||(ie={})),zt=ie.LTR,So=ie.RTL;function fh(s){let e=[];for(let t=0;t=t){if(l.level==i)return o;(r<0||(n!=0?n<0?l.fromt:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}};function uh(s,e){if(s.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(We[m+1]==-d){let g=We[m+2],y=g&2?n:g&4?g&1?r:n:0;y&&(j[c]=j[We[m]]=y),l=m;break}}else{if(We.length==189)break;We[l++]=c,We[l++]=u,We[l++]=a}else if((p=j[c])==2||p==1){let m=p==n;a=m?0:1;for(let g=l-3;g>=0;g-=3){let y=We[g+2];if(y&2)break;if(m)We[g+2]|=2;else{if(y&4)break;We[g+2]|=4}}}}}function Tu(s,e,t,i){for(let n=0,r=i;n<=t.length;n++){let o=n?t[n-1].to:s,l=na;)p==g&&(p=t[--m].from,g=m?t[m-1].to:s),j[--p]=d;a=f}else r=h,a++}}}function Qr(s,e,t,i,n,r,o){let l=i%2?2:1;if(i%2==n%2)for(let a=e,h=0;aa&&o.push(new je(a,m.from,d));let g=m.direction==zt!=!(d%2);Zr(s,g?i+1:i,n,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(f?j[p]!=l:j[p]==l))break;p++}u?Qr(s,a,p,i+1,n,u,o):ae;){let f=!0,c=!1;if(!h||a>r[h-1].to){let m=j[a-1];m!=l&&(f=!1,c=m==16)}let u=!f&&l==1?[]:null,d=f?i:i+1,p=a;e:for(;;)if(h&&p==r[h-1].to){if(c)break e;let m=r[--h];if(!f)for(let g=m.from,y=h;;){if(g==e)break e;if(y&&r[y-1].to==g)g=r[--y].from;else{if(j[g-1]==l)break e;break}}if(u)u.push(m);else{m.toj.length;)j[j.length]=256;let i=[],n=e==zt?0:1;return Zr(s,n,n,t,0,s.length,i),i}function dh(s){return[new je(0,s,0)]}var ph="";function Nu(s,e,t,i,n){var r;let o=i.head-s.from,l=je.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=e[l],h=a.side(n,t);if(o==h){let u=l+=n?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!n,t),h=a.side(n,t)}let f=Ke(s.text,o,a.forward(n,t));(fa.to)&&(f=h),ph=s.text.slice(Math.min(o,f),Math.max(o,f));let c=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return c&&f==h&&c.level+(n?0:1)s.some(e=>e)}),Lu=R.define({combine:s=>s.some(e=>e)}),vh=R.define(),Ui=class s{constructor(e,t="nearest",i="nearest",n=5,r=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new s(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new s(P.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Gs=J.define({map:(s,e)=>s.map(e)}),xh=J.define();function Le(s,e,t){let i=s.facet(bh);i.length?i[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var bt=R.define({combine:s=>s.length?s[0]:!0}),Pu=0,_i=R.define(),Ut=class s{constructor(e,t,i,n,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=n,this.extension=r(this)}static define(e,t){let{eventHandlers:i,eventObservers:n,provide:r,decorations:o}=t||{};return new s(Pu++,e,i,n,l=>{let a=[_i.of(l)];return o&&a.push(is.of(h=>{let f=h.plugin(l);return f?o(f):Q.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return s.define(i=>new e(i),t)}},Yi=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(Le(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(n){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Le(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){Le(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},Ch=R.define(),Co=R.define(),is=R.define(),Ah=R.define(),Ao=R.define(),Mh=R.define();function Ma(s,e){let t=s.state.facet(Mh);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(s):r),n=[];return Z.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,f=o-e.from,c=n;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=Du(e.text,h,f)),a>0&&c.length&&(p=c[c.length-1]).to==h&&p.direction==d)p.to=f,c=p.inner;else{let m={from:h,to:f,direction:d,inner:[]};c.push(m),c=m.inner}}}}),n}var Oh=R.define();function Th(s){let e=0,t=0,i=0,n=0;for(let r of s.state.facet(Oh)){let o=r(s);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:e,right:t,top:i,bottom:n}}var Ki=R.define(),Ue=class s{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new s(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toAf)break;r+=2}if(!a)return i;new s(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}},hn=class s{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=ye.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let n=[];this.changes.iterChangedRanges((r,o,l,a)=>n.push(new Ue(r,o,l,a))),this.changedRanges=n}static create(e,t,i){return new s(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},fn=class extends z{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=Q.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new re],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Ue(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!Hu(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Iu(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:h,to:f}=this.hasComposition;i=new Ue(h,f,e.changes.mapPos(h,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(T.ie||T.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=$u(o,l,e.changes);return i=Ue.extendWithRanges(i,a),!(this.flags&7)&&i.length==0?!1:(this.updateInner(i,e.startState.doc.length,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=T.chrome||T.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||n.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to=0?n[o]:null;if(!l)break;let{fromA:a,toA:h,fromB:f,toB:c}=l,u,d,p,m;if(i&&i.range.fromBf){let S=zi.build(this.view.state.doc,f,i.range.fromB,this.decorations,this.dynamicDecorationMap),v=zi.build(this.view.state.doc,i.range.toB,c,this.decorations,this.dynamicDecorationMap);d=S.breakAtStart,p=S.openStart,m=v.openEnd;let M=this.compositionView(i);v.breakAtStart?M.breakAfter=1:v.content.length&&M.merge(M.length,M.length,v.content[0],!1,v.openStart,0)&&(M.breakAfter=v.content[0].breakAfter,v.content.shift()),S.content.length&&M.merge(0,0,S.content[S.content.length-1],!0,0,S.openEnd)&&S.content.pop(),u=S.content.concat(M).concat(v.content)}else({content:u,breakAtStart:d,openStart:p,openEnd:m}=zi.build(this.view.state.doc,f,c,this.decorations,this.dynamicDecorationMap));let{i:g,off:y}=r.findPos(h,1),{i:w,off:x}=r.findPos(a,-1);ih(this,w,x,g,y,u,d,p,m)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(xh)&&(this.editContextFormatting=i.value)}compositionView(e){let t=new Ye(e.text.nodeValue);t.flags|=8;for(let{deco:n}of e.marks)t=new kt(n,[t],t.length);let i=new re;return i.append(t,0),i}fixCompositionDOM(e){let t=(r,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=z.get(r);l&&l!=o&&(l.dom=null),o.setDOM(r)},i=this.childPos(e.range.fromB,1),n=this.children[i.i];t(e.line,n);for(let r=e.marks.length-1;r>=-1;r--)i=n.childPos(i.off,1),n=n.children[i.i],t(r>=0?e.marks[r].node:e.text,n)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,r=!n&&tn(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(T.gecko&&l.empty&&!this.hasComposition&&Bu(a)){let c=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(c,a.node.childNodes[a.offset]||null)),a=h=new fe(c,0),o=!0}let f=this.view.observer.selectionRange;(o||!f.focusNode||(!ji(a.node,a.offset,f.anchorNode,f.anchorOffset)||!ji(h.node,h.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,l))&&(this.view.observer.ignore(()=>{T.android&&T.chrome&&this.dom.contains(f.focusNode)&&Vu(f.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let c=Ji(this.view.root);if(c)if(l.empty){if(T.gecko){let u=Ru(a.node,a.offset);if(u&&u!=3){let d=(u==1?eh:th)(a.node,a.offset);d&&(a=new fe(d.node,d.offset))}}c.collapse(a.node,a.offset),l.bidiLevel!=null&&c.caretBidiLevel!==void 0&&(c.caretBidiLevel=l.bidiLevel)}else if(c.extend){c.collapse(a.node,a.offset);try{c.extend(h.node,h.offset)}catch(u){}}else{let u=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),u.setEnd(h.node,h.offset),u.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(u)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new fe(f.anchorNode,f.anchorOffset),this.impreciseHead=h.precise?null:new fe(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&ji(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Ji(e.root),{anchorNode:n,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=re.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let f=this.domAtPos(t.head+t.assoc);i.collapse(f.node,f.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&i.collapse(n,r)}moveToLine(e){let t=this.dom,i;if(e.node!=t)return e;for(let n=e.offset;!i&&n=0;n--){let r=z.get(t.childNodes[n]);r instanceof re&&(i=r.domAtPos(r.length))}return i?new fe(i.node,i.offset,!0):e}nearest(e){for(let t=e;t;){let i=z.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;t=0;o--){let l=this.children[o],a=r-l.breakAfter,h=a-l.length;if(ae||l.covers(1))&&(!i||l instanceof re&&!(i instanceof re&&t>=0)))i=l,n=h;else if(i&&h==e&&a==e&&l instanceof Wt&&Math.abs(t)<2){if(l.deco.startSide<0)break;o&&(i=null)}r=h}return i?i.coordsAt(e-n,t):null}coordsForChar(e){let{i:t,off:i}=this.childPos(e,1),n=this.children[t];if(!(n instanceof re))return null;for(;n.children.length;){let{i:l,off:a}=n.childPos(i,1);for(;;l++){if(l==n.children.length)return null;if((n=n.children[l]).length)break}i=a}if(!(n instanceof Ye))return null;let r=Ke(n.text,i);if(r==i)return null;let o=jt(n.dom,i,r).getClientRects();for(let l=0;lMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==ie.LTR;for(let h=0,f=0;fn)break;if(h>=i){let d=c.dom.getBoundingClientRect();if(t.push(d.height),o){let p=c.dom.lastChild,m=p?Xi(p):[];if(m.length){let g=m[m.length-1],y=a?g.right-d.left:d.right-g.left;y>l&&(l=y,this.minWidth=r,this.minWidthFrom=h,this.minWidthTo=u)}}}h=u+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?ie.RTL:ie.LTR}measureTextSize(){for(let r of this.children)if(r instanceof re){let o=r.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,n;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=Xi(e.firstChild)[0];t=e.getBoundingClientRect().height,i=r?r.width/27:7,n=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:n}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new on(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],o=r?r.from-1:this.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Q.replace({widget:new ts(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return Q.set(e)}updateDeco(){let e=1,t=this.view.state.facet(is).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,n=this.view.state.facet(Ah).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(n.length&&(this.dynamicDecorationMap[e++]=i,t.push(Z.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];et.anchor?-1:1),n;if(!i)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,n.left),top:Math.min(i.top,n.top),right:Math.max(i.right,n.right),bottom:Math.max(i.bottom,n.bottom)});let r=Th(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;pu(this.view.scrollDOM,o,t.head{ie.from&&(t=!0)}),t}function _u(s,e,t=1){let i=s.charCategorizer(e),n=s.doc.lineAt(e),r=e-n.from;if(n.length==0)return P.cursor(e);r==0?t=1:r==n.length&&(t=-1);let o=r,l=r;t<0?o=Ke(n.text,r,!1):l=Ke(n.text,r);let a=i(n.text.slice(o,l));for(;o>0;){let h=Ke(n.text,o,!1);if(i(n.text.slice(h,o))!=a)break;o=h}for(;ls?e.left-s:Math.max(0,s-e.right)}function Wu(s,e){return e.top>s?e.top-s:Math.max(0,s-e.bottom)}function Hr(s,e){return s.tope.top+1}function Oa(s,e){return es.bottom?{top:s.top,left:s.left,right:s.right,bottom:e}:s}function to(s,e,t){let i,n,r,o,l=!1,a,h,f,c;for(let p=s.firstChild;p;p=p.nextSibling){let m=Xi(p);for(let g=0;gx||o==x&&r>w){i=p,n=y,r=w,o=x;let S=x?t0?g0)}w==0?t>y.bottom&&(!f||f.bottomy.top)&&(h=p,c=y):f&&Hr(f,y)?f=Ta(f,y.bottom):c&&Hr(c,y)&&(c=Oa(c,y.top))}}if(f&&f.bottom>=t?(i=a,n=f):c&&c.top<=t&&(i=h,n=c),!i)return{node:s,offset:0};let u=Math.max(n.left,Math.min(n.right,e));if(i.nodeType==3)return Ea(i,u,t);if(l&&i.contentEditable!="false")return to(i,u,t);let d=Array.prototype.indexOf.call(s.childNodes,i)+(e>=(n.left+n.right)/2?1:0);return{node:s,offset:d}}function Ea(s,e,t){let i=s.nodeValue.length,n=-1,r=1e9,o=0;for(let l=0;lt?f.top-t:t-f.bottom)-1;if(f.left-1<=e&&f.right+1>=e&&c=(f.left+f.right)/2,d=u;if((T.chrome||T.gecko)&&jt(s,l).getBoundingClientRect().left==f.right&&(d=!u),c<=0)return{node:s,offset:l+(d?1:0)};n=l+(d?1:0),r=c}}}return{node:s,offset:n>-1?n:o>0?s.nodeValue.length:0}}function Nh(s,e,t,i=-1){var n,r;let o=s.contentDOM.getBoundingClientRect(),l=o.top+s.viewState.paddingTop,a,{docHeight:h}=s.viewState,{x:f,y:c}=e,u=c-l;if(u<0)return 0;if(u>h)return s.state.doc.length;for(let S=s.viewState.heightOracle.textHeight/2,v=!1;a=s.elementAtHeight(u),a.type!=ze.Text;)for(;u=i>0?a.bottom+S:a.top-S,!(u>=0&&u<=h);){if(v)return t?null:0;v=!0,i=-i}c=l+u;let d=a.from;if(ds.viewport.to)return s.viewport.to==s.state.doc.length?s.state.doc.length:t?null:Na(s,o,a,f,c);let p=s.dom.ownerDocument,m=s.root.elementFromPoint?s.root:p,g=m.elementFromPoint(f,c);g&&!s.contentDOM.contains(g)&&(g=null),g||(f=Math.max(o.left+1,Math.min(o.right-1,f)),g=m.elementFromPoint(f,c),g&&!s.contentDOM.contains(g)&&(g=null));let y,w=-1;if(g&&((n=s.docView.nearest(g))===null||n===void 0?void 0:n.isEditable)!=!1){if(p.caretPositionFromPoint){let S=p.caretPositionFromPoint(f,c);S&&({offsetNode:y,offset:w}=S)}else if(p.caretRangeFromPoint){let S=p.caretRangeFromPoint(f,c);S&&({startContainer:y,startOffset:w}=S,(!s.contentDOM.contains(y)||T.safari&&qu(y,w,f)||T.chrome&&ju(y,w,f))&&(y=void 0))}}if(!y||!s.docView.dom.contains(y)){let S=re.find(s.docView,d);if(!S)return u>a.top+a.height/2?a.to:a.from;({node:y,offset:w}=to(S.dom,f,c))}let x=s.docView.nearest(y);if(!x)return null;if(x.isWidget&&((r=x.dom)===null||r===void 0?void 0:r.nodeType)==1){let S=x.dom.getBoundingClientRect();return e.ys.defaultLineHeight*1.5){let l=s.viewState.heightOracle.textHeight,a=Math.floor((n-t.top-(s.defaultLineHeight-l)*.5)/l);r+=a*s.viewState.heightOracle.lineLength}let o=s.state.sliceDoc(t.from,t.to);return t.from+ma(o,r,s.state.tabSize)}function qu(s,e,t){let i;if(s.nodeType!=3||e!=(i=s.nodeValue.length))return!1;for(let n=s.nextSibling;n;n=n.nextSibling)if(n.nodeType!=1||n.nodeName!="BR")return!1;return jt(s,i-1,i).getBoundingClientRect().left>t}function ju(s,e,t){if(e!=0)return!1;for(let n=s;;){let r=n.parentNode;if(!r||r.nodeType!=1||r.firstChild!=n)return!1;if(r.classList.contains("cm-line"))break;n=r}let i=s.nodeType==1?s.getBoundingClientRect():jt(s,0,Math.max(s.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function zu(s,e){let t=s.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==ze.Text))return i}return t}function Uu(s,e,t,i){let n=zu(s,e.head),r=!i||n.type!=ze.Text||!(s.lineWrapping||n.widgetLineBreaks)?null:s.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(r){let o=s.dom.getBoundingClientRect(),l=s.textDirectionAt(n.from),a=s.posAtCoords({x:t==(l==ie.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return P.cursor(a,t?-1:1)}return P.cursor(t?n.to:n.from,t?-1:1)}function Da(s,e,t,i){let n=s.state.doc.lineAt(e.head),r=s.bidiSpans(n),o=s.textDirectionAt(n.from);for(let l=e,a=null;;){let h=Nu(n,r,o,l,t),f=ph;if(!h){if(n.number==(t?s.state.doc.lines:1))return l;f=`\n`,n=s.state.doc.line(n.number+(t?1:-1)),r=s.bidiSpans(n),h=s.visualLineSide(n,!t)}if(a){if(!a(f))return l}else{if(!i)return h;a=i(f)}l=h}}function Yu(s,e,t){let i=s.state.charCategorizer(e),n=i(t);return r=>{let o=i(r);return n==_e.Space&&(n=o),n==o}}function Gu(s,e,t,i){let n=e.head,r=t?1:-1;if(n==(t?s.state.doc.length:0))return P.cursor(n,e.assoc);let o=e.goalColumn,l,a=s.contentDOM.getBoundingClientRect(),h=s.coordsAtPos(n,e.assoc||-1),f=s.documentTop;if(h)o==null&&(o=h.left-a.left),l=r<0?h.top:h.bottom;else{let d=s.viewState.lineBlockAt(n);o==null&&(o=Math.min(a.right-a.left,s.defaultCharacterWidth*(n-d.from))),l=(r<0?d.top:d.bottom)+f}let c=a.left+o,u=i!=null?i:s.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=l+(u+d)*r,m=Nh(s,{x:c,y:p},!1,r);if(pa.bottom||(r<0?mn)){let g=s.docView.coordsForChar(m),y=!g||p{if(e>r&&en(s)),t.from,e.head>t.from?-1:1);return i==t.from?t:P.cursor(i,ir)&&this.lineBreak(),n=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,n=this.lineSeparator?null:/\\r\\n?|\\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=n.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){if(e.cmIgnore)return;let t=z.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let n=i.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Ju(e,i.node,i.offset)?t:0))}};function Ju(s,e,t){for(;;){if(!e||t-1;let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=r||o?[]:Zu(e),a=new io(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=ed(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Wr(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),h=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Wr(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),f=e.viewport;if((T.ios||T.chrome)&&e.state.selection.main.empty&&a!=h&&(f.from>0||f.toDate.now()-100?s.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=n.from,h=null;(r===8||T.android&&e.text.length=n.from&&t.to<=n.to&&(t.from!=n.from||t.to!=n.to)&&n.to-n.from-(t.to-t.from)<=4?t={from:n.from,to:n.to,insert:s.state.doc.slice(n.from,t.from).append(t.insert).append(s.state.doc.slice(t.to,n.to))}:(T.mac||T.android)&&t&&t.from==t.to&&t.from==n.head-1&&/^\\. ?$/.test(t.insert.toString())&&s.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=P.single(i.main.anchor-1,i.main.head-1)),t={from:n.from,to:n.to,insert:K.of([" "])}):T.chrome&&t&&t.from==t.to&&t.from==n.head&&t.insert.toString()==`\n `&&s.lineWrapping&&(i&&(i=P.single(i.main.anchor-1,i.main.head-1)),t={from:n.from,to:n.to,insert:K.of([" "])}),t)return Mo(s,t,i,r);if(i&&!i.main.eq(n)){let o=!1,l="select";return s.inputState.lastSelectionTime>Date.now()-50&&(s.inputState.lastSelectionOrigin=="select"&&(o=!0),l=s.inputState.lastSelectionOrigin),s.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function Mo(s,e,t,i=-1){if(T.ios&&s.inputState.flushIOSKey(e))return!0;let n=s.state.selection.main;if(T.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&s.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ci(s.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||i==8&&e.insert.lengthn.head)&&ci(s.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&ci(s.contentDOM,"Delete",46)))return!0;let r=e.insert.toString();s.inputState.composing>=0&&s.inputState.composing++;let o,l=()=>o||(o=Xu(s,e,t));return s.state.facet(wh).some(a=>a(s,e.from,e.to,r,l))||s.dispatch(l()),!0}function Xu(s,e,t){let i,n=s.state,r=n.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&s.inputState.composing<0){let l=r.frome.to?n.sliceDoc(e.to,r.to):"";i=n.replaceSelection(s.state.toText(l+e.insert.sliceString(0,void 0,s.state.lineBreak)+a))}else{let l=n.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(n.selection.ranges.length>1&&s.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let h=s.state.sliceDoc(e.from,e.to),f,c=t&&Eh(s,t.main.head);if(c){let p=e.insert.length-(e.to-e.from);f={from:c.from,to:c.to-p}}else f=s.state.doc.lineAt(r.head);let u=r.to-e.to,d=r.to-r.from;i=n.changeByRange(p=>{if(p.from==r.from&&p.to==r.to)return{changes:l,range:a||p.map(l)};let m=p.to-u,g=m-h.length;if(p.to-p.from!=d||s.state.sliceDoc(g,m)!=h||p.to>=f.from&&p.from<=f.to)return{range:p};let y=n.changes({from:g,to:m,insert:e.insert}),w=p.to-r.to;return{changes:y,range:a?P.range(Math.max(0,a.anchor+w),Math.max(0,a.head+w)):p.map(y)}})}else i={changes:l,selection:a&&n.selection.replaceRange(a)}}let o="input.type";return(s.composing||s.inputState.compositionPendingChange&&s.inputState.compositionEndedAt>Date.now()-50)&&(s.inputState.compositionPendingChange=!1,o+=".compose",s.inputState.compositionFirstChange&&(o+=".start",s.inputState.compositionFirstChange=!1)),n.update(i,{userEvent:o,scrollIntoView:!0})}function Qu(s,e,t,i){let n=Math.min(s.length,e.length),r=0;for(;r0&&l>0&&s.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function Zu(s){let e=[];if(s.root.activeElement!=s.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}=s.observer.selectionRange;return t&&(e.push(new cn(t,i)),(n!=t||r!=i)&&e.push(new cn(n,r))),e}function ed(s,e){if(s.length==0)return null;let t=s[0].pos,i=s.length==2?s[1].pos:t;return t>-1&&i>-1?P.single(t+e,i+e):null}var no=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,T.safari&&e.contentDOM.addEventListener("input",()=>null),T.gecko&&gd(e.contentDOM.ownerDocument)}handleEvent(e){!ad(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let i=this.handlers[e];if(i){for(let n of i.observers)n(this.view,t);for(let n of i.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=td(e),i=this.handlers,n=this.view.contentDOM;for(let r in t)if(r!="scroll"){let o=!t[r].handlers.length,l=i[r];l&&o!=!l.handlers.length&&(n.removeEventListener(r,this.handleEvent),l=null),l||n.addEventListener(r,this.handleEvent,{passive:o})}for(let r in i)r!="scroll"&&!t[r]&&n.removeEventListener(r,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&sd.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),T.android&&T.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return T.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Lh.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||id.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:T.safari&&!T.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function La(s,e){return(t,i)=>{try{return e.call(s,i,t)}catch(n){Le(t.state,n)}}}function td(s){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of s){let n=i.spec;if(n&&n.domEventHandlers)for(let r in n.domEventHandlers){let o=n.domEventHandlers[r];o&&t(r).handlers.push(La(i.value,o))}if(n&&n.domEventObservers)for(let r in n.domEventObservers){let o=n.domEventObservers[r];o&&t(r).observers.push(La(i.value,o))}}for(let i in Pe)t(i).handlers.push(Pe[i]);for(let i in Ce)t(i).observers.push(Ce[i]);return e}var Lh=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],id="dthko",sd=[16,17,18,20,91,92,224,225],Js=6;function Xs(s){return Math.max(0,s)*.7+8}function nd(s,e){return Math.max(Math.abs(s.clientX-e.clientX),Math.abs(s.clientY-e.clientY))}var ro=class{constructor(e,t,i,n){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=mu(e.contentDOM),this.atoms=e.state.facet(Ao).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(X.allowMultipleSelections)&&rd(e,t),this.dragging=ld(e,t)&&Ih(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&nd(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,n=0,r=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=Th(this.view);e.clientX-a.left<=n+Js?t=-Xs(n-e.clientX):e.clientX+a.right>=o-Js&&(t=Xs(e.clientX-o)),e.clientY-a.top<=r+Js?i=-Xs(r-e.clientY):e.clientY+a.bottom>=l-Js&&(i=Xs(e.clientY-l)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;it.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function rd(s,e){let t=s.state.facet(mh);return t.length?t[0](e):T.mac?e.metaKey:e.ctrlKey}function od(s,e){let t=s.state.facet(gh);return t.length?t[0](e):T.mac?!e.altKey:!e.ctrlKey}function ld(s,e){let{main:t}=s.state.selection;if(t.empty)return!1;let i=Ji(s.root);if(!i||i.rangeCount==0)return!0;let n=i.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function ad(s,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=s.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=z.get(t))&&i.ignoreEvent(e))return!1;return!0}var Pe=Object.create(null),Ce=Object.create(null),Ph=T.ie&&T.ie_version<15||T.ios&&T.webkit_version<604;function hd(s){let e=s.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{s.focus(),t.remove(),Bh(s,t.value)},50)}function bn(s,e,t){for(let i of s.facet(e))t=i(t,s);return t}function Bh(s,e){e=bn(s.state,vo,e);let{state:t}=s,i,n=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(oo!=null&&t.selection.ranges.every(a=>a.empty)&&oo==r.toString()){let a=-1;i=t.changeByRange(h=>{let f=t.doc.lineAt(h.from);if(f.from==a)return{range:h};a=f.from;let c=t.toText((o?r.line(n++).text:e)+t.lineBreak);return{changes:{from:f.from,insert:c},range:P.cursor(h.from+c.length)}})}else o?i=t.changeByRange(a=>{let h=r.line(n++);return{changes:{from:a.from,to:a.to,insert:h.text},range:P.cursor(a.from+h.length)}}):i=t.replaceSelection(r);s.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Ce.scroll=s=>{s.inputState.lastScrollTop=s.scrollDOM.scrollTop,s.inputState.lastScrollLeft=s.scrollDOM.scrollLeft};Pe.keydown=(s,e)=>(s.inputState.setSelectionOrigin("select"),e.keyCode==27&&s.inputState.tabFocusMode!=0&&(s.inputState.tabFocusMode=Date.now()+2e3),!1);Ce.touchstart=(s,e)=>{s.inputState.lastTouchTime=Date.now(),s.inputState.setSelectionOrigin("select.pointer")};Ce.touchmove=s=>{s.inputState.setSelectionOrigin("select.pointer")};Pe.mousedown=(s,e)=>{if(s.observer.flush(),s.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of s.state.facet(yh))if(t=i(s,e),t)break;if(!t&&e.button==0&&(t=ud(s,e)),t){let i=!s.hasFocus;s.inputState.startMouseSelection(new ro(s,e,t,i)),i&&s.observer.ignore(()=>{Xa(s.contentDOM);let r=s.root.activeElement;r&&!r.contains(s.contentDOM)&&r.blur()});let n=s.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}return!1};function Pa(s,e,t,i){if(i==1)return P.cursor(e,t);if(i==2)return _u(s.state,e,t);{let n=re.find(s.docView,e),r=s.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:r.from,l=n?n.posAtEnd:r.to;return le>=t.top&&e<=t.bottom&&s>=t.left&&s<=t.right;function fd(s,e,t,i){let n=re.find(s.docView,e);if(!n)return 1;let r=e-n.posAtStart;if(r==0)return 1;if(r==n.length)return-1;let o=n.coordsAt(r,-1);if(o&&Ba(t,i,o))return-1;let l=n.coordsAt(r,1);return l&&Ba(t,i,l)?1:o&&o.bottom>=i?-1:1}function Ia(s,e){let t=s.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:fd(s,t,e.clientX,e.clientY)}}var cd=T.ie&&T.ie_version<=11,Ra=null,Fa=0,$a=0;function Ih(s){if(!cd)return s.detail;let e=Ra,t=$a;return Ra=s,$a=Date.now(),Fa=!e||t>Date.now()-400&&Math.abs(e.clientX-s.clientX)<2&&Math.abs(e.clientY-s.clientY)<2?(Fa+1)%3:1}function ud(s,e){let t=Ia(s,e),i=Ih(e),n=s.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),n=n.map(r.changes))},get(r,o,l){let a=Ia(s,r),h,f=Pa(s,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let c=Pa(s,t.pos,t.bias,i),u=Math.min(c.from,f.from),d=Math.max(c.to,f.to);f=u1&&(h=dd(n,a.pos))?h:l?n.addRange(f):P.create([f])}}}function dd(s,e){for(let t=0;t=e)return P.create(s.ranges.slice(0,t).concat(s.ranges.slice(t+1)),s.mainIndex==t?0:s.mainIndex-(s.mainIndex>t?1:0))}return null}Pe.dragstart=(s,e)=>{let{selection:{main:t}}=s.state;if(e.target.draggable){let n=s.docView.nearest(e.target);if(n&&n.isWidget){let r=n.posAtStart,o=r+n.length;(r>=t.to||o<=t.from)&&(t=P.range(r,o))}}let{inputState:i}=s;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",bn(s.state,xo,s.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Pe.dragend=s=>(s.inputState.draggedContent=null,!1);function Va(s,e,t,i){if(t=bn(s.state,vo,t),!t)return;let n=s.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=s.inputState,o=i&&r&&od(s,e)?{from:r.from,to:r.to}:null,l={from:n,insert:t},a=s.state.changes(o?[o,l]:l);s.focus(),s.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),s.inputState.draggedContent=null}Pe.drop=(s,e)=>{if(!e.dataTransfer)return!1;if(s.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),n=0,r=()=>{++n==t.length&&Va(s,e,i.filter(o=>o!=null).join(s.state.lineBreak),!1)};for(let o=0;o{/[\\x00-\\x08\\x0e-\\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return Va(s,e,i,!0),!0}return!1};Pe.paste=(s,e)=>{if(s.state.readOnly)return!0;s.observer.flush();let t=Ph?null:e.clipboardData;return t?(Bh(s,t.getData("text/plain")||t.getData("text/uri-list")),!0):(hd(s),!1)};function pd(s,e){let t=s.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),s.focus()},50)}function md(s){let e=[],t=[],i=!1;for(let n of s.selection.ranges)n.empty||(e.push(s.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:r}of s.selection.ranges){let o=s.doc.lineAt(r);o.number>n&&(e.push(o.text),t.push({from:o.from,to:Math.min(s.doc.length,o.to+1)})),n=o.number}i=!0}return{text:bn(s,xo,e.join(s.lineBreak)),ranges:t,linewise:i}}var oo=null;Pe.copy=Pe.cut=(s,e)=>{let{text:t,ranges:i,linewise:n}=md(s.state);if(!t&&!n)return!1;oo=n?t:null,e.type=="cut"&&!s.state.readOnly&&s.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let r=Ph?null:e.clipboardData;return r?(r.clearData(),r.setData("text/plain",t),!0):(pd(s,t),!1)};var Rh=ht.define();function Fh(s,e){let t=[];for(let i of s.facet(kh)){let n=i(s,e);n&&t.push(n)}return t?s.update({effects:t,annotations:Rh.of(!0)}):null}function $h(s){setTimeout(()=>{let e=s.hasFocus;if(e!=s.inputState.notifiedFocused){let t=Fh(s.state,e);t?s.dispatch(t):s.update([])}},10)}Ce.focus=s=>{s.inputState.lastFocusTime=Date.now(),!s.scrollDOM.scrollTop&&(s.inputState.lastScrollTop||s.inputState.lastScrollLeft)&&(s.scrollDOM.scrollTop=s.inputState.lastScrollTop,s.scrollDOM.scrollLeft=s.inputState.lastScrollLeft),$h(s)};Ce.blur=s=>{s.observer.clearSelectionRange(),$h(s)};Ce.compositionstart=Ce.compositionupdate=s=>{s.observer.editContext||(s.inputState.compositionFirstChange==null&&(s.inputState.compositionFirstChange=!0),s.inputState.composing<0&&(s.inputState.composing=0))};Ce.compositionend=s=>{s.observer.editContext||(s.inputState.composing=-1,s.inputState.compositionEndedAt=Date.now(),s.inputState.compositionPendingKey=!0,s.inputState.compositionPendingChange=s.observer.pendingRecords().length>0,s.inputState.compositionFirstChange=null,T.chrome&&T.android?s.observer.flushSoon():s.inputState.compositionPendingChange?Promise.resolve().then(()=>s.observer.flush()):setTimeout(()=>{s.inputState.composing<0&&s.docView.hasComposition&&s.update([])},50))};Ce.contextmenu=s=>{s.inputState.lastContextMenu=Date.now()};Pe.beforeinput=(s,e)=>{var t,i;if(e.inputType=="insertReplacementText"&&s.observer.editContext){let r=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(r&&o.length){let l=o[0],a=s.posAtDOM(l.startContainer,l.startOffset),h=s.posAtDOM(l.endContainer,l.endOffset);return Mo(s,{from:a,to:h,insert:s.state.toText(r)},null),!0}}let n;if(T.chrome&&T.android&&(n=Lh.find(r=>r.inputType==e.inputType))&&(s.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>r+10&&s.hasFocus&&(s.contentDOM.blur(),s.focus())},100)}return T.ios&&e.inputType=="deleteContentForward"&&s.observer.flushSoon(),T.safari&&e.inputType=="insertText"&&s.inputState.composing>=0&&setTimeout(()=>Ce.compositionend(s,e),20),!1};var Ha=new Set;function gd(s){Ha.has(s)||(Ha.add(s),s.addEventListener("copy",()=>{}),s.addEventListener("cut",()=>{}))}var _a=["pre-wrap","normal","pre-line","break-spaces"],di=!1;function Ka(){di=!1}var lo=class{constructor(e){this.lineWrapping=e,this.doc=K.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return _a.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=n,this.lineLength=r,a){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>nn&&(di=!0),this.height=e)}replace(e,t,i){return s.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this,o=i.doc;for(let l=n.length-1;l>=0;l--){let{fromA:a,toA:h,fromB:f,toB:c}=n[l],u=r.lineAt(a,U.ByPosNoHeight,i.setDoc(t),0,0),d=u.to>=h?u:r.lineAt(h,U.ByPosNoHeight,i,0,0);for(c+=d.to-h,h=d.to;l>0&&u.from<=n[l-1].toA;)a=n[l-1].fromA,f=n[l-1].fromB,l--,ar*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,n-=l.size}else if(r>n*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(n=r&&o(this.blockAt(0,i,n,r))}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},xe=class s extends dn{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,n){return new qe(n,this.length,i,this.height,this.breaks)}replace(e,t,i){let n=i[0];return i.length==1&&(n instanceof s||n instanceof wt&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof wt?n=new s(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):be.of(i)}updateHeight(e,t=0,i=!1,n){return n&&n.from<=t&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},wt=class s extends be{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,r=n-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:n,perLine:o,perChar:l}}blockAt(e,t,i,n){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,n);if(t.lineWrapping){let h=n+(e0){let r=i[i.length-1];r instanceof s?i[i.length-1]=new s(r.length+n):i.push(null,new s(n-1))}if(e>0){let r=i[0];r instanceof s?i[0]=new s(e+r.length):i.unshift(new s(e-1),null)}return be.of(i)}decomposeLeft(e,t){t.push(new s(e-1),null)}decomposeRight(e,t){t.push(null,new s(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let o=[],l=Math.max(t,n.from),a=-1;for(n.from>t&&o.push(new s(n.from-t-1).updateHeight(e,t));l<=r&&n.more;){let f=e.doc.lineAt(l).length;o.length&&o.push(null);let c=n.heights[n.index++];a==-1?a=c:Math.abs(c-a)>=nn&&(a=-2);let u=new xe(f,c);u.outdated=!1,o.push(u),l+=f+1}l<=r&&o.push(null,new s(r-l).updateHeight(e,l));let h=be.of(o);return(a<0||Math.abs(h.height-this.height)>=nn||Math.abs(a-this.heightMetrics(e,t).perLine)>=nn)&&(di=!0),un(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},ho=class extends be{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,n){let r=i+this.left.height;return el))return h;let f=t==U.ByPosNoHeight?U.ByPosNoHeight:U.ByPos;return a?h.join(this.right.lineAt(l,f,i,o,l)):this.left.lineAt(l,f,i,n,r).join(h)}forEachLine(e,t,i,n,r,o){let l=n+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,l,a,o);else{let h=this.lineAt(a,U.ByPos,i,n,r);e=e&&h.from<=t&&o(h),t>h.to&&this.right.forEachLine(h.to+1,t,i,l,a,o)}}replace(e,t,i){let n=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&Wa(r,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e2*t.size||t.size>2*e.size?be.of(this.break?[e,null,t]:[e,t]):(this.left=un(this.left,e),this.right=un(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return n&&n.from<=t+r.length&&n.more?a=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=l+o.length&&n.more?a=o=o.updateHeight(e,l,i,n):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Wa(s,e){let t,i;s[e]==null&&(t=s[e-1])instanceof wt&&(i=s[e+1])instanceof wt&&s.splice(e-1,3,new wt(t.length+1+i.length))}var yd=5,fo=class s{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof xe?n.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new xe(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=yd)&&this.addLineDeco(n,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new xe(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new wt(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof xe)return e;let t=new xe(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof xe)&&!this.isCovered?this.nodes.push(new xe(0,-1)):(this.writtenTof.clientHeight||f.scrollWidth>f.clientWidth)&&c.overflow!="visible"){let u=f.getBoundingClientRect();r=Math.max(r,u.left),o=Math.min(o,u.right),l=Math.max(l,u.top),a=Math.min(h==s.parentNode?n.innerHeight:a,u.bottom)}h=c.position=="absolute"||c.position=="fixed"?f.offsetParent:f.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function kd(s,e){let t=s.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var Gi=class{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new lo(t),this.stateDeco=e.facet(is).filter(i=>typeof i!="function"),this.heightMap=be.empty().applyChanges(this.stateDeco,K.empty,this.heightOracle.setDoc(e.doc),[new Ue(0,0,0,e.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Q.set(this.lineGaps.map(i=>i.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>n>=r&&n<=o)){let{from:r,to:o}=this.lineBlockAt(n);e.push(new fi(r,o))}}return this.viewports=e.sort((i,n)=>i.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?qa:new po(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(qi(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(is).filter(f=>typeof f!="function");let n=e.changedRanges,r=Ue.extendWithRanges(n,bd(i,this.stateDeco,e?e.changes:ye.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Ka(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),(this.heightMap.height!=o||di)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let h=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Lu)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?ie.RTL:ie.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let h=0,f=0;if(l.width&&l.height){let{scaleX:S,scaleY:v}=Ja(t,l);(S>.005&&Math.abs(this.scaleX-S)>.005||v>.005&&Math.abs(this.scaleY-v)>.005)&&(this.scaleX=S,this.scaleY=v,h|=8,o=a=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,u=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=u)&&(this.paddingTop=c,this.paddingBottom=u,h|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=8);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Za(e.scrollDOM);let p=(this.printing?kd:wd)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,h|=8),a){let S=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(S)&&(o=!0),o||n.lineWrapping&&Math.abs(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:v,charWidth:M,textHeight:O}=e.docView.measureTextSize();o=v>0&&n.refresh(r,v,M,O,w/M,S),o&&(e.docView.minWidth=0,h|=8)}m>0&&g>0?f=Math.max(m,g):m<0&&g<0&&(f=Math.min(m,g)),Ka();for(let v of this.viewports){let M=v.from==this.viewport.from?S:e.docView.measureVisibleLineHeights(v);this.heightMap=(o?be.empty().applyChanges(this.stateDeco,K.empty,this.heightOracle,[new Ue(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new ao(v.from,M))}di&&(h|=2)}let x=!this.viewportIsAppropriate(this.viewport,f)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return x&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(f,this.scrollTarget),h|=this.updateForViewport()),(h&2||x)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new fi(n.lineAt(o-i*1e3,U.ByHeight,r,0,0).from,n.lineAt(l+(1-i)*1e3,U.ByHeight,r,0,0).to);if(t){let{head:h}=t.range;if(ha.to){let f=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=n.lineAt(h,U.ByPos,r,0,0),u;t.y=="center"?u=(c.top+c.bottom)/2-f/2:t.y=="start"||t.y=="nearest"&&h=l+Math.max(10,Math.min(i,250)))&&n>o-2*1e3&&r>1,o=n<<1;if(this.defaultTextDirection!=ie.LTR&&!i)return[];let l=[],a=(f,c,u,d)=>{if(c-ff&&yy.from>=u.from&&y.to<=u.to&&Math.abs(y.from-f)y.fromw));if(!g){if(cy.from<=c&&y.to>=c)){let y=t.moveToLineBoundary(P.cursor(c),!1,!0).head;y>f&&(c=y)}g=new Gi(f,c,this.gapSize(u,f,c,d))}l.push(g)},h=f=>{if(f.lengthf.from&&a(f.from,d,f,c),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];Z.spans(e,this.viewport.from,this.viewport.to,{span(n,r){t.push({from:n,to:r})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((n,r)=>n.from!=t[r].from||n.to!=t[r].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||qi(this.heightMap.lineAt(e,U.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||qi(this.heightMap.lineAt(this.scaler.fromDOM(e),U.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return qi(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},fi=class{constructor(e,t){this.from=e,this.to=t}};function Sd(s,e,t){let i=[],n=s,r=0;return Z.spans(t,s,e,{span(){},point(o,l){o>n&&(i.push({from:n,to:o}),r+=o-n),n=l}},20),n=1)return e[e.length-1].to;let i=Math.floor(s*t);for(let n=0;;n++){let{from:r,to:o}=e[n],l=o-r;if(i<=l)return r+i;i-=l}}function Zs(s,e){let t=0;for(let{from:i,to:n}of s.ranges){if(e<=n){t+=e-i;break}t+=n-i}return t/s.total}function vd(s,e){for(let t of s)if(e(t))return t}var qa={toDOM(s){return s},fromDOM(s){return s},scale:1,eq(s){return s==this}},po=class s{constructor(e,t,i){let n=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let h=t.lineAt(l,U.ByPos,e,0,0).top,f=t.lineAt(a,U.ByPos,e,0,0).bottom;return n+=f-h,{from:l,to:a,top:h,bottom:f,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}};function qi(s,e){if(e.scale==1)return s;let t=e.toDOM(s.top),i=e.toDOM(s.bottom);return new qe(s.from,s.length,t,i-t,Array.isArray(s._content)?s._content.map(n=>qi(n,e)):s._content)}var en=R.define({combine:s=>s.join(" ")}),mo=R.define({combine:s=>s.indexOf(!0)>-1}),go=ve.newName(),Vh=ve.newName(),Hh=ve.newName(),_h={"&light":"."+Vh,"&dark":"."+Hh};function yo(s,e,t){return new ve(e,{finish(i){return/&/.test(i)?i.replace(/&\\w*/,n=>{if(n=="&")return s;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):s+" "+i}})}var xd=yo("."+go,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url(\'data:image/svg+xml,\')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},_h),Cd={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Kr=T.ie&&T.ie_version<=11,bo=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new qr,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(T.ie&&T.ie_version<=11||T.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(T.chrome&&T.chrome_version<126)&&(this.editContext=new wo(e),e.state.facet(bt)&&(e.contentDOM.editContext=this.editContext.editContext)),Kr&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(bt)?i.root.activeElement!=this.dom:!tn(i.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(T.ie&&T.ie_version<=11||T.android&&T.chrome)&&!i.state.selection.main.empty&&n.focusNode&&ji(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ji(e.root);if(!t)return!1;let i=T.safari&&e.root.nodeType==11&&uu(this.dom.ownerDocument)==this.dom&&Ad(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let n=tn(this.dom,i);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&ci(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(n=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:n}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),n=this.selectionChanged&&tn(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new so(this.view,e,t,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let i=this.view.state,n=Dh(this.view,t);return this.view.state==i&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let i=ja(t,e.previousSibling||e.target.previousSibling,-1),n=ja(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(bt)!=e.state.facet(bt)&&(e.view.contentDOM.editContext=e.state.facet(bt)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function ja(s,e,t){for(;e;){let i=z.get(e);if(i&&i.parent==s)return i;let n=e.parentNode;e=n!=s.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function za(s,e){let t=e.startContainer,i=e.startOffset,n=e.endContainer,r=e.endOffset,o=s.docView.domAtPos(s.state.selection.main.anchor);return ji(o.node,o.offset,n,r)&&([t,i,n,r]=[n,r,t,i]),{anchorNode:t,anchorOffset:i,focusNode:n,focusOffset:r}}function Ad(s,e){if(e.getComposedRanges){let n=e.getComposedRanges(s.root)[0];if(n)return za(s,n)}let t=null;function i(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return s.contentDOM.addEventListener("beforeinput",i,!0),s.dom.ownerDocument.execCommand("indent"),s.contentDOM.removeEventListener("beforeinput",i,!0),t?za(s,t):null}var wo=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let{anchor:n}=e.state.selection.main,r={from:this.toEditorPos(i.updateRangeStart),to:this.toEditorPos(i.updateRangeEnd),insert:K.of(i.text.split(`\n`))};r.from==this.from&&nthis.to&&(r.to=n),!(r.from==r.to&&!r.insert.length)&&(this.pendingContextChange=r,e.state.readOnly||Mo(e,r,P.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=i=>{let n=[],r=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o{let n=[];for(let r of i.getTextFormats()){let o=r.underlineStyle,l=r.underlineThickness;if(o!="None"&&l!="None"){let a=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${l=="Thin"?1:2}px`;n.push(Q.mark({attributes:{style:a}}).range(this.toEditorPos(r.rangeStart),this.toEditorPos(r.rangeEnd)))}}e.dispatch({effects:xh.of(Q.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let n=Ji(i.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,n=this.pendingContextChange;return e.changes.iterChanges((r,o,l,a,h)=>{if(i)return;let f=h.length-(o-r);if(n&&o>=n.to)if(n.from==r&&n.to==o&&n.insert.eq(h)){n=this.pendingContextChange=null,t+=f,this.to+=f;return}else n=null,this.revertPending(e.state);if(r+=t,o+=t,o<=this.from)this.from+=f,this.to+=f;else if(rthis.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(o),h.toString()),this.to+=f}t+=f}),n&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(i,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},$=class s{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(n=>n.forEach(r=>i(r,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||gu(e.parent)||document,this.viewState=new pn(e.state||X.create(e)),e.scrollTo&&e.scrollTo.is(Gs)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(_i).map(n=>new Yi(n));for(let n of this.plugins)n.update(this);this.observer=new bo(this),this.inputState=new no(this),this.inputState.ensureHandlers(this.plugins),this.docView=new fn(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof de?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,n,r=this.state;for(let u of e){if(u.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn\'t start from the previous state.");r=u.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(u=>u.annotation(Rh))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Fh(r,o),a||(l=1));let h=this.observer.delayedAndroidKey,f=null;if(h?(this.observer.clearDelayedAndroidKey(),f=this.observer.readChange(),(f&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(f=null)):this.observer.clear(),r.facet(X.phrases)!=this.state.facet(X.phrases))return this.setState(r);n=hn.create(this,r,e),n.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let u of e){if(c&&(c=c.map(u.changes)),u.scrollIntoView){let{main:d}=u.state.selection;c=new Ui(d.empty?d:P.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of u.effects)d.is(Gs)&&(c=d.value.clip(this.state))}this.viewState.update(n,c),this.bidiCache=mn.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(Ki)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(u=>u.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(en)!=n.state.facet(en)&&(this.viewState.mustMeasureContent=!0),(t||i||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let u of this.state.facet(eo))try{u(n)}catch(d){Le(this.state,d,"update listener")}(a||f)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),f&&!Dh(this,f)&&h.force&&ci(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new pn(e),this.plugins=e.facet(_i).map(i=>new Yi(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new fn(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(_i),i=e.state.facet(_i);if(t!=i){let n=[];for(let r of i){let o=t.indexOf(r);if(o<0)n.push(new Yi(r));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Za(i))r=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(n);r=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];a&4||([this.measureRequests,h]=[h,this.measureRequests]);let f=h.map(d=>{try{return d.read(this)}catch(p){return Le(this.state,p),Ua}}),c=hn.create(this,this.state,[]),u=!1;c.flags|=a,t?t.flags|=a:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),u=this.docView.update(c),u&&this.docViewUpdate());for(let d=0;d1||p<-1){n=n+p,i.scrollTop=n/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(eo))l(t)}get themeClasses(){return go+" "+(this.state.facet(mo)?Hh:Vh)+" "+this.state.facet(en)}updateAttrs(){let e=Ya(this,Ch,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(bt)?"true":"false",class:"cm-content",style:`${T.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Ya(this,Co,t);let i=this.observer.ignore(()=>{let n=Gr(this.contentDOM,this.contentAttrs,t),r=Gr(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let n of i.effects)if(n.is(s.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(Ki);let e=this.state.facet(s.cspNonce);ve.mount(this.root,this.styleModules.concat(xd).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn\'t allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return _r(this,e,Da(this,e,t,i))}moveByGroup(e,t){return _r(this,e,Da(this,e,t,i=>Yu(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),n=this.textDirectionAt(e.from),r=i[t?i.length-1:0];return P.cursor(r.side(t,n)+e.from,r.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,i=!0){return Uu(this,e,t,i)}moveVertically(e,t,i){return _r(this,e,Gu(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Nh(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),o=r[je.find(r,e-n.from,-1,t)];return gn(i,o.dir==ie.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(Sh)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Md)return dh(e.length);let t=this.textDirectionAt(e.from),i;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||uh(r.isolates,i=Ma(this,e))))return r.order;i||(i=Ma(this,e));let n=Eu(e.text,t,i);return this.bidiCache.push(new mn(e.from,e.to,t,i,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||T.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Xa(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Gs.of(new Ui(typeof e=="number"?P.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Gs.of(new Ui(P.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Ut.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Ut.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ve.newName(),n=[en.of(i),Ki.of(yo(`.${i}`,e))];return t&&t.dark&&n.push(mo.of(!0)),n}static baseTheme(e){return js.lowest(Ki.of(yo("."+go,e,_h)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),n=i&&z.get(i)||z.get(e);return((t=n==null?void 0:n.rootView)===null||t===void 0?void 0:t.view)||null}};$.styleModule=Ki;$.inputHandler=wh;$.clipboardInputFilter=vo;$.clipboardOutputFilter=xo;$.scrollHandler=vh;$.focusChangeEffect=kh;$.perLineTextDirection=Sh;$.exceptionSink=bh;$.updateListener=eo;$.editable=bt;$.mouseSelectionStyle=yh;$.dragMovesSelection=gh;$.clickAddsSelectionRange=mh;$.decorations=is;$.outerDecorations=Ah;$.atomicRanges=Ao;$.bidiIsolatedRanges=Mh;$.scrollMargins=Oh;$.darkTheme=mo;$.cspNonce=R.define({combine:s=>s.length?s[0]:""});$.contentAttributes=Co;$.editorAttributes=Ch;$.lineWrapping=$.contentAttributes.of({class:"cm-lineWrapping"});$.announce=J.define();var Md=4096,Ua={},mn=class s{constructor(e,t,i,n,r,o){this.from=e,this.to=t,this.dir=i,this.isolates=n,this.fresh=r,this.order=o}static update(e,t){if(t.empty&&!e.some(r=>r.fresh))return e;let i=[],n=e.length?e[e.length-1].dir:ie.LTR;for(let r=Math.max(0,e.length-10);r=0;n--){let r=i[n],o=typeof r=="function"?r(s):r;o&&Yr(o,t)}return t}var tm=T.mac?"mac":T.windows?"win":T.linux?"linux":"key";var Od=!T.ios;var Ga={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};Od&&(Ga[".cm-line"].caretColor=Ga[".cm-content"].caretColor="transparent !important");var im=/x/.unicode!=null?"gu":"g";var sm=$.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"\'\'",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var ut=class extends ft{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};ut.prototype.elementClass="";ut.prototype.toDOM=void 0;ut.prototype.mapMode=ue.TrackBefore;ut.prototype.startSide=ut.prototype.endSide=-1;ut.prototype.point=!0;var Td=0,ss=class{constructor(e,t){this.from=e,this.to=t}},W=class{constructor(e={}){this.id=Td++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn\'t define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can\'t add per-node props to node types");return typeof e!="function"&&(e=we.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};W.closedBy=new W({deserialize:s=>s.split(" ")});W.openedBy=new W({deserialize:s=>s.split(" ")});W.group=new W({deserialize:s=>s.split(" ")});W.isolate=new W({deserialize:s=>{if(s&&s!="rtl"&&s!="ltr"&&s!="auto")throw new RangeError("Invalid value for isolate: "+s);return s||"auto"}});W.contextHash=new W({perNode:!0});W.lookAhead=new W({perNode:!0});W.mounted=new W({perNode:!0});var pi=class{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}static get(e){return e&&e.props&&e.props[W.mounted.id]}},Ed=Object.create(null),we=class s{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):Ed,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new s(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(n)),r){if(r[0].perNode)throw new RangeError("Can\'t store a per-node prop on a node type");t[r[0].id]=r[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(W.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return i=>{for(let n=i.prop(W.group),r=-1;r<(n?n.length:0);r++){let o=t[r<0?i.name:n[r]];if(o)return o}}}};we.none=new we("",Object.create(null),0,8);var wn=new WeakMap,Kh=new WeakMap,se;(function(s){s[s.ExcludeBuffers=1]="ExcludeBuffers",s[s.IncludeAnonymous=2]="IncludeAnonymous",s[s.IgnoreMounts=4]="IgnoreMounts",s[s.IgnoreOverlays=8]="IgnoreOverlays"})(se||(se={}));var ae=class s{constructor(e,t,i,n,r){if(this.type=e,this.children=t,this.positions=i,this.length=n,this.props=null,r&&r.length){this.props=Object.create(null);for(let[o,l]of r)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=pi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let n=i.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new os(this.topNode,e)}cursorAt(e,t=0,i=0){let n=wn.get(this)||this.topNode,r=new os(n);return r.moveTo(e,t),wn.set(this,r._tree),r}get topNode(){return new Ge(this,0,0,null)}resolve(e,t=0){let i=ns(wn.get(this)||this.topNode,e,t,!1);return wn.set(this,i),i}resolveInner(e,t=0){let i=ns(Kh.get(this)||this.topNode,e,t,!0);return Kh.set(this,i),i}resolveStack(e,t=0){return Nd(this,e,t)}iterate(e){let{enter:t,leave:i,from:n=0,to:r=this.length}=e,o=e.mode||0,l=(o&se.IncludeAnonymous)>0;for(let a=this.cursor(o|se.IncludeAnonymous);;){let h=!1;if(a.from<=r&&a.to>=n&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;h=!0}for(;h&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;h=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Po(we.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,n)=>new s(this.type,t,i,n,this.propValues),e.makeTree||((t,i,n)=>new s(we.none,t,i,n)))}static build(e){return Dd(e)}};ae.empty=new ae(we.none,[],[],0);var Oo=class s{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new s(this.buffer,this.index)}},xt=class s{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return we.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,i){let n=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function ns(s,e,t,i){for(var n;s.from==s.to||(t<1?s.from>=e:s.from>e)||(t>-1?s.to<=e:s.to0?l.length:-1;e!=h;e+=t){let f=l[e],c=a[e]+o.from;if(jh(n,i,c,c+f.length)){if(f instanceof xt){if(r&se.ExcludeBuffers)continue;let u=f.findChild(0,f.buffer.length,t,i-c,n);if(u>-1)return new rs(new Eo(o,f,e,c),null,u)}else if(r&se.IncludeAnonymous||!f.type.isAnonymous||Lo(f)){let u;if(!(r&se.IgnoreMounts)&&(u=pi.get(f))&&!u.overlay)return new s(u.tree,c,e,o);let d=new s(f,c,e,o);return r&se.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?f.children.length-1:0,t,i,n)}}}if(r&se.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let n;if(!(i&se.IgnoreOverlays)&&(n=pi.get(this._tree))&&n.overlay){let r=e-this.from;for(let{from:o,to:l}of n.overlay)if((t>0?o<=r:o=r:l>r))return new s(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Wh(s,e,t,i){let n=s.cursor(),r=[];if(!n.firstChild())return r;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return r}for(;;){if(i!=null&&n.type.is(i))return r;if(n.type.is(e)&&r.push(n.node),!n.nextSibling())return i==null?r:[]}}function To(s,e,t=e.length-1){for(let i=s.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var Eo=class{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}},rs=class s extends Sn{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new s(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&se.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new s(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new s(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new s(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let o=i.buffer[this.index+1];e.push(i.slice(n,r,o)),t.push(0)}return new ae(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function zh(s){if(!s.length)return null;let e=0,t=s[0];for(let r=1;rt.from||o.to=e){let l=new Ge(o.tree,o.overlay[0].from+r.from,-1,r);(n||(n=[i])).push(ns(l,e,t,!1))}}return n?zh(n):i}var os=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Ge)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return e?e instanceof Ge?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&se.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&se.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&se.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let n=i<0?0:this.stack[i]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(n)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&se.IncludeAnonymous||l instanceof xt||!l.type.isAnonymous||Lo(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,i=r+1;break e}n=this.stack[--r]}for(let n=i;n=0;r--){if(r<0)return To(this.node,e,n);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}};function Lo(s){return s.children.some(e=>e instanceof xt||!e.type.isAnonymous||Lo(e))}function Dd(s){var e;let{buffer:t,nodeSet:i,maxBufferLength:n=1024,reused:r=[],minRepeatType:o=i.types.length}=s,l=Array.isArray(t)?new Oo(t,t.length):t,a=i.types,h=0,f=0;function c(v,M,O,C,L,N){let{id:D,start:B,end:q,size:I}=l,ne=f;for(;I<0;)if(l.next(),I==-1){let lt=r[D];O.push(lt),C.push(B-v);return}else if(I==-3){h=D;return}else if(I==-4){f=D;return}else throw new RangeError(`Unrecognized record size: ${I}`);let Pt=a[D],ti,Bt,Nl=B-v;if(q-B<=n&&(Bt=g(l.pos-M,L))){let lt=new Uint16Array(Bt.size-Bt.skip),Se=l.pos-Bt.size,He=lt.length;for(;l.pos>Se;)He=y(Bt.start,lt,He);ti=new xt(lt,q-Bt.start,i),Nl=Bt.start-v}else{let lt=l.pos-I;l.next();let Se=[],He=[],It=D>=o?D:-1,ii=0,Ds=q;for(;l.pos>lt;)It>=0&&l.id==It&&l.size>=0?(l.end<=Ds-n&&(p(Se,He,B,ii,l.end,Ds,It,ne),ii=Se.length,Ds=l.end),l.next()):N>2500?u(B,lt,Se,He):c(B,lt,Se,He,It,N+1);if(It>=0&&ii>0&&ii-1&&ii>0){let Dl=d(Pt);ti=Po(Pt,Se,He,0,Se.length,0,q-B,Dl,Dl)}else ti=m(Pt,Se,He,q-B,ne-q)}O.push(ti),C.push(Nl)}function u(v,M,O,C){let L=[],N=0,D=-1;for(;l.pos>M;){let{id:B,start:q,end:I,size:ne}=l;if(ne>4)l.next();else{if(D>-1&&q=0;I-=3)B[ne++]=L[I],B[ne++]=L[I+1]-q,B[ne++]=L[I+2]-q,B[ne++]=ne;O.push(new xt(B,L[2]-q,i)),C.push(q-v)}}function d(v){return(M,O,C)=>{let L=0,N=M.length-1,D,B;if(N>=0&&(D=M[N])instanceof ae){if(!N&&D.type==v&&D.length==C)return D;(B=D.prop(W.lookAhead))&&(L=O[N]+D.length+B)}return m(v,M,O,C,L)}}function p(v,M,O,C,L,N,D,B){let q=[],I=[];for(;v.length>C;)q.push(v.pop()),I.push(M.pop()+O-L);v.push(m(i.types[D],q,I,N-L,B-N)),M.push(L-O)}function m(v,M,O,C,L=0,N){if(h){let D=[W.contextHash,h];N=N?[D].concat(N):[D]}if(L>25){let D=[W.lookAhead,L];N=N?[D].concat(N):[D]}return new ae(v,M,O,C,N)}function g(v,M){let O=l.fork(),C=0,L=0,N=0,D=O.end-n,B={size:0,start:0,skip:0};e:for(let q=O.pos-v;O.pos>q;){let I=O.size;if(O.id==M&&I>=0){B.size=C,B.start=L,B.skip=N,N+=4,C+=4,O.next();continue}let ne=O.pos-I;if(I<0||ne=o?4:0,ti=O.start;for(O.next();O.pos>ne;){if(O.size<0)if(O.size==-3)Pt+=4;else break e;else O.id>=o&&(Pt+=4);O.next()}L=ti,C+=I,N+=Pt}return(M<0||C==v)&&(B.size=C,B.start=L,B.skip=N),B.size>4?B:void 0}function y(v,M,O){let{id:C,start:L,end:N,size:D}=l;if(l.next(),D>=0&&C4){let q=l.pos-(D-4);for(;l.pos>q;)O=y(v,M,O)}M[--O]=B,M[--O]=N-v,M[--O]=L-v,M[--O]=C}else D==-3?h=C:D==-4&&(f=C);return O}let w=[],x=[];for(;l.pos>0;)c(s.start||0,s.bufferStart||0,w,x,-1,0);let S=(e=s.length)!==null&&e!==void 0?e:w.length?x[0]+w[0].length:0;return new ae(a[s.topID],w.reverse(),x.reverse(),S)}var qh=new WeakMap;function kn(s,e){if(!s.isAnonymous||e instanceof xt||e.type!=s)return 1;let t=qh.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=s||!(i instanceof ae)){t=1;break}t+=kn(s,i)}qh.set(e,t)}return t}function Po(s,e,t,i,n,r,o,l,a){let h=0;for(let p=i;p=f)break;M+=O}if(x==S+1){if(M>f){let O=p[S];d(O.children,O.positions,0,O.children.length,m[S]+w);continue}c.push(p[S])}else{let O=m[x-1]+p[x-1].length-v;c.push(Po(s,p,m,S,x,v,O,null,a))}u.push(v+w-r)}}return d(e,t,i,n,0),(l||a)(c,u,o)}var Yt=class s{constructor(e,t,i,n,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let n=[new s(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&n.push(r);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,h=0;;l++){let f=l=i)for(;o&&o.from=u.from||c<=u.to||h){let d=Math.max(u.from,a)-h,p=Math.min(u.to,c)-h;u=d>=p?null:new s(d,p,u.tree,u.offset+h,l>0,!!f)}if(u&&n.push(u),o.to>c)break;o=rnew ss(n.from,n.to)):[new ss(0,0)]:[new ss(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let r=n.advance();if(r)return r}}},Do=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var rm=new W({perNode:!0});var Ld=0,Be=class s{constructor(e,t,i,n){this.name=e,this.set=t,this.base=i,this.modified=n,this.id=Ld++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof s&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let n=new s(i,[],null,[]);if(n.set.push(n),t)for(let r of t.set)n.set.push(r);return n}static defineModifier(e){let t=new Mn(e);return i=>i.modified.indexOf(t)>-1?i:Mn.get(i.base||i,i.modified.concat(t).sort((n,r)=>n.id-r.id))}},Pd=0,Mn=class s{constructor(e){this.name=e,this.instances=[],this.id=Pd++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&Bd(t,l.modified));if(i)return i;let n=[],r=new Be(e.name,n,e,t);for(let l of t)l.instances.push(r);let o=Id(t);for(let l of e.set)if(!l.modified.length)for(let a of o)n.push(s.get(l,a));return r}};function Bd(s,e){return s.length==e.length&&s.every((t,i)=>t==e[i])}function Id(s){let e=[[]];for(let t=0;ti.length-t.length)}function Gh(s){let e=Object.create(null);for(let t in s){let i=s[t];Array.isArray(i)||(i=[i]);for(let n of t.split(" "))if(n){let r=[],o=2,l=n;for(let c=0;;){if(l=="..."&&c>0&&c+3==n.length){o=1;break}let u=/^"(?:[^"\\\\]|\\\\.)*?"|[^\\/!]+/.exec(l);if(!u)throw new RangeError("Invalid path: "+n);if(r.push(u[0]=="*"?"":u[0][0]==\'"\'?JSON.parse(u[0]):u[0]),c+=u[0].length,c==n.length)break;let d=n[c++];if(c==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);l=n.slice(c)}let a=r.length-1,h=r[a];if(!h)throw new RangeError("Invalid path: "+n);let f=new mi(i,o,a>0?r.slice(0,a):null);e[h]=f.sort(e[h])}}return Jh.add(e)}var Jh=new W,mi=class{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=n;for(let l of r)for(let a of l.set){let h=t[a.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function Rd(s,e){let t=null;for(let i of s){let n=i.style(e);n&&(t=t?t+" "+n:n)}return t}function Xh(s,e,t,i=0,n=s.length){let r=new Io(i,Array.isArray(e)?e:[e],t);r.highlightRange(s.cursor(),i,n,"",r.highlighters),r.flush(n)}var Io=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let h=n,f=Fd(e)||mi.empty,c=Rd(r,f.tags);if(c&&(h&&(h+=" "),h+=c,f.mode==1&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(t,l),h),f.opaque)return;let u=e.tree&&e.tree.prop(W.mounted);if(u&&u.overlay){let d=e.node.enter(u.overlay[0].from+l,1),p=this.highlighters.filter(g=>!g.scope||g.scope(u.tree.type)),m=e.firstChild();for(let g=0,y=l;;g++){let w=g=x||!e.nextSibling())););if(!w||x>i)break;y=w.to+l,y>t&&(this.highlightRange(d.cursor(),Math.max(t,w.from+l),Math.min(i,y),"",p),this.startSpan(Math.min(i,y),h))}m&&e.parent()}else if(e.firstChild()){u&&(n="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,r),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}};function Fd(s){let e=s.type.prop(Jh);for(;e&&e.context&&!s.matchContext(e.context);)e=e.next;return e||null}var A=Be.define,xn=A(),Ct=A(),Uh=A(Ct),Yh=A(Ct),At=A(),Cn=A(At),Bo=A(At),Qe=A(),Gt=A(Qe),Je=A(),Xe=A(),Ro=A(),ls=A(Ro),An=A(),b={comment:xn,lineComment:A(xn),blockComment:A(xn),docComment:A(xn),name:Ct,variableName:A(Ct),typeName:Uh,tagName:A(Uh),propertyName:Yh,attributeName:A(Yh),className:A(Ct),labelName:A(Ct),namespace:A(Ct),macroName:A(Ct),literal:At,string:Cn,docString:A(Cn),character:A(Cn),attributeValue:A(Cn),number:Bo,integer:A(Bo),float:A(Bo),bool:A(At),regexp:A(At),escape:A(At),color:A(At),url:A(At),keyword:Je,self:A(Je),null:A(Je),atom:A(Je),unit:A(Je),modifier:A(Je),operatorKeyword:A(Je),controlKeyword:A(Je),definitionKeyword:A(Je),moduleKeyword:A(Je),operator:Xe,derefOperator:A(Xe),arithmeticOperator:A(Xe),logicOperator:A(Xe),bitwiseOperator:A(Xe),compareOperator:A(Xe),updateOperator:A(Xe),definitionOperator:A(Xe),typeOperator:A(Xe),controlOperator:A(Xe),punctuation:Ro,separator:A(Ro),bracket:ls,angleBracket:A(ls),squareBracket:A(ls),paren:A(ls),brace:A(ls),content:Qe,heading:Gt,heading1:A(Gt),heading2:A(Gt),heading3:A(Gt),heading4:A(Gt),heading5:A(Gt),heading6:A(Gt),contentSeparator:A(Qe),list:A(Qe),quote:A(Qe),emphasis:A(Qe),strong:A(Qe),link:A(Qe),monospace:A(Qe),strikethrough:A(Qe),inserted:A(),deleted:A(),changed:A(),invalid:A(),meta:An,documentMeta:A(An),annotation:A(An),processingInstruction:A(An),definition:Be.defineModifier("definition"),constant:Be.defineModifier("constant"),function:Be.defineModifier("function"),standard:Be.defineModifier("standard"),local:Be.defineModifier("local"),special:Be.defineModifier("special")};for(let s in b){let e=b[s];e instanceof Be&&(e.name=s)}var am=Fo([{tag:b.link,class:"tok-link"},{tag:b.heading,class:"tok-heading"},{tag:b.emphasis,class:"tok-emphasis"},{tag:b.strong,class:"tok-strong"},{tag:b.keyword,class:"tok-keyword"},{tag:b.atom,class:"tok-atom"},{tag:b.bool,class:"tok-bool"},{tag:b.url,class:"tok-url"},{tag:b.labelName,class:"tok-labelName"},{tag:b.inserted,class:"tok-inserted"},{tag:b.deleted,class:"tok-deleted"},{tag:b.literal,class:"tok-literal"},{tag:b.string,class:"tok-string"},{tag:b.number,class:"tok-number"},{tag:[b.regexp,b.escape,b.special(b.string)],class:"tok-string2"},{tag:b.variableName,class:"tok-variableName"},{tag:b.local(b.variableName),class:"tok-variableName tok-local"},{tag:b.definition(b.variableName),class:"tok-variableName tok-definition"},{tag:b.special(b.variableName),class:"tok-variableName2"},{tag:b.definition(b.propertyName),class:"tok-propertyName tok-definition"},{tag:b.typeName,class:"tok-typeName"},{tag:b.namespace,class:"tok-namespace"},{tag:b.className,class:"tok-className"},{tag:b.macroName,class:"tok-macroName"},{tag:b.propertyName,class:"tok-propertyName"},{tag:b.operator,class:"tok-operator"},{tag:b.comment,class:"tok-comment"},{tag:b.meta,class:"tok-meta"},{tag:b.invalid,class:"tok-invalid"},{tag:b.punctuation,class:"tok-punctuation"}]);var $o,hs=new W;var $d=new W,Ae=class{constructor(e,t,i=[],n=""){this.data=e,this.name=n,X.prototype.hasOwnProperty("tree")||Object.defineProperty(X.prototype,"tree",{get(){return fs(this)}}),this.parser=t,this.extension=[gi.of(this),X.languageData.of((r,o,l)=>{let a=Qh(r,o,l),h=a.type.prop(hs);if(!h)return[];let f=r.facet(h),c=a.type.prop($d);if(c){let u=a.resolve(o-a.from,l);for(let d of c)if(d.test(u,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(f)}}return f})].concat(i)}isActiveAt(e,t,i=-1){return Qh(e,t,i).type.prop(hs)==this.data}findRegions(e){let t=e.facet(gi);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(r,o)=>{if(r.prop(hs)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(W.mounted);if(l){if(l.tree.prop(hs)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(n(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;a=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},as=null,Wo=class s{constructor(e,t,i=[],n,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new s(e,t,[],ae.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Ko(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ae.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Yt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=as;as=this;try{return e()}finally{as=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Zh(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((h,f,c,u)=>a.push({fromA:h,toA:f,fromB:c,toB:u})),i=Yt.applyChanges(i,a),n=ae.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let h of this.skipped){let f=e.mapPos(h.from,1),c=e.mapPos(h.to,-1);fe.from&&(this.fragments=Zh(this.fragments,n,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends vn{createParse(t,i,n){let r=n[0].from,o=n[n.length-1].to;return{parsedPos:r,advance(){let a=as;if(a){for(let h of n)a.tempSkipped.push(h);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new ae(we.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return as}};function Zh(s,e,t){return Yt.applyChanges(s,[{fromA:e,toA:t,fromB:e,toB:t}])}var cs=class s{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new s(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Wo.create(e.facet(gi).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new s(i)}};Ae.state=at.define({create:cs.init,update(s,e){for(let t of e.effects)if(t.is(Ae.setState))return t.value;return e.startState.facet(gi)!=e.state.facet(gi)?cs.init(e.state):s.apply(e)}});var nf=s=>{let e=setTimeout(()=>s(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(nf=s=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(s,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Vo=typeof navigator!="undefined"&&(!(($o=navigator.scheduling)===null||$o===void 0)&&$o.isInputPending)?()=>navigator.scheduling.isInputPending():null,Vd=Ut.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Ae.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Ae.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=nf(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,a=r.context.work(()=>Vo&&Vo()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:Ae.setState.of(new cs(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Le(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),gi=R.define({combine(s){return s.length?s[0]:null},enables:s=>[Ae.state,Vd,$.contentAttributes.compute([s],e=>{let t=e.facet(s);return t&&t.name?{"data-language":t.name}:{}})]});var Mt=class s{constructor(e,t){this.specs=e;let i;function n(l){let a=ve.newName();return(i||(i=Object.create(null)))["."+a]=l,a}let r=typeof t.all=="string"?t.all:t.all?n(t.all):void 0,o=t.scope;this.scope=o instanceof Ae?l=>l.prop(hs)==o.data:o?l=>l==o:void 0,this.style=Fo(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new ve(i):null,this.themeType=t.themeType}static define(e,t){return new s(e,t||{})}},qo=R.define(),rf=R.define({combine(s){return s.length?[s[0]]:null}});function Ho(s){let e=s.facet(qo);return e.length?e:s.facet(rf)}function On(s,e){let t=[Hd],i;return s instanceof Mt&&(s.module&&t.push($.styleModule.of(s.module)),i=s.themeType),e!=null&&e.fallback?t.push(rf.of(s)):i?t.push(qo.computeN([$.darkTheme],n=>n.facet($.darkTheme)==(i=="dark")?[s]:[])):t.push(qo.of(s)),t}var jo=class{constructor(e){this.markCache=Object.create(null),this.tree=fs(e.state),this.decorations=this.buildDeco(e,Ho(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=fs(e.state),i=Ho(e.state),n=i!=Ho(e.startState),{viewport:r}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return Q.none;let i=new _t;for(let{from:n,to:r}of e.visibleRanges)Xh(this.tree,t,(o,l,a)=>{i.add(o,l,this.markCache[a]||(this.markCache[a]=Q.mark({class:a})))},n,r);return i.finish()}},Hd=js.high(Ut.fromClass(jo,{decorations:s=>s.decorations})),bm=Mt.define([{tag:b.meta,color:"#404740"},{tag:b.link,textDecoration:"underline"},{tag:b.heading,textDecoration:"underline",fontWeight:"bold"},{tag:b.emphasis,fontStyle:"italic"},{tag:b.strong,fontWeight:"bold"},{tag:b.strikethrough,textDecoration:"line-through"},{tag:b.keyword,color:"#708"},{tag:[b.atom,b.bool,b.url,b.contentSeparator,b.labelName],color:"#219"},{tag:[b.literal,b.inserted],color:"#164"},{tag:[b.string,b.deleted],color:"#a11"},{tag:[b.regexp,b.escape,b.special(b.string)],color:"#e40"},{tag:b.definition(b.variableName),color:"#00f"},{tag:b.local(b.variableName),color:"#30a"},{tag:[b.typeName,b.namespace],color:"#085"},{tag:b.className,color:"#167"},{tag:[b.special(b.variableName),b.macroName],color:"#256"},{tag:b.definition(b.propertyName),color:"#00c"},{tag:b.comment,color:"#940"},{tag:b.invalid,color:"#f00"}]);var _d=Object.create(null),ef=[we.none];var tf=[],sf=Object.create(null),Kd=Object.create(null);for(let[s,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Kd[s]=Wd(_d,e);function _o(s,e){tf.indexOf(s)>-1||(tf.push(s),console.warn(e))}function Wd(s,e){let t=[];for(let l of e.split(" ")){let a=[];for(let h of l.split(".")){let f=s[h]||b[h];f?typeof f=="function"?a.length?a=a.map(f):_o(h,`Modifier ${h} used at start of tag`):a.length?_o(h,`Tag ${h} used as modifier`):a=Array.isArray(f)?f:[f]:_o(h,`Unknown highlighting tag ${h}`)}for(let h of a)t.push(h)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),n=i+" "+t.map(l=>l.id),r=sf[n];if(r)return r.id;let o=sf[n]=we.define({id:ef.length,name:i,props:[Gh({[i]:t})]});return ef.push(o),o.id}var wm={rtl:Q.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:ie.RTL}),ltr:Q.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:ie.LTR}),auto:Q.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var qd="#abb2bf",jd="#7d8799",zd="#ffffff",Ud="#21252b",zo="rgba(0, 0, 0, 0.5)",Yd="#292d3e",Uo="#353a42",Gd="rgba(128, 203, 196, 0.2)",of="#ffcc00",Jd=$.theme({"&":{color:"#ffffff",backgroundColor:Yd},".cm-content":{caretColor:of},"&.cm-focused .cm-cursor":{borderLeftColor:of},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Gd},".cm-panels":{backgroundColor:Ud,color:"#ffffff"},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:zo},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847",outline:"1px solid #515a6b"},".cm-gutters":{background:"#292d3e",color:"#676e95",border:"none"},".cm-activeLineGutter":{backgroundColor:zo},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Uo},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Uo,borderBottomColor:Uo},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:zo,color:qd}}},{dark:!0}),Xd=Mt.define([{tag:b.keyword,color:"#c792ea"},{tag:b.operator,color:"#89ddff"},{tag:b.special(b.variableName),color:"#eeffff"},{tag:b.typeName,color:"#f07178"},{tag:b.atom,color:"#f78c6c"},{tag:b.number,color:"#ff5370"},{tag:b.definition(b.variableName),color:"#82aaff"},{tag:b.string,color:"#c3e88d"},{tag:b.special(b.string),color:"#f07178"},{tag:b.comment,color:jd},{tag:b.variableName,color:"#f07178"},{tag:b.tagName,color:"#ff5370"},{tag:b.bracket,color:"#a2a1a4"},{tag:b.meta,color:"#ffcb6b"},{tag:b.attributeName,color:"#c792ea"},{tag:b.propertyName,color:"#c792ea"},{tag:b.className,color:"#decb6b"},{tag:b.invalid,color:zd}]),Qd=[Jd,On(Xd)];var lf="#2e3440",Zo="#3b4252",af="#434c5e",Tn="#4c566a";var hf="#e5e9f0",Qo="#eceff4",Yo="#8fbcbb",ff="#88c0d0",Zd="#81a1c1",Ie="#5e81ac",ep="#bf616a",yi="#d08770",Go="#ebcb8b",cf="#a3be8c",tp="#b48ead",uf="#d30102",el=Qo,Jo=el,ip="#ffffff",Xo=Zo,sp=el,df=Zo,pf=$.theme({"&":{color:lf,backgroundColor:ip},".cm-content":{caretColor:df},".cm-cursor, .cm-dropCursor":{borderLeftColor:df},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:sp},".cm-panels":{backgroundColor:el,color:Tn},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${Tn}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:hf},".cm-activeLine":{backgroundColor:Jo},".cm-selectionMatch":{backgroundColor:hf},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${Tn}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:Qo},".cm-gutters":{backgroundColor:Qo,color:lf,border:"none"},".cm-activeLineGutter":{backgroundColor:Jo},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Xo},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Xo,borderBottomColor:Xo},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Jo,color:Tn}}},{dark:!1}),np=Mt.define([{tag:b.keyword,color:Ie},{tag:[b.name,b.deleted,b.character,b.propertyName,b.macroName],color:yi},{tag:[b.variableName],color:yi},{tag:[b.function(b.variableName)],color:Ie},{tag:[b.labelName],color:Zd},{tag:[b.color,b.constant(b.name),b.standard(b.name)],color:Ie},{tag:[b.definition(b.name),b.separator],color:cf},{tag:[b.brace],color:Yo},{tag:[b.annotation],color:uf},{tag:[b.number,b.changed,b.annotation,b.modifier,b.self,b.namespace],color:ff},{tag:[b.typeName,b.className],color:Go},{tag:[b.operator,b.operatorKeyword],color:cf},{tag:[b.tagName],color:tp},{tag:[b.squareBracket],color:ep},{tag:[b.angleBracket],color:yi},{tag:[b.attributeName],color:Go},{tag:[b.regexp],color:Ie},{tag:[b.quote],color:Zo},{tag:[b.string],color:yi},{tag:b.link,color:Yo,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[b.url,b.escape,b.special(b.string)],color:yi},{tag:[b.meta],color:ff},{tag:[b.comment],color:af,fontStyle:"italic"},{tag:b.strong,fontWeight:"bold",color:Ie},{tag:b.emphasis,fontStyle:"italic",color:Ie},{tag:b.strikethrough,textDecoration:"line-through"},{tag:b.heading,fontWeight:"bold",color:Ie},{tag:b.special(b.heading1),fontWeight:"bold",color:Ie},{tag:b.heading1,fontWeight:"bold",color:Ie},{tag:[b.heading2,b.heading3,b.heading4],fontWeight:"bold",color:Ie},{tag:[b.heading5,b.heading6],color:Ie},{tag:[b.atom,b.bool,b.special(b.variableName)],color:yi},{tag:[b.processingInstruction,b.inserted],color:Yo},{tag:[b.contentSeparator],color:Go},{tag:b.invalid,color:af,borderBottom:`1px dotted ${uf}`}]),Nm=[pf,On(np)];var us=(s,e=0)=>{let t=[];if(e==5||!s||s==null)return"";if(typeof s=="string")return s;if(typeof s=="number")return`${s}`;if(Array.isArray(s))t.push(`${s.map(i=>us(i,e++)).join(" ")}`);else if(typeof s=="object")for(let[i,n]of Object.entries(s))t.push(us(i,e++),us(n,e++));return t.join(" ")};function bi(s=[],e=[]){s||(s=[]),Array.isArray(s)||(s=[s]),e||(e=[]),Array.isArray(e)||(e=[e]);for(let t of e!=null?e:[])if(t)if(Array.isArray(t)){let i=us(t.slice(1));s=s.filter(n=>n.name!=t[0]&&n.desc!=i),s.push({name:t[0],desc:i})}else typeof t=="object"&&("name"in t||"desc"in t)&&(s=s.filter(i=>{var n;return(!((n=i.name)!=null&&n.length)||i.name!=t.name)&&i.desc!=t.desc}),s.push(Rl(Il({},t),{name:t.name,desc:us(t.desc)})));return s}var Ol={};Fl(Ol,{Alias:()=>it,CST:()=>Cl,Composer:()=>Xt,Document:()=>nt,Lexer:()=>Pi,LineCounter:()=>Bi,Pair:()=>Y,Parser:()=>Zt,Scalar:()=>E,Schema:()=>Ti,YAMLError:()=>Ni,YAMLMap:()=>G,YAMLParseError:()=>ke,YAMLSeq:()=>oe,YAMLWarning:()=>Di,isAlias:()=>Oe,isCollection:()=>_,isDocument:()=>Ze,isMap:()=>Te,isNode:()=>H,isPair:()=>V,isScalar:()=>F,isSeq:()=>Ee,parse:()=>fc,parseAllDocuments:()=>hc,parseDocument:()=>Ml,stringify:()=>cc,visit:()=>Ne,visitAsync:()=>ds});var En=Symbol.for("yaml.alias"),Nn=Symbol.for("yaml.document"),Re=Symbol.for("yaml.map"),tl=Symbol.for("yaml.pair"),Me=Symbol.for("yaml.scalar"),dt=Symbol.for("yaml.seq"),ce=Symbol.for("yaml.node.type"),Oe=s=>!!s&&typeof s=="object"&&s[ce]===En,Ze=s=>!!s&&typeof s=="object"&&s[ce]===Nn,Te=s=>!!s&&typeof s=="object"&&s[ce]===Re,V=s=>!!s&&typeof s=="object"&&s[ce]===tl,F=s=>!!s&&typeof s=="object"&&s[ce]===Me,Ee=s=>!!s&&typeof s=="object"&&s[ce]===dt;function _(s){if(s&&typeof s=="object")switch(s[ce]){case Re:case dt:return!0}return!1}function H(s){if(s&&typeof s=="object")switch(s[ce]){case En:case Re:case Me:case dt:return!0}return!1}var mf=s=>(F(s)||_(s))&&!!s.anchor;var me=Symbol("break visit"),gf=Symbol("skip children"),et=Symbol("remove node");function Ne(s,e){let t=yf(e);Ze(s)?wi(null,s.contents,t,Object.freeze([s]))===et&&(s.contents=null):wi(null,s,t,Object.freeze([]))}Ne.BREAK=me;Ne.SKIP=gf;Ne.REMOVE=et;function wi(s,e,t,i){let n=bf(s,e,t,i);if(H(n)||V(n))return wf(s,i,n),wi(s,n,t,i);if(typeof n!="symbol"){if(_(e)){i=Object.freeze(i.concat(e));for(let r=0;rs.replace(/[!,[\\]{}]/g,e=>rp[e]),tt=class s{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,e),this.tags=Object.assign({},s.defaultTags,t)}clone(){let e=new s(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \\t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[r,o]=i;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=i;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\\d+\\.\\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren\'t resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}let[,i,n]=e.match(new RegExp("^(.*!)([^!]*)$","s"));n||t(`The ${e} tag has no suffix`);let r=this.tags[i];if(r)try{return r+decodeURIComponent(n)}catch(o){return t(String(o)),null}return i==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,i]of Object.entries(this.tags))if(e.startsWith(i))return t+op(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(e&&i.length>0&&H(e.contents)){let r={};Ne(e.contents,(o,l)=>{H(l)&&l.tag&&(r[l.tag]=!0)}),n=Object.keys(r)}else n=[];for(let[r,o]of i)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(l=>l.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`\n`)}};tt.defaultYaml={explicit:!1,version:"1.2"};tt.defaultTags={"!!":"tag:yaml.org,2002:"};function Dn(s){if(/[\\x00-\\x19\\s,[\\]{}]/.test(s)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function il(s){let e=new Set;return Ne(s,{Value(t,i){i.anchor&&e.add(i.anchor)}}),e}function sl(s,e){for(let t=1;;++t){let i=`${s}${t}`;if(!e.has(i))return i}}function kf(s,e){let t=[],i=new Map,n=null;return{onAnchor:r=>{t.push(r),n||(n=il(s));let o=sl(e,n);return n.add(o),o},setAnchors:()=>{for(let r of t){let o=i.get(r);if(typeof o=="object"&&o.anchor&&(F(o.node)||_(o.node)))o.node.anchor=o.anchor;else{let l=new Error("Failed to resolve repeated object (this should not happen)");throw l.source=r,l}}},sourceObjects:i}}function Ot(s,e,t,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,r=i.length;nte(i,String(n),t));if(s&&typeof s.toJSON=="function"){if(!t||!mf(s))return s.toJSON(e,t);let i={aliasCount:0,count:1,res:void 0};t.anchors.set(s,i),t.onCreate=r=>{i.res=r,delete t.onCreate};let n=s.toJSON(e,t);return t.onCreate&&t.onCreate(n),n}return typeof s=="bigint"&&!(t!=null&&t.keep)?Number(s):s}var Tt=class{constructor(e){Object.defineProperty(this,ce,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:i,onAnchor:n,reviver:r}={}){if(!Ze(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},l=te(this,"",o);if(typeof n=="function")for(let{count:a,res:h}of o.anchors.values())n(h,a);return typeof r=="function"?Ot(r,{"":l},"",l):l}};var it=class extends Tt{constructor(e){super(En),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let t;return Ne(e,{Node:(i,n)=>{if(n===this)return Ne.BREAK;n.anchor===this.source&&(t=n)}}),t}toJSON(e,t){if(!t)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:r}=t,o=this.resolve(n);if(!o){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(a)}let l=i.get(o);if(l||(te(o,null,t),l=i.get(o)),!l||l.res===void 0){let a="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(a)}if(r>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=Ln(n,o,i)),l.count*l.aliasCount>r)){let a="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(a)}return l.res}toString(e,t,i){let n=`*${this.source}`;if(e){if(Dn(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${n} `}return n}};function Ln(s,e,t){if(Oe(e)){let i=e.resolve(s),n=t&&i&&t.get(i);return n?n.count*n.aliasCount:0}else if(_(e)){let i=0;for(let n of e.items){let r=Ln(s,n,t);r>i&&(i=r)}return i}else if(V(e)){let i=Ln(s,e.key,t),n=Ln(s,e.value,t);return Math.max(i,n)}return 1}var Pn=s=>!s||typeof s!="function"&&typeof s!="object",E=class extends Tt{constructor(e){super(Me),this.value=e}toJSON(e,t){return t!=null&&t.keep?this.value:te(this.value,e,t)}toString(){return String(this.value)}};E.BLOCK_FOLDED="BLOCK_FOLDED";E.BLOCK_LITERAL="BLOCK_LITERAL";E.PLAIN="PLAIN";E.QUOTE_DOUBLE="QUOTE_DOUBLE";E.QUOTE_SINGLE="QUOTE_SINGLE";var lp="tag:yaml.org,2002:";function ap(s,e,t){var i;if(e){let n=t.filter(o=>o.tag===e),r=(i=n.find(o=>!o.format))!=null?i:n[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return t.find(n=>{var r;return((r=n.identify)==null?void 0:r.call(n,s))&&!n.format})}function pt(s,e,t){var c,u,d;if(Ze(s)&&(s=s.contents),H(s))return s;if(V(s)){let p=(u=(c=t.schema[Re]).createNode)==null?void 0:u.call(c,t.schema,null,t);return p.items.push(s),p}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt!="undefined"&&s instanceof BigInt)&&(s=s.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:r,schema:o,sourceObjects:l}=t,a;if(i&&s&&typeof s=="object"){if(a=l.get(s),a)return a.anchor||(a.anchor=n(s)),new it(a.anchor);a={anchor:null,node:null},l.set(s,a)}e!=null&&e.startsWith("!!")&&(e=lp+e.slice(2));let h=ap(s,e,o.tags);if(!h){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){let p=new E(s);return a&&(a.node=p),p}h=s instanceof Map?o[Re]:Symbol.iterator in Object(s)?o[dt]:o[Re]}r&&(r(h),delete t.onTagObj);let f=h!=null&&h.createNode?h.createNode(t.schema,s,t):typeof((d=h==null?void 0:h.nodeClass)==null?void 0:d.from)=="function"?h.nodeClass.from(t.schema,s,t):new E(s);return e?f.tag=e:h.default||(f.tag=h.tag),a&&(a.node=f),f}function ps(s,e,t){let i=t;for(let n=e.length-1;n>=0;--n){let r=e[n];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){let o=[];o[r]=i,i=o}else i=new Map([[r,i]])}return pt(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}var vi=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done,Si=class extends Tt{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(i=>H(i)||V(i)?i.clone(e):i),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(vi(e))this.add(t);else{let[i,...n]=e,r=this.get(i,!0);if(_(r))r.addIn(n,t);else if(r===void 0&&this.schema)this.set(i,ps(this.schema,n,t));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(e){let[t,...i]=e;if(i.length===0)return this.delete(t);let n=this.get(t,!0);if(_(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${i}`)}getIn(e,t){let[i,...n]=e,r=this.get(i,!0);return n.length===0?!t&&F(r)?r.value:r:_(r)?r.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!V(t))return!1;let i=t.value;return i==null||e&&F(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[t,...i]=e;if(i.length===0)return this.has(t);let n=this.get(t,!0);return _(n)?n.hasIn(i):!1}setIn(e,t){let[i,...n]=e;if(n.length===0)this.set(i,t);else{let r=this.get(i,!0);if(_(r))r.setIn(n,t);else if(r===void 0&&this.schema)this.set(i,ps(this.schema,n,t));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};var Sf=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function De(s,e){return/^\\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}var st=(s,e,t)=>s.endsWith(`\n`)?De(t,e):t.includes(`\n`)?`\n`+De(t,e):(s.endsWith(" ")?"":" ")+t;var nl="flow",Bn="block",ms="quoted";function gs(s,e,t="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:r=20,onFold:o,onOverflow:l}={}){if(!n||n<0)return s;nn-Math.max(2,r)?h.push(0):c=n-i);let u,d,p=!1,m=-1,g=-1,y=-1;t===Bn&&(m=vf(s,m,e.length),m!==-1&&(c=m+a));for(let x;x=s[m+=1];){if(t===ms&&x==="\\\\"){switch(g=m,s[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}y=m}if(x===`\n`)t===Bn&&(m=vf(s,m,e.length)),c=m+e.length+a,u=void 0;else{if(x===" "&&d&&d!==" "&&d!==`\n`&&d!==" "){let S=s[m+1];S&&S!==" "&&S!==`\n`&&S!==" "&&(u=m)}if(m>=c)if(u)h.push(u),c=u+a,u=void 0;else if(t===ms){for(;d===" "||d===" ";)d=x,x=s[m+=1],p=!0;let S=m>y+1?m-2:g-1;if(f[S])return s;h.push(S),f[S]=!0,c=S+a,u=void 0}else p=!0}d=x}if(p&&l&&l(),h.length===0)return s;o&&o();let w=s.slice(0,h[0]);for(let x=0;x({indentAtStart:e?s.indent.length:s.indentAtStart,lineWidth:s.options.lineWidth,minContentWidth:s.options.minContentWidth}),Fn=s=>/^(%|---|\\.\\.\\.)/m.test(s);function hp(s,e,t){if(!e||e<0)return!1;let i=e-t,n=s.length;if(n<=i)return!1;for(let r=0,o=0;ri)return!0;if(o=r+1,n-o<=i)return!1}return!0}function ys(s,e){let t=JSON.stringify(s);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,r=e.indent||(Fn(s)?" ":""),o="",l=0;for(let a=0,h=t[a];h;h=t[++a])if(h===" "&&t[a+1]==="\\\\"&&t[a+2]==="n"&&(o+=t.slice(l,a)+"\\\\ ",a+=1,l=a,h="\\\\"),h==="\\\\")switch(t[a+1]){case"u":{o+=t.slice(l,a);let f=t.substr(a+2,4);switch(f){case"0000":o+="\\\\0";break;case"0007":o+="\\\\a";break;case"000b":o+="\\\\v";break;case"001b":o+="\\\\e";break;case"0085":o+="\\\\N";break;case"00a0":o+="\\\\_";break;case"2028":o+="\\\\L";break;case"2029":o+="\\\\P";break;default:f.substr(0,2)==="00"?o+="\\\\x"+f.substr(2):o+=t.substr(a,6)}a+=5,l=a+1}break;case"n":if(i||t[a+2]===\'"\'||t.length\n`;let c,u;for(u=t.length;u>0;--u){let M=t[u-1];if(M!==`\n`&&M!==" "&&M!==" ")break}let d=t.substring(u),p=d.indexOf(`\n`);p===-1?c="-":t===d||p!==d.length-1?(c="+",r&&r()):c="",d&&(t=t.slice(0,-d.length),d[d.length-1]===`\n`&&(d=d.slice(0,-1)),d=d.replace(ol,`$&${h}`));let m=!1,g,y=-1;for(g=0;g")+(m?h?"2":"1":"")+c;if(s&&(S+=" "+l(s.replace(/ ?[\\r\\n]+/g," ")),n&&n()),f)return t=t.replace(/\\n+/g,`$&${h}`),`${S}\n${h}${w}${t}${d}`;t=t.replace(/\\n+/g,`\n$&`).replace(/(?:^|\\n)([\\t ].*)(?:([\\n\\t ]*)\\n(?![\\n\\t ]))?/g,"$1$2").replace(/\\n+/g,`$&${h}`);let v=gs(`${w}${t}${d}`,h,Bn,Rn(i,!0));return`${S}\n${h}${v}`}function fp(s,e,t,i){let{type:n,value:r}=s,{actualString:o,implicitKey:l,indent:a,indentStep:h,inFlow:f}=e;if(l&&r.includes(`\n`)||f&&/[[\\]{},]/.test(r))return xi(r,e);if(!r||/^[\\n\\t ,[\\]{}#&*!|>\'"%@`]|^[?-]$|^[?-][ \\t]|[\\n:][ \\t]|[ \\t]\\n|[\\n\\t ]#|[\\n\\t :]$/.test(r))return l||f||!r.includes(`\n`)?xi(r,e):In(s,e,t,i);if(!l&&!f&&n!==E.PLAIN&&r.includes(`\n`))return In(s,e,t,i);if(Fn(r)){if(a==="")return e.forceBlockIndent=!0,In(s,e,t,i);if(l&&a===h)return xi(r,e)}let c=r.replace(/\\n+/g,`$&\n${a}`);if(o){let u=m=>{var g;return m.default&&m.tag!=="tag:yaml.org,2002:str"&&((g=m.test)==null?void 0:g.test(c))},{compat:d,tags:p}=e.doc.schema;if(p.some(u)||d!=null&&d.some(u))return xi(r,e)}return l?c:gs(c,a,nl,Rn(e,!1))}function mt(s,e,t,i){let{implicitKey:n,inFlow:r}=e,o=typeof s.value=="string"?s:Object.assign({},s,{value:String(s.value)}),{type:l}=s;l!==E.QUOTE_DOUBLE&&/[\\x00-\\x08\\x0b-\\x1f\\x7f-\\x9f\\u{D800}-\\u{DFFF}]/u.test(o.value)&&(l=E.QUOTE_DOUBLE);let a=f=>{switch(f){case E.BLOCK_FOLDED:case E.BLOCK_LITERAL:return n||r?xi(o.value,e):In(o,e,t,i);case E.QUOTE_DOUBLE:return ys(o.value,e);case E.QUOTE_SINGLE:return rl(o.value,e);case E.PLAIN:return fp(o,e,t,i);default:return null}},h=a(l);if(h===null){let{defaultKeyType:f,defaultStringType:c}=e.options,u=n&&f||c;if(h=a(u),h===null)throw new Error(`Unsupported default string type ${u}`)}return h}function $n(s,e){let t=Object.assign({blockQuote:!0,commentString:Sf,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},s.schema.toStringOptions,e),i;switch(t.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:s,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:i,options:t}}function cp(s,e){var n,r,o,l;if(e.tag){let a=s.filter(h=>h.tag===e.tag);if(a.length>0)return(n=a.find(h=>h.format===e.format))!=null?n:a[0]}let t,i;if(F(e)){i=e.value;let a=s.filter(h=>{var f;return(f=h.identify)==null?void 0:f.call(h,i)});t=(r=a.find(h=>h.format===e.format))!=null?r:a.find(h=>!h.format)}else i=e,t=s.find(a=>a.nodeClass&&i instanceof a.nodeClass);if(!t){let a=(l=(o=i==null?void 0:i.constructor)==null?void 0:o.name)!=null?l:typeof i;throw new Error(`Tag not resolved for ${a} value`)}return t}function up(s,e,{anchors:t,doc:i}){if(!i.directives)return"";let n=[],r=(F(s)||_(s))&&s.anchor;r&&Dn(r)&&(t.add(r),n.push(`&${r}`));let o=s.tag?s.tag:e.default?null:e.tag;return o&&n.push(i.directives.tagString(o)),n.join(" ")}function gt(s,e,t,i){var a,h;if(V(s))return s.toString(e,t,i);if(Oe(s)){if(e.doc.directives)return s.toString(e);if((a=e.resolvedAliases)!=null&&a.has(s))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(s):e.resolvedAliases=new Set([s]),s=s.resolve(e.doc)}let n,r=H(s)?s:e.doc.createNode(s,{onTagObj:f=>n=f});n||(n=cp(e.doc.schema.tags,r));let o=up(r,n,e);o.length>0&&(e.indentAtStart=((h=e.indentAtStart)!=null?h:0)+o.length+1);let l=typeof n.stringify=="function"?n.stringify(r,e,t,i):F(r)?mt(r,e,t,i):r.toString(e,t,i);return o?F(r)||l[0]==="{"||l[0]==="["?`${o} ${l}`:`${o}\n${e.indent}${l}`:l}function xf({key:s,value:e},t,i,n){var O,C;let{allNullValues:r,doc:o,indent:l,indentStep:a,options:{commentString:h,indentSeq:f,simpleKeys:c}}=t,u=H(s)&&s.comment||null;if(c){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(_(s)||!H(s)&&typeof s=="object"){let L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let d=!c&&(!s||u&&e==null&&!t.inFlow||_(s)||(F(s)?s.type===E.BLOCK_FOLDED||s.type===E.BLOCK_LITERAL:typeof s=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!d&&(c||!r),indent:l+a});let p=!1,m=!1,g=gt(s,t,()=>p=!0,()=>m=!0);if(!d&&!t.inFlow&&g.length>1024){if(c)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");d=!0}if(t.inFlow){if(r||e==null)return p&&i&&i(),g===""?"?":d?`? ${g}`:g}else if(r&&!c||e==null&&d)return g=`? ${g}`,u&&!p?g+=st(g,t.indent,h(u)):m&&n&&n(),g;p&&(u=null),d?(u&&(g+=st(g,t.indent,h(u))),g=`? ${g}\n${l}:`):(g=`${g}:`,u&&(g+=st(g,t.indent,h(u))));let y,w,x;H(e)?(y=!!e.spaceBefore,w=e.commentBefore,x=e.comment):(y=!1,w=null,x=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!d&&!u&&F(e)&&(t.indentAtStart=g.length+1),m=!1,!f&&a.length>=2&&!t.inFlow&&!d&&Ee(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let S=!1,v=gt(e,t,()=>S=!0,()=>m=!0),M=" ";if(u||y||w){if(M=y?`\n`:"",w){let L=h(w);M+=`\n${De(L,t.indent)}`}v===""&&!t.inFlow?M===`\n`&&(M=`\n\n`):M+=`\n${t.indent}`}else if(!d&&_(e)){let L=v[0],N=v.indexOf(`\n`),D=N!==-1,B=(C=(O=t.inFlow)!=null?O:e.flow)!=null?C:e.items.length===0;if(D||!B){let q=!1;if(D&&(L==="&"||L==="!")){let I=v.indexOf(" ");L==="&"&&I!==-1&&Is===Cf||F(s)&&s.value===Cf&&(!s.type||s.type===E.PLAIN);function ll(s,e,t){let i=s&&Oe(t)?t.resolve(s.doc):t;if(!Te(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,s,Map);for(let[r,o]of n)e instanceof Map?e.has(r)||e.set(r,o):e instanceof Set?e.add(r):Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function pp(s,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(H(s)&&(t!=null&&t.doc)){let i=$n(t.doc,{});i.anchors=new Set;for(let r of t.anchors.keys())i.anchors.add(r.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=s.toString(i);if(!t.mapKeyWarned){let r=JSON.stringify(n);r.length>40&&(r=r.substring(0,36)+\'..."\'),Vn(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return n}return JSON.stringify(e)}function Ci(s,e,t){let i=pt(s,void 0,t),n=pt(e,void 0,t);return new Y(i,n)}var Y=class s{constructor(e,t=null){Object.defineProperty(this,ce,{value:tl}),this.key=e,this.value=t}clone(e){let{key:t,value:i}=this;return H(t)&&(t=t.clone(e)),H(i)&&(i=i.clone(e)),new s(t,i)}toJSON(e,t){let i=t!=null&&t.mapAsMap?new Map:{};return Hn(t,i,this)}toString(e,t,i){return e!=null&&e.doc?xf(this,e,t,i):JSON.stringify(this)}};function Kn(s,e,t){var r;return(((r=e.inFlow)!=null?r:s.flow)?gp:mp)(s,e,t)}function mp({comment:s,items:e},t,{blockItemPrefix:i,flowChars:n,itemIndent:r,onChompKeep:o,onComment:l}){let{indent:a,options:{commentString:h}}=t,f=Object.assign({},t,{indent:r,type:null}),c=!1,u=[];for(let p=0;pg=null,()=>c=!0);g&&(y+=st(y,r,h(g))),c&&g&&(c=!1),u.push(i+y)}let d;if(u.length===0)d=n.start+n.end;else{d=u[0];for(let p=1;pg=null);pf||y.includes(`\n`))&&(h=!0),c.push(y),f=c.length}let{start:u,end:d}=t;if(c.length===0)return u+d;if(!h){let p=c.reduce((m,g)=>m+g.length+2,2);h=e.options.lineWidth>0&&p>e.options.lineWidth}if(h){let p=u;for(let m of c)p+=m?`\n${r}${n}${m}`:`\n`;return`${p}\n${n}${d}`}else return`${u}${o}${c.join(" ")}${o}${d}`}function _n({indent:s,options:{commentString:e}},t,i,n){if(i&&n&&(i=i.replace(/^\\n+/,"")),i){let r=De(e(i),s);t.push(r.trimStart())}}function Et(s,e){let t=F(e)?e.value:e;for(let i of s)if(V(i)&&(i.key===e||i.key===t||F(i.key)&&i.key.value===t))return i}var G=class extends Si{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Re,e),this.items=[]}static from(e,t,i){let{keepUndefined:n,replacer:r}=i,o=new this(e),l=(a,h)=>{if(typeof r=="function")h=r.call(t,a,h);else if(Array.isArray(r)&&!r.includes(a))return;(h!==void 0||n)&&o.items.push(Ci(a,h,i))};if(t instanceof Map)for(let[a,h]of t)l(a,h);else if(t&&typeof t=="object")for(let a of Object.keys(t))l(a,t[a]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,t){var o;let i;V(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new Y(e,e==null?void 0:e.value):i=new Y(e.key,e.value);let n=Et(this.items,i.key),r=(o=this.schema)==null?void 0:o.sortMapEntries;if(n){if(!t)throw new Error(`Key ${i.key} already set`);F(n.value)&&Pn(i.value)?n.value.value=i.value:n.value=i.value}else if(r){let l=this.items.findIndex(a=>r(i,a)<0);l===-1?this.items.push(i):this.items.splice(l,0,i)}else this.items.push(i)}delete(e){let t=Et(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){var r;let i=Et(this.items,e),n=i==null?void 0:i.value;return(r=!t&&F(n)?n.value:n)!=null?r:void 0}has(e){return!!Et(this.items,e)}set(e,t){this.add(new Y(e,t),!0)}toJSON(e,t,i){let n=i?new i:t!=null&&t.mapAsMap?new Map:{};t!=null&&t.onCreate&&t.onCreate(n);for(let r of this.items)Hn(t,n,r);return n}toString(e,t,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!V(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Kn(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:t})}};var Fe={collection:"map",default:!0,nodeClass:G,tag:"tag:yaml.org,2002:map",resolve(s,e){return Te(s)||e("Expected a mapping for this tag"),s},createNode:(s,e,t)=>G.from(s,e,t)};var oe=class extends Si{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(dt,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Wn(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let i=Wn(e);if(typeof i!="number")return;let n=this.items[i];return!t&&F(n)?n.value:n}has(e){let t=Wn(e);return typeof t=="number"&&t=0?e:null}var $e={collection:"seq",default:!0,nodeClass:oe,tag:"tag:yaml.org,2002:seq",resolve(s,e){return Ee(s)||e("Expected a sequence for this tag"),s},createNode:(s,e,t)=>oe.from(s,e,t)};var Nt={identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify(s,e,t,i){return e=Object.assign({actualString:!0},e),mt(s,e,t,i)}};var Jt={identify:s=>s==null,createNode:()=>new E(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new E(null),stringify:({source:s},e)=>typeof s=="string"&&Jt.test.test(s)?s:e.options.nullStr};var bs={identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:s=>new E(s[0]==="t"||s[0]==="T"),stringify({source:s,value:e},t){if(s&&bs.test.test(s)){let i=s[0]==="t"||s[0]==="T";if(e===i)return s}return e?t.options.trueStr:t.options.falseStr}};function he({format:s,minFractionDigits:e,tag:t,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let r=JSON.stringify(i);if(!s&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^\\d/.test(r)){let o=r.indexOf(".");o<0&&(o=r.length,r+=".");let l=e-(r.length-o-1);for(;l-- >0;)r+="0"}return r}var qn={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\\.(?:inf|Inf|INF)|\\.nan|\\.NaN|\\.NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:he},jn={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\\.[0-9]+|[0-9]+(?:\\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s),stringify(s){let e=Number(s.value);return isFinite(e)?e.toExponential():he(s)}},zn={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\\.[0-9]+|[0-9]+\\.[0-9]*)$/,resolve(s){let e=new E(parseFloat(s)),t=s.indexOf(".");return t!==-1&&s[s.length-1]==="0"&&(e.minFractionDigits=s.length-t-1),e},stringify:he};var Un=s=>typeof s=="bigint"||Number.isInteger(s),al=(s,e,t,{intAsBigInt:i})=>i?BigInt(s):parseInt(s.substring(e),t);function Af(s,e,t){let{value:i}=s;return Un(i)&&i>=0?t+i.toString(e):he(s)}var Yn={identify:s=>Un(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(s,e,t)=>al(s,2,8,t),stringify:s=>Af(s,8,"0o")},Gn={identify:Un,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(s,e,t)=>al(s,0,10,t),stringify:he},Jn={identify:s=>Un(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(s,e,t)=>al(s,2,16,t),stringify:s=>Af(s,16,"0x")};var Mf=[Fe,$e,Nt,Jt,bs,Yn,Gn,Jn,qn,jn,zn];function Of(s){return typeof s=="bigint"||Number.isInteger(s)}var Xn=({value:s})=>JSON.stringify(s),yp=[{identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify:Xn},{identify:s=>s==null,createNode:()=>new E(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Xn},{identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true|false$/,resolve:s=>s==="true",stringify:Xn},{identify:Of,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(s,e,{intAsBigInt:t})=>t?BigInt(s):parseInt(s,10),stringify:({value:s})=>Of(s)?s.toString():JSON.stringify(s)},{identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:s=>parseFloat(s),stringify:Xn}],bp={default:!0,tag:"",test:/^/,resolve(s,e){return e(`Unresolved plain scalar ${JSON.stringify(s)}`),s}},Tf=[Fe,$e].concat(yp,bp);var ws={identify:s=>s instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(s,e){if(typeof Buffer=="function")return Buffer.from(s,"base64");if(typeof atob=="function"){let t=atob(s.replace(/[\\n\\r]/g,"")),i=new Uint8Array(t.length);for(let n=0;n1&&e("Each pair must have its own sequence indicator");let r=n.items[0]||new Y(new E(null));if(n.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${n.commentBefore}\n${r.key.commentBefore}`:n.commentBefore),n.comment){let o=(t=r.value)!=null?t:r.key;o.comment=o.comment?`${n.comment}\n${o.comment}`:n.comment}n=r}s.items[i]=V(n)?n:new Y(n)}}else e("Expected a sequence for this tag");return s}function fl(s,e,t){let{replacer:i}=t,n=new oe(s);n.tag="tag:yaml.org,2002:pairs";let r=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof i=="function"&&(o=i.call(e,String(r++),o));let l,a;if(Array.isArray(o))if(o.length===2)l=o[0],a=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let h=Object.keys(o);if(h.length===1)l=h[0],a=o[l];else throw new TypeError(`Expected tuple with one key, not ${h.length} keys`)}else l=o;n.items.push(Ci(l,a,t))}return n}var ks={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:hl,createNode:fl};var Ai=class s extends oe{constructor(){super(),this.add=G.prototype.add.bind(this),this.delete=G.prototype.delete.bind(this),this.get=G.prototype.get.bind(this),this.has=G.prototype.has.bind(this),this.set=G.prototype.set.bind(this),this.tag=s.tag}toJSON(e,t){if(!t)return super.toJSON(e);let i=new Map;t!=null&&t.onCreate&&t.onCreate(i);for(let n of this.items){let r,o;if(V(n)?(r=te(n.key,"",t),o=te(n.value,r,t)):r=te(n,"",t),i.has(r))throw new Error("Ordered maps must not include duplicate keys");i.set(r,o)}return i}static from(e,t,i){let n=fl(e,t,i),r=new this;return r.items=n.items,r}};Ai.tag="tag:yaml.org,2002:omap";var Ss={collection:"seq",identify:s=>s instanceof Map,nodeClass:Ai,default:!1,tag:"tag:yaml.org,2002:omap",resolve(s,e){let t=hl(s,e),i=[];for(let{key:n}of t.items)F(n)&&(i.includes(n.value)?e(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Ai,t)},createNode:(s,e,t)=>Ai.from(s,e,t)};function Ef({value:s,source:e},t){return e&&(s?cl:ul).test.test(e)?e:s?t.options.trueStr:t.options.falseStr}var cl={identify:s=>s===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new E(!0),stringify:Ef},ul={identify:s=>s===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new E(!1),stringify:Ef};var Nf={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\\.(?:inf|Inf|INF)|\\.nan|\\.NaN|\\.NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:he},Df={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s.replace(/_/g,"")),stringify(s){let e=Number(s.value);return isFinite(e)?e.toExponential():he(s)}},Lf={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\\.[0-9_]*$/,resolve(s){let e=new E(parseFloat(s.replace(/_/g,""))),t=s.indexOf(".");if(t!==-1){let i=s.substring(t+1).replace(/_/g,"");i[i.length-1]==="0"&&(e.minFractionDigits=i.length)}return e},stringify:he};var vs=s=>typeof s=="bigint"||Number.isInteger(s);function Qn(s,e,t,{intAsBigInt:i}){let n=s[0];if((n==="-"||n==="+")&&(e+=1),s=s.substring(e).replace(/_/g,""),i){switch(t){case 2:s=`0b${s}`;break;case 8:s=`0o${s}`;break;case 16:s=`0x${s}`;break}let o=BigInt(s);return n==="-"?BigInt(-1)*o:o}let r=parseInt(s,t);return n==="-"?-1*r:r}function dl(s,e,t){let{value:i}=s;if(vs(i)){let n=i.toString(e);return i<0?"-"+t+n.substr(1):t+n}return he(s)}var Pf={identify:vs,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(s,e,t)=>Qn(s,2,2,t),stringify:s=>dl(s,2,"0b")},Bf={identify:vs,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(s,e,t)=>Qn(s,1,8,t),stringify:s=>dl(s,8,"0")},If={identify:vs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(s,e,t)=>Qn(s,0,10,t),stringify:he},Rf={identify:vs,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(s,e,t)=>Qn(s,2,16,t),stringify:s=>dl(s,16,"0x")};var Mi=class s extends G{constructor(e){super(e),this.tag=s.tag}add(e){let t;V(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new Y(e.key,null):t=new Y(e,null),Et(this.items,t.key)||this.items.push(t)}get(e,t){let i=Et(this.items,e);return!t&&V(i)?F(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=Et(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new Y(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,i){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,i);throw new Error("Set items must all have null values")}static from(e,t,i){let{replacer:n}=i,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t)typeof n=="function"&&(o=n.call(t,o,o)),r.items.push(Ci(o,null,i));return r}};Mi.tag="tag:yaml.org,2002:set";var xs={collection:"map",identify:s=>s instanceof Set,nodeClass:Mi,default:!1,tag:"tag:yaml.org,2002:set",createNode:(s,e,t)=>Mi.from(s,e,t),resolve(s,e){if(Te(s)){if(s.hasAllNullValues(!0))return Object.assign(new Mi,s);e("Set items must all have null values")}else e("Expected a mapping for this tag");return s}};function pl(s,e){let t=s[0],i=t==="-"||t==="+"?s.substring(1):s,n=o=>e?BigInt(o):Number(o),r=i.replace(/_/g,"").split(":").reduce((o,l)=>o*n(60)+n(l),n(0));return t==="-"?n(-1)*r:r}function Ff(s){let{value:e}=s,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return he(s);let i="";e<0&&(i="-",e*=t(-1));let n=t(60),r=[e%n];return e<60?r.unshift(0):(e=(e-r[0])/n,r.unshift(e%n),e>=60&&(e=(e-r[0])/n,r.unshift(e))),i+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\\d*$/,"")}var Zn={identify:s=>typeof s=="bigint"||Number.isInteger(s),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(s,e,{intAsBigInt:t})=>pl(s,t),stringify:Ff},er={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*$/,resolve:s=>pl(s,!1),stringify:Ff},Oi={identify:s=>s instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\\\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\\\.[0-9]+)?)(?:[ \\\\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(s){let e=s.match(Oi.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,i,n,r,o,l]=e.map(Number),a=e[7]?Number((e[7]+"00").substr(1,3)):0,h=Date.UTC(t,i-1,n,r||0,o||0,l||0,a),f=e[8];if(f&&f!=="Z"){let c=pl(f,!1);Math.abs(c)<30&&(c*=60),h-=6e4*c}return new Date(h)},stringify:({value:s})=>s.toISOString().replace(/((T00:00)?:00)?\\.000Z$/,"")};var ml=[Fe,$e,Nt,Jt,cl,ul,Pf,Bf,If,Rf,Nf,Df,Lf,ws,Ss,ks,xs,Zn,er,Oi];var $f=new Map([["core",Mf],["failsafe",[Fe,$e,Nt]],["json",Tf],["yaml11",ml],["yaml-1.1",ml]]),Vf={binary:ws,bool:bs,float:zn,floatExp:jn,floatNaN:qn,floatTime:er,int:Gn,intHex:Jn,intOct:Yn,intTime:Zn,map:Fe,null:Jt,omap:Ss,pairs:ks,seq:$e,set:xs,timestamp:Oi},Hf={"tag:yaml.org,2002:binary":ws,"tag:yaml.org,2002:omap":Ss,"tag:yaml.org,2002:pairs":ks,"tag:yaml.org,2002:set":xs,"tag:yaml.org,2002:timestamp":Oi};function tr(s,e){let t=$f.get(e);if(!t)if(Array.isArray(s))t=[];else{let i=Array.from($f.keys()).filter(n=>n!=="yaml11").map(n=>JSON.stringify(n)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(s))for(let i of s)t=t.concat(i);else typeof s=="function"&&(t=s(t.slice()));return t.map(i=>{if(typeof i!="string")return i;let n=Vf[i];if(n)return n;let r=Object.keys(Vf).map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown custom tag "${i}"; use one of ${r}`)})}var wp=(s,e)=>s.keye.key?1:0,Ti=class s{constructor({compat:e,customTags:t,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:l}){this.compat=Array.isArray(e)?tr(e,"compat"):e?tr(null,e):null,this.merge=!!i,this.name=typeof r=="string"&&r||"core",this.knownTags=n?Hf:{},this.tags=tr(t,this.name),this.toStringOptions=l!=null?l:null,Object.defineProperty(this,Re,{value:Fe}),Object.defineProperty(this,Me,{value:Nt}),Object.defineProperty(this,dt,{value:$e}),this.sortMapEntries=typeof o=="function"?o:o===!0?wp:null}clone(){let e=Object.create(s.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};function _f(s,e){var a;let t=[],i=e.directives===!0;if(e.directives!==!1&&s.directives){let h=s.directives.toString(s);h?(t.push(h),i=!0):s.directives.docStart&&(i=!0)}i&&t.push("---");let n=$n(s,e),{commentString:r}=n.options;if(s.commentBefore){t.length!==1&&t.unshift("");let h=r(s.commentBefore);t.unshift(De(h,""))}let o=!1,l=null;if(s.contents){if(H(s.contents)){if(s.contents.spaceBefore&&i&&t.push(""),s.contents.commentBefore){let c=r(s.contents.commentBefore);t.push(De(c,""))}n.forceBlockIndent=!!s.comment,l=s.contents.comment}let h=l?void 0:()=>o=!0,f=gt(s.contents,n,()=>l=null,h);l&&(f+=st(f,"",r(l))),(f[0]==="|"||f[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${f}`:t.push(f)}else t.push(gt(s.contents,n));if((a=s.directives)!=null&&a.docEnd)if(s.comment){let h=r(s.comment);h.includes(`\n`)?(t.push("..."),t.push(De(h,""))):t.push(`... ${h}`)}else t.push("...");else{let h=s.comment;h&&o&&(h=h.replace(/^\\n+/,"")),h&&((!o||l)&&t[t.length-1]!==""&&t.push(""),t.push(De(r(h),"")))}return t.join(`\n`)+`\n`}var nt=class s{constructor(e,t,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ce,{value:Nn});let n=null;typeof t=="function"||Array.isArray(t)?n=t:i===void 0&&t&&(i=t,t=void 0);let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,uniqueKeys:!0,version:"1.2"},i);this.options=r;let{version:o}=r;i!=null&&i._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new tt({version:o}),this.setSchema(o,i),this.contents=e===void 0?null:this.createNode(e,n,i)}clone(){let e=Object.create(s.prototype,{[ce]:{value:Nn}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=H(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Ei(this.contents)&&this.contents.add(e)}addIn(e,t){Ei(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let i=il(this);e.anchor=!t||i.has(t)?sl(t||"a",i):t}return new it(e.anchor)}createNode(e,t,i){let n;if(typeof t=="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let g=w=>typeof w=="number"||w instanceof String||w instanceof Number,y=t.filter(g).map(String);y.length>0&&(t=t.concat(y)),n=t}else i===void 0&&t&&(i=t,t=void 0);let{aliasDuplicateObjects:r,anchorPrefix:o,flow:l,keepUndefined:a,onTagObj:h,tag:f}=i!=null?i:{},{onAnchor:c,setAnchors:u,sourceObjects:d}=kf(this,o||"a"),p={aliasDuplicateObjects:r!=null?r:!0,keepUndefined:a!=null?a:!1,onAnchor:c,onTagObj:h,replacer:n,schema:this.schema,sourceObjects:d},m=pt(e,f,p);return l&&_(m)&&(m.flow=!0),u(),m}createPair(e,t,i={}){let n=this.createNode(e,null,i),r=this.createNode(t,null,i);return new Y(n,r)}delete(e){return Ei(this.contents)?this.contents.delete(e):!1}deleteIn(e){return vi(e)?this.contents==null?!1:(this.contents=null,!0):Ei(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return _(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return vi(e)?!t&&F(this.contents)?this.contents.value:this.contents:_(this.contents)?this.contents.getIn(e,t):void 0}has(e){return _(this.contents)?this.contents.has(e):!1}hasIn(e){return vi(e)?this.contents!==void 0:_(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=ps(this.schema,[e],t):Ei(this.contents)&&this.contents.set(e,t)}setIn(e,t){vi(e)?this.contents=t:this.contents==null?this.contents=ps(this.schema,Array.from(e),t):Ei(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let i;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new tt({version:"1.1"}),i={merge:!0,resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new tt({version:e}),i={merge:!1,resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected \'1.1\', \'1.2\' or null as first argument, but found: ${n}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(i)this.schema=new Ti(Object.assign(i,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:i,maxAliasCount:n,onAnchor:r,reviver:o}={}){let l={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=te(this.contents,t!=null?t:"",l);if(typeof r=="function")for(let{count:h,res:f}of l.anchors.values())r(f,h);return typeof o=="function"?Ot(o,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return _f(this,e)}};function Ei(s){if(_(s))return!0;throw new Error("Expected a YAML collection as document contents")}var Ni=class extends Error{constructor(e,t,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=t}},ke=class extends Ni{constructor(e,t,i){super("YAMLParseError",e,t,i)}},Di=class extends Ni{constructor(e,t,i){super("YAMLWarning",e,t,i)}},Cs=(s,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(l=>e.linePos(l));let{line:i,col:n}=t.linePos[0];t.message+=` at line ${i}, column ${n}`;let r=n-1,o=s.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\\n\\r]+$/,"");if(r>=60&&o.length>80){let l=Math.min(r-39,o.length-79);o="\\u2026"+o.substring(l),r-=l-1}if(o.length>80&&(o=o.substring(0,79)+"\\u2026"),i>1&&/^ *$/.test(o.substring(0,r))){let l=s.substring(e.lineStarts[i-2],e.lineStarts[i-1]);l.length>80&&(l=l.substring(0,79)+`\\u2026\n`),o=l+o}if(/[^ ]/.test(o)){let l=1,a=t.linePos[1];a&&a.line===i&&a.col>n&&(l=Math.max(1,Math.min(a.col-n,80-r)));let h=" ".repeat(r)+"^".repeat(l);t.message+=`:\n\n${o}\n${h}\n`}};function rt(s,{flow:e,indicator:t,next:i,offset:n,onError:r,parentIndent:o,startOnNewline:l}){let a=!1,h=l,f=l,c="",u="",d=!1,p=!1,m=null,g=null,y=null,w=null,x=null,S=null,v=null;for(let C of s)switch(p&&(C.type!=="space"&&C.type!=="newline"&&C.type!=="comma"&&r(C.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p=!1),m&&(h&&C.type!=="comment"&&C.type!=="newline"&&r(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),C.type){case"space":!e&&(t!=="doc-start"||(i==null?void 0:i.type)!=="flow-collection")&&C.source.includes(" ")&&(m=C),f=!0;break;case"comment":{f||r(C,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let L=C.source.substring(1)||" ";c?c+=u+L:c=L,u="",h=!1;break}case"newline":h?c?c+=C.source:a=!0:u+=C.source,h=!0,d=!0,(g||y)&&(w=C),f=!0;break;case"anchor":g&&r(C,"MULTIPLE_ANCHORS","A node can have at most one anchor"),C.source.endsWith(":")&&r(C.offset+C.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=C,v===null&&(v=C.offset),h=!1,f=!1,p=!0;break;case"tag":{y&&r(C,"MULTIPLE_TAGS","A node can have at most one tag"),y=C,v===null&&(v=C.offset),h=!1,f=!1,p=!0;break}case t:(g||y)&&r(C,"BAD_PROP_ORDER",`Anchors and tags must be after the ${C.source} indicator`),S&&r(C,"UNEXPECTED_TOKEN",`Unexpected ${C.source} in ${e!=null?e:"collection"}`),S=C,h=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){x&&r(C,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),x=C,h=!1,f=!1;break}default:r(C,"UNEXPECTED_TOKEN",`Unexpected ${C.type} token`),h=!1,f=!1}let M=s[s.length-1],O=M?M.offset+M.source.length:n;return p&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&r(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(h&&m.indent<=o||(i==null?void 0:i.type)==="block-map"||(i==null?void 0:i.type)==="block-seq")&&r(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:x,found:S,spaceBefore:a,comment:c,hasNewline:d,anchor:g,tag:y,newlineAfterProp:w,end:O,start:v!=null?v:O}}function Dt(s){if(!s)return null;switch(s.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(s.source.includes(`\n`))return!0;if(s.end){for(let e of s.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of s.items){for(let t of e.start)if(t.type==="newline")return!0;if(e.sep){for(let t of e.sep)if(t.type==="newline")return!0}if(Dt(e.key)||Dt(e.value))return!0}return!1;default:return!0}}function As(s,e,t){if((e==null?void 0:e.type)==="flow-collection"){let i=e.end[0];i.indent===s&&(i.source==="]"||i.source==="}")&&Dt(e)&&t(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function ir(s,e,t){let{uniqueKeys:i}=s.options;if(i===!1)return!1;let n=typeof i=="function"?i:(r,o)=>r===o||F(r)&&F(o)&&r.value===o.value&&!(r.value==="<<"&&s.schema.merge);return e.some(r=>n(r.key,t))}var Kf="All mapping items must start at the same column";function Wf({composeNode:s,composeEmptyNode:e},t,i,n,r){var f,c;let o=(f=r==null?void 0:r.nodeClass)!=null?f:G,l=new o(t.schema);t.atRoot&&(t.atRoot=!1);let a=i.offset,h=null;for(let u of i.items){let{start:d,key:p,sep:m,value:g}=u,y=rt(d,{indicator:"explicit-key-ind",next:p!=null?p:m==null?void 0:m[0],offset:a,onError:n,parentIndent:i.indent,startOnNewline:!0}),w=!y.found;if(w){if(p&&(p.type==="block-seq"?n(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==i.indent&&n(a,"BAD_INDENT",Kf)),!y.anchor&&!y.tag&&!m){h=y.end,y.comment&&(l.comment?l.comment+=`\n`+y.comment:l.comment=y.comment);continue}(y.newlineAfterProp||Dt(p))&&n(p!=null?p:d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else((c=y.found)==null?void 0:c.indent)!==i.indent&&n(a,"BAD_INDENT",Kf);let x=y.end,S=p?s(t,p,y,n):e(t,x,d,null,y,n);t.schema.compat&&As(i.indent,p,n),ir(t,l.items,S)&&n(x,"DUPLICATE_KEY","Map keys must be unique");let v=rt(m!=null?m:[],{indicator:"map-value-ind",next:g,offset:S.range[2],onError:n,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(a=v.end,v.found){w&&((g==null?void 0:g.type)==="block-map"&&!v.hasNewline&&n(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&y.starts&&(s.type==="block-map"||s.type==="block-seq");function jf({composeNode:s,composeEmptyNode:e},t,i,n,r){var g,y;let o=i.start.source==="{",l=o?"flow map":"flow sequence",a=(g=r==null?void 0:r.nodeClass)!=null?g:o?G:oe,h=new a(t.schema);h.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1);let c=i.offset+i.start.source.length;for(let w=0;w0){let w=ot(p,m,t.options.strict,n);w.comment&&(h.comment?h.comment+=`\n`+w.comment:h.comment=w.comment),h.range=[i.offset,m,w.offset]}else h.range=[i.offset,m,m];return h}function bl(s,e,t,i,n,r){let o=t.type==="block-map"?Wf(s,e,t,i,r):t.type==="block-seq"?qf(s,e,t,i,r):jf(s,e,t,i,r),l=o.constructor;return n==="!"||n===l.tagName?(o.tag=l.tagName,o):(n&&(o.tag=n),o)}function zf(s,e,t,i,n){var u,d;let r=i.tag,o=r?e.directives.tagName(r.source,p=>n(r,"TAG_RESOLVE_FAILED",p)):null;if(t.type==="block-seq"){let{anchor:p,newlineAfterProp:m}=i,g=p&&r?p.offset>r.offset?p:r:p!=null?p:r;g&&(!m||m.offsetp.tag===o&&p.collection===l);if(!a){let p=e.schema.knownTags[o];if(p&&p.collection===l)e.schema.tags.push(Object.assign({},p,{default:!1})),a=p;else return p!=null&&p.collection?n(r,"BAD_COLLECTION_TYPE",`${p.tag} used for ${l} collection, but expects ${p.collection}`,!0):n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),bl(s,e,t,n,o)}let h=bl(s,e,t,n,o,a),f=(d=(u=a.resolve)==null?void 0:u.call(a,h,p=>n(r,"TAG_RESOLVE_FAILED",p),e.options))!=null?d:h,c=H(f)?f:new E(f);return c.range=h.range,c.tag=o,a!=null&&a.format&&(c.format=a.format),c}function sr(s,e,t){let i=e.offset,n=kp(e,s.options.strict,t);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let r=n.mode===">"?E.BLOCK_FOLDED:E.BLOCK_LITERAL,o=e.source?Sp(e.source):[],l=o.length;for(let m=o.length-1;m>=0;--m){let g=o[m][1];if(g===""||g==="\\r")l=m;else break}if(l===0){let m=n.chomp==="+"&&o.length>0?`\n`.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return e.source&&(g+=e.source.length),{value:m,type:r,comment:n.comment,range:[i,g,g]}}let a=e.indent+n.indent,h=e.offset+n.length,f=0;for(let m=0;ma&&(a=g.length);else{g.length=l;--m)o[m][0].length>a&&(l=m+1);let c="",u="",d=!1;for(let m=0;ma||y[0]===" "?(u===" "?u=`\n`:!d&&u===`\n`&&(u=`\n\n`),c+=u+g.slice(a)+y,u=`\n`,d=!0):y===""?u===`\n`?c+=`\n`:u=`\n`:(c+=u+y,u=" ",d=!1)}switch(n.chomp){case"-":break;case"+":for(let m=l;mt(i+u,d,p);switch(n){case"scalar":l=E.PLAIN,a=vp(r,h);break;case"single-quoted-scalar":l=E.QUOTE_SINGLE,a=xp(r,h);break;case"double-quoted-scalar":l=E.QUOTE_DOUBLE,a=Cp(r,h);break;default:return t(s,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+r.length,i+r.length]}}let f=i+r.length,c=ot(o,f,e,t);return{value:a,type:l,comment:c.comment,range:[i,f,c.offset]}}function vp(s,e){let t="";switch(s[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${s[0]}`;break}case"@":case"`":{t=`reserved character ${s[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),Uf(s)}function xp(s,e){return(s[s.length-1]!=="\'"||s.length===1)&&e(s.length,"MISSING_CHAR","Missing closing \'quote"),Uf(s.slice(1,-1)).replace(/\'\'/g,"\'")}function Uf(s){var a;let e,t;try{e=new RegExp(`(.*?)(?r?s.slice(r,i+1):n)}else t+=n}return(s[s.length-1]!==\'"\'||s.length===1)&&e(s.length,"MISSING_CHAR",\'Missing closing "quote\'),t}function Ap(s,e){let t="",i=s[e+1];for(;(i===" "||i===" "||i===`\n`||i==="\\r")&&!(i==="\\r"&&s[e+2]!==`\n`);)i===`\n`&&(t+=`\n`),e+=1,i=s[e+1];return t||(t=" "),{fold:t,offset:e}}var Mp={0:"\\0",a:"\\x07",b:"\\b",e:"\\x1B",f:"\\f",n:`\n`,r:"\\r",t:" ",v:"\\v",N:"\\x85",_:"\\xA0",L:"\\u2028",P:"\\u2029"," ":" ",\'"\':\'"\',"/":"/","\\\\":"\\\\"," ":" "};function Op(s,e,t,i){let n=s.substr(e,t),o=n.length===t&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;if(isNaN(o)){let l=s.substr(e-2,t+2);return i(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${l}`),l}return String.fromCodePoint(o)}function wl(s,e,t,i){let{value:n,type:r,comment:o,range:l}=e.type==="block-scalar"?sr(s,e,i):nr(e,s.options.strict,i),a=t?s.directives.tagName(t.source,c=>i(t,"TAG_RESOLVE_FAILED",c)):null,h=t&&a?Tp(s.schema,n,a,t,i):e.type==="scalar"?Ep(s,n,e,i):s.schema[Me],f;try{let c=h.resolve(n,u=>i(t!=null?t:e,"TAG_RESOLVE_FAILED",u),s.options);f=F(c)?c:new E(c)}catch(c){let u=c instanceof Error?c.message:String(c);i(t!=null?t:e,"TAG_RESOLVE_FAILED",u),f=new E(n)}return f.range=l,f.source=n,r&&(f.type=r),a&&(f.tag=a),h.format&&(f.format=h.format),o&&(f.comment=o),f}function Tp(s,e,t,i,n){var l;if(t==="!")return s[Me];let r=[];for(let a of s.tags)if(!a.collection&&a.tag===t)if(a.default&&a.test)r.push(a);else return a;for(let a of r)if((l=a.test)!=null&&l.test(e))return a;let o=s.knownTags[t];return o&&!o.collection?(s.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),s[Me])}function Ep({directives:s,schema:e},t,i,n){var o;let r=e.tags.find(l=>{var a;return l.default&&((a=l.test)==null?void 0:a.test(t))})||e[Me];if(e.compat){let l=(o=e.compat.find(a=>{var h;return a.default&&((h=a.test)==null?void 0:h.test(t))}))!=null?o:e[Me];if(r.tag!==l.tag){let a=s.tagString(r.tag),h=s.tagString(l.tag),f=`Value may be parsed as either ${a} or ${h}`;n(i,"TAG_RESOLVE_FAILED",f,!0)}}return r}function Yf(s,e,t){if(e){t===null&&(t=e.length);for(let i=t-1;i>=0;--i){let n=e[i];switch(n.type){case"space":case"comment":case"newline":s-=n.source.length;continue}for(n=e[++i];(n==null?void 0:n.type)==="space";)s+=n.source.length,n=e[++i];break}}return s}var Np={composeNode:kl,composeEmptyNode:rr};function kl(s,e,t,i){let{spaceBefore:n,comment:r,anchor:o,tag:l}=t,a,h=!0;switch(e.type){case"alias":a=Dp(s,e,i),(o||l)&&i(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":a=wl(s,e,l,i),o&&(a.anchor=o.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":a=zf(Np,s,e,t,i),o&&(a.anchor=o.source.substring(1));break;default:{let f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",f),a=rr(s,e.offset,void 0,null,t,i),h=!1}}return o&&a.anchor===""&&i(o,"BAD_ALIAS","Anchor cannot be an empty string"),n&&(a.spaceBefore=!0),r&&(e.type==="scalar"&&e.source===""?a.comment=r:a.commentBefore=r),s.options.keepSourceTokens&&h&&(a.srcToken=e),a}function rr(s,e,t,i,{spaceBefore:n,comment:r,anchor:o,tag:l,end:a},h){let f={type:"scalar",offset:Yf(e,t,i),indent:-1,source:""},c=wl(s,f,l,h);return o&&(c.anchor=o.source.substring(1),c.anchor===""&&h(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(c.spaceBefore=!0),r&&(c.comment=r,c.range[2]=a),c}function Dp({options:s},{offset:e,source:t,end:i},n){let r=new it(t.substring(1));r.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),r.source.endsWith(":")&&n(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+t.length,l=ot(i,o,s.strict,n);return r.range=[e,o,l.offset],l.comment&&(r.comment=l.comment),r}function Gf(s,e,{offset:t,start:i,value:n,end:r},o){let l=Object.assign({_directives:e},s),a=new nt(void 0,l),h={atRoot:!0,directives:a.directives,options:a.options,schema:a.schema},f=rt(i,{indicator:"doc-start",next:n!=null?n:r==null?void 0:r[0],offset:t,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(a.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),a.contents=n?kl(h,n,f,o):rr(h,f.end,i,null,f,o);let c=a.contents.range[2],u=ot(r,c,!1,o);return u.comment&&(a.comment=u.comment),a.range=[t,c,u.offset],a}function Ms(s){if(typeof s=="number")return[s,s+1];if(Array.isArray(s))return s.length===2?s:[s[0],s[1]];let{offset:e,source:t}=s;return[e,e+(typeof t=="string"?t.length:1)]}function Jf(s){var n;let e="",t=!1,i=!1;for(let r=0;r{let o=Ms(t);r?this.warnings.push(new Di(o,i,n)):this.errors.push(new ke(o,i,n))},this.directives=new tt({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:i,afterEmptyLine:n}=Jf(this.prelude);if(i){let r=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${i}`:i;else if(n||e.directives.docStart||!r)e.commentBefore=i;else if(_(r)&&!r.flow&&r.items.length>0){let o=r.items[0];V(o)&&(o=o.key);let l=o.commentBefore;o.commentBefore=l?`${i}\n${l}`:i}else{let o=r.commentBefore;r.commentBefore=o?`${i}\n${o}`:i}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Jf(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,i=-1){for(let n of e)yield*k(this.next(n));yield*k(this.end(t,i))}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,i,n)=>{let r=Ms(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=Gf(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,i=new ke(Ms(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new ke(Ms(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let t=ot(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let i=this.doc.comment;this.doc.comment=i?`${i}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new ke(Ms(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let i=Object.assign({_directives:this.directives},this.options),n=new nt(void 0,i);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,t,t],this.decorate(n,!1),yield n}}};var Cl={};Fl(Cl,{BOM:()=>Os,DOCUMENT:()=>Ts,FLOW_END:()=>Es,SCALAR:()=>Li,createScalarToken:()=>Qf,isCollection:()=>Bp,isScalar:()=>Ip,prettyToken:()=>Rp,resolveAsScalar:()=>Xf,setScalarValue:()=>Zf,stringify:()=>tc,tokenType:()=>xl,visit:()=>Lt});function Xf(s,e=!0,t){if(s){let i=(n,r,o)=>{let l=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(t)t(l,r,o);else throw new ke([l,l+1],r,o)};switch(s.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return nr(s,e,i);case"block-scalar":return sr({options:{strict:e}},s,i)}}return null}function Qf(s,e){var h;let{implicitKey:t=!1,indent:i,inFlow:n=!1,offset:r=-1,type:o="PLAIN"}=e,l=mt({type:o,value:s},{implicitKey:t,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),a=(h=e.end)!=null?h:[{type:"newline",offset:-1,indent:i,source:`\n`}];switch(l[0]){case"|":case">":{let f=l.indexOf(`\n`),c=l.substring(0,f),u=l.substring(f+1)+`\n`,d=[{type:"block-scalar-header",offset:r,indent:i,source:c}];return ec(d,a)||d.push({type:"newline",offset:-1,indent:i,source:`\n`}),{type:"block-scalar",offset:r,indent:i,props:d,source:u}}case\'"\':return{type:"double-quoted-scalar",offset:r,indent:i,source:l,end:a};case"\'":return{type:"single-quoted-scalar",offset:r,indent:i,source:l,end:a};default:return{type:"scalar",offset:r,indent:i,source:l,end:a}}}function Zf(s,e,t={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:r=!1,type:o}=t,l="indent"in s?s.indent:null;if(i&&typeof l=="number"&&(l+=2),!o)switch(s.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let h=s.props[0];if(h.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=h.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let a=mt({type:o,value:e},{implicitKey:n||l===null,indent:l!==null&&l>0?" ".repeat(l):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}});switch(a[0]){case"|":case">":Lp(s,a);break;case\'"\':Sl(s,a,"double-quoted-scalar");break;case"\'":Sl(s,a,"single-quoted-scalar");break;default:Sl(s,a,"scalar")}}function Lp(s,e){let t=e.indexOf(`\n`),i=e.substring(0,t),n=e.substring(t+1)+`\n`;if(s.type==="block-scalar"){let r=s.props[0];if(r.type!=="block-scalar-header")throw new Error("Invalid block scalar header");r.source=i,s.source=n}else{let{offset:r}=s,o="indent"in s?s.indent:-1,l=[{type:"block-scalar-header",offset:r,indent:o,source:i}];ec(l,"end"in s?s.end:void 0)||l.push({type:"newline",offset:-1,indent:o,source:`\n`});for(let a of Object.keys(s))a!=="type"&&a!=="offset"&&delete s[a];Object.assign(s,{type:"block-scalar",indent:o,props:l,source:n})}}function ec(s,e){if(e)for(let t of e)switch(t.type){case"space":case"comment":s.push(t);break;case"newline":return s.push(t),!0}return!1}function Sl(s,e,t){switch(s.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":s.type=t,s.source=e;break;case"block-scalar":{let i=s.props.slice(1),n=e.length;s.props[0].type==="block-scalar-header"&&(n-=s.props[0].source.length);for(let r of i)r.offset+=n;delete s.props,Object.assign(s,{type:t,source:e,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:s.offset+e.length,indent:s.indent,source:`\n`};delete s.items,Object.assign(s,{type:t,source:e,end:[n]});break}default:{let i="indent"in s?s.indent:-1,n="end"in s&&Array.isArray(s.end)?s.end.filter(r=>r.type==="space"||r.type==="comment"||r.type==="newline"):[];for(let r of Object.keys(s))r!=="type"&&r!=="offset"&&delete s[r];Object.assign(s,{type:t,indent:i,source:e,end:n})}}}var tc=s=>"type"in s?lr(s):or(s);function lr(s){switch(s.type){case"block-scalar":{let e="";for(let t of s.props)e+=lr(t);return e+s.source}case"block-map":case"block-seq":{let e="";for(let t of s.items)e+=or(t);return e}case"flow-collection":{let e=s.start.source;for(let t of s.items)e+=or(t);for(let t of s.end)e+=t.source;return e}case"document":{let e=or(s);if(s.end)for(let t of s.end)e+=t.source;return e}default:{let e=s.source;if("end"in s&&s.end)for(let t of s.end)e+=t.source;return e}}}function or({start:s,key:e,sep:t,value:i}){let n="";for(let r of s)n+=r.source;if(e&&(n+=lr(e)),t)for(let r of t)n+=r.source;return i&&(n+=lr(i)),n}var vl=Symbol("break visit"),Pp=Symbol("skip children"),ic=Symbol("remove item");function Lt(s,e){"type"in s&&s.type==="document"&&(s={start:s.start,value:s.value}),sc(Object.freeze([]),s,e)}Lt.BREAK=vl;Lt.SKIP=Pp;Lt.REMOVE=ic;Lt.itemAtPath=(s,e)=>{let t=s;for(let[i,n]of e){let r=t==null?void 0:t[i];if(r&&"items"in r)t=r.items[n];else return}return t};Lt.parentCollection=(s,e)=>{let t=Lt.itemAtPath(s,e.slice(0,-1)),i=e[e.length-1][0],n=t==null?void 0:t[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function sc(s,e,t){let i=t(e,s);if(typeof i=="symbol")return i;for(let n of["key","value"]){let r=e[n];if(r&&"items"in r){for(let o=0;o!!s&&"items"in s,Ip=s=>!!s&&(s.type==="scalar"||s.type==="single-quoted-scalar"||s.type==="double-quoted-scalar"||s.type==="block-scalar");function Rp(s){switch(s){case Os:return"";case Ts:return"";case Es:return"";case Li:return"";default:return JSON.stringify(s)}}function xl(s){switch(s){case Os:return"byte-order-mark";case Ts:return"doc-mode";case Es:return"flow-error-end";case Li:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`\n`:case`\\r\n`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(s[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"\'":return"single-quoted-scalar";case\'"\':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function Ve(s){switch(s){case void 0:case" ":case`\n`:case"\\r":case" ":return!0;default:return!1}}var nc=new Set("0123456789ABCDEFabcdef"),Fp=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*\'()"),ar=new Set(",[]{}"),$p=new Set(` ,[]{}\n\\r `),Al=s=>!s||$p.has(s),Pi=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){var n;if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let i=(n=this.next)!=null?n:"stream";for(;i&&(t||this.hasChars(1));)i=yield*k(this.parseNext(i))}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`\n`?!0:t==="\\r"?this.buffer[e+1]===`\n`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let i=0;for(;t===" ";)t=this.buffer[++i+e];if(t==="\\r"){let n=this.buffer[i+e+1];if(n===`\n`||!n&&!this.atEnd)return e+i+1}return t===`\n`||i>=this.indentNext||!t&&!this.atEnd?e+i:-1}if(t==="-"||t==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&Ve(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&ethis.indentValue&&!Ve(this.charAt(1))&&(this.indentNext=this.indentValue),yield*k(this.parseBlockStart())}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Ve(t)){let i=(yield*k(this.pushCount(1)))+(yield*k(this.pushSpaces(!0)));return this.indentNext=this.indentValue+1,this.indentValue+=i,yield*k(this.parseBlockStart())}return"doc"}*parseDocument(){yield*k(this.pushSpaces(!0));let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*k(this.pushIndicators());switch(e[t]){case"#":yield*k(this.pushCount(e.length-t));case void 0:return yield*k(this.pushNewline()),yield*k(this.parseLineStart());case"{":case"[":return yield*k(this.pushCount(1)),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*k(this.pushCount(1)),"doc";case"*":return yield*k(this.pushUntil(Al)),"doc";case\'"\':case"\'":return yield*k(this.parseQuotedScalar());case"|":case">":return t+=yield*k(this.parseBlockScalarHeader()),t+=yield*k(this.pushSpaces(!0)),yield*k(this.pushCount(e.length-t)),yield*k(this.pushNewline()),yield*k(this.parseBlockScalar());default:return yield*k(this.parsePlainScalar())}}*parseFlowCollection(){let e,t,i=-1;do e=yield*k(this.pushNewline()),e>0?(t=yield*k(this.pushSpaces(!1)),this.indentValue=i=t):t=0,t+=yield*k(this.pushSpaces(!0));while(e+t>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*k(this.pushUntil(t=>Ve(t)||t==="#"))}*parseBlockScalar(){let e=this.pos-1,t=0,i;e:for(let r=this.pos;i=this.buffer[r];++r)switch(i){case" ":t+=1;break;case`\n`:e=r,t=0;break;case"\\r":{let o=this.buffer[r+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`\n`)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let r=this.continueScalar(e+1);if(r===-1)break;e=this.buffer.indexOf(`\n`,r)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\\r"||i===`\n`;)i=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let r=e-1,o=this.buffer[r];o==="\\r"&&(o=this.buffer[--r]);let l=r;for(;o===" ";)o=this.buffer[--r];if(o===`\n`&&r>=this.pos&&r+1+t>l)e=r;else break}while(!0);return yield Li,yield*k(this.pushToIndex(e+1,!0)),yield*k(this.parseLineStart())}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let r=this.buffer[i+1];if(Ve(r)||e&&ar.has(r))break;t=i}else if(Ve(n)){let r=this.buffer[i+1];if(n==="\\r"&&(r===`\n`?(i+=1,n=`\n`,r=this.buffer[i+1]):t=i),r==="#"||e&&ar.has(r))break;if(n===`\n`){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(e&&ar.has(n))break;t=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Li,yield*k(this.pushToIndex(t+1,!0)),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*k(this.pushTag()))+(yield*k(this.pushSpaces(!0)))+(yield*k(this.pushIndicators()));case"&":return(yield*k(this.pushUntil(Al)))+(yield*k(this.pushSpaces(!0)))+(yield*k(this.pushIndicators()));case"-":case"?":case":":{let e=this.flowLevel>0,t=this.charAt(1);if(Ve(t)||e&&ar.has(t))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*k(this.pushCount(1)))+(yield*k(this.pushSpaces(!0)))+(yield*k(this.pushIndicators()))}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];for(;!Ve(t)&&t!==">";)t=this.buffer[++e];return yield*k(this.pushToIndex(t===">"?e+1:e,!1))}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(Fp.has(t))t=this.buffer[++e];else if(t==="%"&&nc.has(this.buffer[e+1])&&nc.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*k(this.pushToIndex(e,!1))}}*pushNewline(){let e=this.buffer[this.pos];return e===`\n`?yield*k(this.pushCount(1)):e==="\\r"&&this.charAt(1)===`\n`?yield*k(this.pushCount(2)):0}*pushSpaces(e){let t=this.pos-1,i;do i=this.buffer[++t];while(i===" "||e&&i===" ");let n=t-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=t),n}*pushUntil(e){let t=this.pos,i=this.buffer[t];for(;!e(i);)i=this.buffer[++t];return yield*k(this.pushToIndex(t,!1))}};var Bi=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,i=this.lineStarts.length;for(;t>1;this.lineStarts[r]=0;)switch(s[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;((t=s[++e])==null?void 0:t.type)==="space";);return s.splice(e,s.length)}function oc(s){if(s.start.type==="flow-seq-start")for(let e of s.items)e.sep&&!e.value&&!Qt(e.start,"explicit-key-ind")&&!Qt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,lc(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}var Zt=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Pi,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(e,t))yield*k(this.next(i));t||(yield*k(this.end()))}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*k(this.step()),this.offset+=e.length;return}let t=xl(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*k(this.step()),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let i=`Not a YAML token: ${e}`;yield*k(this.pop({type:"error",offset:this.offset,message:i,source:e})),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*k(this.pop())}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&(!e||e.type!=="doc-end")){for(;this.stack.length>0;)yield*k(this.pop());this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*k(this.stream());switch(e.type){case"document":return yield*k(this.document(e));case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*k(this.scalar(e));case"block-scalar":return yield*k(this.blockScalar(e));case"block-map":return yield*k(this.blockMap(e));case"block-seq":return yield*k(this.blockSequence(e));case"flow-collection":return yield*k(this.flowCollection(e));case"doc-end":return yield*k(this.documentEnd(e))}yield*k(this.pop())}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e!=null?e:this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let i=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in i?i.indent:0:t.type==="flow-collection"&&i.type==="document"&&(t.indent=0),t.type==="flow-collection"&&oc(t),i.type){case"document":i.value=t;break;case"block-scalar":i.props.push(t);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:t}):n.value=t;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*k(this.pop()),yield*k(this.pop(t))}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&rc(n.start)===-1&&(t.indent===0||n.start.every(r=>r.type!=="comment"||r.indent=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",o=[];if(r&&t.sep&&!t.value){let l=[];for(let a=0;ae.indent&&(l.length=0);break;default:l.length=0}}l.length>=2&&(o=t.sep.splice(l[1]))}switch(this.type){case"anchor":case"tag":r||t.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(o.push(this.sourceToken),e.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Qt(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(lc(t.key)&&!Qt(t.sep,"newline")){let l=Ii(t.start),a=t.key,h=t.sep;h.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,key:a,sep:h}]})}else o.length>0?t.sep=t.sep.concat(o,this.sourceToken):t.sep.push(this.sourceToken);else if(Qt(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let l=Ii(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||r?e.items.push({start:o,key:null,sep:[this.sourceToken]}):Qt(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let l=this.flowScalar(this.type);r||t.value?(e.items.push({start:o,key:l,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(l):(Object.assign(t,{key:l,sep:[]}),this.onKeyLine=!0);return}default:{let l=this.startBlockValue(e);if(l){n&&l.type!=="block-seq"&&e.items.push({start:o}),this.stack.push(l);return}}}}yield*k(this.pop()),yield*k(this.step())}*blockSequence(e){var i;let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let n="end"in t.value?t.value.end:void 0,r=Array.isArray(n)?n[n.length-1]:void 0;(r==null?void 0:r.type)==="comment"?n==null||n.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2],r=(i=n==null?void 0:n.value)==null?void 0:i.end;if(Array.isArray(r)){Array.prototype.push.apply(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||Qt(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*k(this.pop()),yield*k(this.step())}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*k(this.pop()),i=this.peek(1);while(i&&i.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):(yield*k(this.pop()),yield*k(this.step()))}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*k(this.pop()),yield*k(this.step());else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=hr(i),r=Ii(n);oc(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let l={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=l}else yield*k(this.lineEnd(e))}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`\n`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`\n`,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=hr(e),i=Ii(t);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=hr(e),i=Ii(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*k(this.pop())))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*k(this.pop()),yield*k(this.step());break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*k(this.pop()))}}};function ac(s){let e=s.prettyErrors!==!1;return{lineCounter:s.lineCounter||e&&new Bi||null,prettyErrors:e}}function hc(s,e={}){let{lineCounter:t,prettyErrors:i}=ac(e),n=new Zt(t==null?void 0:t.addNewLine),r=new Xt(e),o=Array.from(r.compose(n.parse(s)));if(i&&t)for(let l of o)l.errors.forEach(Cs(s,t)),l.warnings.forEach(Cs(s,t));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function Ml(s,e={}){let{lineCounter:t,prettyErrors:i}=ac(e),n=new Zt(t==null?void 0:t.addNewLine),r=new Xt(e),o=null;for(let l of r.compose(n.parse(s),!0,s.length))if(!o)o=l;else if(o.options.logLevel!=="silent"){o.errors.push(new ke(l.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&t&&(o.errors.forEach(Cs(s,t)),o.warnings.forEach(Cs(s,t))),o}function fc(s,e,t){let i;typeof e=="function"?i=e:t===void 0&&e&&typeof e=="object"&&(t=e);let n=Ml(s,t);if(!n)return null;if(n.warnings.forEach(r=>Vn(n.options.logLevel,r)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},t))}function cc(s,e,t){var n;let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){let r=Math.round(t);t=r<1?void 0:r>8?{indent:8}:{indent:r}}if(s===void 0){let{keepUndefined:r}=(n=t!=null?t:e)!=null?n:{};if(!r)return}return new nt(s,i,t).toString(t)}var Tl=Ol;var fr="STATBLOCK-WIKI-LINK",Vp=new RegExp(`<${fr}>([\\\\s\\\\S]+?)<${fr}>`),cr="STATBLOCK-MARKDOWN-LINK",Hp=new RegExp(`<${cr}>([\\\\s\\\\S]+?)(?:\\\\|([\\\\s\\\\S]+?))?<${cr}>`),_p=/([\\s\\S]+?)/,Ns=class s{static isStatblockLink(e){return _p.test(e)}static replaceWikiLink(e){return`<${fr}>${e}<${fr}>`}static replaceMarkdownLink(e,t){return`<${cr}>${e}${t?"|"+t:""}<${cr}>`}static transformSource(e){return e.replace(/\\[\\[([^\\]]+?)\\]\\]/g,(t,i)=>s.replaceWikiLink(i)).replace(/\\[([^\\]]*?)\\]\\(([^)]+?)\\)/g,(t,i,n)=>s.replaceMarkdownLink(n,i))}static transformYamlSource(e){return s.transformSource(e)}static stringifyLinks(e){return e.replace(new RegExp(Vp,"g"),(t,i)=>`[[${i}]]`).replace(new RegExp(Hp,"g"),(t,i,n)=>`[${n||""}](${i})`)}};var ei=self,El=class{constructor(){this.queue=[];this.parsing=!1;ei.addEventListener("message",e=>{e.data.type=="queue"&&(this.add(...e.data.data),this.debug&&console.debug(`Fantasy Statblocks: Received queue message for ${e.data.data.length} paths`))}),ei.addEventListener("message",e=>{e.data.type=="debug"&&(this.debug=e.data.data)})}add(...e){this.debug&&console.debug(`Fantasy Statblocks: Adding ${e.length} paths to queue`),this.queue.push(...e),this.parsing||this.parse()}processContent(e,t){this.debug&&console.debug(`Fantasy Statblocks: Process Content: ${t.path}`);let i=this.findFirstStatBlock(e);if(i){this.debug&&console.debug(`Fantasy Statblocks: found Statblock: ${JSON.stringify(i)}`);let n=Ns.transformSource(i),r=Object.assign({},Tl.parse(n),{mtime:t.mtime});this.debug&&console.debug(`Fantasy Statblocks: ${JSON.stringify(r)}`),this.processMonster(r,t)}}findFirstStatBlock(e){let t=e.match(/^```[^\\S\\r\\n]*statblock\\s?\\n([\\s\\S]+?)^```/m);return t?t[1]:null}async parse(){for(this.parsing=!0;this.queue.length;){let e=this.queue.shift();this.debug&&console.debug(`Fantasy Statblocks: Parsing ${e} for statblocks (${this.queue.length} to go)`);let t=await this.getFileData(e);if(!e.endsWith(".md")||!t.data)continue;let{file:i,statblock:n}=t.data;try{n==="inline"?this.processContent(t.data.content,i):this.parseFrontmatter(t.data.info,i)}catch(r){console.error(`There was an error parsing the Statblock in ${e}: \n\n${r.message}`)}ei.postMessage({type:"done",data:e})}this.parsing=!1,ei.postMessage({type:"save",data:null})}async getFileData(e){return new Promise(t=>{ei.addEventListener("message",i=>{i.data.type=="file"&&t(i.data)}),ei.postMessage({data:e,type:"get"})})}parseFrontmatter(e,t){if(!e.exists)return;let i=Ns.transformYamlSource(e.frontmatter),n=this.validate(Object.assign({},br(Tl.parse(i)),{mtime:t.mtime}));n.traits&&(n.traits=bi([],n.traits)),this.processMonster(n,t)}processMonster(e,t){e.actions&&(e.actions=bi([],e.actions)),e.bonus_actions&&(e.bonus_actions=bi([],e.bonus_actions)),e.reactions&&(e.reactions=bi([],e.reactions)),e.legendary_actions&&(e.legendary_actions=bi([],e.legendary_actions)),e["statblock-link"]&&e["statblock-link"].startsWith("#")&&(e["statblock-link"]=`[${e.name}](${t.path}${e["statblock-link"]})`),this.debug&&console.debug(`Fantasy Statblocks: Adding ${e.name} to bestiary from ${t.basename}`),ei.postMessage({type:"update",data:{monster:e,path:t.path}})}validate(e){return e}};new El;\n')}var so=class extends kt.Component{constructor(){super(...arguments);this.watchPaths=new Map;this.workers=[];this.index=0;this.queue=new Set}get metadataCache(){return this.plugin.app.metadataCache}get vault(){return this.plugin.app.vault}setDebug(){for(let t of this.workers)t.postMessage({type:"debug",data:this.plugin.settings.debug})}initialize(t){return this.plugin=t,this}onload(){this.setDebug(),this.registerEvent(this.metadataCache.on("changed",async i=>{if(!this.plugin.settings.autoParse)return;let{frontmatter:a}=this.metadataCache.getFileCache(i)??{};if(!a||!a.statblock){this.watchPaths.has(i.path)&&this.delete(i.path);return}this.plugin.settings.debug&&console.debug(`Fantasy Statblocks: Reparsing ${i.name}`),this.parsePath(i)})),this.registerEvent(this.vault.on("rename",async(i,a)=>{this.plugin.settings.autoParse&&i instanceof kt.TFile&&this.watchPaths.has(a)&&(this.plugin.settings.debug&&console.debug(`Fantasy Statblocks: Handling rename of ${a} to ${i.path}`),await this.delete(a),this.parsePath(i))})),this.registerEvent(this.vault.on("delete",i=>{this.plugin.settings.autoParse&&i instanceof kt.TFile&&this.watchPaths.has(i.path)&&this.delete(i.path)}));let t=kt.Platform.isIosApp?2:Math.max(Math.ceil(navigator.hardwareConcurrency/2),2);for(let i=0;i{if(s.data.type=="get"){let r=s.data.data,o=this.plugin.app.vault.getAbstractFileByPath(r);if(this.queue.delete(r),o instanceof kt.TFile){let l=await this.getFileInformation(o);a.postMessage(l??{type:"file"})}else a.postMessage({type:"file"}),this.parsePath(o)}}),a.addEventListener("message",async s=>{if(s.data.type=="update"){let{monster:r,path:o}=s.data.data,l=ve.hasCreature(r.name);r.path=o,ve.addEphemeralCreature(r),this.watchPaths.set(o,r.name),this.plugin.settings.debug&&console.debug(`Fantasy Statblocks: ${l?"Updated":"Added"} ${r.name}`)}}),a.addEventListener("message",async s=>{s.data.type=="save"&&await this.save()})}this.plugin.app.workspace.onLayoutReady(()=>{if(!this.plugin.settings.autoParse){ve.setResolved(!0);return}this.start(!0)})}async save(){this.queue.size||(this.startTime&&(console.info(`Fantasy Statblocks: Frontmatter Parsing Complete in ${((Date.now()-this.startTime)/1e3).toLocaleString()} seconds.`),this.startTime=0),this.announce&&(new kt.Notice("Fantasy Statblocks: Frontmatter Parsing complete."),this.announce=!1),ve.setResolved(!0))}async delete(t){ve.removeEphemeralCreature(this.watchPaths.get(t)),this.watchPaths.delete(t),this.plugin.settings.debug&&console.debug(`Fantasy Statblocks: Removing '${t}' from bestiary`)}start(t=!1){ve.setResolved(!1),this.announce=t,this.startTime=Date.now(),console.info("Fantasy Statblocks: Starting Frontmatter Parsing."),this.plugin.settings.paths?.length||(this.plugin.settings.paths=["/"]);let i=!1;for(let a of this.plugin.settings.paths){let s=this.vault.getAbstractFileByPath(a);s&&(i=!0,this.parsePath(s))}i||this.save()}pathContainsFile(t){if(!this.plugin.settings.paths.length||this.plugin.settings.paths.contains("/"))return!0;for(let i of this.plugin.settings.paths)if(t.path.startsWith(i))return!0;return!1}parsePath(t){if(!this.pathContainsFile(t))return;let i=new Set;for(let a of this.getFiles(t))i.add(a);this.startParsing([...i])}startParsing(t){if(t.length){for(let i of t)this.queue.add(i);this.workers[this.index].postMessage({type:"queue",data:t}),this.index=(this.index+1)%this.workers.length}}async getFileInformation(t){if(this.watchPaths.has(t.path)&&ve.get(this.watchPaths.get(t.path))?.mtime==t.stat.mtime)return null;let i=this.plugin.app.metadataCache.getFileCache(t);if(!i?.frontmatter?.statblock||i?.frontmatter?.statblock!==!0&&i?.frontmatter?.statblock!=="true"&&i?.frontmatter?.statblock!=="inline")return null;let a=await this.plugin.app.vault.cachedRead(t),s=(0,kt.getFrontMatterInfo)(a);return{type:"file",data:{statblock:i.frontmatter.statblock=="inline"?"inline":"frontmatter",content:a,info:s,file:{path:t.path,basename:t.basename,mtime:t.stat.mtime}}}}getFiles(t){let i=[];if(t instanceof kt.TFolder)for(let a of t.children)i.push(a.path);return t instanceof kt.TFile&&t.extension==="md"&&i.push(t.path),i}async reparseVault(){this.start(!1)}onunload(){for(let t of this.workers)t.terminate();this.workers=[]}},kn=new so;var Kp=[{name:"Aboleth",source:"5e SRD",size:"Large",type:"aberration",subtype:"",alignment:"lawful evil",ac:17,hp:135,hit_dice:"18d10 + 36",speed:"10 ft., swim 40 ft.",stats:[21,9,15,18,15,18],saves:[{constitution:6},{intelligence:8},{wisdom:6}],skillsaves:[{history:12},{perception:10}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 20",languages:"Deep Speech, telepathy 120 ft.",cr:"10",bestiary:!0,traits:[{name:"Amphibious",desc:"The aboleth can breathe air and water.",attack_bonus:0},{name:"Mucous Cloud",desc:"While underwater, the aboleth is surrounded by transformative mucus. A creature that touches the aboleth or that hits it with a melee attack while within 5 ft. of it must make a DC 14 Constitution saving throw. On a failure, the creature is diseased for 1d4 hours. The diseased creature can breathe only underwater.",attack_bonus:0},{name:"Probing Telepathy",desc:"If a creature communicates telepathically with the aboleth, the aboleth learns the creature's greatest desires if the aboleth can see the creature.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The aboleth makes three tentacle attacks.",attack_bonus:0},{name:"Tentacle",desc:"Melee Weapon Attack: +9 to hit, reach 10 ft., one target. Hit: 12 (2d6 + 5) bludgeoning damage. If the target is a creature, it must succeed on a DC 14 Constitution saving throw or become diseased. The disease has no effect for 1 minute and can be removed by any magic that cures disease. After 1 minute, the diseased creature's skin becomes translucent and slimy, the creature can't regain hit points unless it is underwater, and the disease can be removed only by heal or another disease-curing spell of 6th level or higher. When the creature is outside a body of water, it takes 6 (1d12) acid damage every 10 minutes unless moisture is applied to the skin before 10 minutes have passed.",attack_bonus:9,damage_dice:"2d6",damage_bonus:5},{name:"Tail",desc:"Melee Weapon Attack: +9 to hit, reach 10 ft. one target. Hit: 15 (3d6 + 5) bludgeoning damage.",attack_bonus:9,damage_dice:"3d6",damage_bonus:5},{name:"Enslave (3/day)",desc:`The aboleth targets one creature it can see within 30 ft. of it. The target must succeed on a DC 14 Wisdom saving throw or be magically charmed by the aboleth until the aboleth dies or until it is on a different plane of existence from the target. The charmed target is under the aboleth's control and can't take reactions, and the aboleth and the target can communicate telepathically with each other over any distance. Whenever the charmed target takes damage, the target can repeat the saving throw. On a success, the effect ends. No more than once every 24 hours, the target can also repeat the saving throw when it is at least 1 mile away from the aboleth.`,attack_bonus:0}],legendary_actions:[{name:"Detect",desc:"The aboleth makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Swipe",desc:"The aboleth makes one tail attack.",attack_bonus:0},{name:"Psychic Drain (Costs 2 Actions)",desc:"One creature charmed by the aboleth takes 10 (3d6) psychic damage, and the aboleth regains hit points equal to the damage the creature takes.",attack_bonus:0}]},{name:"Acolyte",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:10,hp:9,hit_dice:"2d8",speed:"30 ft.",stats:[10,10,10,10,14,11],skillsaves:[{medicine:4},{religion:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 12",languages:"any one language (usually Common)",cr:"1/4",bestiary:!0,traits:[],actions:[{name:"Club",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 2 (1d4) bludgeoning damage.",attack_bonus:2,damage_dice:"1d4"}],spells:["The acolyte is a 1st-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 12, +4 to hit with spell attacks). The acolyte has following cleric spells prepared:",{"Cantrips (at will)":"light, sacred flame, thaumaturgy"},{"1st level (3 slots)":"bless, cure wounds, sanctuary"}]},{name:"Adult Black Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"chaotic evil",ac:19,hp:195,hit_dice:"17d12 + 84",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[23,14,21,14,13,17],saves:[{dexterity:7},{constitution:10},{wisdom:6},{charisma:8}],skillsaves:[null,{perception:11},{stealth:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 21",languages:"Common, Draconic",cr:"14",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +11 to hit, reach 10 ft., one target. Hit: 17 (2d10 + 6) piercing damage plus 4 (1d8) acid damage.",attack_bonus:11,damage_dice:"2d10 + 1d8",damage_bonus:6},{name:"Claw",desc:"Melee Weapon Attack: +11 to hit, reach 5 ft., one target. Hit: 13 (2d6 + 6) slashing damage.",attack_bonus:11,damage_dice:"2d6",damage_bonus:6},{name:"Tail",desc:"Melee Weapon Attack: +11 to hit, reach 15 ft., one target. Hit: 15 (2d8 + 6) bludgeoning damage.",attack_bonus:11,damage_dice:"2d8",damage_bonus:6},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 16 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Acid Breath (Recharge 5-6)",desc:"The dragon exhales acid in a 60-foot line that is 5 feet wide. Each creature in that line must make a DC 18 Dexterity saving throw, taking 54 (12d8) acid damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"12d8"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 10 ft. of the dragon must succeed on a DC 19 Dexterity saving throw or take 13 (2d6 + 6) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Adult Blue Dracolich",source:"5e SRD",size:"Huge",type:"undead",subtype:"",alignment:"lawful evil",ac:19,hp:225,hit_dice:"18d12 + 108",speed:"40 ft., burrow 30 ft., fly 80 ft.",stats:[25,10,23,16,15,19],skillsaves:[{perception:12}],damage_vulnerabilities:"",damage_resistances:"necrotic",damage_immunities:"lightning, poison",condition_immunities:"charmed, exhaustion, frightened, paralyzed, poisoned",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 22",languages:"Common, Draconic",cr:"17",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dracolich fails a saving throw, it can choose to succeed instead.",attack_bonus:0},{name:"Magic Resistance",desc:"The dracolich has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dracolich can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +12 to hit, reach 10 ft., one target. Hit: 18 (2d10 + 7) piercing damage plus 5 (1d10) lightning damage.",attack_bonus:12,damage_dice:"2d10 + 1d10",damage_bonus:7},{name:"Claw",desc:"Melee Weapon Attack: +12 to hit, reach 5 ft., one target. Hit: 14 (2d6 + 7) slashing damage.",attack_bonus:12,damage_dice:"2d6",damage_bonus:7},{name:"Tail",desc:"Melee Weapon Attack: +12 to hit, reach 15 ft., one target. Hit: 16 (2d8 + 7) bludgeoning damage.",attack_bonus:12,damage_dice:"2d8",damage_bonus:7},{name:"Frightful Presence",desc:"Each creature of the dracolich's choice that is within 120 feet of the dracolich and aware of it must succeed on a DC 18 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dracolich's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Lightning Breath (Recharge 5-6)",desc:"The dracolich exhales lightning in a 90-foot line that is 5 feet wide. Each creature in that line must make a DC 20 Dexterity saving throw, taking 66 (12d10) lightning damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"12d10"}],legendary_actions:[{name:"Detect",desc:"The dracolich makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dracolich makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dracolich beats its tattered wings. Each creature within 10 ft. of the dracolich must succeed on a DC 21 Dexterity saving throw or take 14 (2d6 + 7) bludgeoning damage and be knocked prone. After beating its wings this way, the dracolich can fly up to half its flying speed.",attack_bonus:0}]},{name:"Adult Blue Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"lawful evil",ac:19,hp:225,hit_dice:"18d12 + 108",speed:"40 ft., burrow 30 ft., fly 80 ft.",stats:[25,10,23,16,15,19],saves:[{dexterity:5},{constitution:11},{wisdom:7},{charisma:9}],skillsaves:[null,{perception:12},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 22",languages:"Common, Draconic",cr:"16",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +12 to hit, reach 10 ft., one target. Hit: 18 (2d10 + 7) piercing damage plus 5 (1d10) lightning damage.",attack_bonus:12,damage_dice:"2d10 + 1d10",damage_bonus:7},{name:"Claw",desc:"Melee Weapon Attack: +12 to hit, reach 5 ft., one target. Hit: 14 (2d6 + 7) slashing damage.",attack_bonus:12,damage_dice:"2d6",damage_bonus:7},{name:"Tail",desc:"Melee Weapon Attack: +12 to hit, reach 15 ft., one target. Hit: 16 (2d8 + 7) bludgeoning damage.",attack_bonus:12,damage_dice:"2d8",damage_bonus:7},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 ft. of the dragon and aware of it must succeed on a DC 17 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Lightning Breath (Recharge 5-6)",desc:"The dragon exhales lightning in a 90-foot line that is 5 ft. wide. Each creature in that line must make a DC 19 Dexterity saving throw, taking 66 (12d10) lightning damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"12d10"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 10 ft. of the dragon must succeed on a DC 20 Dexterity saving throw or take 14 (2d6 + 7) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Adult Brass Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"chaotic good",ac:18,hp:172,hit_dice:"15d12 + 74",speed:"40 ft., burrow 40 ft., fly 80 ft.",stats:[23,10,21,14,13,17],saves:[{dexterity:5},{constitution:10},{wisdom:6},{charisma:8}],skillsaves:[null,{history:7},{persuasion:8},{perception:11},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 21",languages:"Common, Draconic",cr:"13",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +11 to hit, reach,.0 ft., one target. Hit: 17 (2d10 + 6) piercing damage.",attack_bonus:11,damage_dice:"2d10",damage_bonus:6},{name:"Claw",desc:"Melee Weapon Attack: +11 to hit, reach 5 ft., one target. Hit: 13 (2d6 + 6) slashing damage.",attack_bonus:11,damage_dice:"2d6",damage_bonus:6},{name:"Tail",desc:"Melee Weapon Attack: +11 to hit, reach 15 ft., one target. Hit: 15 (2d8 + 6) bludgeoning damage.",attack_bonus:11,damage_dice:"2d8",damage_bonus:6},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 16 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Fire Breath. The dragon exhales fire in an 60-foot line that is 5 feet wide. Each creature in that line must make a DC 18 Dexterity saving throw, taking 45 (13d6) fire damage on a failed save, or half as much damage on a successful one. Sleep Breath. The dragon exhales sleep gas in a 60-foot cone. Each creature in that area must succeed on a DC 18 Constitution saving throw or fall unconscious for 10 minutes. This effect ends for a creature if the creature takes damage or someone uses an action to wake it.`,attack_bonus:0,damage_dice:"13d6"}]},{name:"Adult Bronze Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"lawful good",ac:19,hp:212,hit_dice:"17d12 + 101",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[25,10,23,16,15,19],saves:[{dexterity:5},{constitution:11},{wisdom:7},{charisma:9}],skillsaves:[{insight:7},{perception:12},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 22",languages:"Common, Draconic",cr:"15",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +12 to hit, reach 10 ft., one target. Hit: 18 (2d10 + 7) piercing damage.",attack_bonus:12,damage_dice:"2d10",damage_bonus:7},{name:"Claw",desc:"Melee Weapon Attack: +12 to hit, reach 5 ft., one target. Hit: 14 (2d6 + 7) slashing damage.",attack_bonus:12,damage_dice:"2d6",damage_bonus:7},{name:"Tail",desc:"Melee Weapon Attack: +12 to hit, reach 15 ft., one target. Hit: 16 (2d8 + 7) bludgeoning damage.",attack_bonus:12,damage_dice:"2d8",damage_bonus:7},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 17 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Lightning Breath. The dragon exhales lightning in a 90-foot line that is 5 feet wide. Each creature in that line must make a DC 19 Dexterity saving throw, taking 66 (12d10) lightning damage on a failed save, or half as much damage on a successful one. Repulsion Breath. The dragon exhales repulsion energy in a 30-foot cone. Each creature in that area must succeed on a DC 19 Strength saving throw. On a failed save, the creature is pushed 60 feet away from the dragon.`,attack_bonus:0,damage_dice:"12d10"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 10 ft. of the dragon must succeed on a DC 20 Dexterity saving throw or take 14 (2d6 + 7) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Adult Copper Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"chaotic good",ac:18,hp:184,hit_dice:"16d12 + 80",speed:"40 ft., climb 40 ft., fly 80 ft.",stats:[23,12,21,18,15,17],saves:[{dexterity:6},{constitution:10},{wisdom:7},{charisma:8}],skillsaves:[{deception:8},{perception:12},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 22",languages:"Common, Draconic",cr:"14",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +11 to hit, reach 10 ft., one target. Hit: 17 (2d10 + 6) piercing damage.",attack_bonus:11,damage_dice:"2d10",damage_bonus:6},{name:"Claw",desc:"Melee Weapon Attack: +11 to hit, reach 5 ft., one target. Hit: 13 (2d6 + 6) slashing damage.",attack_bonus:11,damage_dice:"2d6",damage_bonus:6},{name:"Tail",desc:"Melee Weapon Attack: +11 to hit, reach 15 ft., one target. Hit: 15 (2d8 + 6) bludgeoning damage.",attack_bonus:11,damage_dice:"2d8",damage_bonus:6},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 16 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Acid Breath. The dragon exhales acid in an 60-foot line that is 5 feet wide. Each creature in that line must make a DC 18 Dexterity saving throw, taking 54 (12d8) acid damage on a failed save, or half as much damage on a successful one. Slowing Breath. The dragon exhales gas in a 60-foot cone. Each creature in that area must succeed on a DC 18 Constitution saving throw. On a failed save, the creature can't use reactions, its speed is halved, and it can't make more than one attack on its turn. In addition, the creature can use either an action or a bonus action on its turn, but not both. These effects last for 1 minute. The creature can repeat the saving throw at the end of each of its turns, ending the effect on itself with a successful save.`,attack_bonus:0,damage_dice:"12d8"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 10 ft. of the dragon must succeed on a DC 19 Dexterity saving throw or take 13 (2d6 + 6) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Adult Gold Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"lawful good",ac:19,hp:256,hit_dice:"19d12 + 132",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[27,14,25,16,15,24],saves:[{dexterity:8},{constitution:13},{wisdom:8},{charisma:13}],skillsaves:[{insight:8},{persuasion:13},{perception:14},{stealth:8}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 24",languages:"Common, Draconic",cr:"17",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +14 to hit, reach 10 ft., one target. Hit: 19 (2d10 + 8) piercing damage.",attack_bonus:14,damage_dice:"2d10",damage_bonus:8},{name:"Claw",desc:"Melee Weapon Attack: +14 to hit, reach 5 ft., one target. Hit: 15 (2d6 + 8) slashing damage.",attack_bonus:14,damage_dice:"2d6",damage_bonus:8},{name:"Tail",desc:"Melee Weapon Attack: +14 to hit, reach 15 ft., one target. Hit: 17 (2d8 + 8) bludgeoning damage.",attack_bonus:14,damage_dice:"2d8",damage_bonus:8},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 21 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Fire Breath. The dragon exhales fire in a 60-foot cone. Each creature in that area must make a DC 21 Dexterity saving throw, taking 66 (12d10) fire damage on a failed save, or half as much damage on a successful one. Weakening Breath. The dragon exhales gas in a 60-foot cone. Each creature in that area must succeed on a DC 21 Strength saving throw or have disadvantage on Strength-based attack rolls, Strength checks, and Strength saving throws for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.`,attack_bonus:0,damage_dice:"12d10"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 10 ft. of the dragon must succeed on a DC 22 Dexterity saving throw or take 15 (2d6 + 8) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Adult Green Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"lawful evil",ac:19,hp:207,hit_dice:"18d12 + 90",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[23,12,21,18,15,17],saves:[{dexterity:6},{constitution:10},{wisdom:7},{charisma:8}],skillsaves:[{deception:8},{insight:7},{persuasion:8},{perception:12},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"poisoned",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 22",languages:"Common, Draconic",cr:"15",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +11 to hit, reach 10 ft., one target. Hit: 17 (2d10 + 6) piercing damage plus 7 (2d6) poison damage.",attack_bonus:11,damage_dice:"2d10 + 2d6",damage_bonus:6},{name:"Claw",desc:"Melee Weapon Attack: +11 to hit, reach 5 ft., one target. Hit: 13 (2d6 + 6) slashing damage.",attack_bonus:11,damage_dice:"2d6",damage_bonus:6},{name:"Tail",desc:"Melee Weapon Attack: +11 to hit, reach 15 ft., one target. Hit: 15 (2d8 + 6) bludgeoning damage.",attack_bonus:11,damage_dice:"2d8",damage_bonus:6},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 16 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours .",attack_bonus:0},{name:"Poison Breath (Recharge 5-6)",desc:"The dragon exhales poisonous gas in a 60-foot cone. Each creature in that area must make a DC 18 Constitution saving throw, taking 56 (16d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"16d6"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 10 ft. of the dragon must succeed on a DC 19 Dexterity saving throw or take 13 (2d6 + 6) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Adult Red Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"chaotic evil",ac:19,hp:256,hit_dice:"19d12 + 132",speed:"40 ft., climb 40 ft., fly 80 ft.",stats:[27,10,25,16,13,21],saves:[{dexterity:6},{constitution:13},{wisdom:7},{charisma:11}],skillsaves:[{perception:13},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 23",languages:"Common, Draconic",cr:"17",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +14 to hit, reach 10 ft., one target. Hit: 19 (2d10 + 8) piercing damage plus 7 (2d6) fire damage.",attack_bonus:14,damage_dice:"2d10 + 2d6",damage_bonus:8},{name:"Claw",desc:"Melee Weapon Attack: +14 to hit, reach 5 ft., one target. Hit: 15 (2d6 + 8) slashing damage.",attack_bonus:14,damage_dice:"2d6",damage_bonus:8},{name:"Tail",desc:"Melee Weapon Attack: +14 to hit, reach 15 ft., one target. Hit: 17 (2d8 + 8) bludgeoning damage.",attack_bonus:14,damage_dice:"2d8",damage_bonus:8},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 ft. of the dragon and aware of it must succeed on a DC 19 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Fire Breath (Recharge 5-6)",desc:"The dragon exhales fire in a 60-foot cone. Each creature in that area must make a DC 21 Dexterity saving throw, taking 63 (18d6) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"18d6"},{name:"Lair Actions",desc:`On initiative count 20 (losing initiative ties), the dragon takes a lair action to cause one of the following effects: the dragon can't use the same effect two rounds in a row: \u2022 Magma erupts from a point on the ground the dragon can see within 120 feet of it, creating a 20-foot-high, 5-foot-radius geyser. Each creature in the geyser's area must make a DC 15 Dexterity saving throw, taking 21 (6d6) fire damage on a failed save, or half as much damage on a successful one. \u2022 A tremor shakes the lair in a 60-foot-radius around the dragon. Each creature other than the dragon on the ground in that area must succeed on a DC 15 Dexterity saving throw or be knocked prone. \u2022 Volcanic gases form a cloud in a 20-foot-radius sphere centered on a point the dragon can see within 120 feet of it. The sphere spreads around corners, and its area is lightly obscured. It lasts until initiative count 20 on the next round. Each creature that starts its turn in the cloud must succeed on a DC 13 Constitution saving throw or be poisoned until the end of its turn. While poisoned in this way, a creature is incapacitated.`,attack_bonus:0,damage_dice:"6d6"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 10 ft. of the dragon must succeed on a DC 22 Dexterity saving throw or take 15 (2d6 + 8) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Adult Silver Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"lawful good",ac:19,hp:243,hit_dice:"18d12 + 126",speed:"40 ft., fly 80 ft.",stats:[27,10,25,16,13,21],saves:[{dexterity:5},{constitution:12},{wisdom:6},{charisma:10}],skillsaves:[{arcana:8},{history:8},{perception:11},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 21",languages:"Common, Draconic",cr:"16",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +13 to hit, reach 10 ft., one target. Hit: 19 (2d10 + 8) piercing damage.",attack_bonus:13,damage_dice:"2d10",damage_bonus:8},{name:"Claw",desc:"Melee Weapon Attack: +13 to hit, reach 5 ft., one target. Hit: 15 (2d6 + 8) slashing damage.",attack_bonus:13,damage_dice:"2d6",damage_bonus:8},{name:"Tail",desc:"Melee Weapon Attack: +13 to hit, reach 15 ft., one target. Hit: 17 (2d8 + 8) bludgeoning damage.",attack_bonus:13,damage_dice:"2d8",damage_bonus:8},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 18 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Cold Breath. The dragon exhales an icy blast in a 60-foot cone. Each creature in that area must make a DC 20 Constitution saving throw, taking 58 (13d8) cold damage on a failed save, or half as much damage on a successful one. Paralyzing Breath. The dragon exhales paralyzing gas in a 60-foot cone. Each creature in that area must succeed on a DC 20 Constitution saving throw or be paralyzed for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.`,attack_bonus:0,damage_dice:"13d8"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 10 ft. of the dragon must succeed on a DC 22 Dexterity saving throw or take 15 (2d6 + 8) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Adult White Dragon",source:"5e SRD",size:"Huge",type:"dragon",subtype:"",alignment:"chaotic evil",ac:18,hp:200,hit_dice:"16d12 + 96",speed:"40 ft., burrow 30 ft., fly 80 ft., swim 40 ft.",stats:[22,10,22,8,12,12],saves:[{dexterity:5},{constitution:11},{wisdom:6},{charisma:6}],skillsaves:[{perception:11},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 21",languages:"Common, Draconic",cr:"13",bestiary:!0,traits:[{name:"Ice Walk",desc:"The dragon can move across and climb icy surfaces without needing to make an ability check. Additionally, difficult terrain composed of ice or snow doesn't cost it extra moment.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +11 to hit, reach 10 ft., one target. Hit: 17 (2d10 + 6) piercing damage plus 4 (1d8) cold damage.",attack_bonus:11,damage_dice:"2d10 + 1d8",damage_bonus:6},{name:"Claw",desc:"Melee Weapon Attack: +11 to hit, reach 5 ft., one target. Hit: 13 (2d6 + 6) slashing damage.",attack_bonus:11,damage_dice:"2d6",damage_bonus:6},{name:"Tail",desc:"Melee Weapon Attack: +11 to hit, reach 15 ft., one target. Hit: 15 (2d8 + 6) bludgeoning damage.",attack_bonus:11,damage_dice:"2d8",damage_bonus:6},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 ft. of the dragon and aware of it must succeed on a DC 14 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Cold Breath (Recharge 5-6)",desc:"The dragon exhales an icy blast in a 60-foot cone. Each creature in that area must make a DC 19 Constitution saving throw, taking 54 (12d8) cold damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"12d8"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 10 ft. of the dragon must succeed on a DC 19 Dexterity saving throw or take 13 (2d6 + 6) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Air Elemental",source:"5e SRD",size:"Large",type:"elemental",subtype:"",alignment:"neutral",ac:15,hp:90,hit_dice:"12d10 + 24",speed:"fly 90 ft. (hover)",stats:[14,20,14,6,10,6],damage_vulnerabilities:"",damage_resistances:"lightning; thunder; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"exhaustion, grappled, paralyzed, petrified, poisoned, prone, restrained, unconscious",senses:"darkvision 60 ft., passive Perception 10",languages:"Auran",cr:"5",bestiary:!0,traits:[{name:"Air Form",desc:"The elemental can enter a hostile creature's space and stop there. It can move through a space as narrow as 1 inch wide without squeezing.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The elemental makes two slam attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one target. Hit: 14 (2d8 + 5) bludgeoning damage.",attack_bonus:8,damage_dice:"2d8",damage_bonus:5},{name:"Whirlwind (Recharge 4-6)",desc:`Each creature in the elemental's space must make a DC 13 Strength saving throw. On a failure, a target takes 15 (3d8 + 2) bludgeoning damage and is flung up 20 feet away from the elemental in a random direction and knocked prone. If a thrown target strikes an object, such as a wall or floor, the target takes 3 (1d6) bludgeoning damage for every 10 feet it was thrown. If the target is thrown at another creature, that creature must succeed on a DC 13 Dexterity saving throw or take the same damage and be knocked prone. If the saving throw is successful, the target takes half the bludgeoning damage and isn't flung away or knocked prone.`,attack_bonus:0}]},{name:"Ancient Black Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"chaotic evil",ac:22,hp:367,hit_dice:"21d20 + 146",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[27,14,25,16,15,19],saves:[{dexterity:9},{constitution:14},{wisdom:9},{charisma:11}],skillsaves:[{perception:16},{stealth:9}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 26",languages:"Common, Draconic",cr:"21",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack:+ 15 to hit, reach 15 ft., one target. Hit: 19 (2d10 + 8) piercing damage plus 9 (2d8) acid damage.",attack_bonus:15,damage_dice:"2d10 + 2d8",damage_bonus:8},{name:"Claw",desc:"Melee Weapon Attack: +15 to hit, reach 10 ft., one target. Hit: 15 (2d6 + 8) slashing damage.",attack_bonus:15,damage_dice:"2d6",damage_bonus:8},{name:"Tail",desc:"Melee Weapon Attack: +15 to hit, reach 20 ft ., one target. Hit: 17 (2d8 + 8) bludgeoning damage.",attack_bonus:15,damage_dice:"2d8",damage_bonus:8},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 19 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Acid Breath (Recharge 5-6)",desc:"The dragon exhales acid in a 90-foot line that is 10 feet wide. Each creature in that line must make a DC 22 Dexterity saving throw, taking 67 (15d8) acid damage on a failed save, or half as much damage on a successful one.",attack_bonus:0}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 15 ft. of the dragon must succeed on a DC 23 Dexterity saving throw or take 15 (2d6 + 8) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Ancient Blue Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"lawful evil",ac:22,hp:481,hit_dice:"26d20 + 208",speed:"40 ft., burrow 40 ft., fly 80 ft.",stats:[29,10,27,18,17,21],saves:[{dexterity:7},{constitution:15},{wisdom:10},{charisma:12}],skillsaves:[{perception:17},{stealth:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 27",languages:"Common, Draconic",cr:"23",bestiary:!0,actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +16 to hit, reach 15 ft., one target. Hit: 20 (2d10 + 9) piercing damage plus 11 (2d10) lightning damage.",attack_bonus:16,damage_dice:"2d10 + 2d10",damage_bonus:9},{name:"Claw",desc:"Melee Weapon Attack: +16 to hit, reach 10 ft., one target. Hit: 16 (2d6 + 9) slashing damage.",attack_bonus:16,damage_dice:"2d6",damage_bonus:9},{name:"Tail",desc:"Melee Weapon Attack: +16 to hit, reach 20 ft., one target. Hit: 18 (2d8 + 9) bludgeoning damage.",attack_bonus:16,damage_dice:"2d8",damage_bonus:9},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 20 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Lightning Breath (Recharge 5-6)",desc:"The dragon exhales lightning in a 120-foot line that is 10 feet wide. Each creature in that line must make a DC 23 Dexterity saving throw, taking 88 (16d10) lightning damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"16d10"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 15 ft. of the dragon must succeed on a DC 24 Dexterity saving throw or take 16 (2d6 + 9) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Ancient Brass Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"chaotic good",ac:20,hp:297,hit_dice:"17d20 + 118",speed:"40 ft., burrow 40 ft., fly 80 ft.",stats:[27,10,25,16,15,19],saves:[{dexterity:6},{constitution:13},{wisdom:8},{charisma:10}],skillsaves:[{history:9},{persuasion:10},{perception:14},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 24",languages:"Common, Draconic",cr:"20",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +14 to hit, reach 15 ft., one target. Hit: 19 (2d10 + 8) piercing damage.",attack_bonus:14,damage_dice:"2d10",damage_bonus:8},{name:"Claw",desc:"Melee Weapon Attack: +14 to hit, reach 10 ft., one target. Hit: 15 (2d6 + 8) slashing damage.",attack_bonus:14,damage_dice:"2d6",damage_bonus:8},{name:"Tail",desc:"Melee Weapon Attack: +14 to hit, reach 20 ft., one target. Hit: 17 (2d8 + 8) bludgeoning damage.",attack_bonus:14,damage_dice:"2d8",damage_bonus:8},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 18 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons: Fire Breath. The dragon exhales fire in an 90-foot line that is 10 feet wide. Each creature in that line must make a DC 21 Dexterity saving throw, taking 56 (16d6) fire damage on a failed save, or half as much damage on a successful one. Sleep Breath. The dragon exhales sleep gas in a 90-foot cone. Each creature in that area must succeed on a DC 21 Constitution saving throw or fall unconscious for 10 minutes. This effect ends for a creature if the creature takes damage or someone uses an action to wake it.`,attack_bonus:0,damage_dice:"16d6"},{name:"Change Shape",desc:`The dragon magically polymorphs into a humanoid or beast that has a challenge rating no higher than its own, or back into its true form. It reverts to its true form if it dies. Any equipment it is wearing or carrying is absorbed or borne by the new form (the dragon's choice). In a new form, the dragon retains its alignment, hit points, Hit Dice, ability to speak, proficiencies, Legendary Resistance, lair actions, and Intelligence, Wisdom, and Charisma scores, as well as this action. Its statistics and capabilities are otherwise replaced by those of the new form, except any class features or legendary actions of that form.`,attack_bonus:0}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 15 ft. of the dragon must succeed on a DC 22 Dexterity saving throw or take 15 (2d6 + 8) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Ancient Bronze Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"lawful good",ac:22,hp:444,hit_dice:"24d20 + 192",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[29,10,27,18,17,21],saves:[{dexterity:7},{constitution:15},{wisdom:10},{charisma:12}],skillsaves:[{insight:10},{perception:17},{stealth:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 27",languages:"Common, Draconic",cr:"22",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +16 to hit, reach 15 ft., one target. Hit: 20 (2d10 + 9) piercing damage.",attack_bonus:16,damage_dice:"2d10",damage_bonus:9},{name:"Claw",desc:"Melee Weapon Attack: +16 to hit, reach 10 ft., one target. Hit: 16 (2d6 + 9) slashing damage.",attack_bonus:16,damage_dice:"1d6",damage_bonus:9},{name:"Tail",desc:"Melee Weapon Attack: +16 to hit, reach 20 ft., one target. Hit: 18 (2d8 + 9) bludgeoning damage.",attack_bonus:0,damage_dice:"2d8",damage_bonus:9},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 20 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Lightning Breath. The dragon exhales lightning in a 120-foot line that is 10 feet wide. Each creature in that line must make a DC 23 Dexterity saving throw, taking 88 (16d10) lightning damage on a failed save, or half as much damage on a successful one. Repulsion Breath. The dragon exhales repulsion energy in a 30-foot cone. Each creature in that area must succeed on a DC 23 Strength saving throw. On a failed save, the creature is pushed 60 feet away from the dragon.`,attack_bonus:0,damage_dice:"16d10"},{name:"Change Shape",desc:`The dragon magically polymorphs into a humanoid or beast that has a challenge rating no higher than its own, or back into its true form. It reverts to its true form if it dies. Any equipment it is wearing or carrying is absorbed or borne by the new form (the dragon's choice). In a new form, the dragon retains its alignment, hit points, Hit Dice, ability to speak, proficiencies, Legendary Resistance, lair actions, and Intelligence, Wisdom, and Charisma scores, as well as this action. Its statistics and capabilities are otherwise replaced by those of the new form, except any class features or legendary actions of that form.`,attack_bonus:0}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 15 ft. of the dragon must succeed on a DC 24 Dexterity saving throw or take 16 (2d6 + 9) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Ancient Copper Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"chaotic good",ac:21,hp:350,hit_dice:"20d20 + 140",speed:"40 ft., climb 40 ft., fly 80 ft.",stats:[27,12,25,20,17,19],saves:[{dexterity:8},{constitution:14},{wisdom:10},{charisma:11}],skillsaves:[{stealth:8},{perception:17},{deception:11}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 27",languages:"Common, Draconic",cr:"21",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +15 to hit, reach 15 ft., one target. Hit: 19 (2d10 + 8) piercing damage.",attack_bonus:15,damage_dice:"2d10",damage_bonus:8},{name:"Claw",desc:"Melee Weapon Attack: +15 to hit, reach 10 ft., one target. Hit: 15 (2d6 + 8) slashing damage.",attack_bonus:15,damage_dice:"2d6",damage_bonus:8},{name:"Tail",desc:"Melee Weapon Attack: +15 to hit, reach 20 ft., one target. Hit: 17 (2d8 + 8) bludgeoning damage.",attack_bonus:15,damage_dice:"2d8",damage_bonus:8},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 19 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Acid Breath. The dragon exhales acid in an 90-foot line that is 10 feet wide. Each creature in that line must make a DC 22 Dexterity saving throw, taking 63 (14d8) acid damage on a failed save, or half as much damage on a successful one. Slowing Breath. The dragon exhales gas in a 90-foot cone. Each creature in that area must succeed on a DC 22 Constitution saving throw. On a failed save, the creature can't use reactions, its speed is halved, and it can't make more than one attack on its turn. In addition, the creature can use either an action or a bonus action on its turn, but not both. These effects last for 1 minute. The creature can repeat the saving throw at the end of each of its turns, ending the effect on itself with a successful save.`,attack_bonus:0,damage_dice:"14d8"},{name:"Change Shape",desc:`The dragon magically polymorphs into a humanoid or beast that has a challenge rating no higher than its own, or back into its true form. It reverts to its true form if it dies. Any equipment it is wearing or carrying is absorbed or borne by the new form (the dragon's choice). In a new form, the dragon retains its alignment, hit points, Hit Dice, ability to speak, proficiencies, Legendary Resistance, lair actions, and Intelligence, Wisdom, and Charisma scores, as well as this action. Its statistics and capabilities are otherwise replaced by those of the new form, except any class features or legendary actions of that form.`,attack_bonus:0}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 15 ft. of the dragon must succeed on a DC 23 Dexterity saving throw or take 15 (2d6 + 8) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Ancient Gold Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"lawful good",ac:22,hp:546,hit_dice:"28d20 + 252",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[30,14,29,18,17,28],saves:[{dexterity:9},{constitution:16},{wisdom:10},{charisma:16}],skillsaves:[{persuasion:16},{stealth:9},{perception:17},{insight:10}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 27",languages:"Common, Draconic",cr:"24",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +17 to hit, reach 15 ft., one target. Hit: 21 (2d10 + 10) piercing damage.",attack_bonus:17,damage_dice:"2d10",damage_bonus:10},{name:"Claw",desc:"Melee Weapon Attack: +17 to hit, reach 10 ft., one target. Hit: 17 (2d6 + 10) slashing damage.",attack_bonus:17,damage_dice:"2d6",damage_bonus:10},{name:"Tail",desc:"Melee Weapon Attack: +17 to hit, reach 20 ft., one target. Hit: 19 (2d8 + 10) bludgeoning damage.",attack_bonus:17,damage_dice:"2d8",damage_bonus:10},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 24 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Fire Breath. The dragon exhales fire in a 90-foot cone. Each creature in that area must make a DC 24 Dexterity saving throw, taking 71 (13d10) fire damage on a failed save, or half as much damage on a successful one. Weakening Breath. The dragon exhales gas in a 90-foot cone. Each creature in that area must succeed on a DC 24 Strength saving throw or have disadvantage on Strength-based attack rolls, Strength checks, and Strength saving throws for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.`,attack_bonus:0,damage_dice:"13d10"},{name:"Change Shape",desc:`The dragon magically polymorphs into a humanoid or beast that has a challenge rating no higher than its own, or back into its true form. It reverts to its true form if it dies. Any equipment it is wearing or carrying is absorbed or borne by the new form (the dragon's choice). In a new form, the dragon retains its alignment, hit points, Hit Dice, ability to speak, proficiencies, Legendary Resistance, lair actions, and Intelligence, Wisdom, and Charisma scores, as well as this action. Its statistics and capabilities are otherwise replaced by those of the new form, except any class features or legendary actions of that form.`,attack_bonus:0}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 15 ft. of the dragon must succeed on a DC 25 Dexterity saving throw or take 17 (2d6 + 10) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Ancient Green Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"lawful evil",ac:21,hp:385,hit_dice:"22d20 + 154",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[27,12,25,20,17,19],saves:[{dexterity:8},{constitution:14},{wisdom:10},{charisma:11}],skillsaves:[{deception:11},{insight:10},{perception:17},{persuasion:11},{stealth:8}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"poisoned",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 27",languages:"Common, Draconic",cr:"22",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +15 to hit, reach 15 ft., one target. Hit: 19 (2d10 + 8) piercing damage plus 10 (3d6) poison damage.",attack_bonus:15,damage_dice:"2d10 + 3d6",damage_bonus:9},{name:"Claw",desc:"Melee Weapon Attack: +15 to hit, reach 10 ft., one target. Hit: 22 (4d6 + 8) slashing damage.",attack_bonus:15,damage_dice:"4d6",damage_bonus:8},{name:"Tail",desc:"Melee Weapon Attack: +15 to hit, reach 20 ft., one target. Hit: 17 (2d8 + 8) bludgeoning damage.",attack_bonus:16,damage_dice:"2d8",damage_bonus:8},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 19 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Poison Breath (Recharge 5-6)",desc:"The dragon exhales poisonous gas in a 90-foot cone. Each creature in that area must make a DC 22 Constitution saving throw, taking 77 (22d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"22d6"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 15 ft. of the dragon must succeed on a DC 23 Dexterity saving throw or take 15 (2d6 + 8) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Ancient Red Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"chaotic evil",ac:22,hp:546,hit_dice:"28d20 + 252",speed:"40 ft., climb 40 ft., fly 80 ft.",stats:[30,10,29,18,15,23],saves:[{dexterity:7},{constitution:16},{wisdom:9},{charisma:13}],skillsaves:[{perception:16},{stealth:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 26",languages:"Common, Draconic",cr:"24",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +17 to hit, reach 15 ft., one target. Hit: 21 (2d10 + 10) piercing damage plus 14 (4d6) fire damage.",attack_bonus:17,damage_dice:"2d10 + 4d6",damage_bonus:10},{name:"Claw",desc:"Melee Weapon Attack: +17 to hit, reach 10 ft., one target. Hit: 17 (2d6 + 10) slashing damage.",attack_bonus:17,damage_dice:"2d6",damage_bonus:10},{name:"Tail",desc:"Melee Weapon Attack: +17 to hit, reach 20 ft., one target. Hit: 19 (2d8 + 10) bludgeoning damage.",attack_bonus:17,damage_dice:"2d8",damage_bonus:10},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 21 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Fire Breath (Recharge 5-6)",desc:"The dragon exhales fire in a 90-foot cone. Each creature in that area must make a DC 24 Dexterity saving throw, taking 91 (26d6) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"26d6"}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 15 ft. of the dragon must succeed on a DC 25 Dexterity saving throw or take 17 (2d6 + 10) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Ancient Silver Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"lawful good",ac:22,hp:487,hit_dice:"25d20 + 224",speed:"40 ft., fly 80 ft.",stats:[30,10,29,18,15,23],saves:[{dexterity:7},{constitution:16},{wisdom:9},{charisma:13}],skillsaves:[{arcana:11},{perception:16},{history:11},{stealth:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 26",languages:"Common, Draconic",cr:"23",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +17 to hit, reach 15 ft., one target. Hit: 21 (2d10 + 10) piercing damage.",attack_bonus:17,damage_dice:"2d10",damage_bonus:10},{name:"Claw",desc:"Melee Weapon Attack: +17 to hit, reach 10 ft., one target. Hit: 17 (2d6 + 10) slashing damage.",attack_bonus:17,damage_dice:"2d6",damage_bonus:10},{name:"Tail",desc:"Melee Weapon Attack: +17 to hit, reach 20 ft., one target. Hit: 19 (2d8 + 10) bludgeoning damage.",attack_bonus:17,damage_dice:"2d8",damage_bonus:10},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 21 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Cold Breath. The dragon exhales an icy blast in a 90-foot cone. Each creature in that area must make a DC 24 Constitution saving throw, taking 67 (15d8) cold damage on a failed save, or half as much damage on a successful one. Paralyzing Breath. The dragon exhales paralyzing gas in a 90- foot cone. Each creature in that area must succeed on a DC 24 Constitution saving throw or be paralyzed for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.`,attack_bonus:0,damage_dice:"15d8"},{name:"Change Shape",desc:`The dragon magically polymorphs into a humanoid or beast that has a challenge rating no higher than its own, or back into its true form. It reverts to its true form if it dies. Any equipment it is wearing or carrying is absorbed or borne by the new form (the dragon's choice). In a new form, the dragon retains its alignment, hit points, Hit Dice, ability to speak, proficiencies, Legendary Resistance, lair actions, and Intelligence, Wisdom, and Charisma scores, as well as this action. Its statistics and capabilities are otherwise replaced by those of the new form, except any class features or legendary actions of that form.`,attack_bonus:0}],legendary_actions:[{name:"Detect",desc:"The dragon makes a Wisdom (Perception) check.",attack_bonus:0},{name:"Tail Attack",desc:"The dragon makes a tail attack.",attack_bonus:0},{name:"Wing Attack (Costs 2 Actions)",desc:"The dragon beats its wings. Each creature within 15 ft. of the dragon must succeed on a DC 25 Dexterity saving throw or take 17 (2d6 + 10) bludgeoning damage and be knocked prone. The dragon can then fly up to half its flying speed.",attack_bonus:0}]},{name:"Ancient White Dragon",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"chaotic evil",ac:20,hp:333,hit_dice:"18d20 + 144",speed:"40 ft., burrow 40 ft., fly 80 ft., swim 40 ft.",stats:[26,10,26,10,13,14],saves:[{dexterity:6},{constitution:14},{wisdom:7},{charisma:8}],skillsaves:[{perception:13},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 23",languages:"Common, Draconic",cr:"20",bestiary:!0,traits:[{name:"Ice Walk",desc:"The dragon can move across and climb icy surfaces without needing to make an ability check. Additionally, difficult terrain composed of ice or snow doesn't cost it extra moment.",attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the dragon fails a saving throw, it can choose to succeed instead.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon can use its Frightful Presence. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +14 to hit, reach 15 ft., one target. Hit: 19 (2d10 + 8) piercing damage plus 9 (2d8) cold damage.",attack_bonus:14,damage_dice:"2d10 + 2d8",damage_bonus:8},{name:"Claw",desc:"Melee Weapon Attack: +14 to hit, reach 10 ft., one target. Hit: 15 (2d6 + 8) slashing damage.",attack_bonus:14,damage_dice:"2d6",damage_bonus:8},{name:"Tail",desc:"Melee Weapon Attack: +14 to hit, reach 20 ft., one target. Hit: 17 (2d8 + 8) bludgeoning damage.",attack_bonus:14,damage_dice:"2d8",damage_bonus:8},{name:"Frightful Presence",desc:"Each creature of the dragon's choice that is within 120 feet of the dragon and aware of it must succeed on a DC 16 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the dragon's Frightful Presence for the next 24 hours .",attack_bonus:0},{name:"Cold Breath (Recharge 5-6)",desc:"The dragon exhales an icy blast in a 90-foot cone. Each creature in that area must make a DC 22 Constitution saving throw, taking 72 (l6d8) cold damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"16d8"}]},{name:"Androsphinx",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"lawful neutral",ac:17,hp:199,hit_dice:"19d10 + 94",speed:"40 ft., fly 60 ft.",stats:[22,10,20,16,18,23],saves:[{dexterity:6},{constitution:11},{intelligence:9},{wisdom:10}],skillsaves:[{religion:15},{perception:10},{arcana:9}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"psychic; bludgeoning, piercing, and slashing from nonmagical weapons",condition_immunities:"charmed, frightened",senses:"truesight 120 ft., passive Perception 20",languages:"Common, Sphinx",cr:"17",bestiary:!0,traits:[{name:"Inscrutable",desc:"The sphinx is immune to any effect that would sense its emotions or read its thoughts, as well as any divination spell that it refuses. Wisdom (Insight) checks made to ascertain the sphinx's intentions or sincerity have disadvantage.",attack_bonus:0},{name:"Magic Weapons",desc:"The sphinx's weapon attacks are magical.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The sphinx makes two claw attacks.",attack_bonus:0},{name:"Claw",desc:"Melee Weapon Attack: +12 to hit, reach 5 ft., one target. Hit: 17 (2d10 + 6) slashing damage.",attack_bonus:12,damage_dice:"2d10",damage_bonus:6},{name:"Roar (3/Day)",desc:`The sphinx emits a magical roar. Each time it roars before finishing a long rest, the roar is louder and the effect is different, as detailed below. Each creature within 500 feet of the sphinx and able to hear the roar must make a saving throw. First Roar. Each creature that fails a DC 18 Wisdom saving throw is frightened for 1 minute. A frightened creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. Second Roar. Each creature that fails a DC 18 Wisdom saving throw is deafened and frightened for 1 minute. A frightened creature is paralyzed and can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. Third Roar. Each creature makes a DC 18 Constitution saving throw. On a failed save, a creature takes 44 (8d10) thunder damage and is knocked prone. On a successful save, the creature takes half as much damage and isn't knocked prone.`,attack_bonus:0}],legendary_actions:[{name:"Claw Attack",desc:"The sphinx makes one claw attack.",attack_bonus:0},{name:"Teleport (Costs 2 Actions)",desc:"The sphinx magically teleports, along with any equipment it is wearing or carrying, up to 120 feet to an unoccupied space it can see.",attack_bonus:0},{name:"Cast a Spell (Costs 3 Actions)",desc:"The sphinx casts a spell from its list of prepared spells, using a spell slot as normal.",attack_bonus:0}],spells:["The sphinx is a 12th-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 18, +10 to hit with spell attacks). It requires no material components to cast its spells. The sphinx has the following cleric spells prepared:",{"Cantrips (at will)":"sacred flame, spare the dying, thaumaturgy"},{"1st level (4 slots)":"command, detect evil and good, detect magic"},{"2nd level (3 slots)":"lesser restoration, zone of truth"},{"3rd level (3 slots)":"dispel magic, tongues"},{"4th level (3 slots)":"banishment, freedom of movement"},{"5th level (2 slots)":"flame strike, greater restoration"},{"6th level (1 slot)":"heroes' feast"}]},{name:"Animated Armor",source:"5e SRD",size:"Medium",type:"construct",subtype:"",alignment:"unaligned",ac:18,hp:33,hit_dice:"6d8 + 6",speed:"25 ft.",stats:[14,11,13,1,3,1],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison, psychic",condition_immunities:"blinded, charmed, deafened, exhaustion, frightened, paralyzed, petrified, poisoned",senses:"blindsight 60 ft. (blind beyond this radius), passive Perception 6",languages:"",cr:"1",bestiary:!0,traits:[{name:"Antimagic Susceptibility",desc:"The armor is incapacitated while in the area of an antimagic field. If targeted by dispel magic, the armor must succeed on a Constitution saving throw against the caster's spell save DC or fall unconscious for 1 minute.",attack_bonus:0},{name:"False Appearance",desc:"While the armor remains motionless, it is indistinguishable from a normal suit of armor.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The armor makes two melee attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) bludgeoning damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Ankheg",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"unaligned",ac:14,hp:39,hit_dice:"6d10 + 6",speed:"30 ft., burrow 10 ft.",stats:[17,11,13,1,13,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., tremorsense 60 ft., passive Perception 11",languages:"",cr:"2",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) slashing damage plus 3 (1d6) acid damage. If the target is a Large or smaller creature, it is grappled (escape DC 13). Until this grapple ends, the ankheg can bite only the grappled creature and has advantage on attack rolls to do so.",attack_bonus:5,damage_dice:"2d6 + 1d6",damage_bonus:3},{name:"Acid Spray (Recharge 6)",desc:"The ankheg spits acid in a line that is 30 ft. long and 5 ft. wide, provided that it has no creature grappled. Each creature in that line must make a DC 13 Dexterity saving throw, taking 10 (3d6) acid damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"3d6"}]},{name:"Ape",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:19,hit_dice:"3d8 + 5",speed:"30 ft., climb 30 ft.",stats:[16,14,14,6,12,7],skillsaves:[{athletics:5},{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"1/2",bestiary:!0,actions:[{name:"Multiattack",desc:"The ape makes two fist attacks.",attack_bonus:0},{name:"Fist",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) bludgeoning damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Rock",desc:"Ranged Weapon Attack: +5 to hit, range 25/50 ft., one target. Hit: 6 (1d6 + 3) bludgeoning damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3}]},{name:"Archmage",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:12,hp:99,hit_dice:"18d8 + 18",speed:"30 ft.",stats:[10,14,12,20,15,16],saves:[{intelligence:9},{wisdom:6}],skillsaves:[{arcana:13},{history:13}],damage_vulnerabilities:"",damage_resistances:"damage from spells; non magical bludgeoning, piercing, and slashing (from stoneskin)",damage_immunities:"",condition_immunities:"",senses:"passive Perception 12",languages:"any six languages",cr:"12",bestiary:!0,traits:[{name:"Magic Resistance",desc:"The archmage has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Dagger",desc:"Melee or Ranged Weapon Attack: +6 to hit, reach 5 ft. or range 20/60 ft., one target. Hit: 4 (1d4 + 2) piercing damage.",attack_bonus:6,damage_dice:"1d4",damage_bonus:2}],spells:["The archmage is an 18th-level spellcaster. Its spellcasting ability is Intelligence (spell save DC 17, +9 to hit with spell attacks). The archmage can cast disguise self and invisibility at will and has the following wizard spells prepared:",{"Cantrips (at will)":"fire bolt, light, mage hand, prestidigitation, shocking grasp"},{"1st level (4 slots)":"detect magic, identify, mage armor*, magic missile"},{"2nd level (3 slots)":"detect thoughts, mirror image, misty step"},{"3rd level (3 slots)":"counterspell,fly, lightning bolt"},{"4th level (3 slots)":"banishment, fire shield, stoneskin*"},{"5th level (3 slots)":"cone of cold, scrying, wall of force"},{"6th level (1 slot)":"globe of invulnerability"},{"7th level (1 slot)":"teleport"},{"8th level (1 slot)":"mind blank*"},{"9th level (1 slot)":"time stop"},"* The archmage casts these spells on itself before combat."]},{name:"Assassin",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any non-good alignment",ac:15,hp:78,hit_dice:"12d8 + 24",speed:"30 ft.",stats:[11,16,14,13,11,10],saves:[{dexterity:6},{intelligence:4}],skillsaves:[{acrobatics:6},{deception:3},{perception:3},{stealth:9}],damage_vulnerabilities:"",damage_resistances:"poison",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"Thieves' cant plus any two languages",cr:"8",bestiary:!0,traits:[{name:"Assassinate",desc:"During its first turn, the assassin has advantage on attack rolls against any creature that hasn't taken a turn. Any hit the assassin scores against a surprised creature is a critical hit.",attack_bonus:0},{name:"Evasion",desc:"If the assassin is subjected to an effect that allows it to make a Dexterity saving throw to take only half damage, the assassin instead takes no damage if it succeeds on the saving throw, and only half damage if it fails.",attack_bonus:0},{name:"Sneak Attack (1/Turn)",desc:"The assassin deals an extra 13 (4d6) damage when it hits a target with a weapon attack and has advantage on the attack roll, or when the target is within 5 ft. of an ally of the assassin that isn't incapacitated and the assassin doesn't have disadvantage on the attack roll.",attack_bonus:0,damage_dice:"4d6"}],actions:[{name:"Multiattack",desc:"The assassin makes two shortsword attacks.",attack_bonus:0},{name:"Shortsword",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) piercing damage, and the target must make a DC 15 Constitution saving throw, taking 24 (7d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:6,damage_dice:"1d6",damage_bonus:3},{name:"Light Crossbow",desc:"Ranged Weapon Attack: +6 to hit, range 80/320 ft., one target. Hit: 7 (1d8 + 3) piercing damage, and the target must make a DC 15 Constitution saving throw, taking 24 (7d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:6,damage_dice:"1d8",damage_bonus:3}]},{name:"Awakened Shrub",source:"5e SRD",size:"Small",type:"plant",subtype:"",alignment:"unaligned",ac:9,hp:10,hit_dice:"3d6 + -1",speed:"20 ft.",stats:[3,8,11,10,10,6],damage_vulnerabilities:"fire",damage_resistances:"piercing",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"one language known by its creator",cr:"0",bestiary:!0,traits:[{name:"False Appearance",desc:"While the shrub remains motionless, it is indistinguishable from a normal shrub.",attack_bonus:0}],actions:[{name:"Rake",desc:"Melee Weapon Attack: +1 to hit, reach 5 ft., one target. Hit: 1 (1d4 \u2014 1) slashing damage.",attack_bonus:1,damage_dice:"1d4",damage_bonus:-1}]},{name:"Awakened Tree",source:"5e SRD",size:"Huge",type:"plant",subtype:"",alignment:"unaligned",ac:13,hp:59,hit_dice:"7d12 + 13",speed:"20 ft.",stats:[19,6,15,10,10,7],damage_vulnerabilities:"fire",damage_resistances:"bludgeoning, piercing",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"one language known by its creator",cr:"2",bestiary:!0,traits:[{name:"False Appearance",desc:"While the tree remains motionless, it is indistinguishable from a normal tree.",attack_bonus:0}],actions:[{name:"Slam",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one target. Hit: 14 (3d6 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"3d6",damage_bonus:4}]},{name:"Axe Beak",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:19,hit_dice:"3d10 + 2",speed:"50 ft.",stats:[14,12,12,2,10,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"1/4",bestiary:!0,actions:[{name:"Beak",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 6 (1d8 + 2) slashing damage.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2}]},{name:"Azer",source:"5e SRD",size:"Medium",type:"elemental",subtype:"",alignment:"lawful neutral",ac:17,hp:39,hit_dice:"6d8 + 12",speed:"30 ft.",stats:[17,12,15,12,13,10],saves:[{constitution:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"passive Perception 11",languages:"Ignan",cr:"2",bestiary:!0,traits:[{name:"Heated Body",desc:"A creature that touches the azer or hits it with a melee attack while within 5 ft. of it takes 5 (1d10) fire damage.",attack_bonus:0,damage_dice:"1d10"},{name:"Heated Weapons",desc:"When the azer hits with a metal melee weapon, it deals an extra 3 (1d6) fire damage (included in the attack).",attack_bonus:0},{name:"Illumination",desc:"The azer sheds bright light in a 10-foot radius and dim light for an additional 10 ft..",attack_bonus:0}],actions:[{name:"Warhammer",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) bludgeoning damage, or 8 (1d10 + 3) bludgeoning damage if used with two hands to make a melee attack, plus 3 (1d6) fire damage.",attack_bonus:5,damage_dice:"1d8 + 1d6",damage_bonus:3}]},{name:"Baboon",source:"5e SRD",size:"Small",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:3,hit_dice:"1d6 + -1",speed:"30 ft., climb 30 ft.",stats:[8,14,11,4,12,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 11",languages:"",cr:"0",bestiary:!0,traits:[{name:"Pack Tactics",desc:"The baboon has advantage on an attack roll against a creature if at least one of the baboon's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +1 to hit, reach 5 ft., one target. Hit: 1 (1d4 \u2014 1) piercing damage.",attack_bonus:1,damage_dice:"1d4",damage_bonus:-1}]},{name:"Badger",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:3,hit_dice:"1d4",speed:"20 ft., burrow 5 ft.",stats:[4,11,12,2,12,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 11",languages:"",cr:"0",bestiary:!0,traits:[{name:"Keen Smell",desc:"The badger has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 1 piercing damage.",attack_bonus:2,damage_bonus:1}]},{name:"Balor",source:"5e SRD",size:"Huge",type:"fiend",subtype:"demon",alignment:"chaotic evil",ac:19,hp:262,hit_dice:"21d12 + 125",speed:"40 ft., fly 80 ft.",stats:[26,15,22,20,16,22],saves:[{strength:14},{constitution:12},{wisdom:9},{charisma:12}],damage_vulnerabilities:"",damage_resistances:"cold, lightning; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"truesight 120 ft., passive Perception 13",languages:"Abyssal, telepathy 120 ft.",cr:"19",bestiary:!0,traits:[{name:"Death Throes",desc:"When the balor dies, it explodes, and each creature within 30 feet of it must make a DC 20 Dexterity saving throw, taking 70 (20d6) fire damage on a failed save, or half as much damage on a successful one. The explosion ignites flammable objects in that area that aren't being worn or carried, and it destroys the balor's weapons.",attack_bonus:0,damage_dice:"20d6"},{name:"Fire Aura",desc:"At the start of each of the balor's turns, each creature within 5 feet of it takes 10 (3d6) fire damage, and flammable objects in the aura that aren't being worn or carried ignite. A creature that touches the balor or hits it with a melee attack while within 5 feet of it takes 10 (3d6) fire damage.",attack_bonus:0,damage_dice:"3d6"},{name:"Magic Resistance",desc:"The balor has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Magic Weapons",desc:"The balor's weapon attacks are magical.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The balor makes two attacks: one with its longsword and one with its whip.",attack_bonus:0},{name:"Longsword",desc:"Melee Weapon Attack: +14 to hit, reach 10 ft., one target. Hit: 21 (3d8 + 8) slashing damage plus 13 (3d8) lightning damage. If the balor scores a critical hit, it rolls damage dice three times, instead of twice.",attack_bonus:14,damage_dice:"3d8 + 3d8",damage_bonus:8},{name:"Whip",desc:"Melee Weapon Attack: +14 to hit, reach 30 ft., one target. Hit: 15 (2d6 + 8) slashing damage plus 10 (3d6) fire damage, and the target must succeed on a DC 20 Strength saving throw or be pulled up to 25 feet toward the balor.",attack_bonus:14,damage_dice:"2d6 + 3d6",damage_bonus:8},{name:"Teleport",desc:"The balor magically teleports, along with any equipment it is wearing or carrying, up to 120 feet to an unoccupied space it can see.",attack_bonus:0},{name:"Variant: Summon Demon (1/Day)",desc:`The demon chooses what to summon and attempts a magical summoning. A balor has a 50 percent chance of summoning 1d8 vrocks, 1d6 hezrous, 1d4 glabrezus, 1d3 nalfeshnees, 1d2 mariliths, or one goristro. A summoned demon appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other demons. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.`,attack_bonus:0}]},{name:"Bandit",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any non-lawful alignment",ac:12,hp:11,hit_dice:"2d8 + 2",speed:"30 ft.",stats:[11,12,12,10,10,10],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"any one language (usually Common)",cr:"1/8",bestiary:!0,actions:[{name:"Scimitar",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) slashing damage.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1},{name:"Light Crossbow",desc:"Ranged Weapon Attack: +3 to hit, range 80 ft./320 ft., one target. Hit: 5 (1d8 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d8",damage_bonus:1}]},{name:"Bandit Captain",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any non-lawful alignment",ac:15,hp:65,hit_dice:"10d8 + 20",speed:"30 ft.",stats:[15,16,14,14,11,14],saves:[{strength:4},{dexterity:5},{wisdom:2}],skillsaves:[{athletics:4},{deception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"any two languages",cr:"2",bestiary:!0,actions:[{name:"Multiattack",desc:"The captain makes three melee attacks: two with its scimitar and one with its dagger. Or the captain makes two ranged attacks with its daggers.",attack_bonus:0},{name:"Scimitar",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Dagger",desc:"Melee or Ranged Weapon Attack: +5 to hit, reach 5 ft. or range 20/60 ft., one target. Hit: 5 (1d4 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d4",damage_bonus:3}],reactions:[{name:"Parry",desc:"The captain adds 2 to its AC against one melee attack that would hit it. To do so, the captain must see the attacker and be wielding a melee weapon.",attack_bonus:0}]},{name:"Barbed Devil",source:"5e SRD",size:"Medium",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:15,hp:110,hit_dice:"13d8 + 51",speed:"30 ft.",stats:[16,17,18,12,14,14],saves:[{strength:6},{constitution:7},{wisdom:5},{charisma:5}],skillsaves:[{deception:5},{insight:5},{perception:8}],damage_vulnerabilities:"",damage_resistances:"cold; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"darkvision 120 ft., passive Perception 18",languages:"Infernal, telepathy 120 ft.",cr:"5",bestiary:!0,traits:[{name:"Barbed Hide",desc:"At the start of each of its turns, the barbed devil deals 5 (1d10) piercing damage to any creature grappling it.",attack_bonus:0,damage_dice:"1d10"},{name:"Devil's Sight",desc:"Magical darkness doesn't impede the devil's darkvision.",attack_bonus:0},{name:"Magic Resistance",desc:"The devil has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The devil makes three melee attacks: one with its tail and two with its claws. Alternatively, it can use Hurl Flame twice.",attack_bonus:0},{name:"Claw",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft ., one target. Hit: 6 (1d6 + 3) piercing damage.",attack_bonus:6,damage_dice:"1d6",damage_bonus:3},{name:"Tail",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) piercing damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:3},{name:"Hurl Flame",desc:"Ranged Spell Attack: +5 to hit, range 150 ft., one target. Hit: 10 (3d6) fire damage. If the target is a flammable object that isn't being worn or carried, it also catches fire.",attack_bonus:5,damage_dice:"3d6"}]},{name:"Basilisk",source:"5e SRD",size:"Medium",type:"monstrosity",subtype:"",alignment:"unaligned",ac:12,hp:52,hit_dice:"8d8 + 16",speed:"20 ft.",stats:[16,8,15,2,8,7],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 9",languages:"",cr:"3",bestiary:!0,traits:[{name:"Petrifying Gaze",desc:`If a creature starts its turn within 30 ft. of the basilisk and the two of them can see each other, the basilisk can force the creature to make a DC 12 Constitution saving throw if the basilisk isn't incapacitated. On a failed save, the creature magically begins to turn to stone and is restrained. It must repeat the saving throw at the end of its next turn. On a success, the effect ends. On a failure, the creature is petrified until freed by the greater restoration spell or other magic. A creature that isn't surprised can avert its eyes to avoid the saving throw at the start of its turn. If it does so, it can't see the basilisk until the start of its next turn, when it can avert its eyes again. If it looks at the basilisk in the meantime, it must immediately make the save. If the basilisk sees its reflection within 30 ft. of it in bright light, it mistakes itself for a rival and targets itself with its gaze.`,attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) piercing damage plus 7 (2d6) poison damage.",attack_bonus:5,damage_dice:"2d6 + 2d6",damage_bonus:3}]},{name:"Bat",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:1,hit_dice:"1d4 + -2",speed:"5 ft., fly 30 ft.",stats:[2,15,8,2,12,4],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 60 ft., passive Perception 11",languages:"",cr:"0",bestiary:!0,traits:[{name:"Echolocation",desc:"The bat can't use its blindsight while deafened.",attack_bonus:0},{name:"Keen Hearing",desc:"The bat has advantage on Wisdom (Perception) checks that rely on hearing.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +0 to hit, reach 5 ft., one creature. Hit: 1 piercing damage.",attack_bonus:0,damage_bonus:1}]},{name:"Bearded Devil",source:"5e SRD",size:"Medium",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:13,hp:52,hit_dice:"8d8 + 16",speed:"30 ft.",stats:[16,15,15,9,11,11],saves:[{strength:5},{constitution:4},{wisdom:2}],damage_vulnerabilities:"",damage_resistances:"cold; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"darkvision 120 ft., passive Perception 10",languages:"Infernal, telepathy 120 ft.",cr:"3",bestiary:!0,traits:[{name:"Devil's Sight",desc:"Magical darkness doesn't impede the devil's darkvision.",attack_bonus:0},{name:"Magic Resistance",desc:"The devil has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Steadfast",desc:"The devil can't be frightened while it can see an allied creature within 30 feet of it.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The devil makes two attacks: one with its beard and one with its glaive.",attack_bonus:0},{name:"Beard",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one creature. Hit: 6 (1d8 + 2) piercing damage, and the target must succeed on a DC 12 Constitution saving throw or be poisoned for 1 minute. While poisoned in this way, the target can't regain hit points. The target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:5,damage_dice:"1d8",damage_bonus:2},{name:"Glaive",desc:"Melee Weapon Attack: +5 to hit, reach 10 ft., one target. Hit: 8 (1d10 + 3) slashing damage. If the target is a creature other than an undead or a construct, it must succeed on a DC 12 Constitution saving throw or lose 5 (1d10) hit points at the start of each of its turns due to an infernal wound. Each time the devil hits the wounded target with this attack, the damage dealt by the wound increases by 5 (1d10). Any creature can take an action to stanch the wound with a successful DC 12 Wisdom (Medicine) check. The wound also closes if the target receives magical healing.",attack_bonus:5,damage_dice:"1d10",damage_bonus:3}]},{name:"Behir",source:"5e SRD",size:"Huge",type:"monstrosity",subtype:"",alignment:"neutral evil",ac:17,hp:168,hit_dice:"16d12 + 64",speed:"50 ft., climb 40 ft.",stats:[23,16,18,7,14,12],skillsaves:[{perception:6},{stealth:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning",condition_immunities:"",senses:"darkvision 90 ft., passive Perception 16",languages:"Draconic",cr:"11",bestiary:!0,actions:[{name:"Multiattack",desc:"The behir makes two attacks: one with its bite and one to constrict.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 22 (3d10 + 6) piercing damage.",attack_bonus:10,damage_dice:"3d10",damage_bonus:6},{name:"Constrict",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one Large or smaller creature. Hit: 17 (2d10 + 6) bludgeoning damage plus 17 (2d10 + 6) slashing damage. The target is grappled (escape DC 16) if the behir isn't already constricting a creature, and the target is restrained until this grapple ends.",attack_bonus:10,damage_dice:"2d10 + 2d10",damage_bonus:6},{name:"Lightning Breath (Recharge 5-6)",desc:"The behir exhales a line of lightning that is 20 ft. long and 5 ft. wide. Each creature in that line must make a DC 16 Dexterity saving throw, taking 66 (12d10) lightning damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"12d10"},{name:"Swallow",desc:`The behir makes one bite attack against a Medium or smaller target it is grappling. If the attack hits, the target is also swallowed, and the grapple ends. While swallowed, the target is blinded and restrained, it has total cover against attacks and other effects outside the behir, and it takes 21 (6d6) acid damage at the start of each of the behir's turns. A behir can have only one creature swallowed at a time. If the behir takes 30 damage or more on a single turn from the swallowed creature, the behir must succeed on a DC 14 Constitution saving throw at the end of that turn or regurgitate the creature, which falls prone in a space within 10 ft. of the behir. If the behir dies, a swallowed creature is no longer restrained by it and can escape from the corpse by using 15 ft. of movement, exiting prone.`,attack_bonus:0,damage_dice:"6d6"}]},{name:"Berserker",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any chaotic alignment",ac:13,hp:67,hit_dice:"9d8 + 26",speed:"30 ft.",stats:[16,12,17,9,11,9],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"any one language (usually Common)",cr:"2",bestiary:!0,traits:[{name:"Reckless",desc:"At the start of its turn, the berserker can gain advantage on all melee weapon attack rolls during that turn, but attack rolls against it have advantage until the start of its next turn.",attack_bonus:0}],actions:[{name:"Greataxe",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 9 (1d12 + 3) slashing damage.",attack_bonus:5,damage_dice:"1d12",damage_bonus:3}]},{name:"Black Bear",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:19,hit_dice:"3d8 + 5",speed:"40 ft., climb 30 ft.",stats:[15,10,14,2,12,7],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Keen Smell",desc:"The bear has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The bear makes two attacks: one with its bite and one with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:3,damage_dice:"1d6",damage_bonus:2},{name:"Claws",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 7 (2d4 + 2) slashing damage.",attack_bonus:3,damage_dice:"2d4",damage_bonus:2}]},{name:"Black Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"chaotic evil",ac:17,hp:33,hit_dice:"6d8 + 6",speed:"30 ft., fly 60 ft., swim 30 ft.",stats:[15,14,13,10,11,13],saves:[{dexterity:4},{constitution:3},{wisdom:2},{charisma:3}],skillsaves:[{perception:4},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"2",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (1d10 + 2) piercing damage plus 2 (1d4) acid damage.",attack_bonus:4,damage_dice:"1d10",damage_bonus:2},{name:"Acid Breath (Recharge 5-6)",desc:"The dragon exhales acid in a 15-foot line that is 5 feet wide. Each creature in that line must make a DC 11 Dexterity saving throw, taking 22 (Sd8) acid damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"5d8"}]},{name:"Black Pudding",source:"5e SRD",size:"Large",type:"ooze",subtype:"",alignment:"unaligned",ac:7,hp:85,hit_dice:"10d10 + 30",speed:"20 ft., climb 20 ft.",stats:[16,5,16,1,6,1],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid, cold, lightning, slashing",condition_immunities:"blinded, charmed, deafened, exhaustion, frightened, prone",senses:"blindsight 60 ft. (blind beyond this radius), passive Perception 8",languages:"",cr:"4",bestiary:!0,traits:[{name:"Amorphous",desc:"The pudding can move through a space as narrow as 1 inch wide without squeezing.",attack_bonus:0},{name:"Corrosive Form",desc:"A creature that touches the pudding or hits it with a melee attack while within 5 feet of it takes 4 (1d8) acid damage. Any nonmagical weapon made of metal or wood that hits the pudding corrodes. After dealing damage, the weapon takes a permanent and cumulative -1 penalty to damage rolls. If its penalty drops to -5, the weapon is destroyed. Nonmagical ammunition made of metal or wood that hits the pudding is destroyed after dealing damage. The pudding can eat through 2-inch-thick, nonmagical wood or metal in 1 round.",attack_bonus:0,damage_dice:"1d8"},{name:"Spider Climb",desc:"The pudding can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0}],actions:[{name:"Pseudopod",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) bludgeoning damage plus 18 (4d8) acid damage. In addition, nonmagical armor worn by the target is partly dissolved and takes a permanent and cumulative -1 penalty to the AC it offers. The armor is destroyed if the penalty reduces its AC to 10.",attack_bonus:5,damage_dice:"1d6 + 4d8",damage_bonus:3}],reactions:[{name:"Split",desc:"When a pudding that is Medium or larger is subjected to lightning or slashing damage, it splits into two new puddings if it has at least 10 hit points. Each new pudding has hit points equal to half the original pudding's, rounded down. New puddings are one size smaller than the original pudding.",attack_bonus:0}]},{name:"Blink Dog",source:"5e SRD",size:"Medium",type:"fey",subtype:"",alignment:"lawful good",ac:13,hp:22,hit_dice:"4d8 + 4",speed:"40 ft.",stats:[12,17,12,10,13,11],skillsaves:[{perception:3},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"Blink Dog, understands Sylvan but can't speak it",cr:"1/4",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The dog has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1},{name:"Teleport (Recharge 4-6)",desc:"The dog magically teleports, along with any equipment it is wearing or carrying, up to 40 ft. to an unoccupied space it can see. Before or after teleporting, the dog can make one bite attack.",attack_bonus:0}]},{name:"Blood Hawk",source:"5e SRD",size:"Small",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:7,hit_dice:"2d6",speed:"10 ft., fly 60 ft.",stats:[6,14,10,3,14,5],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"",cr:"1/8",bestiary:!0,traits:[{name:"Keen Sight",desc:"The hawk has advantage on Wisdom (Perception) checks that rely on sight.",attack_bonus:0},{name:"Pack Tactics",desc:"The hawk has advantage on an attack roll against a creature if at least one of the hawk's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Beak",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 4 (1d4 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Blue Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"lawful evil",ac:17,hp:52,hit_dice:"8d8 + 16",speed:"30 ft., burrow 15 ft., fly 60 ft.",stats:[17,10,15,12,11,15],saves:[{dexterity:2},{constitution:4},{wisdom:2},{charisma:4}],skillsaves:[{perception:4},{stealth:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"3",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 8 (1d10 + 3) piercing damage plus 3 (1d6) lightning damage.",attack_bonus:5,damage_dice:"1d10 + 1d6",damage_bonus:3},{name:"Lightning Breath (Recharge 5-6)",desc:"The dragon exhales lightning in a 30-foot line that is 5 feet wide. Each creature in that line must make a DC 12 Dexterity saving throw, taking 22 (4d10) lightning damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"4d10"}]},{name:"Boar",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:11,hit_dice:"2d8 + 2",speed:"40 ft.",stats:[13,11,12,2,9,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 9",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Charge",desc:"If the boar moves at least 20 ft. straight toward a target and then hits it with a tusk attack on the same turn, the target takes an extra 3 (1d6) slashing damage. If the target is a creature, it must succeed on a DC 11 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"1d6"},{name:"Relentless (Recharges after a Short or Long Rest)",desc:"If the boar takes 7 damage or less that would reduce it to 0 hit points, it is reduced to 1 hit point instead.",attack_bonus:0}],actions:[{name:"Tusk",desc:"Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) slashing damage.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Bone Devil",source:"5e SRD",size:"Large",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:19,hp:142,hit_dice:"15d10 + 59",speed:"40 ft., fly 40 ft.",stats:[18,16,18,13,14,16],saves:[{intelligence:5},{wisdom:6},{charisma:7}],skillsaves:[{deception:7},{insight:6}],damage_vulnerabilities:"",damage_resistances:"cold; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"darkvision 120 ft., passive Perception 9",languages:"Infernal, telepathy 120 ft.",cr:"12",bestiary:!0,traits:[{name:"Devil's Sight",desc:"Magical darkness doesn't impede the devil's darkvision.",attack_bonus:0},{name:"Magic Resistance",desc:"The devil has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The devil makes three attacks: two with its claws and one with its sting.",attack_bonus:0},{name:"Multiattack",desc:"The devil makes three attacks: two with its claws and one with its sting.",attack_bonus:0},{name:"Claw",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target. Hit: 8 (1d8 + 4) slashing damage.",attack_bonus:8,damage_dice:"1d8",damage_bonus:4},{name:"Claw",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target. Hit: 8 (1d8 + 4) slashing damage.",attack_bonus:8,damage_dice:"1d8",damage_bonus:4},{name:"Sting",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target. Hit: 13 (2d8 + 4) piercing damage plus 17 (5d6) poison damage, and the target must succeed on a DC 14 Constitution saving throw or become poisoned for 1 minute. The target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success .",attack_bonus:8,damage_dice:"2d8",damage_bonus:4},{name:"Sting",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target. Hit: 13 (2d8 + 4) piercing damage plus 17 (5d6) poison damage, and the target must succeed on a DC 14 Constitution saving throw or become poisoned for 1 minute. The target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success .",attack_bonus:8,damage_dice:"2d8",damage_bonus:4}]},{name:"Brass Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"chaotic good",ac:16,hp:16,hit_dice:"3d8 + 2",speed:"30 ft., burrow 15 ft., fly 60 ft.",stats:[15,10,13,10,11,13],saves:[{dexterity:2},{constitution:3},{wisdom:2},{charisma:3}],skillsaves:[{perception:4},{stealth:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"1",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (1d10 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d10",damage_bonus:2},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Fire Breath. The dragon exhales fire in an 20-foot line that is 5 feet wide. Each creature in that line must make a DC 11 Dexterity saving throw, taking 14 (4d6) fire damage on a failed save, or half as much damage on a successful one. Sleep Breath. The dragon exhales sleep gas in a 15-foot cone. Each creature in that area must succeed on a DC 11 Constitution saving throw or fall unconscious for 1 minute. This effect ends for a creature if the creature takes damage or someone uses an action to wake it.`,attack_bonus:0,damage_dice:"4d6"}]},{name:"Bronze Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"lawful good",ac:17,hp:32,hit_dice:"5d8 + 9",speed:"30 ft., fly 60 ft., swim 30 ft.",stats:[17,10,15,12,11,15],saves:[{dexterity:2},{constitution:4},{wisdom:2},{charisma:4}],skillsaves:[{perception:4},{stealth:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"2",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 8 (1d10 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d10",damage_bonus:3},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Lightning Breath. The dragon exhales lightning in a 40-foot line that is 5 feet wide. Each creature in that line must make a DC 12 Dexterity saving throw, taking 16 (3d10) lightning damage on a failed save, or half as much damage on a successful one. Repulsion Breath. The dragon exhales repulsion energy in a 30-foot cone. Each creature in that area must succeed on a DC 12 Strength saving throw. On a failed save, the creature is pushed 30 feet away from the dragon.`,attack_bonus:0,damage_dice:"3d10"}]},{name:"Brown Bear",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:34,hit_dice:"4d10 + 12",speed:"40 ft., climb 30 ft.",stats:[19,10,16,2,13,7],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"1",bestiary:!0,traits:[{name:"Keen Smell",desc:"The bear has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The bear makes two attacks: one with its bite and one with its claws.",attack_bonus:0},{name:"Bite",desc:"Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 8 (1d8 + 4) piercing damage.",attack_bonus:5,damage_dice:"1d8",damage_bonus:4},{name:"Claws",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:5,damage_dice:"2d6",damage_bonus:4}]},{name:"Bugbear",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"goblinoid",alignment:"chaotic evil",ac:16,hp:27,hit_dice:"5d8 + 4",speed:"30 ft.",stats:[15,14,13,8,11,9],skillsaves:[{stealth:6},{survival:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"Common, Goblin",cr:"1",bestiary:!0,traits:[{name:"Brute",desc:"A melee weapon deals one extra die of its damage when the bugbear hits with it (included in the attack).",attack_bonus:0},{name:"Surprise Attack",desc:"If the bugbear surprises a creature and hits it with an attack during the first round of combat, the target takes an extra 7 (2d6) damage from the attack.",attack_bonus:0,damage_dice:"2d6"}],actions:[{name:"Morningstar",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 11 (2d8 + 2) piercing damage.",attack_bonus:4,damage_dice:"2d8",damage_bonus:2},{name:"Javelin",desc:"Melee or Ranged Weapon Attack: +4 to hit, reach 5 ft. or range 30/120 ft., one target. Hit: 9 (2d6 + 2) piercing damage in melee or 5 (1d6 + 2) piercing damage at range.",attack_bonus:4,damage_dice:"2d6",damage_bonus:2}]},{name:"Bulette",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"unaligned",ac:17,hp:94,hit_dice:"9d10 + 44",speed:"40 ft., burrow 40 ft.",stats:[19,11,21,2,10,5],skillsaves:[{perception:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., tremorsense 60 ft., passive Perception 16",languages:"",cr:"5",bestiary:!0,traits:[{name:"Standing Leap",desc:"The bulette's long jump is up to 30 ft. and its high jump is up to 15 ft., with or without a running start.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 30 (4d12 + 4) piercing damage.",attack_bonus:7,damage_dice:"4d12",damage_bonus:4},{name:"Deadly Leap",desc:"If the bulette jumps at least 15 ft. as part of its movement, it can then use this action to land on its ft. in a space that contains one or more other creatures. Each of those creatures must succeed on a DC 16 Strength or Dexterity saving throw (target's choice) or be knocked prone and take 14 (3d6 + 4) bludgeoning damage plus 14 (3d6 + 4) slashing damage. On a successful save, the creature takes only half the damage, isn't knocked prone, and is pushed 5 ft. out of the bulette's space into an unoccupied space of the creature's choice. If no unoccupied space is within range, the creature instead falls prone in the bulette's space.",attack_bonus:0}]},{name:"Camel",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:9,hp:15,hit_dice:"2d10 + 4",speed:"50 ft.",stats:[16,8,14,2,8,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 9",languages:"",cr:"1/8",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 2 (1d4) bludgeoning damage.",attack_bonus:5,damage_dice:"1d4"}]},{name:"Carrion Crawler",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"unaligned",ac:13,hp:51,hit_dice:"6d10 + 18",speed:"30 ft., climb 30 ft.",stats:[14,13,16,1,12,5],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 13",languages:"",cr:"2",bestiary:!0,traits:[{name:"Keen Smell",desc:"The carrion crawler has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0},{name:"Spider Climb",desc:"The carrion crawler can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The carrion crawler makes two attacks: one with its tentacles and one with its bite.",attack_bonus:0},{name:"Tentacles",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one creature. Hit: 4 (1d4 + 2) poison damage, and the target must succeed on a DC 13 Constitution saving throw or be poisoned for 1 minute. Until this poison ends, the target is paralyzed. The target can repeat the saving throw at the end of each of its turns, ending the poison on itself on a success.",attack_bonus:8,damage_dice:"1d4",damage_bonus:2},{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (2d4 + 2) piercing damage.",attack_bonus:4,damage_dice:"2d4",damage_bonus:2}]},{name:"Cat",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:2,hit_dice:"1d4 + -1",speed:"40 ft., climb 30 ft.",stats:[3,15,10,3,12,7],skillsaves:[{perception:3},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"0",bestiary:!0,traits:[{name:"Keen Smell",desc:"The cat has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Claws",desc:"Melee Weapon Attack: +0 to hit, reach 5 ft., one target. Hit: 1 slashing damage.",attack_bonus:0,damage_bonus:1}]},{name:"Cave Bear",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:42,hit_dice:"5d10 + 14",speed:"40 ft., swim 30 ft.",stats:[20,10,16,2,13,7],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 13",languages:"",cr:"2",bestiary:!0,traits:[{name:"Keen Smell",desc:"The bear has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The bear makes two attacks: one with its bite and one with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 9 (1d8 + 5) piercing damage.",attack_bonus:7,damage_dice:"1d8",damage_bonus:5},{name:"Claws",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 12 (2d6 + 5) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:5}]},{name:"Centaur",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"neutral good",ac:12,hp:45,hit_dice:"6d10 + 12",speed:"50 ft.",stats:[18,14,14,9,13,11],skillsaves:[{athletics:6},{perception:3},{survival:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"Elvish, Sylvan",cr:"2",bestiary:!0,traits:[{name:"Charge",desc:"If the centaur moves at least 30 ft. straight toward a target and then hits it with a pike attack on the same turn, the target takes an extra 10 (3d6) piercing damage.",attack_bonus:0,damage_dice:"3d6"}],actions:[{name:"Multiattack",desc:"The centaur makes two attacks: one with its pike and one with its hooves or two with its longbow.",attack_bonus:0},{name:"Pike",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one target. Hit: 9 (1d10 + 4) piercing damage.",attack_bonus:6,damage_dice:"1d10",damage_bonus:4},{name:"Hooves",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4},{name:"Longbow",desc:"Ranged Weapon Attack: +4 to hit, range 150/600 ft., one target. Hit: 6 (1d8 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2}]},{name:"Chain Devil",source:"5e SRD",size:"Medium",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:16,hp:85,hit_dice:"10d8 + 40",speed:"30 ft.",stats:[18,15,18,11,12,14],damage_vulnerabilities:"",damage_resistances:"cold; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"darkvision 120 ft., passive Perception 8",languages:"Infernal, telepathy 120 ft.",cr:"11",bestiary:!0,traits:[{name:"Devil's Sight",desc:"Magical darkness doesn't impede the devil's darkvision.",attack_bonus:0},{name:"Magic Resistance",desc:"The devil has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The devil makes two attacks with its chains.",attack_bonus:0},{name:"Chain",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target. Hit: 11 (2d6 + 4) slashing damage. The target is grappled (escape DC 14) if the devil isn't already grappling a creature. Until this grapple ends, the target is restrained and takes 7 (2d6) piercing damage at the start of each of its turns.",attack_bonus:8,damage_dice:"2d6",damage_bonus:4},{name:"Animate Chains (Recharges after a Short or Long Rest)",desc:`Up to four chains the devil can see within 60 feet of it magically sprout razor-edged barbs and animate under the devil's control, provided that the chains aren't being worn or carried. Each animated chain is an object with AC 20, 20 hit points, resistance to piercing damage, and immunity to psychic and thunder damage. When the devil uses Multiattack on its turn, it can use each animated chain to make one additional chain attack. An animated chain can grapple one creature of its own but can't make attacks while grappling. An animated chain reverts to its inanimate state if reduced to 0 hit points or if the devil is incapacitated or dies.`,attack_bonus:0}],reactions:[{name:"Unnerving Mask",desc:"When a creature the devil can see starts its turn within 30 feet of the devil, the devil can create the illusion that it looks like one of the creature's departed loved ones or bitter enemies. If the creature can see the devil, it must succeed on a DC 14 Wisdom saving throw or be frightened until the end of its turn.",attack_bonus:0}]},{name:"Chimera",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"chaotic evil",ac:14,hp:114,hit_dice:"12d10 + 48",speed:"30 ft., fly 60 ft.",stats:[19,11,19,3,14,10],skillsaves:[{perception:8}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 18",languages:"understands Draconic but can't speak",cr:"6",bestiary:!0,actions:[{name:"Multiattack",desc:"The chimera makes three attacks: one with its bite, one with its horns, and one with its claws. When its fire breath is available, it can use the breath in place of its bite or horns.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) piercing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Horns",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 10 (1d12 + 4) bludgeoning damage.",attack_bonus:7,damage_dice:"1d12",damage_bonus:4},{name:"Claws",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Fire Breath (Recharge 5-6)",desc:"The dragon head exhales fire in a 15-foot cone. Each creature in that area must make a DC 15 Dexterity saving throw, taking 31 (7d8) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"7d8"}]},{name:"Chuul",source:"5e SRD",size:"Large",type:"aberration",subtype:"",alignment:"chaotic evil",ac:16,hp:93,hit_dice:"11d10 + 32",speed:"30 ft., swim 30 ft.",stats:[19,10,16,5,11,5],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 14",languages:"understands Deep Speech but can't speak",cr:"4",bestiary:!0,traits:[{name:"Amphibious",desc:"The chuul can breathe air and water.",attack_bonus:0},{name:"Sense Magic",desc:"The chuul senses magic within 120 feet of it at will. This trait otherwise works like the detect magic spell but isn't itself magical.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The chuul makes two pincer attacks. If the chuul is grappling a creature, the chuul can also use its tentacles once.",attack_bonus:0},{name:"Pincer",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one target. Hit: 11 (2d6 + 4) bludgeoning damage. The target is grappled (escape DC 14) if it is a Large or smaller creature and the chuul doesn't have two other creatures grappled.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4},{name:"Tentacles",desc:"One creature grappled by the chuul must succeed on a DC 13 Constitution saving throw or be poisoned for 1 minute. Until this poison ends, the target is paralyzed. The target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:0}]},{name:"Clay Golem",source:"5e SRD",size:"Large",type:"construct",subtype:"",alignment:"unaligned",ac:14,hp:133,hit_dice:"14d10 + 56",speed:"20 ft.",stats:[20,9,18,3,8,1],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid, poison, psychic; bludgeoning, piercing, and slashing from nonmagical weapons that aren't adamantine",condition_immunities:"charmed, exhaustion, frightened, paralyzed, petrified, poisoned",senses:"darkvision 60 ft., passive Perception 9",languages:"understands the languages of its creator but can't speak",cr:"9",bestiary:!0,traits:[{name:"Acid Absorption",desc:"Whenever the golem is subjected to acid damage, it takes no damage and instead regains a number of hit points equal to the acid damage dealt.",attack_bonus:0},{name:"Berserk",desc:"Whenever the golem starts its turn with 60 hit points or fewer, roll a d6. On a 6, the golem goes berserk. On each of its turns while berserk, the golem attacks the nearest creature it can see. If no creature is near enough to move to and attack, the golem attacks an object, with preference for an object smaller than itself. Once the golem goes berserk, it continues to do so until it is destroyed or regains all its hit points.",attack_bonus:0},{name:"Immutable Form",desc:"The golem is immune to any spell or effect that would alter its form.",attack_bonus:0},{name:"Magic Resistance",desc:"The golem has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Magic Weapons",desc:"The golem's weapon attacks are magical.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The golem makes two slam attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one target. Hit: 16 (2d10 + 5) bludgeoning damage. If the target is a creature, it must succeed on a DC 15 Constitution saving throw or have its hit point maximum reduced by an amount equal to the damage taken. The target dies if this attack reduces its hit point maximum to 0. The reduction lasts until removed by the greater restoration spell or other magic.",attack_bonus:8,damage_dice:"2d10",damage_bonus:5},{name:"Haste (Recharge 5-6)",desc:"Until the end of its next turn, the golem magically gains a +2 bonus to its AC, has advantage on Dexterity saving throws, and can use its slam attack as a bonus action.",attack_bonus:0}]},{name:"Cloaker",source:"5e SRD",size:"Large",type:"aberration",subtype:"",alignment:"chaotic neutral",ac:14,hp:78,hit_dice:"12d10 + 12",speed:"10 ft., fly 40 ft.",stats:[17,15,12,13,12,14],skillsaves:[{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 11",languages:"Deep Speech, Undercommon",cr:"8",bestiary:!0,traits:[{name:"Damage Transfer",desc:"While attached to a creature, the cloaker takes only half the damage dealt to it (rounded down). and that creature takes the other half.",attack_bonus:0},{name:"False Appearance",desc:"While the cloaker remains motionless without its underside exposed, it is indistinguishable from a dark leather cloak.",attack_bonus:0},{name:"Light Sensitivity",desc:"While in bright light, the cloaker has disadvantage on attack rolls and Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The cloaker makes two attacks: one with its bite and one with its tail.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one creature. Hit: 10 (2d6 + 3) piercing damage, and if the target is Large or smaller, the cloaker attaches to it. If the cloaker has advantage against the target, the cloaker attaches to the target's head, and the target is blinded and unable to breathe while the cloaker is attached. While attached, the cloaker can make this attack only against the target and has advantage on the attack roll. The cloaker can detach itself by spending 5 feet of its movement. A creature, including the target, can take its action to detach the cloaker by succeeding on a DC 16 Strength check.",attack_bonus:6,damage_dice:"2d6",damage_bonus:3},{name:"Tail",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one creature. Hit: 7 (1d8 + 3) slashing damage.",attack_bonus:6,damage_dice:"1d8",damage_bonus:3},{name:"Moan",desc:"Each creature within 60 feet of the cloaker that can hear its moan and that isn't an aberration must succeed on a DC 13 Wisdom saving throw or become frightened until the end of the cloaker's next turn. If a creature's saving throw is successful, the creature is immune to the cloaker's moan for the next 24 hours.",attack_bonus:0},{name:"Phantasms (Recharges after a Short or Long Rest)",desc:`The cloaker magically creates three illusory duplicates of itself if it isn't in bright light. The duplicates move with it and mimic its actions, shifting position so as to make it impossible to track which cloaker is the real one. If the cloaker is ever in an area of bright light, the duplicates disappear. Whenever any creature targets the cloaker with an attack or a harmful spell while a duplicate remains, that creature rolls randomly to determine whether it targets the cloaker or one of the duplicates. A creature is unaffected by this magical effect if it can't see or if it relies on senses other than sight. A duplicate has the cloaker's AC and uses its saving throws. If an attack hits a duplicate, or if a duplicate fails a saving throw against an effect that deals damage, the duplicate disappears.`,attack_bonus:0}]},{name:"Cloud Giant",source:"5e SRD",size:"Huge",type:"giant",subtype:"",alignment:"neutral good (50%) or neutral evil (50%)",ac:14,hp:200,hit_dice:"16d12 + 96",speed:"40 ft.",stats:[27,10,22,12,16,16],saves:[{constitution:10},{wisdom:7},{charisma:7}],skillsaves:[{insight:7},{perception:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 17",languages:"Common, Giant",cr:"9",bestiary:!0,traits:[{name:"Keen Smell",desc:"The giant has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The giant's innate spellcasting ability is Charisma. It can innately cast the following spells, requiring no material components: At will: detect magic, fog cloud, light 3/day each: feather fall, fly, misty step, telekinesis 1/day each: control weather, gaseous form`,attack_bonus:0}],actions:[{name:"Multiattack",desc:"The giant makes two morningstar attacks.",attack_bonus:0},{name:"Morningstar",desc:"Melee Weapon Attack: +12 to hit, reach 10 ft., one target. Hit: 21 (3d8 + 8) piercing damage.",attack_bonus:12,damage_dice:"3d8",damage_bonus:8},{name:"Rock",desc:"Ranged Weapon Attack: +12 to hit, range 60/240 ft., one target. Hit: 30 (4d10 + 8) bludgeoning damage.",attack_bonus:12,damage_dice:"4d10",damage_bonus:8}]},{name:"Cockatrice",source:"5e SRD",size:"Small",type:"monstrosity",subtype:"",alignment:"unaligned",ac:11,hp:27,hit_dice:"6d6 + 6",speed:"20 ft., fly 40 ft.",stats:[6,12,12,2,13,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 11",languages:"",cr:"1/2",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one creature. Hit: 3 (1d4 + 1) piercing damage, and the target must succeed on a DC 11 Constitution saving throw against being magically petrified. On a failed save, the creature begins to turn to stone and is restrained. It must repeat the saving throw at the end of its next turn. On a success, the effect ends. On a failure, the creature is petrified for 24 hours.",attack_bonus:3,damage_dice:"1d4",damage_bonus:1}]},{name:"Commoner",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:10,hp:4,hit_dice:"1d8 + -1",speed:"30 ft.",stats:[10,10,10,10,10,10],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"any one language (usually Common)",cr:"0",bestiary:!0,actions:[{name:"Club",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 2 (1d4) bludgeoning damage.",attack_bonus:2,damage_dice:"1d4"}]},{name:"Constrictor Snake",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:13,hit_dice:"2d10 + 2",speed:"30 ft., swim 30 ft.",stats:[15,14,12,1,10,3],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., passive Perception 10",languages:"",cr:"1/4",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Constrict",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 6 (1d8 + 2) bludgeoning damage, and the target is grappled (escape DC 14). Until this grapple ends, the creature is restrained, and the snake can't constrict another target.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2}]},{name:"Copper Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"chaotic good",ac:16,hp:22,hit_dice:"4d8 + 4",speed:"30 ft., climb 30 ft., fly 60 ft.",stats:[15,12,13,14,11,13],saves:[{dexterity:3},{constitution:3},{wisdom:2},{charisma:3}],skillsaves:[{perception:4},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"1",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (1d10 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d10",damage_bonus:2},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Acid Breath. The dragon exhales acid in an 20-foot line that is 5 feet wide. Each creature in that line must make a DC 11 Dexterity saving throw, taking 18 (4d8) acid damage on a failed save, or half as much damage on a successful one. Slowing Breath. The dragon exhales gas in a 1 5-foot cone. Each creature in that area must succeed on a DC 11 Constitution saving throw. On a failed save, the creature can't use reactions, its speed is halved, and it can't make more than one attack on its turn. In addition, the creature can use either an action or a bonus action on its turn, but not both. These effects last for 1 minute. The creature can repeat the saving throw at the end of each of its turns, ending the effect on itself with a successful save.`,attack_bonus:0,damage_dice:"4d8"}]},{name:"Couatl",source:"5e SRD",size:"Medium",type:"celestial",subtype:"",alignment:"lawful good",ac:19,hp:97,hit_dice:"13d8 + 38",speed:"30 ft., fly 90 ft.",stats:[16,20,17,18,20,18],saves:[{constitution:5},{wisdom:7},{charisma:6}],damage_vulnerabilities:"",damage_resistances:"radiant",damage_immunities:"psychic; bludgeoning, piercing, and slashing from nonmagical weapons",condition_immunities:"",senses:"truesight 120 ft., passive Perception 15",languages:"all, telepathy 120 ft.",cr:"4",bestiary:!0,traits:[{name:"Innate Spellcasting",desc:`The couatl's spellcasting ability is Charisma (spell save DC 14). It can innately cast the following spells, requiring only verbal components: At will: detect evil and good, detect magic, detect thoughts 3/day each: bless, create food and water, cure wounds, lesser restoration, protection from poison, sanctuary, shield 1/day each: dream, greater restoration, scrying`,attack_bonus:0},{name:"Magic Weapons",desc:"The couatl's weapon attacks are magical.",attack_bonus:0},{name:"Shielded Mind",desc:"The couatl is immune to scrying and to any effect that would sense its emotions, read its thoughts, or detect its location.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one creature. Hit: 8 (1d6 + 5) piercing damage, and the target must succeed on a DC 13 Constitution saving throw or be poisoned for 24 hours. Until this poison ends, the target is unconscious. Another creature can use an action to shake the target awake.",attack_bonus:8,damage_dice:"1d6",damage_bonus:5},{name:"Constrict",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one Medium or smaller creature. Hit: 10 (2d6 + 3) bludgeoning damage, and the target is grappled (escape DC 15). Until this grapple ends, the target is restrained, and the couatl can't constrict another target.",attack_bonus:6,damage_dice:"2d6",damage_bonus:3},{name:"Change Shape",desc:`The couatl magically polymorphs into a humanoid or beast that has a challenge rating equal to or less than its own, or back into its true form. It reverts to its true form if it dies. Any equipment it is wearing or carrying is absorbed or borne by the new form (the couatl's choice). In a new form, the couatl retains its game statistics and ability to speak, but its AC, movement modes, Strength, Dexterity, and other actions are replaced by those of the new form, and it gains any statistics and capabilities (except class features, legendary actions, and lair actions) that the new form has but that it lacks. If the new form has a bite attack, the couatl can use its bite in that form.`,attack_bonus:0}]},{name:"Crab",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:2,hit_dice:"1d4",speed:"20 ft., swim 20 ft.",stats:[2,11,10,1,8,2],skillsaves:[{stealth:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 30 ft., passive Perception 9",languages:"",cr:"0",bestiary:!0,traits:[{name:"Amphibious",desc:"The crab can breathe air and water.",attack_bonus:0}],actions:[{name:"Claw",desc:"Melee Weapon Attack: +0 to hit, reach 5 ft., one target. Hit: 1 bludgeoning damage.",attack_bonus:0,damage_bonus:1}]},{name:"Crocodile",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:19,hit_dice:"3d10 + 2",speed:"20 ft., swim 20 ft.",stats:[15,10,13,2,10,5],skillsaves:[{stealth:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Hold Breath",desc:"The crocodile can hold its breath for 15 minutes.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 7 (1d10 + 2) piercing damage, and the target is grappled (escape DC 12). Until this grapple ends, the target is restrained, and the crocodile can't bite another target",attack_bonus:4,damage_dice:"1d10",damage_bonus:2}]},{name:"Cult Fanatic",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any non-good alignment",ac:13,hp:22,hit_dice:"6d8 + -5",speed:"30 ft.",stats:[11,14,12,10,13,14],skillsaves:[{deception:4},{persuasion:4},{religion:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 11",languages:"any one language (usually Common)",cr:"2",bestiary:!0,traits:[{name:"Dark Devotion",desc:"The fanatic has advantage on saving throws against being charmed or frightened.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The fanatic makes two melee attacks.",attack_bonus:0},{name:"Dagger",desc:"Melee or Ranged Weapon Attack: +4 to hit, reach 5 ft. or range 20/60 ft., one creature. Hit: 4 (1d4 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}],spells:["The fanatic is a 4th-level spellcaster. Its spell casting ability is Wisdom (spell save DC 11, +3 to hit with spell attacks). The fanatic has the following cleric spells prepared:","Cantrips (at will): light, sacred flame, thaumaturgy",{"1st level (4 slots)":"command, inflict wounds, shield of faith"},{"2nd level (3 slots)":"hold person, spiritual weapon"}]},{name:"Cultist",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any non-good alignment",ac:12,hp:9,hit_dice:"2d8",speed:"30 ft.",stats:[11,12,10,10,11,10],skillsaves:[{deception:2},{religion:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"any one language (usually Common)",cr:"1/8",bestiary:!0,traits:[{name:"Dark Devotion",desc:"The cultist has advantage on saving throws against being charmed or frightened.",attack_bonus:0}],actions:[{name:"Scimitar",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one creature. Hit: 4 (1d6 + 1) slashing damage.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Darkmantle",source:"5e SRD",size:"Small",type:"monstrosity",subtype:"",alignment:"unaligned",ac:11,hp:22,hit_dice:"5d6 + 4",speed:"10 ft., fly 30 ft.",stats:[16,12,13,2,10,5],skillsaves:[{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 60 ft., passive Perception 10",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Echolocation",desc:"The darkmantle can't use its blindsight while deafened.",attack_bonus:0},{name:"False Appearance",desc:"While the darkmantle remains motionless, it is indistinguishable from a cave formation such as a stalactite or stalagmite.",attack_bonus:0}],actions:[{name:"Crush",desc:`Melee Weapon Attack: +5 to hit, reach 5 ft., one creature. Hit: 6 (1d6 + 3) bludgeoning damage, and the darkmantle attaches to the target. If the target is Medium or smaller and the darkmantle has advantage on the attack roll, it attaches by engulfing the target's head, and the target is also blinded and unable to breathe while the darkmantle is attached in this way. While attached to the target, the darkmantle can attack no other creature except the target but has advantage on its attack rolls. The darkmantle's speed also becomes 0, it can't benefit from any bonus to its speed, and it moves with the target. A creature can detach the darkmantle by making a successful DC 13 Strength check as an action. On its turn, the darkmantle can detach itself from the target by using 5 feet of movement.`,attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Darkness Aura (1/day)",desc:"A 15-foot radius of magical darkness extends out from the darkmantle, moves with it, and spreads around corners. The darkness lasts as long as the darkmantle maintains concentration, up to 10 minutes (as if concentrating on a spell). Darkvision can't penetrate this darkness, and no natural light can illuminate it. If any of the darkness overlaps with an area of light created by a spell of 2nd level or lower, the spell creating the light is dispelled.",attack_bonus:0}]},{name:"Death Dog",source:"5e SRD",size:"Medium",type:"monstrosity",subtype:"",alignment:"neutral evil",ac:12,hp:39,hit_dice:"6d8 + 12",speed:"40 ft.",stats:[15,14,14,3,13,6],skillsaves:[{perception:5},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 15",languages:"",cr:"1",bestiary:!0,traits:[{name:"Two-Headed",desc:"The dog has advantage on Wisdom (Perception) checks and on saving throws against being blinded, charmed, deafened, frightened, stunned, or knocked unconscious.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dog makes two bite attacks.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage. If the target is a creature, it must succeed on a DC 12 Constitution saving throw against disease or become poisoned until the disease is cured. Every 24 hours that elapse, the creature must repeat the saving throw, reducing its hit point maximum by 5 (1d10) on a failure. This reduction lasts until the disease is cured. The creature dies if the disease reduces its hit point maximum to 0.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Deep Gnome (Svirfneblin)",source:"5e SRD",size:"Small",type:"humanoid",subtype:"gnome",alignment:"neutral good",ac:15,hp:16,hit_dice:"3d6 + 5",speed:"20 ft.",stats:[15,14,14,12,10,9],skillsaves:[{perception:2},{investigation:3},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 12",languages:"Gnomish, Terran, Undercommon",cr:"1/2",bestiary:!0,traits:[{name:"Stone Camouflage",desc:"The gnome has advantage on Dexterity (Stealth) checks made to hide in rocky terrain.",attack_bonus:0},{name:"Gnome Cunning",desc:"The gnome has advantage on Intelligence, Wisdom, and Charisma saving throws against magic.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The gnome's innate spellcasting ability is Intelligence (spell save DC 11). It can innately cast the following spells, requiring no material components: At will: nondetection (self only) 1/day each: blindness/deafness, blur, disguise self`,attack_bonus:0}],actions:[{name:"War Pick",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 6 (1d8 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2},{name:"Poisoned Dart",desc:"Ranged Weapon Attack: +4 to hit, range 30/120 ft., one creature. Hit: 4 (1d4 + 2) piercing damage, and the target must succeed on a DC 12 Constitution saving throw or be poisoned for 1 minute. The target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Deer",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:4,hit_dice:"1d8 + -1",speed:"50 ft.",stats:[11,16,11,2,14,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 12",languages:"",cr:"0",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 2 (1d4) piercing damage.",attack_bonus:2,damage_dice:"1d4"}]},{name:"Deva",source:"5e SRD",size:"Medium",type:"celestial",subtype:"",alignment:"lawful good",ac:17,hp:136,hit_dice:"16d8 + 64",speed:"30 ft., fly 90 ft.",stats:[18,18,18,17,20,20],saves:[{wisdom:9},{charisma:9}],skillsaves:[{insight:9},{perception:9}],damage_vulnerabilities:"",damage_resistances:"radiant; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"",condition_immunities:"charmed, exhaustion, frightened",senses:"darkvision 120 ft., passive Perception 19",languages:"all, telepathy 120 ft.",cr:"10",bestiary:!0,traits:[{name:"Angelic Weapons",desc:"The deva's weapon attacks are magical. When the deva hits with any weapon, the weapon deals an extra 4d8 radiant damage (included in the attack).",attack_bonus:0},{name:"Innate Spellcasting",desc:`The deva's spellcasting ability is Charisma (spell save DC 17). The deva can innately cast the following spells, requiring only verbal components: At will: detect evil and good 1/day each: commune, raise dead`,attack_bonus:0},{name:"Magic Resistance",desc:"The deva has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The deva makes two melee attacks.",attack_bonus:0},{name:"Mace",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one target. Hit: 7 (1d6 + 4) bludgeoning damage plus 18 (4d8) radiant damage.",attack_bonus:8,damage_dice:"1d6 + 4d8",damage_bonus:4},{name:"Healing Touch (3/Day)",desc:"The deva touches another creature. The target magically regains 20 (4d8 + 2) hit points and is freed from any curse, disease, poison, blindness, or deafness.",attack_bonus:0},{name:"Change Shape",desc:`The deva magically polymorphs into a humanoid or beast that has a challenge rating equal to or less than its own, or back into its true form. It reverts to its true form if it dies. Any equipment it is wearing or carrying is absorbed or borne by the new form (the deva's choice). In a new form, the deva retains its game statistics and ability to speak, but its AC, movement modes, Strength, Dexterity, and special senses are replaced by those of the new form, and it gains any statistics and capabilities (except class features, legendary actions, and lair actions) that the new form has but that it lacks.`,attack_bonus:0}]},{name:"Dire Wolf",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:14,hp:37,hit_dice:"5d10 + 9",speed:"50 ft.",stats:[17,15,15,3,12,7],skillsaves:[{perception:3},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"1",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The wolf has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0},{name:"Pack Tactics",desc:"The wolf has advantage on an attack roll against a creature if at least one of the wolf's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) piercing damage. If the target is a creature, it must succeed on a DC 13 Strength saving throw or be knocked prone.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3}]},{name:"Djinni",source:"5e SRD",size:"Large",type:"elemental",subtype:"",alignment:"chaotic good",ac:17,hp:161,hit_dice:"14d10 + 84",speed:"30 ft., fly 90 ft.",stats:[21,15,22,15,16,20],saves:[{dexterity:6},{wisdom:7},{charisma:9}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning, thunder",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 13",languages:"Auran",cr:"11",bestiary:!0,traits:[{name:"Elemental Demise",desc:"If the djinni dies, its body disintegrates into a warm breeze, leaving behind only equipment the djinni was wearing or carrying.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The djinni's innate spellcasting ability is Charisma (spell save DC 17, +9 to hit with spell attacks). It can innately cast the following spells, requiring no material components: At will: detect evil and good, detect magic, thunderwave 3/day each: create food and water (can create wine instead of water), tongues, wind walk 1/day each: conjure elemental (air elemental only), creation, gaseous form, invisibility, major image, plane shift`,attack_bonus:0},{name:"Variant: Genie Powers",desc:`Genies have a variety of magical capabilities, including spells. A few have even greater powers that allow them to alter their appearance or the nature of reality. Disguises. Some genies can veil themselves in illusion to pass as other similarly shaped creatures. Such genies can innately cast the disguise self spell at will, often with a longer duration than is normal for that spell. Mightier genies can cast the true polymorph spell one to three times per day, possibly with a longer duration than normal. Such genies can change only their own shape, but a rare few can use the spell on other creatures and objects as well. Wishes. The genie power to grant wishes is legendary among mortals. Only the most potent genies, such as those among the nobility, can do so. A particular genie that has this power can grant one to three wishes to a creature that isn't a genie. Once a genie has granted its limit of wishes, it can't grant wishes again for some amount of time (usually 1 year). and cosmic law dictates that the same genie can expend its limit of wishes on a specific creature only once in that creature's existence. To be granted a wish, a creature within 60 feet of the genie states a desired effect to it. The genie can then cast the wish spell on the creature's behalf to bring about the effect. Depending on the genie's nature, the genie might try to pervert the intent of the wish by exploiting the wish's poor wording. The perversion of the wording is usually crafted to be to the genie's benefit.`,attack_bonus:0}],actions:[{name:"Multiattack",desc:"The djinni makes three scimitar attacks.",attack_bonus:0},{name:"Scimitar",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one target. Hit: 12 (2d6 + 5) slashing damage plus 3 (1d6) lightning or thunder damage (djinni's choice).",attack_bonus:9,damage_dice:"2d6 + 1d6",damage_bonus:5},{name:"Create Whirlwind",desc:`A 5-foot-radius, 30-foot-tall cylinder of swirling air magically forms on a point the djinni can see within 120 feet of it. The whirlwind lasts as long as the djinni maintains concentration (as if concentrating on a spell). Any creature but the djinni that enters the whirlwind must succeed on a DC 18 Strength saving throw or be restrained by it. The djinni can move the whirlwind up to 60 feet as an action, and creatures restrained by the whirlwind move with it. The whirlwind ends if the djinni loses sight of it. A creature can use its action to free a creature restrained by the whirlwind, including itself, by succeeding on a DC 18 Strength check. If the check succeeds, the creature is no longer restrained and moves to the nearest space outside the whirlwind.`,attack_bonus:0}]},{name:"Doppelganger",source:"5e SRD",size:"Medium",type:"monstrosity",subtype:"shapechanger",alignment:"unaligned",ac:14,hp:52,hit_dice:"8d8 + 16",speed:"30 ft.",stats:[11,18,14,11,12,14],skillsaves:[{deception:6},{insight:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"charmed",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 11",languages:"Common",cr:"3",bestiary:!0,traits:[{name:"Shapechanger",desc:"The doppelganger can use its action to polymorph into a Small or Medium humanoid it has seen, or back into its true form. Its statistics, other than its size, are the same in each form. Any equipment it is wearing or carrying isn't transformed. It reverts to its true form if it dies.",attack_bonus:0},{name:"Ambusher",desc:"The doppelganger has advantage on attack rolls against any creature it has surprised.",attack_bonus:0},{name:"Surprise Attack",desc:"If the doppelganger surprises a creature and hits it with an attack during the first round of combat, the target takes an extra 10 (3d6) damage from the attack.",attack_bonus:0,damage_dice:"3d6"}],actions:[{name:"Multiattack",desc:"The doppelganger makes two melee attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 7 (1d6 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"1d6",damage_bonus:4},{name:"Read Thoughts",desc:"The doppelganger magically reads the surface thoughts of one creature within 60 ft. of it. The effect can penetrate barriers, but 3 ft. of wood or dirt, 2 ft. of stone, 2 inches of metal, or a thin sheet of lead blocks it. While the target is in range, the doppelganger can continue reading its thoughts, as long as the doppelganger's concentration isn't broken (as if concentrating on a spell). While reading the target's mind, the doppelganger has advantage on Wisdom (Insight) and Charisma (Deception, Intimidation, and Persuasion) checks against the target.",attack_bonus:0}]},{name:"Draft Horse",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:19,hit_dice:"3d10 + 2",speed:"40 ft.",stats:[18,10,12,2,11,7],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"1/4",bestiary:!0,actions:[{name:"Hooves",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 9 (2d4 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"2d4",damage_bonus:4}]},{name:"Dragon Turtle",source:"5e SRD",size:"Gargantuan",type:"dragon",subtype:"",alignment:"neutral",ac:20,hp:341,hit_dice:"22d20 + 110",speed:"20 ft., swim 40 ft.",stats:[25,10,20,10,12,12],saves:[{dexterity:6},{constitution:11},{wisdom:7}],damage_vulnerabilities:"",damage_resistances:"fire",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 11",languages:"Aquan, Draconic",cr:"17",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon turtle can breathe air and water.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon turtle makes three attacks: one with its bite and two with its claws. It can make one tail attack in place of its two claw attacks.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +13 to hit, reach 15 ft., one target. Hit: 26 (3d12 + 7) piercing damage.",attack_bonus:13,damage_dice:"3d12",damage_bonus:7},{name:"Claw",desc:"Melee Weapon Attack: +13 to hit, reach 10 ft., one target. Hit: 16 (2d8 + 7) slashing damage.",attack_bonus:13,damage_dice:"2d8",damage_bonus:7},{name:"Tail",desc:"Melee Weapon Attack: +13 to hit, reach 15 ft., one target. Hit: 26 (3d12 + 7) bludgeoning damage. If the target is a creature, it must succeed on a DC 20 Strength saving throw or be pushed up to 10 feet away from the dragon turtle and knocked prone.",attack_bonus:13,damage_dice:"3d12",damage_bonus:7},{name:"Steam Breath (Recharge 5-6)",desc:"The dragon turtle exhales scalding steam in a 60-foot cone. Each creature in that area must make a DC 18 Constitution saving throw, taking 52 (15d6) fire damage on a failed save, or half as much damage on a successful one. Being underwater doesn't grant resistance against this damage.",attack_bonus:0,damage_dice:"15d6"}]},{name:"Dretch",source:"5e SRD",size:"Small",type:"fiend",subtype:"demon",alignment:"chaotic evil",ac:11,hp:18,hit_dice:"4d6 + 4",speed:"20 ft.",stats:[11,11,12,5,8,3],damage_vulnerabilities:"",damage_resistances:"cold, fire, lightning",damage_immunities:"poison",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 9",languages:"Abyssal, telepathy 60 ft. (works only with creatures that understand Abyssal)",cr:"1/4",bestiary:!0,actions:[{name:"Multiattack",desc:"The dretch makes two attacks: one with its bite and one with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 3 (1d6) piercing damage.",attack_bonus:2,damage_dice:"1d6"},{name:"Claws",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 5 (2d4) slashing damage.",attack_bonus:2,damage_dice:"2d4"},{name:"Fetid Cloud (1/Day)",desc:"A 10-foot radius of disgusting green gas extends out from the dretch. The gas spreads around corners, and its area is lightly obscured. It lasts for 1 minute or until a strong wind disperses it. Any creature that starts its turn in that area must succeed on a DC 11 Constitution saving throw or be poisoned until the start of its next turn. While poisoned in this way, the target can take either an action or a bonus action on its turn, not both, and can't take reactions.",attack_bonus:0}]},{name:"Drider",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"chaotic evil",ac:19,hp:123,hit_dice:"13d10 + 51",speed:"30 ft., climb 30 ft.",stats:[16,16,18,13,14,12],skillsaves:[{perception:5},{stealth:9}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 15",languages:"Elvish, Undercommon",cr:"6",bestiary:!0,traits:[{name:"Fey Ancestry",desc:"The drider has advantage on saving throws against being charmed, and magic can't put the drider to sleep.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The drider's innate spellcasting ability is Wisdom (spell save DC 13). The drider can innately cast the following spells, requiring no material components: At will: dancing lights 1/day each: darkness, faerie fire`,attack_bonus:0},{name:"Spider Climb",desc:"The drider can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0},{name:"Sunlight Sensitivity",desc:"While in sunlight, the drider has disadvantage on attack rolls, as well as on Wisdom (Perception) checks that rely on sight.",attack_bonus:0},{name:"Web Walker",desc:"The drider ignores movement restrictions caused by webbing.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The drider makes three attacks, either with its longsword or its longbow. It can replace one of those attacks with a bite attack.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one creature. Hit: 2 (1d4) piercing damage plus 9 (2d8) poison damage.",attack_bonus:6,damage_dice:"1d4",damage_bonus:2},{name:"Longsword",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) slashing damage, or 8 (1d10 + 3) slashing damage if used with two hands.",attack_bonus:6,damage_dice:"1d8",damage_bonus:3},{name:"Longbow",desc:"Ranged Weapon Attack: +6 to hit, range 150/600 ft., one target. Hit: 7 (1d8 + 3) piercing damage plus 4 (1d8) poison damage.",attack_bonus:6,damage_dice:"1d8",damage_bonus:3}]},{name:"Drow",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"elf",alignment:"neutral evil",ac:15,hp:13,hit_dice:"3d8 + -1",speed:"30 ft.",stats:[10,14,10,11,11,12],skillsaves:[{perception:2},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 12",languages:"Elvish, Undercommon",cr:"1/4",bestiary:!0,traits:[{name:"Fey Ancestry",desc:"The drow has advantage on saving throws against being charmed, and magic can't put the drow to sleep.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The drow's spellcasting ability is Charisma (spell save DC 11). It can innately cast the following spells, requiring no material components: At will: dancing lights 1/day each: darkness, faerie fire`,attack_bonus:0},{name:"Sunlight Sensitivity",desc:"While in sunlight, the drow has disadvantage on attack rolls, as well as on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Shortsword",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Hand Crossbow",desc:"Ranged Weapon Attack: +4 to hit, range 30/120 ft., one target. Hit: 5 (1d6 + 2) piercing damage, and the target must succeed on a DC 13 Constitution saving throw or be poisoned for 1 hour. If the saving throw fails by 5 or more, the target is also unconscious while poisoned in this way. The target wakes up if it takes damage or if another creature takes an action to shake it awake.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Druid",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:11,hp:27,hit_dice:"5d8 + 4",speed:"30 ft.",stats:[10,12,13,12,15,11],skillsaves:[{nature:3},{medicine:4},{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"Druidic plus any two languages",cr:"2",bestiary:!0,traits:[],actions:[{name:"Quarterstaff",desc:"Melee Weapon Attack: +2 to hit (+4 to hit with shillelagh), reach 5 ft., one target. Hit: 3 (1d6) bludgeoning damage, or 6 (1d8 + 2) bludgeoning damage with shillelagh or if wielded with two hands.",attack_bonus:2,damage_dice:"1d6"}],spells:["The druid is a 4th-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 12, +4 to hit with spell attacks). It has the following druid spells prepared:",{"Cantrips (at will)":"druidcraft, produce flame, shillelagh"},{"1st level (4 slots)":"entangle, longstrider, speak with animals, thunderwave"},{"2nd level (3 slots)":"animal messenger, barkskin"}]},{name:"Dryad",source:"5e SRD",size:"Medium",type:"fey",subtype:"",alignment:"neutral",ac:11,hp:22,hit_dice:"5d8 + -1",speed:"30 ft.",stats:[10,12,11,14,15,18],skillsaves:[{perception:4},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"Elvish, Sylvan",cr:"1",bestiary:!0,traits:[{name:"Innate Spellcasting",desc:`The dryad's innate spellcasting ability is Charisma (spell save DC 14). The dryad can innately cast the following spells, requiring no material components: At will: druidcraft 3/day each: entangle, goodberry 1/day each: barkskin, pass without trace, shillelagh`,attack_bonus:0},{name:"Magic Resistance",desc:"The dryad has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Speak with Beasts and Plants",desc:"The dryad can communicate with beasts and plants as if they shared a language.",attack_bonus:0},{name:"Tree Stride",desc:"Once on her turn, the dryad can use 10 ft. of her movement to step magically into one living tree within her reach and emerge from a second living tree within 60 ft. of the first tree, appearing in an unoccupied space within 5 ft. of the second tree. Both trees must be large or bigger.",attack_bonus:0}],actions:[{name:"Club",desc:"Melee Weapon Attack: +2 to hit (+6 to hit with shillelagh), reach 5 ft., one target. Hit: 2 (1 d4) bludgeoning damage, or 8 (1d8 + 4) bludgeoning damage with shillelagh.",attack_bonus:2,damage_dice:"1d4"},{name:"Fey Charm",desc:`The dryad targets one humanoid or beast that she can see within 30 feet of her. If the target can see the dryad, it must succeed on a DC 14 Wisdom saving throw or be magically charmed. The charmed creature regards the dryad as a trusted friend to be heeded and protected. Although the target isn't under the dryad's control, it takes the dryad's requests or actions in the most favorable way it can. Each time the dryad or its allies do anything harmful to the target, it can repeat the saving throw, ending the effect on itself on a success. Otherwise, the effect lasts 24 hours or until the dryad dies, is on a different plane of existence from the target, or ends the effect as a bonus action. If a target's saving throw is successful, the target is immune to the dryad's Fey Charm for the next 24 hours. The dryad can have no more than one humanoid and up to three beasts charmed at a time.`,attack_bonus:0}]},{name:"Duergar",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"dwarf",alignment:"lawful evil",ac:16,hp:26,hit_dice:"4d8 + 8",speed:"25 ft.",stats:[14,11,14,11,10,9],damage_vulnerabilities:"",damage_resistances:"poison",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 10",languages:"Dwarvish, Undercommon",cr:"1",bestiary:!0,traits:[{name:"Duergar Resilience",desc:"The duergar has advantage on saving throws against poison, spells, and illusions, as well as to resist being charmed or paralyzed.",attack_bonus:0},{name:"Sunlight Sensitivity",desc:"While in sunlight, the duergar has disadvantage on attack rolls, as well as on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Enlarge (Recharges after a Short or Long Rest)",desc:"For 1 minute, the duergar magically increases in size, along with anything it is wearing or carrying. While enlarged, the duergar is Large, doubles its damage dice on Strength-based weapon attacks (included in the attacks), and makes Strength checks and Strength saving throws with advantage. If the duergar lacks the room to become Large, it attains the maximum size possible in the space available.",attack_bonus:0},{name:"War Pick",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 6 (1d8 + 2) piercing damage, or 11 (2d8 + 2) piercing damage while enlarged.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2},{name:"Javelin",desc:"Melee or Ranged Weapon Attack: +4 to hit, reach 5 ft. or range 30/120 ft., one target. Hit: 5 (1d6 + 2) piercing damage, or 9 (2d6 + 2) piercing damage while enlarged.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Invisibility (Recharges after a Short or Long Rest)",desc:"The duergar magically turns invisible until it attacks, casts a spell, or uses its Enlarge, or until its concentration is broken, up to 1 hour (as if concentrating on a spell). Any equipment the duergar wears or carries is invisible with it .",attack_bonus:0}]},{name:"Dust Mephit",source:"5e SRD",size:"Small",type:"elemental",subtype:"",alignment:"neutral evil",ac:12,hp:17,hit_dice:"5d6 + -1",speed:"30 ft., fly 30 ft.",stats:[5,14,10,9,11,10],skillsaves:[{perception:2},{stealth:4}],damage_vulnerabilities:"fire",damage_resistances:"",damage_immunities:"poison",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 12",languages:"Auran, Terran",cr:"1/2",bestiary:!0,traits:[{name:"Death Burst",desc:"When the mephit dies, it explodes in a burst of dust. Each creature within 5 ft. of it must then succeed on a DC 10 Constitution saving throw or be blinded for 1 minute. A blinded creature can repeat the saving throw on each of its turns, ending the effect on itself on a success.",attack_bonus:0},{name:"Innate Spellcasting (1/Day)",desc:"The mephit can innately cast sleep, requiring no material components. Its innate spellcasting ability is Charisma.",attack_bonus:0}],actions:[{name:"Claws",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 4 (1d4 + 2) slashing damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2},{name:"Blinding Breath (Recharge 6)",desc:"The mephit exhales a 15-foot cone of blinding dust. Each creature in that area must succeed on a DC 10 Dexterity saving throw or be blinded for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:0},{name:"Variant: Summon Mephits (1/Day)",desc:"The mephit has a 25 percent chance of summoning 1d4 mephits of its kind. A summoned mephit appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other mephits. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.",attack_bonus:0}]},{name:"Eagle",source:"5e SRD",size:"Small",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:3,hit_dice:"1d6 + -1",speed:"10 ft., fly 60 ft.",stats:[6,15,10,2,14,7],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"",cr:"0",bestiary:!0,traits:[{name:"Keen Sight",desc:"The eagle has advantage on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Talons",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 4 (1d4 + 2) slashing damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Earth Elemental",source:"5e SRD",size:"Large",type:"elemental",subtype:"",alignment:"neutral",ac:17,hp:126,hit_dice:"12d10 + 60",speed:"30 ft., burrow 30 ft.",stats:[20,8,20,5,10,5],damage_vulnerabilities:"thunder",damage_resistances:"bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"exhaustion, paralyzed, petrified, poisoned, unconscious",senses:"darkvision 60 ft., tremorsense 60 ft., passive Perception 10",languages:"Terran",cr:"5",bestiary:!0,traits:[{name:"Earth Glide",desc:"The elemental can burrow through nonmagical, unworked earth and stone. While doing so, the elemental doesn't disturb the material it moves through.",attack_bonus:0},{name:"Siege Monster",desc:"The elemental deals double damage to objects and structures.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The elemental makes two slam attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target. Hit: 14 (2d8 + 5) bludgeoning damage.",attack_bonus:8,damage_dice:"2d8",damage_bonus:5}]},{name:"Efreeti",source:"5e SRD",size:"Large",type:"elemental",subtype:"",alignment:"lawful evil",ac:17,hp:200,hit_dice:"16d10 + 112",speed:"40 ft., fly 60 ft.",stats:[22,12,24,16,15,16],saves:[{intelligence:7},{wisdom:6},{charisma:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 12",languages:"Ignan",cr:"11",bestiary:!0,traits:[{name:"Elemental Demise",desc:"If the efreeti dies, its body disintegrates in a flash of fire and puff of smoke, leaving behind only equipment the djinni was wearing or carrying.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The efreeti's innate spell casting ability is Charisma (spell save DC 15, +7 to hit with spell attacks). It can innately cast the following spells, requiring no material components: At will: detect magic 3/day: enlarge/reduce, tongues 1/day each: conjure elemental (fire elemental only), gaseous form, invisibility, major image, plane shift, wall of fire`,attack_bonus:0},{name:"Variant: Genie Powers",desc:`Genies have a variety of magical capabilities, including spells. A few have even greater powers that allow them to alter their appearance or the nature of reality. Disguises. Some genies can veil themselves in illusion to pass as other similarly shaped creatures. Such genies can innately cast the disguise self spell at will, often with a longer duration than is normal for that spell. Mightier genies can cast the true polymorph spell one to three times per day, possibly with a longer duration than normal. Such genies can change only their own shape, but a rare few can use the spell on other creatures and objects as well. Wishes. The genie power to grant wishes is legendary among mortals. Only the most potent genies, such as those among the nobility, can do so. A particular genie that has this power can grant one to three wishes to a creature that isn't a genie. Once a genie has granted its limit of wishes, it can't grant wishes again for some amount of time (usually 1 year). and cosmic law dictates that the same genie can expend its limit of wishes on a specific creature only once in that creature's existence. To be granted a wish, a creature within 60 feet of the genie states a desired effect to it. The genie can then cast the wish spell on the creature's behalf to bring about the effect. Depending on the genie's nature, the genie might try to pervert the intent of the wish by exploiting the wish's poor wording. The perversion of the wording is usually crafted to be to the genie's benefit.`,attack_bonus:0}],actions:[{name:"Multiattack",desc:"The efreeti makes two scimitar attacks or uses its Hurl Flame twice.",attack_bonus:0},{name:"Scimitar",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one target. Hit: 13 (2d6 + 6) slashing damage plus 7 (2d6) fire damage.",attack_bonus:10,damage_dice:"2d6 + 2d6",damage_bonus:6},{name:"Hurl Flame",desc:"Ranged Spell Attack: +7 to hit, range 120 ft., one target. Hit: 17 (5d6) fire damage.",attack_bonus:7,damage_dice:"5d6"}]},{name:"Elephant",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:76,hit_dice:"8d12 + 24",speed:"40 ft.",stats:[22,9,17,3,11,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"4",bestiary:!0,traits:[{name:"Trampling Charge",desc:"If the elephant moves at least 20 ft. straight toward a creature and then hits it with a gore attack on the same turn, that target must succeed on a DC 12 Strength saving throw or be knocked prone. If the target is prone, the elephant can make one stomp attack against it as a bonus action.",attack_bonus:0}],actions:[{name:"Gore",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one target. Hit: 19 (3d8 + 6) piercing damage.",attack_bonus:8,damage_dice:"3d8",damage_bonus:6},{name:"Stomp",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one prone creature. Hit: 22 (3d10 + 6) bludgeoning damage.",attack_bonus:8,damage_dice:"3d10",damage_bonus:6}]},{name:"Elk",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:13,hit_dice:"2d10 + 2",speed:"50 ft.",stats:[16,10,12,2,10,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Charge",desc:"If the elk moves at least 20 ft. straight toward a target and then hits it with a ram attack on the same turn, the target takes an extra 7 (2d6) damage. If the target is a creature, it must succeed on a DC 13 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"2d6"}],actions:[{name:"Ram",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) bludgeoning damage.",attack_bonus:0},{name:"Hooves",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one prone creature. Hit: 8 (2d4 + 3) bludgeoning damage.",attack_bonus:0}]},{name:"Erinyes",source:"5e SRD",size:"Medium",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:18,hp:153,hit_dice:"18d8 + 72",speed:"30 ft., fly 60 ft.",stats:[18,16,18,14,14,18],saves:[{dexterity:7},{constitution:8},{wisdom:6},{charisma:8}],damage_vulnerabilities:"",damage_resistances:"cold; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"truesight 120 ft., passive Perception 12",languages:"Infernal, telepathy 120 ft.",cr:"12",bestiary:!0,traits:[{name:"Hellish Weapons",desc:"The erinyes's weapon attacks are magical and deal an extra 13 (3d8) poison damage on a hit (included in the attacks).",attack_bonus:0},{name:"Magic Resistance",desc:"The erinyes has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The erinyes makes three attacks",attack_bonus:0},{name:"Longsword",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one target. Hit: 8 (1d8 + 4) slashing damage, or 9 (1d10 + 4) slashing damage if used with two hands, plus 13 (3d8) poison damage.",attack_bonus:8,damage_dice:"1d8 + 3d8",damage_bonus:4},{name:"Longbow",desc:"Ranged Weapon Attack: +7 to hit, range 150/600 ft., one target. Hit: 7 (1d8 + 3) piercing damage plus 13 (3d8) poison damage, and the target must succeed on a DC 14 Constitution saving throw or be poisoned. The poison lasts until it is removed by the lesser restoration spell or similar magic.",attack_bonus:7,damage_dice:"1d8 + 3d8",damage_bonus:3},{name:"Variant: Rope of Entanglement",desc:"Some erinyes carry a rope of entanglement (detailed in the Dungeon Master's Guide). When such an erinyes uses its Multiattack, the erinyes can use the rope in place of two of the attacks.",attack_bonus:0}],reactions:[{name:"Parry",desc:"The erinyes adds 4 to its AC against one melee attack that would hit it. To do so, the erinyes must see the attacker and be wielding a melee weapon.",attack_bonus:0}]},{name:"Ettercap",source:"5e SRD",size:"Medium",type:"monstrosity",subtype:"",alignment:"neutral evil",ac:13,hp:44,hit_dice:"8d8 + 8",speed:"30 ft., climb 30 ft.",stats:[14,15,13,7,12,8],skillsaves:[{perception:3},{stealth:4},{survival:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 13",languages:"",cr:"2",bestiary:!0,traits:[{name:"Spider Climb",desc:"The ettercap can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0},{name:"Web Sense",desc:"While in contact with a web, the ettercap knows the exact location of any other creature in contact with the same web.",attack_bonus:0},{name:"Web Walker",desc:"The ettercap ignores movement restrictions caused by webbing.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The ettercap makes two attacks: one with its bite and one with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 6 (1d8 + 2) piercing damage plus 4 (1d8) poison damage. The target must succeed on a DC 11 Constitution saving throw or be poisoned for 1 minute. The creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2},{name:"Claws",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (2d4 + 2) slashing damage.",attack_bonus:4,damage_dice:"2d4",damage_bonus:2},{name:"Web (Recharge 5-6)",desc:"Ranged Weapon Attack: +4 to hit, range 30/60 ft., one Large or smaller creature. Hit: The creature is restrained by webbing. As an action, the restrained creature can make a DC 11 Strength check, escaping from the webbing on a success. The effect ends if the webbing is destroyed. The webbing has AC 10, 5 hit points, is vulnerable to fire damage and immune to bludgeoning damage.",attack_bonus:0},{name:"Variant: Web Garrote",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one Medium or Small creature against which the ettercap has advantage on the attack roll. Hit: 4 (1d4 + 2) bludgeoning damage, and the target is grappled (escape DC 12). Until this grapple ends, the target can't breathe, and the ettercap has advantage on attack rolls against it.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Ettin",source:"5e SRD",size:"Large",type:"giant",subtype:"",alignment:"chaotic evil",ac:12,hp:85,hit_dice:"10d10 + 30",speed:"40 ft.",stats:[21,8,17,6,10,8],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"Giant, Orc",cr:"4",bestiary:!0,traits:[{name:"Two Heads",desc:"The ettin has advantage on Wisdom (Perception) checks and on saving throws against being blinded, charmed, deafened, frightened, stunned, and knocked unconscious.",attack_bonus:0},{name:"Wakeful",desc:"When one of the ettin's heads is asleep, its other head is awake.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The ettin makes two attacks: one with its battleaxe and one with its morningstar.",attack_bonus:0},{name:"Battleaxe",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 14 (2d8 + 5) slashing damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:5},{name:"Morningstar",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 14 (2d8 + 5) piercing damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:5}]},{name:"Fire Elemental",source:"5e SRD",size:"Large",type:"elemental",subtype:"",alignment:"neutral",ac:13,hp:102,hit_dice:"12d10 + 36",speed:"50 ft.",stats:[10,17,16,6,10,7],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"fire, poison",condition_immunities:"exhaustion, grappled, paralyzed, petrified, poisoned, prone, restrained, unconscious",senses:"darkvision 60 ft., passive Perception 10",languages:"Ignan",cr:"5",bestiary:!0,traits:[{name:"Fire Form",desc:"The elemental can move through a space as narrow as 1 inch wide without squeezing. A creature that touches the elemental or hits it with a melee attack while within 5 ft. of it takes 5 (1d10) fire damage. In addition, the elemental can enter a hostile creature's space and stop there. The first time it enters a creature's space on a turn, that creature takes 5 (1d10) fire damage and catches fire; until someone takes an action to douse the fire, the creature takes 5 (1d10) fire damage at the start of each of its turns.",attack_bonus:0,damage_dice:"5d10"},{name:"Illumination",desc:"The elemental sheds bright light in a 30-foot radius and dim light in an additional 30 ft..",attack_bonus:0},{name:"Water Susceptibility",desc:"For every 5 ft. the elemental moves in water, or for every gallon of water splashed on it, it takes 1 cold damage.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The elemental makes two touch attacks.",attack_bonus:0},{name:"Touch",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) fire damage. If the target is a creature or a flammable object, it ignites. Until a creature takes an action to douse the fire, the target takes 5 (1d10) fire damage at the start of each of its turns.",attack_bonus:6,damage_dice:"2d6",damage_bonus:3}]},{name:"Fire Giant",source:"5e SRD",size:"Huge",type:"giant",subtype:"",alignment:"lawful evil",ac:18,hp:162,hit_dice:"13d12 + 77",speed:"30 ft.",stats:[25,9,23,10,14,13],saves:[{dexterity:3},{constitution:10},{charisma:5}],skillsaves:[{athletics:11},{perception:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"passive Perception 16",languages:"Giant",cr:"9",bestiary:!0,actions:[{name:"Multiattack",desc:"The giant makes two greatsword attacks.",attack_bonus:0},{name:"Greatsword",desc:"Melee Weapon Attack: +11 to hit, reach 10 ft., one target. Hit: 28 (6d6 + 7) slashing damage.",attack_bonus:11,damage_dice:"6d6",damage_bonus:7},{name:"Rock",desc:"Ranged Weapon Attack: +11 to hit, range 60/240 ft., one target. Hit: 29 (4d10 + 7) bludgeoning damage.",attack_bonus:11,damage_dice:"4d10",damage_bonus:7}]},{name:"Flesh Golem",source:"5e SRD",size:"Medium",type:"construct",subtype:"",alignment:"neutral",ac:9,hp:93,hit_dice:"11d8 + 43",speed:"30 ft.",stats:[19,9,18,6,10,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning, poison; bludgeoning, piercing, and slashing from nonmagical weapons that aren't adamantine",condition_immunities:"charmed, exhaustion, frightened, paralyzed, petrified, poisoned",senses:"darkvision 60 ft., passive Perception 10",languages:"understands the languages of its creator but can't speak",cr:"5",bestiary:!0,traits:[{name:"Berserk",desc:`Whenever the golem starts its turn with 40 hit points or fewer, roll a d6. On a 6, the golem goes berserk. On each of its turns while berserk, the golem attacks the nearest creature it can see. If no creature is near enough to move to and attack, the golem attacks an object, with preference for an object smaller than itself. Once the golem goes berserk, it continues to do so until it is destroyed or regains all its hit points. The golem's creator, if within 60 feet of the berserk golem, can try to calm it by speaking firmly and persuasively. The golem must be able to hear its creator, who must take an action to make a DC 15 Charisma (Persuasion) check. If the check succeeds, the golem ceases being berserk. If it takes damage while still at 40 hit points or fewer, the golem might go berserk again.`,attack_bonus:0},{name:"Aversion of Fire",desc:"If the golem takes fire damage, it has disadvantage on attack rolls and ability checks until the end of its next turn.",attack_bonus:0},{name:"Immutable Form",desc:"The golem is immune to any spell or effect that would alter its form.",attack_bonus:0},{name:"Lightning Absorption",desc:"Whenever the golem is subjected to lightning damage, it takes no damage and instead regains a number of hit points equal to the lightning damage dealt.",attack_bonus:0},{name:"Magic Resistance",desc:"The golem has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Magic Weapons",desc:"The golem's weapon attacks are magical.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The golem makes two slam attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) bludgeoning damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:4}]},{name:"Flying Snake",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:14,hp:5,hit_dice:"2d4",speed:"30 ft., fly 60 ft., swim 30 ft.",stats:[4,18,11,2,12,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., passive Perception 11",languages:"",cr:"1/8",bestiary:!0,traits:[{name:"Flyby",desc:"The snake doesn't provoke opportunity attacks when it flies out of an enemy's reach.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 1 piercing damage plus 7 (3d4) poison damage.",attack_bonus:6,damage_bonus:1}]},{name:"Flying Sword",source:"5e SRD",size:"Small",type:"construct",subtype:"",alignment:"unaligned",ac:17,hp:17,hit_dice:"5d6 + -1",speed:"0 ft., fly 50 ft. It can hover.",stats:[12,15,11,1,5,1],saves:[{dexterity:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison, psychic",condition_immunities:"blinded, charmed, deafened, frightened, paralyzed, petrified, poisoned",senses:"blindsight 60 ft. (blind beyond this radius), passive Perception 7",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Antimagic Susceptibility",desc:"The sword is incapacitated while in the area of an antimagic field. If targeted by dispel magic, the sword must succeed on a Constitution saving throw against the caster's spell save DC or fall unconscious for 1 minute.",attack_bonus:0},{name:"False Appearance",desc:"While the sword remains motionless and isn't flying, it is indistinguishable from a normal sword.",attack_bonus:0}],actions:[{name:"Longsword",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 5 (1d8 + 1) slashing damage.",attack_bonus:3,damage_dice:"1d8",damage_bonus:1}]},{name:"Frog",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:1,hit_dice:"1d4 + -2",speed:"20 ft., swim 20 ft.",stats:[1,13,8,1,8,3],skillsaves:[{perception:1},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 11",languages:"",cr:"0",bestiary:!0,traits:[{name:"Amphibious",desc:"The frog can breathe air and water",attack_bonus:0},{name:"Standing Leap",desc:"The frog's long jump is up to 10 ft. and its high jump is up to 5 ft., with or without a running start.",attack_bonus:0}]},{name:"Frost Giant",source:"5e SRD",size:"Huge",type:"giant",subtype:"",alignment:"neutral evil",ac:15,hp:138,hit_dice:"12d12 + 60",speed:"40 ft.",stats:[23,9,21,9,10,12],saves:[{constitution:8},{wisdom:3},{charisma:4}],skillsaves:[{athletics:9},{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"passive Perception 13",languages:"Giant",cr:"8",bestiary:!0,actions:[{name:"Multiattack",desc:"The giant makes two greataxe attacks.",attack_bonus:0},{name:"Greataxe",desc:"Melee Weapon Attack: +9 to hit, reach 10 ft., one target. Hit: 25 (3d12 + 6) slashing damage.",attack_bonus:9,damage_dice:"3d12",damage_bonus:6},{name:"Rock",desc:"Ranged Weapon Attack: +9 to hit, range 60/240 ft., one target. Hit: 28 (4d10 + 6) bludgeoning damage.",attack_bonus:9,damage_dice:"4d10",damage_bonus:6}]},{name:"Gargoyle",source:"5e SRD",size:"Medium",type:"elemental",subtype:"",alignment:"chaotic evil",ac:15,hp:52,hit_dice:"7d8 + 20",speed:"30 ft., fly 60 ft.",stats:[15,11,16,6,11,7],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, and slashing from nonmagical weapons that aren't adamantine",damage_immunities:"poison",condition_immunities:"exhaustion, petrified, poisoned",senses:"darkvision 60 ft., passive Perception 10",languages:"Terran",cr:"2",bestiary:!0,traits:[{name:"False Appearance",desc:"While the gargoyle remains motion less, it is indistinguishable from an inanimate statue.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The gargoyle makes two attacks: one with its bite and one with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Claws",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) slashing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Gelatinous Cube",source:"5e SRD",size:"Large",type:"ooze",subtype:"",alignment:"unaligned",ac:6,hp:84,hit_dice:"8d10 + 40",speed:"15 ft.",stats:[14,3,20,1,6,1],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"blinded, charmed, deafened, exhaustion, frightened, prone",senses:"blindsight 60 ft. (blind beyond this radius), passive Perception 8",languages:"",cr:"2",bestiary:!0,traits:[{name:"Ooze Cube",desc:`The cube takes up its entire space. Other creatures can enter the space, but a creature that does so is subjected to the cube's Engulf and has disadvantage on the saving throw. Creatures inside the cube can be seen but have total cover. A creature within 5 feet of the cube can take an action to pull a creature or object out of the cube. Doing so requires a successful DC 12 Strength check, and the creature making the attempt takes 10 (3d6) acid damage. The cube can hold only one Large creature or up to four Medium or smaller creatures inside it at a time.`,attack_bonus:0},{name:"Transparent",desc:"Even when the cube is in plain sight, it takes a successful DC 15 Wisdom (Perception) check to spot a cube that has neither moved nor attacked. A creature that tries to enter the cube's space while unaware of the cube is surprised by the cube.",attack_bonus:0}],actions:[{name:"Pseudopod",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 10 (3d6) acid damage.",attack_bonus:4,damage_dice:"3d6"},{name:"Engulf",desc:`The cube moves up to its speed. While doing so, it can enter Large or smaller creatures' spaces. Whenever the cube enters a creature's space, the creature must make a DC 12 Dexterity saving throw. On a successful save, the creature can choose to be pushed 5 feet back or to the side of the cube. A creature that chooses not to be pushed suffers the consequences of a failed saving throw. On a failed save, the cube enters the creature's space, and the creature takes 10 (3d6) acid damage and is engulfed. The engulfed creature can't breathe, is restrained, and takes 21 (6d6) acid damage at the start of each of the cube's turns. When the cube moves, the engulfed creature moves with it. An engulfed creature can try to escape by taking an action to make a DC 12 Strength check. On a success, the creature escapes and enters a space of its choice within 5 feet of the cube.`,attack_bonus:0}]},{name:"Ghast",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"chaotic evil",ac:13,hp:36,hit_dice:"8d8",speed:"30 ft.",stats:[16,17,10,11,10,8],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"necrotic",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 10",languages:"Common",cr:"2",bestiary:!0,traits:[{name:"Stench",desc:"Any creature that starts its turn within 5 ft. of the ghast must succeed on a DC 10 Constitution saving throw or be poisoned until the start of its next turn. On a successful saving throw, the creature is immune to the ghast's Stench for 24 hours.",attack_bonus:0},{name:"Turn Defiance",desc:"The ghast and any ghouls within 30 ft. of it have advantage on saving throws against effects that turn undead.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one creature. Hit: 12 (2d8 + 3) piercing damage.",attack_bonus:3,damage_dice:"2d8",damage_bonus:3},{name:"Claws",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) slashing damage. If the target is a creature other than an undead, it must succeed on a DC 10 Constitution saving throw or be paralyzed for 1 minute. The target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3}]},{name:"Ghost",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"any alignment",ac:11,hp:45,hit_dice:"10d8",speed:"0 ft., fly 40 ft. It can hover.",stats:[7,13,10,10,12,17],damage_vulnerabilities:"",damage_resistances:"acid, fire, lightning, thunder; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"cold, necrotic, poison",condition_immunities:"charmed, exhaustion, frightened, grappled, paralyzed, petrified, poisoned, prone, restrained",senses:"darkvision 60 ft., passive Perception 11",languages:"any languages it knew in life",cr:"4",bestiary:!0,traits:[{name:"Ethereal Sight",desc:"The ghost can see 60 ft. into the Ethereal Plane when it is on the Material Plane, and vice versa.",attack_bonus:0},{name:"Incorporeal Movement",desc:"The ghost can move through other creatures and objects as if they were difficult terrain. It takes 5 (1d10) force damage if it ends its turn inside an object.",attack_bonus:0}],actions:[{name:"Withering Touch",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 17 (4d6 + 3) necrotic damage.",attack_bonus:5,damage_dice:"4d6",damage_bonus:3},{name:"Etherealness",desc:"The ghost enters the Ethereal Plane from the Material Plane, or vice versa. It is visible on the Material Plane while it is in the Border Ethereal, and vice versa, yet it can't affect or be affected by anything on the other plane.",attack_bonus:0},{name:"Horrifying Visage",desc:"Each non-undead creature within 60 ft. of the ghost that can see it must succeed on a DC 13 Wisdom saving throw or be frightened for 1 minute. If the save fails by 5 or more, the target also ages 1d4 _ 10 years. A frightened target can repeat the saving throw at the end of each of its turns, ending the frightened condition on itself on a success. If a target's saving throw is successful or the effect ends for it, the target is immune to this ghost's Horrifying Visage for the next 24 hours. The aging effect can be reversed with a greater restoration spell, but only within 24 hours of it occurring.",attack_bonus:0},{name:"Possession (Recharge 6)",desc:`One humanoid that the ghost can see within 5 ft. of it must succeed on a DC 13 Charisma saving throw or be possessed by the ghost; the ghost then disappears, and the target is incapacitated and loses control of its body. The ghost now controls the body but doesn't deprive the target of awareness. The ghost can't be targeted by any attack, spell, or other effect, except ones that turn undead, and it retains its alignment, Intelligence, Wisdom, Charisma, and immunity to being charmed and frightened. It otherwise uses the possessed target's statistics, but doesn't gain access to the target's knowledge, class features, or proficiencies. The possession lasts until the body drops to 0 hit points, the ghost ends it as a bonus action, or the ghost is turned or forced out by an effect like the dispel evil and good spell. When the possession ends, the ghost reappears in an unoccupied space within 5 ft. of the body. The target is immune to this ghost's Possession for 24 hours after succeeding on the saving throw or after the possession ends.`,attack_bonus:0}]},{name:"Ghoul",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"chaotic evil",ac:12,hp:22,hit_dice:"5d8 + -1",speed:"30 ft.",stats:[13,15,10,7,10,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 10",languages:"Common",cr:"1",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one creature. Hit: 9 (2d6 + 2) piercing damage.",attack_bonus:2,damage_dice:"2d6",damage_bonus:2},{name:"Claws",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (2d4 + 2) slashing damage. If the target is a creature other than an elf or undead, it must succeed on a DC 10 Constitution saving throw or be paralyzed for 1 minute. The target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:0}]},{name:"Giant Ape",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:157,hit_dice:"15d12 + 59",speed:"40 ft., climb 40 ft.",stats:[23,14,18,7,12,7],skillsaves:[{athletics:9},{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"",cr:"7",bestiary:!0,actions:[{name:"Multiattack",desc:"The ape makes two fist attacks.",attack_bonus:0},{name:"Fist",desc:"Melee Weapon Attack: +9 to hit, reach 10 ft., one target. Hit: 22 (3d10 + 6) bludgeoning damage.",attack_bonus:9,damage_dice:"3d10",damage_bonus:6},{name:"Rock",desc:"Ranged Weapon Attack: +9 to hit, range 50/100 ft., one target. Hit: 30 (7d6 + 6) bludgeoning damage.",attack_bonus:9,damage_dice:"7d6",damage_bonus:6}]},{name:"Giant Badger",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:13,hit_dice:"2d8 + 4",speed:"30 ft., burrow 10 ft.",stats:[13,10,15,2,12,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 11",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Keen Smell",desc:"The badger has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The badger makes two attacks: one with its bite and one with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1},{name:"Claws",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 6 (2d4 + 1) slashing damage.",attack_bonus:3,damage_dice:"2d4",damage_bonus:1}]},{name:"Giant Bat",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:22,hit_dice:"4d10",speed:"10 ft., fly 60 ft.",stats:[15,16,11,2,12,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 60 ft., passive Perception 11",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Echolocation",desc:"The bat can't use its blindsight while deafened.",attack_bonus:0},{name:"Keen Hearing",desc:"The bat has advantage on Wisdom (Perception) checks that rely on hearing.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Giant Boar",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:42,hit_dice:"5d10 + 14",speed:"40 ft.",stats:[17,10,16,2,7,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 8",languages:"",cr:"2",bestiary:!0,traits:[{name:"Charge",desc:"If the boar moves at least 20 ft. straight toward a target and then hits it with a tusk attack on the same turn, the target takes an extra 7 (2d6) slashing damage. If the target is a creature, it must succeed on a DC 13 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"2d6"},{name:"Relentless (Recharges after a Short or Long Rest)",desc:"If the boar takes 10 damage or less that would reduce it to 0 hit points, it is reduced to 1 hit point instead.",attack_bonus:0}],actions:[{name:"Tusk",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3}]},{name:"Giant Centipede",source:"5e SRD",size:"Small",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:4,hit_dice:"1d6",speed:"30 ft., climb 30 ft.",stats:[5,14,12,1,7,3],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 30 ft., passive Perception 8",languages:"",cr:"1/4",bestiary:!0,actions:[{name:"Bite",desc:"Bite. Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 4 (1d4 + 2) piercing damage, and the target must succeed on a DC 11 Constitution saving throw or take 10 (3d6) poison damage. If the poison damage reduces the target to 0 hit points, the target is stable but poisoned for 1 hour, even after regaining hit points, and is paralyzed while poisoned in this way.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Giant Constrictor Snake",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:60,hit_dice:"8d12 + 8",speed:"30 ft., swim 30 ft.",stats:[19,14,12,1,10,3],skillsaves:[{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., passive Perception 12",languages:"",cr:"2",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one creature. Hit: 11 (2d6 + 4) piercing damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4},{name:"Constrict",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one creature. Hit: 13 (2d8 + 4) bludgeoning damage, and the target is grappled (escape DC 16). Until this grapple ends, the creature is restrained, and the snake can't constrict another target.",attack_bonus:6,damage_dice:"2d8",damage_bonus:4}]},{name:"Giant Crab",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:15,hp:13,hit_dice:"3d8 + -1",speed:"30 ft., swim 30 ft.",stats:[13,15,11,1,9,3],skillsaves:[{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 30 ft., passive Perception 9",languages:"",cr:"1/8",bestiary:!0,traits:[{name:"Amphibious",desc:"The crab can breathe air and water.",attack_bonus:0}],actions:[{name:"Claw",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) bludgeoning damage, and the target is grappled (escape DC 11). The crab has two claws, each of which can grapple only one target.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Giant Crocodile",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:14,hp:85,hit_dice:"9d12 + 26",speed:"30 ft., swim 50 ft.",stats:[21,9,17,2,10,7],skillsaves:[{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"5",bestiary:!0,traits:[{name:"Hold Breath",desc:"The crocodile can hold its breath for 30 minutes.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The crocodile makes two attacks: one with its bite and one with its tail.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one target. Hit: 21 (3d10 + 5) piercing damage, and the target is grappled (escape DC 16). Until this grapple ends, the target is restrained, and the crocodile can't bite another target.",attack_bonus:8,damage_dice:"3d10",damage_bonus:5},{name:"Tail",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target not grappled by the crocodile. Hit: 14 (2d8 + 5) bludgeoning damage. If the target is a creature, it must succeed on a DC 16 Strength saving throw or be knocked prone.",attack_bonus:8,damage_dice:"2d8",damage_bonus:5}]},{name:"Giant Eagle",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"neutral good",ac:13,hp:26,hit_dice:"4d10 + 4",speed:"10 ft., fly 80 ft.",stats:[16,17,13,8,14,10],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"Giant Eagle, understands Common and Auran but can't speak",cr:"1",bestiary:!0,traits:[{name:"Keen Sight",desc:"The eagle has advantage on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The eagle makes two attacks: one with its beak and one with its talons.",attack_bonus:0},{name:"Beak",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Talons",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3}]},{name:"Giant Elk",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:15,hp:42,hit_dice:"5d12 + 9",speed:"60 ft.",stats:[19,16,14,7,14,10],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"Giant Elk, understands Common, Elvish, and Sylvan but can't speak",cr:"2",bestiary:!0,traits:[{name:"Charge",desc:"If the elk moves at least 20 ft. straight toward a target and then hits it with a ram attack on the same turn, the target takes an extra 7 (2d6) damage. If the target is a creature, it must succeed on a DC 14 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"2d6"}],actions:[{name:"Ram",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one target. Hit: 11 (2d6 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4},{name:"Hooves",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one prone creature. Hit: 22 (4d8 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"4d8",damage_bonus:4}]},{name:"Giant Fire Beetle",source:"5e SRD",size:"Small",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:4,hit_dice:"1d6",speed:"30 ft.",stats:[8,10,12,1,7,3],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 30 ft., passive Perception 8",languages:"",cr:"0",bestiary:!0,traits:[{name:"Illumination",desc:"The beetle sheds bright light in a 10-foot radius and dim light for an additional 10 ft..",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +1 to hit, reach 5 ft., one target. Hit: 2 (1d6 \u2014 1) slashing damage.",attack_bonus:1,damage_dice:"1d6",damage_bonus:-1}]},{name:"Giant Frog",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:18,hit_dice:"4d8",speed:"30 ft., swim 30 ft.",stats:[12,13,11,2,10,3],skillsaves:[{perception:2},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 12",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Amphibious",desc:"The frog can breathe air and water",attack_bonus:0},{name:"Standing Leap",desc:"The frog's long jump is up to 20 ft. and its high jump is up to 10 ft., with or without a running start.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) piercing damage, and the target is grappled (escape DC 11). Until this grapple ends, the target is restrained, and the frog can't bite another target.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1},{name:"Swallow",desc:"The frog makes one bite attack against a Small or smaller target it is grappling. If the attack hits, the target is swallowed, and the grapple ends. The swallowed target is blinded and restrained, it has total cover against attacks and other effects outside the frog, and it takes 5 (2d4) acid damage at the start of each of the frog's turns. The frog can have only one target swallowed at a time. If the frog dies, a swallowed creature is no longer restrained by it and can escape from the corpse using 5 ft. of movement, exiting prone.",attack_bonus:0}]},{name:"Giant Goat",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:19,hit_dice:"3d10 + 2",speed:"40 ft.",stats:[17,11,12,3,12,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 11",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Charge",desc:"If the goat moves at least 20 ft. straight toward a target and then hits it with a ram attack on the same turn, the target takes an extra 5 (2d4) bludgeoning damage. If the target is a creature, it must succeed on a DC 13 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"2d4"},{name:"Sure-Footed",desc:"The goat has advantage on Strength and Dexterity saving throws made against effects that would knock it prone.",attack_bonus:0}],actions:[{name:"Ram",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 8 (2d4 + 3) bludgeoning damage.",attack_bonus:5,damage_dice:"2d4",damage_bonus:3}]},{name:"Giant Hyena",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:45,hit_dice:"6d10 + 12",speed:"50 ft.",stats:[16,14,14,2,12,7],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"1",bestiary:!0,traits:[{name:"Rampage",desc:"When the hyena reduces a creature to 0 hit points with a melee attack on its turn, the hyena can take a bonus action to move up to half its speed and make a bite attack.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3}]},{name:"Giant Lizard",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:19,hit_dice:"3d10 + 2",speed:"30 ft., climb 30 ft.",stats:[15,12,13,2,10,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 10",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Variant: Hold Breath",desc:"The lizard can hold its breath for 15 minutes. (A lizard that has this trait also has a swimming speed of 30 feet.)",attack_bonus:0},{name:"Variant: Spider Climb",desc:"The lizard can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 6 (1d8 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2}]},{name:"Giant Octopus",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:52,hit_dice:"8d10 + 8",speed:"10 ft., swim 60 ft.",stats:[17,13,13,4,10,4],skillsaves:[{perception:4},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"",cr:"1",bestiary:!0,traits:[{name:"Hold Breath",desc:"While out of water, the octopus can hold its breath for 1 hour.",attack_bonus:0},{name:"Underwater Camouflage",desc:"The octopus has advantage on Dexterity (Stealth) checks made while underwater.",attack_bonus:0},{name:"Water Breathing",desc:"The octopus can breathe only underwater.",attack_bonus:0}],actions:[{name:"Tentacles",desc:"Melee Weapon Attack: +5 to hit, reach 15 ft., one target. Hit: 10 (2d6 + 3) bludgeoning damage. If the target is a creature, it is grappled (escape DC 16). Until this grapple ends, the target is restrained, and the octopus can't use its tentacles on another target.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3},{name:"Ink Cloud (Recharges after a Short or Long Rest)",desc:"A 20-foot-radius cloud of ink extends all around the octopus if it is underwater. The area is heavily obscured for 1 minute, although a significant current can disperse the ink. After releasing the ink, the octopus can use the Dash action as a bonus action.",attack_bonus:0}]},{name:"Giant Owl",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"neutral",ac:12,hp:19,hit_dice:"3d10 + 2",speed:"5 ft., fly 60 ft.",stats:[13,15,12,8,13,10],skillsaves:[{perception:5},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 15",languages:"Giant Owl, understands Common, Elvish, and Sylvan but can't speak",cr:"1/4",bestiary:!0,traits:[{name:"Flyby",desc:"The owl doesn't provoke opportunity attacks when it flies out of an enemy's reach.",attack_bonus:0},{name:"Keen Hearing and Sight",desc:"The owl has advantage on Wisdom (Perception) checks that rely on hearing or sight.",attack_bonus:0}],actions:[{name:"Talons",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 8 (2d6 + 1) slashing damage.",attack_bonus:3,damage_dice:"2d6",damage_bonus:1}]},{name:"Giant Poisonous Snake",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:14,hp:11,hit_dice:"2d8 + 2",speed:"30 ft., swim 30 ft.",stats:[10,18,13,2,10,3],skillsaves:[{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., passive Perception 12",languages:"",cr:"1/4",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one target. Hit: 6 (1d4 + 4) piercing damage, and the target must make a DC 11 Constitution saving throw, taking 10 (3d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:6,damage_dice:"1d4",damage_bonus:4}]},{name:"Giant Rat",source:"5e SRD",size:"Small",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:7,hit_dice:"2d6",speed:"30 ft.",stats:[7,15,11,2,10,4],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"",cr:"1/8",bestiary:!0,traits:[{name:"Keen Smell",desc:"The rat has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0},{name:"Pack Tactics",desc:"The rat has advantage on an attack roll against a creature if at least one of the rat's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 4 (1d4 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Giant Rat (Diseased)",source:"5e SRD",size:"Small",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:7,hit_dice:"2d6",speed:"30 ft.",stats:[7,15,11,2,10,4],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"",cr:"1/8",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 3 (1d4 + 2) piercing damage. If the target is a creature, it must succeed on a DC 10 Constitution saving throw or contract a disease. Until the disease is cured, the target can't regain hit points except by magical means, and the target's hit point maximum decreases by 3 (1d6) every 24 hours. If the target's hit point maximum drops to 0 as a result of this disease, the target dies.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Giant Scorpion",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:15,hp:52,hit_dice:"7d10 + 13",speed:"40 ft.",stats:[15,13,15,1,9,3],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 60 ft., passive Perception 9",languages:"",cr:"3",bestiary:!0,actions:[{name:"Claw",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 6 (1d8 + 2) bludgeoning damage, and the target is grappled (escape DC 12). The scorpion has two claws, each of which can grapple only one target.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2},{name:"Multiattack",desc:"The scorpion makes three attacks: two with its claws and one with its sting.",attack_bonus:0},{name:"Sting",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 7 (1d10 + 2) piercing damage, and the target must make a DC 12 Constitution saving throw, taking 22 (4d10) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:4,damage_dice:"1d10",damage_bonus:2}]},{name:"Giant Sea Horse",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:16,hit_dice:"3d10 + -1",speed:"0 ft., swim 40 ft.",stats:[12,15,11,2,12,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 11",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Charge",desc:"If the sea horse moves at least 20 ft. straight toward a target and then hits it with a ram attack on the same turn, the target takes an extra 7 (2d6) bludgeoning damage. If the target is a creature, it must succeed on a DC 11 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"2d6"},{name:"Water Breathing",desc:"The sea horse can breathe only underwater.",attack_bonus:0}],actions:[{name:"Ram",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) bludgeoning damage.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Giant Shark",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:126,hit_dice:"11d12 + 54",speed:"swim 50 ft.",stats:[23,11,21,1,10,5],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 60 ft., passive Perception 13",languages:"",cr:"5",bestiary:!0,traits:[{name:"Blood Frenzy",desc:"The shark has advantage on melee attack rolls against any creature that doesn't have all its hit points.",attack_bonus:0},{name:"Water Breathing",desc:"The shark can breathe only underwater.",attack_bonus:0}],actions:[{name:"Bite",desc:"Weapon Attack: +9 to hit, reach 5 ft., one target. Hit: 22 (3d10 + 6) piercing damage.",attack_bonus:9,damage_dice:"3d10",damage_bonus:6}]},{name:"Giant Spider",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:14,hp:26,hit_dice:"4d10 + 4",speed:"30 ft., climb 30 ft.",stats:[14,16,12,2,11,4],skillsaves:[{stealth:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 10",languages:"",cr:"1",bestiary:!0,traits:[{name:"Spider Climb",desc:"The spider can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0},{name:"Web Sense",desc:"While in contact with a web, the spider knows the exact location of any other creature in contact with the same web.",attack_bonus:0},{name:"Web Walker",desc:"The spider ignores movement restrictions caused by webbing.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one creature. Hit: 7 (1d8 + 3) piercing damage, and the target must make a DC 11 Constitution saving throw, taking 9 (2d8) poison damage on a failed save, or half as much damage on a successful one. If the poison damage reduces the target to 0 hit points, the target is stable but poisoned for 1 hour, even after regaining hit points, and is paralyzed while poisoned in this way.",attack_bonus:5,damage_dice:"1d8",damage_bonus:3},{name:"Web (Recharge 5-6)",desc:"Ranged Weapon Attack: +5 to hit, range 30/60 ft., one creature. Hit: The target is restrained by webbing. As an action, the restrained target can make a DC 12 Strength check, bursting the webbing on a success. The webbing can also be attacked and destroyed (AC 10; hp 5; vulnerability to fire damage; immunity to bludgeoning, poison, and psychic damage).",attack_bonus:5}]},{name:"Giant Toad",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:39,hit_dice:"6d10 + 6",speed:"20 ft., swim 40 ft.",stats:[15,13,13,2,10,3],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 10",languages:"",cr:"1",bestiary:!0,traits:[{name:"Amphibious",desc:"The toad can breathe air and water",attack_bonus:0},{name:"Standing Leap",desc:"The toad's long jump is up to 20 ft. and its high jump is up to 10 ft., with or without a running start.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (1d10 + 2) piercing damage plus 5 (1d10) poison damage, and the target is grappled (escape DC 13). Until this grapple ends, the target is restrained, and the toad can't bite another target.",attack_bonus:4,damage_dice:"1d10",damage_bonus:2},{name:"Swallow",desc:`The toad makes one bite attack against a Medium or smaller target it is grappling. If the attack hits, the target is swallowed, and the grapple ends. The swallowed target is blinded and restrained, it has total cover against attacks and other effects outside the toad, and it takes 10 (3d6) acid damage at the start of each of the toad's turns. The toad can have only one target swallowed at a time. If the toad dies, a swallowed creature is no longer restrained by it and can escape from the corpse using 5 feet of movement, exiting prone.`,attack_bonus:0}]},{name:"Giant Vulture",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"neutral evil",ac:10,hp:22,hit_dice:"3d10 + 5",speed:"10 ft., fly 60 ft.",stats:[15,10,15,6,12,7],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"understands Common but can't speak",cr:"1",bestiary:!0,traits:[{name:"Keen Sight and Smell",desc:"The vulture has advantage on Wisdom (Perception) checks that rely on sight or smell.",attack_bonus:0},{name:"Pack Tactics",desc:"The vulture has advantage on an attack roll against a creature if at least one of the vulture's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The vulture makes two attacks: one with its beak and one with its talons.",attack_bonus:0},{name:"Beak",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (2d4 + 2) piercing damage.",attack_bonus:4,damage_dice:"2d4",damage_bonus:2},{name:"Talons",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 9 (2d6 + 2) slashing damage.",attack_bonus:4,damage_dice:"2d6",damage_bonus:2}]},{name:"Giant Wasp",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:13,hit_dice:"3d8 + -1",speed:"10 ft., fly 50 ft., swim 50 ft.",stats:[10,14,10,1,10,3],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"1/2",bestiary:!0,actions:[{name:"Sting",desc:"Sting. Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 5 (1d6 + 2) piercing damage, and the target must make a DC 11 Constitution saving throw, taking 10 (3d6) poison damage on a failed save, or half as much damage on a successful one. If the poison damage reduces the target to 0 hit points, the target is stable but poisoned for 1 hour, even after regaining hit points, and is paralyzed while poisoned in this way.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Giant Weasel",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:9,hit_dice:"2d8",speed:"40 ft.",stats:[11,16,10,4,12,5],skillsaves:[{perception:3},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 13",languages:"",cr:"1/8",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The weasel has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0}],actions:[{name:"Bite",desc:"Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 5 (1d4 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d4",damage_bonus:3}]},{name:"Giant Wolf Spider",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:11,hit_dice:"2d8 + 2",speed:"40 ft., climb 40 ft.",stats:[12,16,13,3,12,4],skillsaves:[{perception:3},{stealth:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 13",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Spider Climb",desc:"The spider can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0},{name:"Web Sense",desc:"While in contact with a web, the spider knows the exact location of any other creature in contact with the same web.",attack_bonus:0},{name:"Web Walker",desc:"The spider ignores movement restrictions caused by webbing.",attack_bonus:0}],actions:[{name:"Bite",desc:"Weapon Attack: +3 to hit, reach 5 ft., one creature. Hit: 4 (1d6 + 1) piercing damage, and the target must make a DC 11 Constitution saving throw, taking 7 (2d6) poison damage on a failed save, or half as much damage on a successful one. If the poison damage reduces the target to 0 hit points, the target is stable but poisoned for 1 hour, even after regaining hit points, and is paralyzed while poisoned in this way.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Gibbering Mouther",source:"5e SRD",size:"Medium",type:"aberration",subtype:"",alignment:"neutral",ac:9,hp:67,hit_dice:"9d8 + 26",speed:"10 ft., swim 10 ft.",stats:[10,8,16,3,10,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"prone",senses:"darkvision 60 ft., passive Perception 10",languages:"",cr:"2",bestiary:!0,traits:[{name:"Aberrant Ground",desc:"The ground in a 10-foot radius around the mouther is doughlike difficult terrain. Each creature that starts its turn in that area must succeed on a DC 10 Strength saving throw or have its speed reduced to 0 until the start of its next turn.",attack_bonus:0},{name:"Gibbering",desc:"The mouther babbles incoherently while it can see any creature and isn't incapacitated. Each creature that starts its turn within 20 feet of the mouther and can hear the gibbering must succeed on a DC 10 Wisdom saving throw. On a failure, the creature can't take reactions until the start of its next turn and rolls a d8 to determine what it does during its turn. On a 1 to 4, the creature does nothing. On a 5 or 6, the creature takes no action or bonus action and uses all its movement to move in a randomly determined direction. On a 7 or 8, the creature makes a melee attack against a randomly determined creature within its reach or does nothing if it can't make such an attack.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The gibbering mouther makes one bite attack and, if it can, uses its Blinding Spittle.",attack_bonus:0},{name:"Bites",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one creature. Hit: 17 (5d6) piercing damage. If the target is Medium or smaller, it must succeed on a DC 10 Strength saving throw or be knocked prone. If the target is killed by this damage, it is absorbed into the mouther.",attack_bonus:2,damage_dice:"5d6"},{name:"Blinding Spittle (Recharge 5-6)",desc:"The mouther spits a chemical glob at a point it can see within 15 feet of it. The glob explodes in a blinding flash of light on impact. Each creature within 5 feet of the flash must succeed on a DC 13 Dexterity saving throw or be blinded until the end of the mouther's next turn.",attack_bonus:0}]},{name:"Glabrezu",source:"5e SRD",size:"Large",type:"fiend",subtype:"demon",alignment:"chaotic evil",ac:17,hp:157,hit_dice:"15d10 + 74",speed:"40 ft.",stats:[20,15,21,19,17,16],saves:[{strength:9},{constitution:9},{wisdom:7},{charisma:7}],damage_vulnerabilities:"",damage_resistances:"cold, fire, lightning; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"poisoned",senses:"truesight 120 ft., passive Perception 13",languages:"Abyssal, telepathy 120 ft.",cr:"9",bestiary:!0,traits:[{name:"Innate Spellcasting",desc:`The glabrezu's spellcasting ability is Intelligence (spell save DC 16). The glabrezu can innately cast the following spells, requiring no material components: At will: darkness, detect magic, dispel magic 1/day each: confusion, fly, power word stun`,attack_bonus:0},{name:"Magic Resistance",desc:"The glabrezu has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The glabrezu makes four attacks: two with its pincers and two with its fists. Alternatively, it makes two attacks with its pincers and casts one spell.",attack_bonus:0},{name:"Pincer",desc:"Melee Weapon Attack: +9 to hit, reach 10 ft., one target. Hit: 16 (2d10 + 5) bludgeoning damage. If the target is a Medium or smaller creature, it is grappled (escape DC 15). The glabrezu has two pincers, each of which can grapple only one target.",attack_bonus:9,damage_dice:"2d10",damage_bonus:5},{name:"Fist",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one target. Hit: 7 (2d4 + 2) bludgeoning damage.",attack_bonus:9,damage_dice:"2d4",damage_bonus:2},{name:"Variant: Summon Demon (1/Day)",desc:`The demon chooses what to summon and attempts a magical summoning. A glabrezu has a 30 percent chance of summoning 1d3 vrocks, 1d2 hezrous, or one glabrezu. A summoned demon appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other demons. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.`,attack_bonus:0}]},{name:"Gladiator",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:16,hp:112,hit_dice:"15d8 + 44",speed:"30 ft.",stats:[18,15,16,10,12,15],saves:[{strength:7},{dexterity:5},{constitution:6}],skillsaves:[{intimidation:5},{athletics:10}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 11",languages:"any one language (usually Common)",cr:"5",bestiary:!0,traits:[{name:"Brave",desc:"The gladiator has advantage on saving throws against being frightened.",attack_bonus:0},{name:"Brute",desc:"A melee weapon deals one extra die of its damage when the gladiator hits with it (included in the attack).",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The gladiator makes three melee attacks or two ranged attacks.",attack_bonus:0},{name:"Spear",desc:"Melee or Ranged Weapon Attack: +7 to hit, reach 5 ft. and range 20/60 ft., one target. Hit: 11 (2d6 + 4) piercing damage, or 13 (2d8 + 4) piercing damage if used with two hands to make a melee attack.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Shield Bash",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one creature. Hit: 9 (2d4 + 4) bludgeoning damage. If the target is a Medium or smaller creature, it must succeed on a DC 15 Strength saving throw or be knocked prone.",attack_bonus:7,damage_dice:"2d4",damage_bonus:4}],reactions:[{name:"Parry",desc:"The gladiator adds 3 to its AC against one melee attack that would hit it. To do so, the gladiator must see the attacker and be wielding a melee weapon.",attack_bonus:0}]},{name:"Gnoll",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"gnoll",alignment:"chaotic evil",ac:15,hp:22,hit_dice:"5d8 + -1",speed:"30 ft.",stats:[14,12,11,6,10,7],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"Gnoll",cr:"1/2",bestiary:!0,traits:[{name:"Rampage",desc:"When the gnoll reduces a creature to 0 hit points with a melee attack on its turn, the gnoll can take a bonus action to move up to half its speed and make a bite attack.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 4 (1d4 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2},{name:"Spear",desc:"Melee or Ranged Weapon Attack: +4 to hit, reach 5 ft. or range 20/60 ft., one target. Hit: 5 (1d6 + 2) piercing damage, or 6 (1d8 + 2) piercing damage if used with two hands to make a melee attack.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Longbow",desc:"Ranged Weapon Attack: +3 to hit, range 150/600 ft., one target. Hit: 5 (1d8 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d8",damage_bonus:1}]},{name:"Goat",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:4,hit_dice:"1d8 + -1",speed:"40 ft.",stats:[12,10,11,2,10,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"0",bestiary:!0,traits:[{name:"Charge",desc:"If the goat moves at least 20 ft. straight toward a target and then hits it with a ram attack on the same turn, the target takes an extra 2 (1d4) bludgeoning damage. If the target is a creature, it must succeed on a DC 10 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"1d4"},{name:"Sure-Footed",desc:"The goat has advantage on Strength and Dexterity saving throws made against effects that would knock it prone.",attack_bonus:0}],actions:[{name:"Ram",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 3 (1d4 + 1) bludgeoning damage.",attack_bonus:3,damage_dice:"1d4",damage_bonus:1}]},{name:"Goblin",source:"5e SRD",size:"Small",type:"humanoid",subtype:"goblinoid",alignment:"neutral evil",ac:15,hp:7,hit_dice:"2d6",speed:"30 ft.",stats:[8,14,10,10,8,8],skillsaves:[{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 9",languages:"Common, Goblin",cr:"1/4",bestiary:!0,traits:[{name:"Nimble Escape",desc:"The goblin can take the Disengage or Hide action as a bonus action on each of its turns.",attack_bonus:0}],actions:[{name:"Scimitar",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) slashing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Shortbow",desc:"Ranged Weapon Attack: +4 to hit, range 80/320 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Gold Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"lawful good",ac:17,hp:60,hit_dice:"8d8 + 24",speed:"30 ft., fly 60 ft., swim 30 ft.",stats:[19,14,17,14,11,16],saves:[{dexterity:4},{constitution:5},{wisdom:2},{charisma:5}],skillsaves:[{perception:4},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"3",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 9 (1d10 + 4) piercing damage.",attack_bonus:6,damage_dice:"1d10",damage_bonus:4},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Fire Breath. The dragon exhales fire in a 15-foot cone. Each creature in that area must make a DC 13 Dexterity saving throw, taking 22 (4d10) fire damage on a failed save, or half as much damage on a successful one. Weakening Breath. The dragon exhales gas in a 15-foot cone. Each creature in that area must succeed on a DC 13 Strength saving throw or have disadvantage on Strength-based attack rolls, Strength checks, and Strength saving throws for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.`,attack_bonus:0,damage_dice:"4d10"}]},{name:"Gorgon",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"unaligned",ac:19,hp:114,hit_dice:"12d10 + 48",speed:"40 ft.",stats:[20,11,18,2,12,7],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"petrified",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"",cr:"5",bestiary:!0,traits:[{name:"Trampling Charge",desc:"If the gorgon moves at least 20 feet straight toward a creature and then hits it with a gore attack on the same turn, that target must succeed on a DC 16 Strength saving throw or be knocked prone. If the target is prone, the gorgon can make one attack with its hooves against it as a bonus action.",attack_bonus:0}],actions:[{name:"Gore",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one target. Hit: 18 (2d12 + 5) piercing damage.",attack_bonus:8,damage_dice:"2d12",damage_bonus:5},{name:"Hooves",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one target. Hit: 16 (2d10 + 5) bludgeoning damage.",attack_bonus:8,damage_dice:"2d10",damage_bonus:5},{name:"Petrifying Breath (Recharge 5-6)",desc:"The gorgon exhales petrifying gas in a 30-foot cone. Each creature in that area must succeed on a DC 13 Constitution saving throw. On a failed save, a target begins to turn to stone and is restrained. The restrained target must repeat the saving throw at the end of its next turn. On a success, the effect ends on the target. On a failure, the target is petrified until freed by the greater restoration spell or other magic.",attack_bonus:0}]},{name:"Gray Ooze",source:"5e SRD",size:"Medium",type:"ooze",subtype:"",alignment:"unaligned",ac:8,hp:22,hit_dice:"3d8 + 8",speed:"10 ft., climb 10 ft.",stats:[12,6,16,1,6,2],skillsaves:[{stealth:2}],damage_vulnerabilities:"",damage_resistances:"acid, cold, fire",damage_immunities:"",condition_immunities:"blinded, charmed, deafened, exhaustion, frightened, prone",senses:"blindsight 60 ft. (blind beyond this radius), passive Perception 8",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Amorphous",desc:"The ooze can move through a space as narrow as 1 inch wide without squeezing.",attack_bonus:0},{name:"Corrode Metal",desc:`Any nonmagical weapon made of metal that hits the ooze corrodes. After dealing damage, the weapon takes a permanent and cumulative -1 penalty to damage rolls. If its penalty drops to -5, the weapon is destroyed. Nonmagical ammunition made of metal that hits the ooze is destroyed after dealing damage. The ooze can eat through 2-inch-thick, nonmagical metal in 1 round.`,attack_bonus:0},{name:"False Appearance",desc:"While the ooze remains motionless, it is indistinguishable from an oily pool or wet rock.",attack_bonus:0}],actions:[{name:"Pseudopod",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) bludgeoning damage plus 7 (2d6) acid damage, and if the target is wearing nonmagical metal armor, its armor is partly corroded and takes a permanent and cumulative -1 penalty to the AC it offers. The armor is destroyed if the penalty reduces its AC to 10.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Green Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"lawful evil",ac:17,hp:38,hit_dice:"7d8 + 6",speed:"30 ft., fly 60 ft., swim 30 ft.",stats:[15,12,13,14,11,13],saves:[{dexterity:3},{constitution:3},{wisdom:2},{charisma:3}],skillsaves:[{perception:4},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"poisoned",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"2",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (1d10 + 2) piercing damage plus 3 (1d6) poison damage.",attack_bonus:4,damage_dice:"1d10 + 1d6",damage_bonus:3},{name:"Poison Breath (Recharge 5-6)",desc:"The dragon exhales poisonous gas in a 15-foot cone. Each creature in that area must make a DC 11 Constitution saving throw, taking 21 (6d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"6d6"}]},{name:"Green Hag",source:"5e SRD",size:"Medium",type:"fey",subtype:"",alignment:"neutral evil",ac:17,hp:82,hit_dice:"11d8 + 32",speed:"30 ft.",stats:[18,12,16,13,14,14],skillsaves:[{arcana:3},{deception:4},{perception:4},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"Common, Draconic, Sylvan",cr:"3",bestiary:!0,traits:[{name:"Amphibious",desc:"The hag can breathe air and water.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The hag's innate spellcasting ability is Charisma (spell save DC 12). She can innately cast the following spells, requiring no material components: At will: dancing lights, minor illusion, vicious mockery`,attack_bonus:0},{name:"Mimicry",desc:"The hag can mimic animal sounds and humanoid voices. A creature that hears the sounds can tell they are imitations with a successful DC 14 Wisdom (Insight) check.",attack_bonus:0},{name:"Hag Coven",desc:`When hags must work together, they form covens, in spite of their selfish natures. A coven is made up of hags of any type, all of whom are equals within the group. However, each of the hags continues to desire more personal power. A coven consists of three hags so that any arguments between two hags can be settled by the third. If more than three hags ever come together, as might happen if two covens come into conflict, the result is usually chaos.`,attack_bonus:0},{name:"Shared Spellcasting (Coven Only)",desc:`While all three members of a hag coven are within 30 feet of one another, they can each cast the following spells from the wizard's spell list but must share the spell slots among themselves: \u2022 1st level (4 slots): identify, ray of sickness \u2022 2nd level (3 slots): hold person, locate object \u2022 3rd level (3 slots): bestow curse, counterspell, lightning bolt \u2022 4th level (3 slots): phantasmal killer, polymorph \u2022 5th level (2 slots): contact other plane, scrying \u2022 6th level (1 slot): eye bite For casting these spells, each hag is a 12th-level spellcaster that uses Intelligence as her spellcasting ability. The spell save DC is 12+the hag's Intelligence modifier, and the spell attack bonus is 4+the hag's Intelligence modifier.`,attack_bonus:0},{name:"Hag Eye (Coven Only)",desc:`A hag coven can craft a magic item called a hag eye, which is made from a real eye coated in varnish and often fitted to a pendant or other wearable item. The hag eye is usually entrusted to a minion for safekeeping and transport. A hag in the coven can take an action to see what the hag eye sees if the hag eye is on the same plane of existence. A hag eye has AC 10, 1 hit point, and darkvision with a radius of 60 feet. If it is destroyed, each coven member takes 3d10 psychic damage and is blinded for 24 hours. A hag coven can have only one hag eye at a time, and creating a new one requires all three members of the coven to perform a ritual. The ritual takes 1 hour, and the hags can't perform it while blinded. During the ritual, if the hags take any action other than performing the ritual, they must start over.`,attack_bonus:0}],actions:[{name:"Claws",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) slashing damage.",attack_bonus:6,damage_dice:"2d8",damage_bonus:4},{name:"Illusory Appearance",desc:`The hag covers herself and anything she is wearing or carrying with a magical illusion that makes her look like another creature of her general size and humanoid shape. The illusion ends if the hag takes a bonus action to end it or if she dies. The changes wrought by this effect fail to hold up to physical inspection. For example, the hag could appear to have smooth skin, but someone touching her would feel her rough flesh. Otherwise, a creature must take an action to visually inspect the illusion and succeed on a DC 20 Intelligence (Investigation) check to discern that the hag is disguised.`,attack_bonus:0},{name:"Invisible Passage",desc:"The hag magically turns invisible until she attacks or casts a spell, or until her concentration ends (as if concentrating on a spell). While invisible, she leaves no physical evidence of her passage, so she can be tracked only by magic. Any equipment she wears or carries is invisible with her.",attack_bonus:0}]},{name:"Grick",source:"5e SRD",size:"Medium",type:"monstrosity",subtype:"",alignment:"neutral",ac:14,hp:27,hit_dice:"6d8",speed:"30 ft., climb 30 ft.",stats:[14,14,11,3,14,5],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, and slashing damage from nonmagical weapons",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 12",languages:"",cr:"2",bestiary:!0,traits:[{name:"Stone Camouflage",desc:"The grick has advantage on Dexterity (Stealth) checks made to hide in rocky terrain.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The grick makes one attack with its tentacles. If that attack hits, the grick can make one beak attack against the same target.",attack_bonus:0},{name:"Tentacles",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 9 (2d6 + 2) slashing damage.",attack_bonus:4,damage_dice:"2d6",damage_bonus:2},{name:"Beak",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Griffon",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"unaligned",ac:12,hp:59,hit_dice:"7d10 + 20",speed:"30 ft., fly 80 ft.",stats:[18,15,16,2,13,8],skillsaves:[{perception:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 15",languages:"",cr:"2",bestiary:!0,traits:[{name:"Keen Sight",desc:"The griffon has advantage on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The griffon makes two attacks: one with its beak and one with its claws.",attack_bonus:0},{name:"Beak",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 8 (1d8 + 4) piercing damage.",attack_bonus:6,damage_dice:"1d8",damage_bonus:4},{name:"Claws",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4}]},{name:"Grimlock",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"grimlock",alignment:"neutral evil",ac:11,hp:11,hit_dice:"2d8 + 2",speed:"30 ft.",stats:[16,12,12,9,8,6],skillsaves:[{athletics:5},{perception:3},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"blinded",condition_immunities:"",senses:"blindsight 30 ft. or 10 ft. while deafened (blind beyond this radius), passive Perception 13",languages:"Undercommon",cr:"1/4",bestiary:!0,traits:[{name:"Blind Senses",desc:"The grimlock can't use its blindsight while deafened and unable to smell.",attack_bonus:0},{name:"Keen Hearing and Smell",desc:"The grimlock has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0},{name:"Stone Camouflage",desc:"The grimlock has advantage on Dexterity (Stealth) checks made to hide in rocky terrain.",attack_bonus:0}],actions:[{name:"Spiked Bone Club",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 5 (1d4 + 3) bludgeoning damage plus 2 (1d4) piercing damage.",attack_bonus:5,damage_dice:"1d4 + 1d4",damage_bonus:5}]},{name:"Guard",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:16,hp:11,hit_dice:"2d8 + 2",speed:"30 ft.",stats:[13,12,12,10,11,10],skillsaves:[{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 12",languages:"any one language (usually Common)",cr:"1/8",bestiary:!0,actions:[{name:"Spear",desc:"Melee or Ranged Weapon Attack: +3 to hit, reach 5 ft. or range 20/60 ft., one target. Hit: 4 (1d6 + 1) piercing damage or 5 (1d8 + 1) piercing damage if used with two hands to make a melee attack.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Guardian Naga",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"lawful good",ac:18,hp:127,hit_dice:"15d10 + 44",speed:"40 ft.",stats:[19,18,16,16,19,18],saves:[{dexterity:8},{constitution:7},{intelligence:7},{wisdom:8},{charisma:8}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"charmed, poisoned",senses:"darkvision 60 ft., passive Perception 14",languages:"Celestial, Common",cr:"10",bestiary:!0,traits:[{name:"Rejuvenation",desc:"If it dies, the naga returns to life in 1d6 days and regains all its hit points. Only a wish spell can prevent this trait from functioning.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one creature. Hit: 8 (1d8 + 4) piercing damage, and the target must make a DC 15 Constitution saving throw, taking 45 (10d8) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:8,damage_dice:"1d8",damage_bonus:4},{name:"Spit Poison",desc:"Ranged Weapon Attack: +8 to hit, range 15/30 ft., one creature. Hit: The target must make a DC 15 Constitution saving throw, taking 45 (10d8) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:8,damage_dice:"10d8"}],spells:["The naga is an 11th-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 16, +8 to hit with spell attacks), and it needs only verbal components to cast its spells. It has the following cleric spells prepared:",{"Cantrips (at will)":"mending, sacred flame, thaumaturgy"},{"1st level (4 slots)":"command, cure wounds, shield of faith"},{"2nd level (3 slots)":"calm emotions, hold person"},{"3rd level (3 slots)":"bestow curse, clairvoyance"},{"4th level (3 slots)":"banishment, freedom of movement"},{"5th level (2 slots)":"flame strike, geas"},{"6th level (1 slot)":"true seeing"}]},{name:"Gynosphinx",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"lawful neutral",ac:17,hp:136,hit_dice:"16d10 + 48",speed:"40 ft., fly 60 ft.",stats:[18,15,16,18,18,18],skillsaves:[{arcana:12},{history:12},{perception:8},{religion:8}],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"psychic",condition_immunities:"charmed, frightened",senses:"truesight 120 ft., passive Perception 18",languages:"Common, Sphinx",cr:"11",bestiary:!0,traits:[{name:"Inscrutable",desc:"The sphinx is immune to any effect that would sense its emotions or read its thoughts, as well as any divination spell that it refuses. Wisdom (Insight) checks made to ascertain the sphinx's intentions or sincerity have disadvantage.",attack_bonus:0},{name:"Magic Weapons",desc:"The sphinx's weapon attacks are magical.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The sphinx makes two claw attacks.",attack_bonus:0},{name:"Claw",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) slashing damage.",attack_bonus:9,damage_dice:"2d8",damage_bonus:4}],legendary_actions:[{name:"Claw Attack",desc:"The sphinx makes one claw attack.",attack_bonus:0},{name:"Teleport (Costs 2 Actions)",desc:"The sphinx magically teleports, along with any equipment it is wearing or carrying, up to 120 feet to an unoccupied space it can see.",attack_bonus:0},{name:"Cast a Spell (Costs 3 Actions)",desc:"The sphinx casts a spell from its list of prepared spells, using a spell slot as normal.",attack_bonus:0}],spells:["The sphinx is a 9th-level spellcaster. Its spellcasting ability is Intelligence (spell save DC 16, +8 to hit with spell attacks). It requires no material components to cast its spells. The sphinx has the following wizard spells prepared:",{"Cantrips (at will)":"mage hand, minor illusion, prestidigitation"},{"1st level (4 slots)":"detect magic, identify, shield"},{"2nd level (3 slots)":"darkness, locate object, suggestion"},{"3rd level (3 slots)":"dispel magic, remove curse, tongues"},{"4th level (3 slots)":"banishment, greater invisibility"},{"5th level (1 slot)":"legend lore"}]},{name:"Half-Red Dragon Veteran",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"human",alignment:"any alignment",ac:18,hp:65,hit_dice:"10d8 + 20",speed:"30 ft.",stats:[16,13,14,10,11,10],damage_vulnerabilities:"",damage_resistances:"fire",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 12",languages:"Common, Draconic",cr:"5",bestiary:!0,actions:[{name:"Multiattack",desc:"The veteran makes two longsword attacks. If it has a shortsword drawn, it can also make a shortsword attack.",attack_bonus:0},{name:"Longsword",desc:"Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) slashing damage, or 8 (1d10 + 3) slashing damage if used with two hands.",attack_bonus:5,damage_dice:"1d8",damage_bonus:3},{name:"Shortsword",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Heavy Crossbow",desc:"Ranged Weapon Attack: +3 to hit, range 100/400 ft., one target. Hit: 6 (1d10 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d10",damage_bonus:1},{name:"Fire Breath (Recharge 5-6)",desc:"The veteran exhales fire in a 15-foot cone. Each creature in that area must make a DC 15 Dexterity saving throw, taking 24 (7d6) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"7d6"}]},{name:"Harpy",source:"5e SRD",size:"Medium",type:"monstrosity",subtype:"",alignment:"chaotic evil",ac:11,hp:38,hit_dice:"7d8 + 6",speed:"20 ft., fly 40 ft.",stats:[12,13,12,7,10,13],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"Common",cr:"1",bestiary:!0,actions:[{name:"Multiattack",desc:"The harpy makes two attacks: one with its claws and one with its club.",attack_bonus:0},{name:"Claws",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 6 (2d4 + 1) slashing damage.",attack_bonus:3,damage_dice:"2d4",damage_bonus:1},{name:"Club",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 3 (1d4 + 1) bludgeoning damage.",attack_bonus:3,damage_dice:"1d4",damage_bonus:1},{name:"Luring Song",desc:`The harpy sings a magical melody. Every humanoid and giant within 300 ft. of the harpy that can hear the song must succeed on a DC 11 Wisdom saving throw or be charmed until the song ends. The harpy must take a bonus action on its subsequent turns to continue singing. It can stop singing at any time. The song ends if the harpy is incapacitated. While charmed by the harpy, a target is incapacitated and ignores the songs of other harpies. If the charmed target is more than 5 ft. away from the harpy, the must move on its turn toward the harpy by the most direct route. It doesn't avoid opportunity attacks, but before moving into damaging terrain, such as lava or a pit, and whenever it takes damage from a source other than the harpy, a target can repeat the saving throw. A creature can also repeat the saving throw at the end of each of its turns. If a creature's saving throw is successful, the effect ends on it. A target that successfully saves is immune to this harpy's song for the next 24 hours.`,attack_bonus:0}]},{name:"Hawk",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:1,hit_dice:"1d4 + -2",speed:"10 ft., fly 60 ft.",stats:[5,16,8,2,14,6],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"",cr:"0",bestiary:!0,traits:[{name:"Keen Sight",desc:"The hawk has advantage on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Talons",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 1 slashing damage.",attack_bonus:5,damage_bonus:1}]},{name:"Hell Hound",source:"5e SRD",size:"Medium",type:"fiend",subtype:"",alignment:"lawful evil",ac:15,hp:45,hit_dice:"7d8 + 13",speed:"50 ft.",stats:[17,12,14,6,13,6],skillsaves:[{perception:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 15",languages:"understands Infernal but can't speak it",cr:"3",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The hound has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0},{name:"Pack Tactics",desc:"The hound has advantage on an attack roll against a creature if at least one of the hound's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) piercing damage plus 7 (2d6) fire damage.",attack_bonus:5,damage_dice:"1d8",damage_bonus:3},{name:"Fire Breath (Recharge 5-6)",desc:"The hound exhales fire in a 15-foot cone. Each creature in that area must make a DC 12 Dexterity saving throw, taking 21 (6d6) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"6d6"}]},{name:"Hezrou",source:"5e SRD",size:"Large",type:"fiend",subtype:"demon",alignment:"chaotic evil",ac:16,hp:136,hit_dice:"13d10 + 64",speed:"30 ft.",stats:[19,17,20,5,12,13],saves:[{strength:7},{constitution:8},{wisdom:4}],damage_vulnerabilities:"",damage_resistances:"cold, fire, lightning; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"poisoned",senses:"darkvision 120 ft., passive Perception 11",languages:"Abyssal, telepathy 120 ft.",cr:"8",bestiary:!0,traits:[{name:"Magic Resistance",desc:"The hezrou has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Stench",desc:"Any creature that starts its turn within 10 feet of the hezrou must succeed on a DC 14 Constitution saving throw or be poisoned until the start of its next turn. On a successful saving throw, the creature is immune to the hezrou's stench for 24 hours.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The hezrou makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 15 (2d10 + 4) piercing damage.",attack_bonus:7,damage_dice:"2d10",damage_bonus:4},{name:"Claws",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Variant: Summon Demon (1/Day)",desc:`The demon chooses what to summon and attempts a magical summoning. A hezrou has a 30 percent chance of summoning 2d6 dretches or one hezrou. A summoned demon appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other demons. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.`,attack_bonus:0}]},{name:"Hill Giant",source:"5e SRD",size:"Huge",type:"giant",subtype:"",alignment:"chaotic evil",ac:13,hp:105,hit_dice:"10d12 + 40",speed:"40 ft.",stats:[21,8,19,5,9,6],skillsaves:[{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 12",languages:"Giant",cr:"5",bestiary:!0,actions:[{name:"Multiattack",desc:"The giant makes two greatclub attacks.",attack_bonus:0},{name:"Greatclub",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target. Hit: 18 (3d8 + 5) bludgeoning damage.",attack_bonus:8,damage_dice:"3d8",damage_bonus:5},{name:"Rock",desc:"Ranged Weapon Attack: +8 to hit, range 60/240 ft., one target. Hit: 21 (3d10 + 5) bludgeoning damage.",attack_bonus:8,damage_dice:"3d10",damage_bonus:5}]},{name:"Hippogriff",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"unaligned",ac:11,hp:19,hit_dice:"3d10 + 2",speed:"40 ft, fly 60 ft.",stats:[17,13,13,2,12,8],skillsaves:[{perception:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 15",languages:"",cr:"1",bestiary:!0,traits:[{name:"Keen Sight",desc:"The hippogriff has advantage on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The hippogriff makes two attacks: one with its beak and one with its claws.",attack_bonus:0},{name:"Beak",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 8 (1d10 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d10",damage_bonus:3},{name:"Claws",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3}]},{name:"Hobgoblin",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"goblinoid",alignment:"lawful evil",ac:18,hp:11,hit_dice:"2d8 + 2",speed:"30 ft.",stats:[13,12,12,10,10,9],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"Common, Goblin",cr:"1/2",bestiary:!0,traits:[{name:"Martial Advantage",desc:"Once per turn, the hobgoblin can deal an extra 7 (2d6) damage to a creature it hits with a weapon attack if that creature is within 5 ft. of an ally of the hobgoblin that isn't incapacitated.",attack_bonus:0,damage_dice:"2d6"}],actions:[{name:"Longsword",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 5 (1d8 + 1) slashing damage, or 6 (1d10 + 1) slashing damage if used with two hands.",attack_bonus:3,damage_dice:"1d8",damage_bonus:1},{name:"Longbow",desc:"Ranged Weapon Attack: +3 to hit, range 150/600 ft., one target. Hit: 5 (1d8 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d8",damage_bonus:1}]},{name:"Homunculus",source:"5e SRD",size:"Tiny",type:"construct",subtype:"",alignment:"neutral",ac:13,hp:5,hit_dice:"2d4",speed:"20 ft., fly 40 ft.",stats:[4,15,11,10,10,7],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"charmed, poisoned",senses:"darkvision 60 ft., passive Perception 10",languages:"understands the languages of its creator but can't speak",cr:"0",bestiary:!0,traits:[{name:"Telepathic Bond",desc:"While the homunculus is on the same plane of existence as its master, it can magically convey what it senses to its master, and the two can communicate telepathically.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 1 piercing damage, and the target must succeed on a DC 10 Constitution saving throw or be poisoned for 1 minute. If the saving throw fails by 5 or more, the target is instead poisoned for 5 (1d10) minutes and unconscious while poisoned in this way.",attack_bonus:4,damage_bonus:1}]},{name:"Horned Devil",source:"5e SRD",size:"Large",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:18,hp:148,hit_dice:"17d10 + 54",speed:"20 ft., fly 60 ft.",stats:[22,17,21,12,16,17],saves:[{strength:10},{dexterity:7},{wisdom:7},{charisma:7}],damage_vulnerabilities:"",damage_resistances:"cold; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"darkvision 120 ft., passive Perception 13",languages:"Infernal, telepathy 120 ft.",cr:"11",bestiary:!0,traits:[{name:"Devil's Sight",desc:"Magical darkness doesn't impede the devil's darkvision.",attack_bonus:0},{name:"Magic Resistance",desc:"The devil has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The devil makes three melee attacks: two with its fork and one with its tail. It can use Hurl Flame in place of any melee attack.",attack_bonus:0},{name:"Fork",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 15 (2d8 + 6) piercing damage.",attack_bonus:10,damage_dice:"2d8",damage_bonus:6},{name:"Tail",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 10 (1d8 + 6) piercing damage. If the target is a creature other than an undead or a construct, it must succeed on a DC 17 Constitution saving throw or lose 10 (3d6) hit points at the start of each of its turns due to an infernal wound. Each time the devil hits the wounded target with this attack, the damage dealt by the wound increases by 10 (3d6). Any creature can take an action to stanch the wound with a successful DC 12 Wisdom (Medicine) check. The wound also closes if the target receives magical healing.",attack_bonus:10,damage_dice:"1d8",damage_bonus:6},{name:"Hurl Flame",desc:"Ranged Spell Attack: +7 to hit, range 150 ft., one target. Hit: 14 (4d6) fire damage. If the target is a flammable object that isn't being worn or carried, it also catches fire.",attack_bonus:7,damage_dice:"4d6"}]},{name:"Hunter Shark",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:45,hit_dice:"6d10 + 12",speed:"swim 40 ft.",stats:[18,13,15,1,10,4],skillsaves:[{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 12",languages:"",cr:"2",bestiary:!0,traits:[{name:"Blood Frenzy",desc:"The shark has advantage on melee attack rolls against any creature that doesn't have all its hit points.",attack_bonus:0},{name:"Water Breathing",desc:"The shark can breathe only underwater.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) piercing damage.",attack_bonus:6,damage_dice:"2d8",damage_bonus:4}]},{name:"Hydra",source:"5e SRD",size:"Huge",type:"monstrosity",subtype:"",alignment:"unaligned",ac:15,hp:172,hit_dice:"15d12 + 74",speed:"30 ft., swim 30 ft.",stats:[20,12,20,2,10,7],skillsaves:[{perception:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 16",languages:"",cr:"8",bestiary:!0,traits:[{name:"Hold Breath",desc:"The hydra can hold its breath for 1 hour.",attack_bonus:0},{name:"Multiple Heads",desc:`The hydra has five heads. While it has more than one head, the hydra has advantage on saving throws against being blinded, charmed, deafened, frightened, stunned, and knocked unconscious. Whenever the hydra takes 25 or more damage in a single turn, one of its heads dies. If all its heads die, the hydra dies. At the end of its turn, it grows two heads for each of its heads that died since its last turn, unless it has taken fire damage since its last turn. The hydra regains 10 hit points for each head regrown in this way.`,attack_bonus:0},{name:"Reactive Heads",desc:"For each head the hydra has beyond one, it gets an extra reaction that can be used only for opportunity attacks.",attack_bonus:0},{name:"Wakeful",desc:"While the hydra sleeps, at least one of its heads is awake.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The hydra makes as many bite attacks as it has heads.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target. Hit: 10 (1d10 + 5) piercing damage.",attack_bonus:8,damage_dice:"1d10",damage_bonus:5}]},{name:"Hyena",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:5,hit_dice:"1d8",speed:"50 ft.",stats:[11,13,12,2,12,5],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"0",bestiary:!0,traits:[{name:"Pack Tactics",desc:"The hyena has advantage on an attack roll against a creature if at least one of the hyena's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Bite",desc:"Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 3 (1d6) piercing damage.",attack_bonus:2,damage_dice:"1d6"}]},{name:"Ice Devil",source:"5e SRD",size:"Large",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:18,hp:180,hit_dice:"19d10 + 75",speed:"40 ft.",stats:[21,14,18,18,15,18],saves:[{dexterity:7},{constitution:9},{wisdom:7},{charisma:9}],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"blindsight 60 ft., darkvision 120 ft., passive Perception 12",languages:"Infernal, telepathy 120 ft.",cr:"14",bestiary:!0,traits:[{name:"Devil's Sight",desc:"Magical darkness doesn't impede the devil's darkvision.",attack_bonus:0},{name:"Magic Resistance",desc:"The devil has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The devil makes three attacks: one with its bite, one with its claws, and one with its tail.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one target. Hit: 12 (2d6 + 5) piercing damage plus 10 (3d6) cold damage.",attack_bonus:10,damage_dice:"2d6 + 3d6",damage_bonus:5},{name:"Claws",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one target. Hit: 10 (2d4 + 5) slashing damage plus 10 (3d6) cold damage.",attack_bonus:10,damage_dice:"2d4 + 3d6",damage_bonus:5},{name:"Tail",desc:"Melee Weapon Attack:+10 to hit, reach 10 ft., one target. Hit: 12 (2d6 + 5) bludgeoning damage plus 10 (3d6) cold damage.",attack_bonus:10,damage_dice:"2d6 + 3d6",damage_bonus:5},{name:"Wall of Ice",desc:`The devil magically forms an opaque wall of ice on a solid surface it can see within 60 feet of it. The wall is 1 foot thick and up to 30 feet long and 10 feet high, or it's a hemispherical dome up to 20 feet in diameter. When the wall appears, each creature in its space is pushed out of it by the shortest route. The creature chooses which side of the wall to end up on, unless the creature is incapacitated. The creature then makes a DC 17 Dexterity saving throw, taking 35 (10d6) cold damage on a failed save, or half as much damage on a successful one. The wall lasts for 1 minute or until the devil is incapacitated or dies. The wall can be damaged and breached; each 10-foot section has AC 5, 30 hit points, vulnerability to fire damage, and immunity to acid, cold, necrotic, poison, and psychic damage. If a section is destroyed, it leaves behind a sheet of frigid air in the space the wall occupied. Whenever a creature finishes moving through the frigid air on a turn, willingly or otherwise, the creature must make a DC 17 Constitution saving throw, taking 17 (5d6) cold damage on a failed save, or half as much damage on a successful one. The frigid air dissipates when the rest of the wall vanishes.`,attack_bonus:0}]},{name:"Ice Mephit",source:"5e SRD",size:"Small",type:"elemental",subtype:"",alignment:"neutral evil",ac:11,hp:21,hit_dice:"6d6",speed:"30 ft., fly 30 ft.",stats:[7,13,10,9,11,12],skillsaves:[{perception:2},{stealth:3}],damage_vulnerabilities:"bludgeoning, fire",damage_resistances:"",damage_immunities:"cold, poison",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 12",languages:"Aquan, Auran",cr:"1/2",bestiary:!0,traits:[{name:"Death Burst",desc:"When the mephit dies, it explodes in a burst of jagged ice. Each creature within 5 ft. of it must make a DC 10 Dexterity saving throw, taking 4 (1d8) slashing damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"1d8"},{name:"False Appearance",desc:"While the mephit remains motionless, it is indistinguishable from an ordinary shard of ice.",attack_bonus:0},{name:"Innate Spellcasting (1/Day)",desc:"The mephit can innately cast fog cloud, requiring no material components. Its innate spellcasting ability is Charisma.",attack_bonus:0}],actions:[{name:"Claws",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one creature. Hit: 3 (1d4 + 1) slashing damage plus 2 (1d4) cold damage.",attack_bonus:3,damage_dice:"1d4",damage_bonus:1},{name:"Frost Breath (Recharge 6)",desc:"The mephit exhales a 15-foot cone of cold air. Each creature in that area must succeed on a DC 10 Dexterity saving throw, taking 5 (2d4) cold damage on a failed save, or half as much damage on a successful one.",attack_bonus:0},{name:"Variant: Summon Mephits (1/Day)",desc:"The mephit has a 25 percent chance of summoning 1d4 mephits of its kind. A summoned mephit appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other mephits. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.",attack_bonus:0}]},{name:"Imp",source:"5e SRD",size:"Tiny",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:13,hp:10,hit_dice:"3d4 + 2",speed:"20 ft., fly 40 ft.",stats:[6,17,13,11,12,14],skillsaves:[{deception:4},{insight:3},{persuasion:4},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"cold; bludgeoning, piercing, and slashing from nonmagical/nonsilver weapons",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"darkvision 120 ft., passive Perception 11",languages:"Infernal, Common",cr:"1",bestiary:!0,traits:[{name:"Shapechanger",desc:"The imp can use its action to polymorph into a beast form that resembles a rat (speed 20 ft.), a raven (20 ft., fly 60 ft.), or a spider (20 ft., climb 20 ft.), or back into its true form. Its statistics are the same in each form, except for the speed changes noted. Any equipment it is wearing or carrying isn't transformed. It reverts to its true form if it dies.",attack_bonus:0},{name:"Devil's Sight",desc:"Magical darkness doesn't impede the imp's darkvision.",attack_bonus:0},{name:"Magic Resistance",desc:"The imp has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Variant: Familiar",desc:"The imp can serve another creature as a familiar, forming a telepathic bond with its willing master. While the two are bonded, the master can sense what the quasit senses as long as they are within 1 mile of each other. While the imp is within 10 feet of its master, the master shares the quasit's Magic Resistance trait. At any time and for any reason, the imp can end its service as a familiar, ending the telepathic bond.",attack_bonus:0}],actions:[{name:"Sting (Bite in Beast Form)",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft ., one target. Hit: 5 (1d4 + 3) piercing damage, and the target must make on a DC 11 Constitution saving throw, taking 10 (3d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:5,damage_dice:"1d4",damage_bonus:3},{name:"Invisibility",desc:"The imp magically turns invisible until it attacks, or until its concentration ends (as if concentrating on a spell). Any equipment the imp wears or carries is invisible with it.",attack_bonus:0}]},{name:"Invisible Stalker",source:"5e SRD",size:"Medium",type:"elemental",subtype:"",alignment:"neutral",ac:14,hp:104,hit_dice:"16d8 + 32",speed:"50 ft., fly 50 ft. (hover)",stats:[16,19,14,10,15,11],skillsaves:[{perception:8},{stealth:10}],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"exhaustion, grappled, paralyzed, petrified, poisoned, prone, restrained, unconscious",senses:"darkvision 60 ft., passive Perception 18",languages:"Auran, understands Common but doesn't speak it",cr:"6",bestiary:!0,traits:[{name:"Invisibility",desc:"The stalker is invisible.",attack_bonus:0},{name:"Faultless Tracker",desc:"The stalker is given a quarry by its summoner. The stalker knows the direction and distance to its quarry as long as the two of them are on the same plane of existence. The stalker also knows the location of its summoner.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The stalker makes two slam attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) bludgeoning damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:3}]},{name:"Iron Golem",source:"5e SRD",size:"Large",type:"construct",subtype:"",alignment:"unaligned",ac:20,hp:210,hit_dice:"20d10 + 100",speed:"30 ft.",stats:[24,9,20,3,11,1],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire, poison, psychic; bludgeoning, piercing, and slashing from nonmagical weapons that aren't adamantine",condition_immunities:"charmed, exhaustion, frightened, paralyzed, petrified, poisoned",senses:"darkvision 120 ft., passive Perception 10",languages:"understands the languages of its creator but can't speak",cr:"16",bestiary:!0,traits:[{name:"Fire Absorption",desc:"Whenever the golem is subjected to fire damage, it takes no damage and instead regains a number of hit points equal to the fire damage dealt.",attack_bonus:0},{name:"Immutable Form",desc:"The golem is immune to any spell or effect that would alter its form.",attack_bonus:0},{name:"Magic Resistance",desc:"The golem has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Magic Weapons",desc:"The golem's weapon attacks are magical.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The golem makes two melee attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +13 to hit, reach 5 ft., one target. Hit: 20 (3d8 + 7) bludgeoning damage.",attack_bonus:13,damage_dice:"3d8",damage_bonus:7},{name:"Sword",desc:"Melee Weapon Attack: +13 to hit, reach 10 ft., one target. Hit: 23 (3d10 + 7) slashing damage.",attack_bonus:13,damage_dice:"3d10",damage_bonus:7},{name:"Poison Breath (Recharge 5-6)",desc:"The golem exhales poisonous gas in a 15-foot cone. Each creature in that area must make a DC 19 Constitution saving throw, taking 45 (l0d8) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"10d8"}]},{name:"Jackal",source:"5e SRD",size:"Small",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:3,hit_dice:"1d6 + -1",speed:"40 ft.",stats:[8,15,11,3,12,6],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"0",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The jackal has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0},{name:"Pack Tactics",desc:"The jackal has advantage on an attack roll against a creature if at least one of the jackal's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +1 to hit, reach 5 ft., one target. Hit: 1 (1d4 \u2014 1) piercing damage.",attack_bonus:1,damage_dice:"1d4",damage_bonus:-1}]},{name:"Killer Whale",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:90,hit_dice:"12d12 + 12",speed:"swim 60 ft.",stats:[19,10,13,3,12,7],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 120 ft., passive Perception 13",languages:"",cr:"3",bestiary:!0,traits:[{name:"Echolocation",desc:"The whale can't use its blindsight while deafened.",attack_bonus:0},{name:"Hold Breath",desc:"The whale can hold its breath for 30 minutes",attack_bonus:0},{name:"Keen Hearing",desc:"The whale has advantage on Wisdom (Perception) checks that rely on hearing.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 21 (5d6 + 4) piercing damage.",attack_bonus:0}]},{name:"Knight",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:18,hp:52,hit_dice:"8d8 + 16",speed:"30 ft.",stats:[16,11,14,11,11,15],saves:[{constitution:4},{wisdom:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"any one language (usually Common)",cr:"3",bestiary:!0,traits:[{name:"Brave",desc:"The knight has advantage on saving throws against being frightened.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The knight makes two melee attacks.",attack_bonus:0},{name:"Greatsword",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3},{name:"Heavy Crossbow",desc:"Ranged Weapon Attack: +2 to hit, range 100/400 ft., one target. Hit: 5 (1d10) piercing damage.",attack_bonus:2,damage_dice:"1d10"},{name:"Leadership (Recharges after a Short or Long Rest)",desc:"For 1 minute, the knight can utter a special command or warning whenever a nonhostile creature that it can see within 30 ft. of it makes an attack roll or a saving throw. The creature can add a d4 to its roll provided it can hear and understand the knight. A creature can benefit from only one Leadership die at a time. This effect ends if the knight is incapacitated.",attack_bonus:0}],reactions:[{name:"Parry",desc:"The knight adds 2 to its AC against one melee attack that would hit it. To do so, the knight must see the attacker and be wielding a melee weapon.",attack_bonus:0}]},{name:"Kobold",source:"5e SRD",size:"Small",type:"humanoid",subtype:"kobold",alignment:"lawful evil",ac:12,hp:5,hit_dice:"2d6 + -2",speed:"30 ft.",stats:[7,15,9,8,7,8],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 8",languages:"Common, Draconic",cr:"1/8",bestiary:!0,traits:[{name:"Sunlight Sensitivity",desc:"While in sunlight, the kobold has disadvantage on attack rolls, as well as on Wisdom (Perception) checks that rely on sight.",attack_bonus:0},{name:"Pack Tactics",desc:"The kobold has advantage on an attack roll against a creature if at least one of the kobold's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Dagger",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 4 (1d4 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2},{name:"Sling",desc:"Ranged Weapon Attack: +4 to hit, range 30/120 ft., one target. Hit: 4 (1d4 + 2) bludgeoning damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Kraken",source:"5e SRD",size:"Gargantuan",type:"monstrosity",subtype:"titan",alignment:"chaotic evil",ac:18,hp:472,hit_dice:"27d20 + 188",speed:"20 ft., swim 60 ft.",stats:[30,11,25,22,18,20],saves:[{strength:17},{dexterity:7},{constitution:14},{intelligence:13},{wisdom:11}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning; bludgeoning, piercing, and slashing from nonmagical weapons",condition_immunities:"frightened, paralyzed",senses:"truesight 120 ft., passive Perception 14",languages:"understands Abyssal, Celestial, Infernal, and Primordial but can't speak, telepathy 120 ft.",cr:"23",bestiary:!0,traits:[{name:"Amphibious",desc:"The kraken can breathe air and water.",attack_bonus:0},{name:"Freedom of Movement",desc:"The kraken ignores difficult terrain, and magical effects can't reduce its speed or cause it to be restrained. It can spend 5 feet of movement to escape from nonmagical restraints or being grappled.",attack_bonus:0},{name:"Siege Monster",desc:"The kraken deals double damage to objects and structures.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The kraken makes three tentacle attacks, each of which it can replace with one use of Fling.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 23 (3d8 + 10) piercing damage. If the target is a Large or smaller creature grappled by the kraken, that creature is swallowed, and the grapple ends. While swallowed, the creature is blinded and restrained, it has total cover against attacks and other effects outside the kraken, and it takes 42 (12d6) acid damage at the start of each of the kraken's turns. If the kraken takes 50 damage or more on a single turn from a creature inside it, the kraken must succeed on a DC 25 Constitution saving throw at the end of that turn or regurgitate all swallowed creatures, which fall prone in a space within 10 feet of the kraken. If the kraken dies, a swallowed creature is no longer restrained by it and can escape from the corpse using 15 feet of movement, exiting prone.",attack_bonus:7,damage_dice:"3d8",damage_bonus:10},{name:"Tentacle",desc:"Melee Weapon Attack: +7 to hit, reach 30 ft., one target. Hit: 20 (3d6 + 10) bludgeoning damage, and the target is grappled (escape DC 18). Until this grapple ends, the target is restrained. The kraken has ten tentacles, each of which can grapple one target.",attack_bonus:7,damage_dice:"3d6",damage_bonus:10},{name:"Fling",desc:"One Large or smaller object held or creature grappled by the kraken is thrown up to 60 feet in a random direction and knocked prone. If a thrown target strikes a solid surface, the target takes 3 (1d6) bludgeoning damage for every 10 feet it was thrown. If the target is thrown at another creature, that creature must succeed on a DC 18 Dexterity saving throw or take the same damage and be knocked prone.",attack_bonus:0},{name:"Lightning Storm",desc:"The kraken magically creates three bolts of lightning, each of which can strike a target the kraken can see within 120 feet of it. A target must make a DC 23 Dexterity saving throw, taking 22 (4d10) lightning damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"4d10"}],legendary_actions:[{name:"Tentacle Attack or Fling",desc:"The kraken makes one tentacle attack or uses its Fling.",attack_bonus:0},{name:"Lightning Storm (Costs 2 Actions)",desc:"The kraken uses Lightning Storm.",attack_bonus:0},{name:"Ink Cloud (Costs 3 Actions)",desc:"While underwater, the kraken expels an ink cloud in a 60-foot radius. The cloud spreads around corners, and that area is heavily obscured to creatures other than the kraken. Each creature other than the kraken that ends its turn there must succeed on a DC 23 Constitution saving throw, taking 16 (3d10) poison damage on a failed save, or half as much damage on a successful one. A strong current disperses the cloud, which otherwise disappears at the end of the kraken's next turn.",attack_bonus:0}]},{name:"Lamia",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"chaotic evil",ac:13,hp:97,hit_dice:"13d10 + 25",speed:"30 ft.",stats:[16,13,15,14,15,16],skillsaves:[{deception:7},{insight:4},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 12",languages:"Abyssal, Common",cr:"4",bestiary:!0,traits:[{name:"Innate Spellcasting",desc:"The lamia's innate spellcasting ability is Charisma (spell save DC 13). It can innately cast the following spells, requiring no material components. At will: disguise self (any humanoid form), major image 3/day each: charm person, mirror image, scrying, suggestion 1/day: geas",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The lamia makes two attacks: one with its claws and one with its dagger or Intoxicating Touch.",attack_bonus:0},{name:"Claws",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 14 (2d10 + 3) slashing damage.",attack_bonus:5,damage_dice:"2d10",damage_bonus:3},{name:"Dagger",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 5 (1d4 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d4",damage_bonus:3},{name:"Intoxicating Touch",desc:"Melee Spell Attack: +5 to hit, reach 5 ft., one creature. Hit: The target is magically cursed for 1 hour. Until the curse ends, the target has disadvantage on Wisdom saving throws and all ability checks.",attack_bonus:0}]},{name:"Lemure",source:"5e SRD",size:"Medium",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:7,hp:13,hit_dice:"3d8 + -1",speed:"15 ft.",stats:[10,5,11,1,11,3],damage_vulnerabilities:"",damage_resistances:"cold",damage_immunities:"fire, poison",condition_immunities:"charmed, frightened, poisoned",senses:"darkvision 120 ft., passive Perception 10",languages:"understands infernal but can't speak",cr:"0",bestiary:!0,traits:[{name:"Devil's Sight",desc:"Magical darkness doesn't impede the lemure's darkvision.",attack_bonus:0},{name:"Hellish Rejuvenation",desc:"A lemure that dies in the Nine Hells comes back to life with all its hit points in 1d10 days unless it is killed by a good-aligned creature with a bless spell cast on that creature or its remains are sprinkled with holy water.",attack_bonus:0}],actions:[{name:"Fist",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 2 (1d4) bludgeoning damage",attack_bonus:3,damage_dice:"1d4"}]},{name:"Lich",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"any evil alignment",ac:17,hp:135,hit_dice:"18d8 + 54",speed:"30 ft.",stats:[11,16,16,20,14,16],saves:[{constitution:10},{intelligence:12},{wisdom:9}],skillsaves:[{arcana:18},{history:12},{insight:9},{perception:9}],damage_vulnerabilities:"",damage_resistances:"cold, lightning, necrotic",damage_immunities:"poison; bludgeoning, piercing, and slashing from nonmagical weapons",condition_immunities:"charmed, exhaustion, frightened, paralyzed, poisoned",senses:"truesight 120 ft., passive Perception 19",languages:"Common plus up to five other languages",cr:"21",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the lich fails a saving throw, it can choose to succeed instead.",attack_bonus:0},{name:"Rejuvenation",desc:"If it has a phylactery, a destroyed lich gains a new body in 1d10 days, regaining all its hit points and becoming active again. The new body appears within 5 feet of the phylactery.",attack_bonus:0},{name:"Turn Resistance",desc:"The lich has advantage on saving throws against any effect that turns undead.",attack_bonus:0}],actions:[{name:"Paralyzing Touch",desc:"Melee Spell Attack: +12 to hit, reach 5 ft., one creature. Hit: 10 (3d6) cold damage. The target must succeed on a DC 18 Constitution saving throw or be paralyzed for 1 minute. The target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:12,damage_dice:"3d6"}],legendary_actions:[{name:"Cantrip",desc:"The lich casts a cantrip.",attack_bonus:0},{name:"Paralyzing Touch (Costs 2 Actions)",desc:"The lich uses its Paralyzing Touch.",attack_bonus:0},{name:"Frightening Gaze (Costs 2 Actions)",desc:"The lich fixes its gaze on one creature it can see within 10 feet of it. The target must succeed on a DC 18 Wisdom saving throw against this magic or become frightened for 1 minute. The frightened target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a target's saving throw is successful or the effect ends for it, the target is immune to the lich's gaze for the next 24 hours.",attack_bonus:0},{name:"Disrupt Life (Costs 3 Actions)",desc:"Each living creature within 20 feet of the lich must make a DC 18 Constitution saving throw against this magic, taking 21 (6d6) necrotic damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"6d6"}],spells:["The lich is an 18th-level spellcaster. Its spellcasting ability is Intelligence (spell save DC 20, +12 to hit with spell attacks). The lich has the following wizard spells prepared:",{"Cantrips (at will)":"mage hand, prestidigitation, ray of frost"},{"1st level (4 slots)":"detect magic, magic missile, shield, thunderwave"},{"2nd level (3 slots)":"detect thoughts, invisibility, Melf's acid arrow, mirror image"},{"3rd level (3 slots)":"animate dead, counterspell, dispel magic, fireball"},{"4th level (3 slots)":"blight, dimension door"},{"5th level (3 slots)":"cloudkill, scrying"},{"6th level (1 slot)":"disintegrate, globe of invulnerability"},{"7th level (1 slot)":"finger of death, plane shift"},{"8th level (1 slot)":"dominate monster, power word stun"},{"9th level (1 slot)":"power word kill"}]},{name:"Lion",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:26,hit_dice:"4d10 + 4",speed:"50 ft.",stats:[17,15,13,3,12,8],skillsaves:[{perception:3},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"1",bestiary:!0,traits:[{name:"Keen Smell",desc:"The lion has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0},{name:"Pack Tactics",desc:"The lion has advantage on an attack roll against a creature if at least one of the lion's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0},{name:"Pounce",desc:"If the lion moves at least 20 ft. straight toward a creature and then hits it with a claw attack on the same turn, that target must succeed on a DC 13 Strength saving throw or be knocked prone. If the target is prone, the lion can make one bite attack against it as a bonus action.",attack_bonus:0},{name:"Running Leap",desc:"With a 10-foot running start, the lion can long jump up to 25 ft..",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d8",damage_bonus:3},{name:"Claw",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3}]},{name:"Lizard",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:2,hit_dice:"1d4 + -1",speed:"20 ft., climb 20 ft.",stats:[2,11,10,1,8,3],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 9",languages:"",cr:"0",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +0 to hit, reach 5 ft., one target. Hit: 1 piercing damage.",attack_bonus:0,damage_bonus:1}]},{name:"Lizardfolk",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"lizardfolk",alignment:"neutral",ac:15,hp:22,hit_dice:"4d8 + 4",speed:"30 ft., swim 30 ft.",stats:[15,10,13,7,12,7],skillsaves:[{perception:3},{stealth:4},{survival:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"Draconic",cr:"1/2",bestiary:!0,traits:[{name:"Hold Breath",desc:"The lizardfolk can hold its breath for 15 minutes.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The lizardfolk makes two melee attacks, each one with a different weapon.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Heavy Club",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) bludgeoning damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Javelin",desc:"Melee or Ranged Weapon Attack: +4 to hit, reach 5 ft. or range 30/120 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Spiked Shield",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Mage",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:12,hp:40,hit_dice:"9d8 + -1",speed:"30 ft.",stats:[9,14,11,17,12,11],saves:[{intelligence:6},{wisdom:4}],skillsaves:[{arcana:6},{history:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 11",languages:"any four languages",cr:"6",bestiary:!0,traits:[],actions:[{name:"Dagger",desc:"Melee or Ranged Weapon Attack: +5 to hit, reach 5 ft. or range 20/60 ft., one target. Hit: 4 (1d4 + 2) piercing damage.",attack_bonus:5,damage_dice:"1d4",damage_bonus:2}],spells:["The mage is a 9th-level spellcaster. Its spellcasting ability is Intelligence (spell save DC 14, +6 to hit with spell attacks). The mage has the following wizard spells prepared:",{"Cantrips (at will)":"fire bolt, light, mage hand, prestidigitation"},{"1st level (4 slots)":"detect magic, mage armor, magic missile, shield"},{"2nd level (3 slots)":"misty step, suggestion"},{"3rd level (3 slots)":"counterspell, fireball, fly"},{"4th level (3 slots)":"greater invisibility, ice storm"},{"5th level (1 slot)":"cone of cold"}]},{name:"Magma Mephit",source:"5e SRD",size:"Small",type:"elemental",subtype:"",alignment:"neutral evil",ac:11,hp:22,hit_dice:"5d6 + 4",speed:"30 ft., fly 30 ft.",stats:[8,12,12,7,10,10],skillsaves:[{stealth:3}],damage_vulnerabilities:"cold",damage_resistances:"",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 10",languages:"Ignan, Terran",cr:"1/2",bestiary:!0,traits:[{name:"Death Burst",desc:"When the mephit dies, it explodes in a burst of lava. Each creature within 5 ft. of it must make a DC 11 Dexterity saving throw, taking 7 (2d6) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"2d6"},{name:"False Appearance",desc:"While the mephit remains motionless, it is indistinguishable from an ordinary mound of magma.",attack_bonus:0},{name:"Innate Spellcasting (1/Day)",desc:"The mephit can innately cast heat metal (spell save DC 10), requiring no material components. Its innate spellcasting ability is Charisma.",attack_bonus:0}],actions:[{name:"Claws",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft ., one creature. Hit: 3 (1d4 + 1) slashing damage plus 2 (1d4) fire damage.",attack_bonus:3,damage_dice:"1d4",damage_bonus:1},{name:"Fire Breath (Recharge 6)",desc:"The mephit exhales a 15-foot cone of fire. Each creature in that area must make a DC 11 Dexterity saving throw, taking 7 (2d6) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0},{name:"Variant: Summon Mephits (1/Day)",desc:"The mephit has a 25 percent chance of summoning 1d4 mephits of its kind. A summoned mephit appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other mephits. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.",attack_bonus:0}]},{name:"Magmin",source:"5e SRD",size:"Small",type:"elemental",subtype:"",alignment:"chaotic neutral",ac:14,hp:9,hit_dice:"2d6 + 2",speed:"30 ft.",stats:[7,15,12,8,11,10],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"fire",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"Ignan",cr:"1/2",bestiary:!0,traits:[{name:"Death Burst",desc:"When the magmin dies, it explodes in a burst of fire and magma. Each creature within 10 ft. of it must make a DC 11 Dexterity saving throw, taking 7 (2d6) fire damage on a failed save, or half as much damage on a successful one. Flammable objects that aren't being worn or carried in that area are ignited.",attack_bonus:0,damage_dice:"2d6"},{name:"Ignited Illumination",desc:"As a bonus action, the magmin can set itself ablaze or extinguish its flames. While ablaze, the magmin sheds bright light in a 10-foot radius and dim light for an additional 10 ft.",attack_bonus:0}],actions:[{name:"Touch",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (2d6) fire damage. If the target is a creature or a flammable object, it ignites. Until a target takes an action to douse the fire, the target takes 3 (1d6) fire damage at the end of each of its turns.",attack_bonus:4,damage_dice:"2d6"}]},{name:"Mammoth",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:126,hit_dice:"11d12 + 54",speed:"40 ft.",stats:[24,9,21,3,11,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"6",bestiary:!0,traits:[{name:"Trampling Charge",desc:"If the mammoth moves at least 20 ft. straight toward a creature and then hits it with a gore attack on the same turn, that target must succeed on a DC 18 Strength saving throw or be knocked prone. If the target is prone, the mammoth can make one stomp attack against it as a bonus action.",attack_bonus:0}],actions:[{name:"Gore",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 25 (4d8 + 7) piercing damage.",attack_bonus:10,damage_dice:"4d8",damage_bonus:7},{name:"Stomp",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one prone creature. Hit: 29 (4d10 + 7) bludgeoning damage.",attack_bonus:10,damage_dice:"4d10",damage_bonus:7}]},{name:"Manticore",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"lawful evil",ac:14,hp:68,hit_dice:"8d10 + 24",speed:"30 ft., fly 50 ft.",stats:[17,16,17,7,12,8],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 11",languages:"",cr:"3",bestiary:!0,traits:[{name:"Tail Spike Regrowth",desc:"The manticore has twenty-four tail spikes. Used spikes regrow when the manticore finishes a long rest.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The manticore makes three attacks: one with its bite and two with its claws or three with its tail spikes.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d8",damage_bonus:3},{name:"Claw",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Tail Spike",desc:"Ranged Weapon Attack: +5 to hit, range 100/200 ft., one target. Hit: 7 (1d8 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d8",damage_bonus:3}]},{name:"Marilith",source:"5e SRD",size:"Large",type:"fiend",subtype:"demon",alignment:"chaotic evil",ac:18,hp:189,hit_dice:"18d10 + 90",speed:"40 ft.",stats:[18,20,20,18,16,20],saves:[{strength:9},{constitution:10},{wisdom:8},{charisma:10}],damage_vulnerabilities:"",damage_resistances:"cold, fire, lightning; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"poisoned",senses:"truesight 120 ft., passive Perception 13",languages:"Abyssal, telepathy 120 ft.",cr:"16",bestiary:!0,traits:[{name:"Magic Resistance",desc:"The marilith has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Magic Weapons",desc:"The marilith's weapon attacks are magical.",attack_bonus:0},{name:"Reactive",desc:"The marilith can take one reaction on every turn in combat.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The marilith can make seven attacks: six with its longswords and one with its tail.",attack_bonus:0},{name:"Longsword",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) slashing damage.",attack_bonus:9,damage_dice:"2d8",damage_bonus:4},{name:"Tail",desc:"Melee Weapon Attack: +9 to hit, reach 10 ft., one creature. Hit: 15 (2d10 + 4) bludgeoning damage. If the target is Medium or smaller, it is grappled (escape DC 19). Until this grapple ends, the target is restrained, the marilith can automatically hit the target with its tail, and the marilith can't make tail attacks against other targets.",attack_bonus:9,damage_dice:"2d10",damage_bonus:4},{name:"Teleport",desc:"The marilith magically teleports, along with any equipment it is wearing or carrying, up to 120 feet to an unoccupied space it can see.",attack_bonus:0},{name:"Variant: Summon Demon (1/Day)",desc:`The demon chooses what to summon and attempts a magical summoning. A marilith has a 50 percent chance of summoning 1d6 vrocks, 1d4 hezrous, 1d3 glabrezus, 1d2 nalfeshnees, or one marilith. A summoned demon appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other demons. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.`,attack_bonus:0}],reactions:[{name:"Parry",desc:"The marilith adds 5 to its AC against one melee attack that would hit it. To do so, the marilith must see the attacker and be wielding a melee weapon.",attack_bonus:0}]},{name:"Mastiff",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:5,hit_dice:"1d8",speed:"40 ft.",stats:[13,14,12,3,12,7],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"1/8",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The mastiff has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) piercing damage. If the target is a creature, it must succeed on a DC 11 Strength saving throw or be knocked prone.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Medusa",source:"5e SRD",size:"Medium",type:"monstrosity",subtype:"",alignment:"lawful evil",ac:15,hp:127,hit_dice:"17d8 + 50",speed:"30 ft.",stats:[10,15,16,12,13,15],skillsaves:[{deception:5},{insight:4},{perception:4},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"Common",cr:"6",bestiary:!0,traits:[{name:"Petrifying Gaze",desc:`When a creature that can see the medusa's eyes starts its turn within 30 ft. of the medusa, the medusa can force it to make a DC 14 Constitution saving throw if the medusa isn't incapacitated and can see the creature. If the saving throw fails by 5 or more, the creature is instantly petrified. Otherwise, a creature that fails the save begins to turn to stone and is restrained. The restrained creature must repeat the saving throw at the end of its next turn, becoming petrified on a failure or ending the effect on a success. The petrification lasts until the creature is freed by the greater restoration spell or other magic. Unless surprised, a creature can avert its eyes to avoid the saving throw at the start of its turn. If the creature does so, it can't see the medusa until the start of its next turn, when it can avert its eyes again. If the creature looks at the medusa in the meantime, it must immediately make the save. If the medusa sees itself reflected on a polished surface within 30 ft. of it and in an area of bright light, the medusa is, due to its curse, affected by its own gaze.`,attack_bonus:0}],actions:[{name:"Multiattack",desc:"The medusa makes either three melee attacks \u2014 one with its snake hair and two with its shortsword \u2014 or two ranged attacks with its longbow.",attack_bonus:0},{name:"Snake Hair",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one creature. Hit: 4 (1d4 + 2) piercing damage plus 14 (4d6) poison damage.",attack_bonus:5,damage_dice:"1d4",damage_bonus:2},{name:"Shortsword",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:2},{name:"Longbow",desc:"Ranged Weapon Attack: +5 to hit, range 150/600 ft., one target. Hit: 6 (1d8 + 2) piercing damage plus 7 (2d6) poison damage.",attack_bonus:5,damage_dice:"2d6"}]},{name:"Merfolk",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"merfolk",alignment:"neutral",ac:11,hp:11,hit_dice:"2d8 + 2",speed:"10 ft., swim 40 ft.",stats:[10,13,12,11,11,12],skillsaves:[{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 12",languages:"Aquan, Common",cr:"1/8",bestiary:!0,traits:[{name:"Amphibious",desc:"The merfolk can breathe air and water.",attack_bonus:0}],actions:[{name:"Spear",desc:"Melee or Ranged Weapon Attack: +2 to hit, reach 5 ft. or range 20/60 ft., one target. Hit: 3 (1d6) piercing damage, or 4 (1d8) piercing damage if used with two hands to make a melee attack.",attack_bonus:2,damage_dice:"1d6"}]},{name:"Merrow",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"chaotic evil",ac:13,hp:45,hit_dice:"6d10 + 12",speed:"10 ft., swim 40 ft.",stats:[18,10,15,8,10,9],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"Abyssal, Aquan",cr:"2",bestiary:!0,traits:[{name:"Amphibious",desc:"The merrow can breathe air and water.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The merrow makes two attacks: one with its bite and one with its claws or harpoon.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 8 (1d8 + 4) piercing damage.",attack_bonus:6,damage_dice:"1d8",damage_bonus:4},{name:"Claws",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 9 (2d4 + 4) slashing damage.",attack_bonus:6,damage_dice:"2d4",damage_bonus:4},{name:"Harpoon",desc:"Melee or Ranged Weapon Attack: +6 to hit, reach 5 ft. or range 20/60 ft., one target. Hit: 11 (2d6 + 4) piercing damage. If the target is a Huge or smaller creature, it must succeed on a Strength contest against the merrow or be pulled up to 20 feet toward the merrow.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4}]},{name:"Mimic",source:"5e SRD",size:"Medium",type:"monstrosity",subtype:"shapechanger",alignment:"neutral",ac:12,hp:58,hit_dice:"9d8 + 17",speed:"15 ft.",stats:[17,12,15,5,13,8],skillsaves:[{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid",condition_immunities:"prone",senses:"darkvision 60 ft., passive Perception 11",languages:"",cr:"2",bestiary:!0,traits:[{name:"Shapechanger",desc:"The mimic can use its action to polymorph into an object or back into its true, amorphous form. Its statistics are the same in each form. Any equipment it is wearing or carrying isn 't transformed. It reverts to its true form if it dies.",attack_bonus:0},{name:"Adhesive (Object Form Only)",desc:"The mimic adheres to anything that touches it. A Huge or smaller creature adhered to the mimic is also grappled by it (escape DC 13). Ability checks made to escape this grapple have disadvantage.",attack_bonus:0},{name:"False Appearance (Object Form Only)",desc:"While the mimic remains motionless, it is indistinguishable from an ordinary object.",attack_bonus:0},{name:"Grappler",desc:"The mimic has advantage on attack rolls against any creature grappled by it.",attack_bonus:0}],actions:[{name:"Pseudopod",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) bludgeoning damage. If the mimic is in object form, the target is subjected to its Adhesive trait.",attack_bonus:5,damage_dice:"1d8",damage_bonus:3},{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) piercing damage plus 4 (1d8) acid damage.",attack_bonus:5,damage_dice:"1d8 + 1d8",damage_bonus:3}]},{name:"Minotaur",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"chaotic evil",ac:14,hp:76,hit_dice:"9d10 + 26",speed:"40 ft.",stats:[18,11,16,6,16,9],skillsaves:[{perception:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 17",languages:"Abyssal",cr:"3",bestiary:!0,traits:[{name:"Charge",desc:"If the minotaur moves at least 10 ft. straight toward a target and then hits it with a gore attack on the same turn, the target takes an extra 9 (2d8) piercing damage. If the target is a creature, it must succeed on a DC 14 Strength saving throw or be pushed up to 10 ft. away and knocked prone.",attack_bonus:0,damage_dice:"2d8"},{name:"Labyrinthine Recall",desc:"The minotaur can perfectly recall any path it has traveled.",attack_bonus:0},{name:"Reckless",desc:"At the start of its turn, the minotaur can gain advantage on all melee weapon attack rolls it makes during that turn, but attack rolls against it have advantage until the start of its next turn.",attack_bonus:0}],actions:[{name:"Greataxe",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 17 (2d12 + 4) slashing damage.",attack_bonus:6,damage_dice:"2d12",damage_bonus:4},{name:"Gore",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) piercing damage.",attack_bonus:6,damage_dice:"2d8",damage_bonus:4}]},{name:"Minotaur Skeleton",source:"5e SRD",size:"Large",type:"undead",subtype:"",alignment:"lawful evil",ac:12,hp:67,hit_dice:"9d10 + 17",speed:"40 ft.",stats:[18,11,15,6,8,5],damage_vulnerabilities:"bludgeoning",damage_resistances:"",damage_immunities:"poison",condition_immunities:"exhaustion, poisoned",senses:"darkvision 60 ft., passive Perception 9",languages:"understands Abyssal but can't speak",cr:"2",bestiary:!0,traits:[{name:"Charge",desc:"If the skeleton moves at least 10 feet straight toward a target and then hits it with a gore attack on the same turn, the target takes an extra 9 (2d8) piercing damage. If the target is a creature, it must succeed on a DC 14 Strength saving throw or be pushed up to 10 feet away and knocked prone.",attack_bonus:0,damage_dice:"2d8"}],actions:[{name:"Greataxe",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 17 (2d12 + 4) slashing damage.",attack_bonus:6,damage_dice:"2d12",damage_bonus:4},{name:"Gore",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) piercing damage.",attack_bonus:6,damage_dice:"2d8",damage_bonus:4}]},{name:"Mule",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:11,hit_dice:"2d8 + 2",speed:"40 ft.",stats:[14,10,13,2,10,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"1/8",bestiary:!0,traits:[{name:"Beast of Burden",desc:"The mule is considered to be a Large animal for the purpose of determining its carrying capacity.",attack_bonus:0},{name:"Sure-Footed",desc:"The mule has advantage on Strength and Dexterity saving throws made against effects that would knock it prone.",attack_bonus:0}],actions:[{name:"Hooves",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 4 (1d4 + 2) bludgeoning damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Mummy",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"lawful evil",ac:11,hp:58,hit_dice:"9d8 + 17",speed:"20 ft.",stats:[16,8,15,6,10,12],saves:[{wisdom:2}],damage_vulnerabilities:"fire",damage_resistances:"",damage_immunities:"bludgeoning, piercing, and slashing from nonmagical weapons",condition_immunities:"necrotic, poisoned",senses:"darkvision 60 ft., passive Perception 10",languages:"the languages it knew in life",cr:"3",bestiary:!0,actions:[{name:"Multiattack",desc:"The mummy can use its Dreadful Glare and makes one attack with its rotting fist.",attack_bonus:0},{name:"Rotting Fist",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) bludgeoning damage plus 10 (3d6) necrotic damage. If the target is a creature, it must succeed on a DC 12 Constitution saving throw or be cursed with mummy rot. The cursed target can't regain hit points, and its hit point maximum decreases by 10 (3d6) for every 24 hours that elapse. If the curse reduces the target's hit point maximum to 0, the target dies, and its body turns to dust. The curse lasts until removed by the remove curse spell or other magic.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3},{name:"Dreadful Glare",desc:"The mummy targets one creature it can see within 60 ft. of it. If the target can see the mummy, it must succeed on a DC 11 Wisdom saving throw against this magic or become frightened until the end of the mummy's next turn. If the target fails the saving throw by 5 or more, it is also paralyzed for the same duration. A target that succeeds on the saving throw is immune to the Dreadful Glare of all mummies (but not mummy lords) for the next 24 hours.",attack_bonus:0}]},{name:"Mummy Lord",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"lawful evil",ac:17,hp:97,hit_dice:"13d8 + 38",speed:"20 ft.",stats:[18,10,17,11,18,16],saves:[{constitution:8},{intelligence:5},{wisdom:9},{charisma:8}],skillsaves:[{history:5},{religion:5}],damage_vulnerabilities:"bludgeoning",damage_resistances:"",damage_immunities:"necrotic, poison; bludgeoning, piercing, and slashing from nonmagical weapons",condition_immunities:"charmed, exhaustion, frightened, paralyzed, poisoned",senses:"darkvision 60 ft., passive Perception 14",languages:"the languages it knew in life",cr:"15",bestiary:!0,traits:[{name:"Magic Resistance",desc:"The mummy lord has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Rejuvenation",desc:"A destroyed mummy lord gains a new body in 24 hours if its heart is intact, regaining all its hit points and becoming active again. The new body appears within 5 feet of the mummy lord's heart.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The mummy can use its Dreadful Glare and makes one attack with its rotting fist.",attack_bonus:0},{name:"Rotting Fist",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one target. Hit: 14 (3d6 + 4) bludgeoning damage plus 21 (6d6) necrotic damage. If the target is a creature, it must succeed on a DC 16 Constitution saving throw or be cursed with mummy rot. The cursed target can't regain hit points, and its hit point maximum decreases by 10 (3d6) for every 24 hours that elapse. If the curse reduces the target's hit point maximum to 0, the target dies, and its body turns to dust. The curse lasts until removed by the remove curse spell or other magic.",attack_bonus:9,damage_dice:"3d6 + 6d6",damage_bonus:4},{name:"Dreadful Glare",desc:"The mummy lord targets one creature it can see within 60 feet of it. If the target can see the mummy lord, it must succeed on a DC 16 Wisdom saving throw against this magic or become frightened until the end of the mummy's next turn. If the target fails the saving throw by 5 or more, it is also paralyzed for the same duration. A target that succeeds on the saving throw is immune to the Dreadful Glare of all mummies and mummy lords for the next 24 hours.",attack_bonus:0}],legendary_actions:[{name:"Attack",desc:"The mummy lord makes one attack with its rotting fist or uses its Dreadful Glare.",attack_bonus:0},{name:"Blinding Dust",desc:"Blinding dust and sand swirls magically around the mummy lord. Each creature within 5 feet of the mummy lord must succeed on a DC 16 Constitution saving throw or be blinded until the end of the creature's next turn.",attack_bonus:0},{name:"Blasphemous Word (Costs 2 Actions)",desc:"The mummy lord utters a blasphemous word. Each non-undead creature within 10 feet of the mummy lord that can hear the magical utterance must succeed on a DC 16 Constitution saving throw or be stunned until the end of the mummy lord's next turn.",attack_bonus:0},{name:"Channel Negative Energy (Costs 2 Actions)",desc:"The mummy lord magically unleashes negative energy. Creatures within 60 feet of the mummy lord, including ones behind barriers and around corners, can't regain hit points until the end of the mummy lord's next turn.",attack_bonus:0},{name:"Whirlwind of Sand (Costs 2 Actions)",desc:"The mummy lord magically transforms into a whirlwind of sand, moves up to 60 feet, and reverts to its normal form. While in whirlwind form, the mummy lord is immune to all damage, and it can't be grappled, petrified, knocked prone, restrained, or stunned. Equipment worn or carried by the mummy lord remain in its possession.",attack_bonus:0}],spells:["The mummy lord is a 10th-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 17, +9 to hit with spell attacks). The mummy lord has the following cleric spells prepared:",{"Cantrips (at will)":"sacred flame, thaumaturgy"},{"1st level (4 slots)":"command, guiding bolt, shield of faith"},{"2nd level (3 slots)":"hold person, silence, spiritual weapon"},{"3rd level (3 slots)":"animate dead, dispel magic"},{"4th level (3 slots)":"divination, guardian of faith"},{"5th level (2 slots)":"contagion, insect plague"},{"6th level (1 slot)":"harm"}]},{name:"Nalfeshnee",source:"5e SRD",size:"Large",type:"fiend",subtype:"demon",alignment:"chaotic evil",ac:18,hp:184,hit_dice:"16d10 + 96",speed:"20 ft., fly 30 ft.",stats:[21,10,22,19,12,15],saves:[{constitution:11},{intelligence:9},{wisdom:6},{charisma:7}],damage_vulnerabilities:"",damage_resistances:"cold, fire, lightning; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"poisoned",senses:"truesight 120 ft., passive Perception 11",languages:"Abyssal, telepathy 120 ft.",cr:"13",bestiary:!0,traits:[{name:"Magic Resistance",desc:"The nalfeshnee has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The nalfeshnee uses Horror Nimbus if it can. It then makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one target. Hit: 32 (5d10 + 5) piercing damage.",attack_bonus:10,damage_dice:"5d10",damage_bonus:5},{name:"Claw",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 15 (3d6 + 5) slashing damage.",attack_bonus:10,damage_dice:"3d6",damage_bonus:5},{name:"Horror Nimbus (Recharge 5-6)",desc:"The nalfeshnee magically emits scintillating, multicolored light. Each creature within 15 feet of the nalfeshnee that can see the light must succeed on a DC 15 Wisdom saving throw or be frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the nalfeshnee's Horror Nimbus for the next 24 hours.",attack_bonus:0},{name:"Teleport",desc:"The nalfeshnee magically teleports, along with any equipment it is wearing or carrying, up to 120 feet to an unoccupied space it can see.",attack_bonus:0},{name:"Variant: Summon Demon (1/Day)",desc:`The demon chooses what to summon and attempts a magical summoning. A nalfeshnee has a 50 percent chance of summoning 1d4 vrocks, 1d3 hezrous, 1d2 glabrezus, or one nalfeshnee. A summoned demon appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other demons. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.`,attack_bonus:0}]},{name:"Night Hag",source:"5e SRD",size:"Medium",type:"fiend",subtype:"",alignment:"neutral evil",ac:17,hp:112,hit_dice:"15d8 + 44",speed:"30 ft.",stats:[18,15,16,16,14,16],skillsaves:[{deception:7},{insight:6},{perception:6},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"cold, fire; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"",condition_immunities:"charmed",senses:"darkvision 120 ft., passive Perception 16",languages:"Abyssal, Common, Infernal, Primordial",cr:"5",bestiary:!0,traits:[{name:"Innate Spellcasting",desc:`The hag's innate spellcasting ability is Charisma (spell save DC 14, +6 to hit with spell attacks). She can innately cast the following spells, requiring no material components: At will: detect magic, magic missile 2/day each: plane shift (self only), ray of enfeeblement, sleep`,attack_bonus:0},{name:"Magic Resistance",desc:"The hag has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Night Hag Items",desc:`A night hag carries two very rare magic items that she must craft for herself If either object is lost, the night hag will go to great lengths to retrieve it, as creating a new tool takes time and effort. Heartstone: This lustrous black gem allows a night hag to become ethereal while it is in her possession. The touch of a heartstone also cures any disease. Crafting a heartstone takes 30 days. Soul Bag: When an evil humanoid dies as a result of a night hag's Nightmare Haunting, the hag catches the soul in this black sack made of stitched flesh. A soul bag can hold only one evil soul at a time, and only the night hag who crafted the bag can catch a soul with it. Crafting a soul bag takes 7 days and a humanoid sacrifice (whose flesh is used to make the bag).`,attack_bonus:0},{name:"Hag Coven",desc:`When hags must work together, they form covens, in spite of their selfish natures. A coven is made up of hags of any type, all of whom are equals within the group. However, each of the hags continues to desire more personal power. A coven consists of three hags so that any arguments between two hags can be settled by the third. If more than three hags ever come together, as might happen if two covens come into conflict, the result is usually chaos.`,attack_bonus:0},{name:"Shared Spellcasting (Coven Only)",desc:`While all three members of a hag coven are within 30 feet of one another, they can each cast the following spells from the wizard's spell list but must share the spell slots among themselves: \u2022 1st level (4 slots): identify, ray of sickness \u2022 2nd level (3 slots): hold person, locate object \u2022 3rd level (3 slots): bestow curse, counterspell, lightning bolt \u2022 4th level (3 slots): phantasmal killer, polymorph \u2022 5th level (2 slots): contact other plane, scrying \u2022 6th level (1 slot): eye bite For casting these spells, each hag is a 12th-level spellcaster that uses Intelligence as her spellcasting ability. The spell save DC is 12+the hag's Intelligence modifier, and the spell attack bonus is 4+the hag's Intelligence modifier.`,attack_bonus:0},{name:"Hag Eye (Coven Only)",desc:`A hag coven can craft a magic item called a hag eye, which is made from a real eye coated in varnish and often fitted to a pendant or other wearable item. The hag eye is usually entrusted to a minion for safekeeping and transport. A hag in the coven can take an action to see what the hag eye sees if the hag eye is on the same plane of existence. A hag eye has AC 10, 1 hit point, and darkvision with a radius of 60 feet. If it is destroyed, each coven member takes 3d10 psychic damage and is blinded for 24 hours. A hag coven can have only one hag eye at a time, and creating a new one requires all three members of the coven to perform a ritual. The ritual takes 1 hour, and the hags can't perform it while blinded. During the ritual, if the hags take any action other than performing the ritual, they must start over.`,attack_bonus:0}],actions:[{name:"Claws (Hag Form Only)",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:4},{name:"Change Shape",desc:"The hag magically polymorphs into a Small or Medium female humanoid, or back into her true form. Her statistics are the same in each form. Any equipment she is wearing or carrying isn't transformed. She reverts to her true form if she dies.",attack_bonus:0},{name:"Etherealness",desc:"The hag magically enters the Ethereal Plane from the Material Plane, or vice versa. To do so, the hag must have a heartstone in her possession.",attack_bonus:0},{name:"Nightmare Haunting (1/Day)",desc:"While on the Ethereal Plane, the hag magically touches a sleeping humanoid on the Material Plane. A protection from evil and good spell cast on the target prevents this contact, as does a magic circle. As long as the contact persists, the target has dreadful visions. If these visions last for at least 1 hour, the target gains no benefit from its rest, and its hit point maximum is reduced by 5 (1d10). If this effect reduces the target's hit point maximum to 0, the target dies, and if the target was evil, its soul is trapped in the hag's soul bag. The reduction to the target's hit point maximum lasts until removed by the greater restoration spell or similar magic.",attack_bonus:0}]},{name:"Nightmare",source:"5e SRD",size:"Large",type:"fiend",subtype:"",alignment:"neutral evil",ac:13,hp:68,hit_dice:"8d10 + 24",speed:"60 ft., fly 90 ft.",stats:[18,15,16,10,13,15],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"passive Perception 11",languages:"understands Abyssal, Common, and Infernal but can't speak",cr:"3",bestiary:!0,traits:[{name:"Confer Fire Resistance",desc:"The nightmare can grant resistance to fire damage to anyone riding it.",attack_bonus:0},{name:"Illumination",desc:"The nightmare sheds bright light in a 10-foot radius and dim light for an additional 10 feet.",attack_bonus:0}],actions:[{name:"Hooves",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) bludgeoning damage plus 7 (2d6) fire damage.",attack_bonus:6,damage_dice:"2d8 + 2d6",damage_bonus:4},{name:"Ethereal Stride",desc:"The nightmare and up to three willing creatures within 5 feet of it magically enter the Ethereal Plane from the Material Plane, or vice versa.",attack_bonus:0}]},{name:"Noble",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:15,hp:9,hit_dice:"2d8",speed:"30 ft.",stats:[11,12,11,12,14,16],skillsaves:[{deception:5},{insight:4},{persuasion:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 12",languages:"any two languages",cr:"1/8",bestiary:!0,actions:[{name:"Rapier",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 5 (1d8 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d8",damage_bonus:1}],reactions:[{name:"Parry",desc:"The noble adds 2 to its AC against one melee attack that would hit it. To do so, the noble must see the attacker and be wielding a melee weapon.",attack_bonus:0}]},{name:"Ochre Jelly",source:"5e SRD",size:"Large",type:"ooze",subtype:"",alignment:"unaligned",ac:8,hp:45,hit_dice:"6d10 + 12",speed:"10 ft., climb 10 ft.",stats:[15,6,14,2,6,1],damage_vulnerabilities:"",damage_resistances:"acid",damage_immunities:"lightning, slashing",condition_immunities:"blinded, charmed, deafened, exhaustion, frightened, prone",senses:"blindsight 60 ft. (blind beyond this radius), passive Perception 8",languages:"",cr:"2",bestiary:!0,traits:[{name:"Amorphous",desc:"The jelly can move through a space as narrow as 1 inch wide without squeezing.",attack_bonus:0},{name:"Spider Climb",desc:"The jelly can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0}],actions:[{name:"Pseudopod",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 9 (2d6 + 2) bludgeoning damage plus 3 (1d6) acid damage.",attack_bonus:4,damage_dice:"2d6",damage_bonus:2}],reactions:[{name:"Split",desc:"When a jelly that is Medium or larger is subjected to lightning or slashing damage, it splits into two new jellies if it has at least 10 hit points. Each new jelly has hit points equal to half the original jelly's, rounded down. New jellies are one size smaller than the original jelly.",attack_bonus:0}]},{name:"Octopus",source:"5e SRD",size:"Small",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:3,hit_dice:"1d6 + -1",speed:"5 ft., swim 30 ft.",stats:[4,15,11,3,10,4],skillsaves:[{perception:2},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 12",languages:"",cr:"0",bestiary:!0,traits:[{name:"Hold Breath",desc:"While out of water, the octopus can hold its breath for 30 minutes.",attack_bonus:0},{name:"Underwater Camouflage",desc:"The octopus has advantage on Dexterity (Stealth) checks made while underwater.",attack_bonus:0},{name:"Water Breathing",desc:"The octopus can breathe only underwater.",attack_bonus:0}],actions:[{name:"Tentacles",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 1 bludgeoning damage, and the target is grappled (escape DC 10). Until this grapple ends, the octopus can't use its tentacles on another target.",attack_bonus:4,damage_bonus:1},{name:"Ink Cloud (Recharges after a Short or Long Rest)",desc:"A 5-foot-radius cloud of ink extends all around the octopus if it is underwater. The area is heavily obscured for 1 minute, although a significant current can disperse the ink. After releasing the ink, the octopus can use the Dash action as a bonus action.",attack_bonus:0}]},{name:"Ogre",source:"5e SRD",size:"Large",type:"giant",subtype:"",alignment:"chaotic evil",ac:11,hp:59,hit_dice:"7d10 + 20",speed:"40 ft.",stats:[19,8,16,5,7,7],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 8",languages:"Common, Giant",cr:"2",bestiary:!0,actions:[{name:"Greatclub",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"2d8",damage_bonus:4},{name:"Javelin",desc:"Melee or Ranged Weapon Attack: +6 to hit, reach 5 ft. or range 30/120 ft., one target. Hit: 11 (2d6 + 4) piercing damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4}]},{name:"Ogre Zombie",source:"5e SRD",size:"Large",type:"undead",subtype:"",alignment:"neutral evil",ac:8,hp:85,hit_dice:"9d10 + 35",speed:"30 ft.",stats:[19,6,18,3,6,5],saves:[{wisdom:0}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 8",languages:"understands Common and Giant but can't speak",cr:"2",bestiary:!0,traits:[{name:"Undead Fortitude",desc:"If damage reduces the zombie to 0 hit points, it must make a Constitution saving throw with a DC of 5+the damage taken, unless the damage is radiant or from a critical hit. On a success, the zombie drops to 1 hit point instead.",attack_bonus:0}],actions:[{name:"Morningstar",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"2d8",damage_bonus:4}]},{name:"Oni",source:"5e SRD",size:"Large",type:"giant",subtype:"",alignment:"lawful evil",ac:16,hp:110,hit_dice:"13d10 + 38",speed:"30 ft., fly 30 ft.",stats:[19,11,16,14,12,15],saves:[{dexterity:3},{constitution:6},{wisdom:4},{charisma:5}],skillsaves:[{arcana:5},{deception:8},{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"Common, Giant",cr:"7",bestiary:!0,traits:[{name:"Innate Spellcasting",desc:`The oni's innate spellcasting ability is Charisma (spell save DC 13). The oni can innately cast the following spells, requiring no material components: At will: darkness, invisibility 1/day each: charm person, cone of cold, gaseous form, sleep`,attack_bonus:0},{name:"Magic Weapons",desc:"The oni's weapon attacks are magical.",attack_bonus:0},{name:"Regeneration",desc:"The oni regains 10 hit points at the start of its turn if it has at least 1 hit point.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The oni makes two attacks, either with its claws or its glaive.",attack_bonus:0},{name:"Claw (Oni Form Only)",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 8 (1d8 + 4) slashing damage.",attack_bonus:7,damage_dice:"1d8",damage_bonus:4},{name:"Glaive",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one target. Hit: 15 (2d10 + 4) slashing damage, or 9 (1d10 + 4) slashing damage in Small or Medium form.",attack_bonus:7,damage_dice:"2d10",damage_bonus:4},{name:"Change Shape",desc:"The oni magically polymorphs into a Small or Medium humanoid, into a Large giant, or back into its true form. Other than its size, its statistics are the same in each form. The only equipment that is transformed is its glaive, which shrinks so that it can be wielded in humanoid form. If the oni dies, it reverts to its true form, and its glaive reverts to its normal size.",attack_bonus:0}]},{name:"Orc",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"orc",alignment:"chaotic evil",ac:13,hp:15,hit_dice:"2d8 + 6",speed:"30 ft.",stats:[16,12,16,7,11,10],skillsaves:[{intimidation:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"Common, Orc",cr:"1/2",bestiary:!0,traits:[{name:"Aggressive",desc:"As a bonus action, the orc can move up to its speed toward a hostile creature that it can see.",attack_bonus:0}],actions:[{name:"Greataxe",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 9 (1d12 + 3) slashing damage.",attack_bonus:5,damage_dice:"1d12",damage_bonus:3},{name:"Javelin",desc:"Melee or Ranged Weapon Attack: +5 to hit, reach 5 ft. or range 30/120 ft., one target. Hit: 6 (1d6 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3}]},{name:"Otyugh",source:"5e SRD",size:"Large",type:"aberration",subtype:"",alignment:"neutral",ac:14,hp:114,hit_dice:"12d10 + 48",speed:"30 ft.",stats:[16,11,19,6,13,6],saves:[{constitution:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 11",languages:"Otyugh",cr:"5",bestiary:!0,traits:[{name:"Limited Telepathy",desc:"The otyugh can magically transmit simple messages and images to any creature within 120 ft. of it that can understand a language. This form of telepathy doesn't allow the receiving creature to telepathically respond.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The otyugh makes three attacks: one with its bite and two with its tentacles.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 12 (2d8 + 3) piercing damage. If the target is a creature, it must succeed on a DC 15 Constitution saving throw against disease or become poisoned until the disease is cured. Every 24 hours that elapse, the target must repeat the saving throw, reducing its hit point maximum by 5 (1d10) on a failure. The disease is cured on a success. The target dies if the disease reduces its hit point maximum to 0. This reduction to the target's hit point maximum lasts until the disease is cured.",attack_bonus:6,damage_dice:"2d8",damage_bonus:3},{name:"Tentacle",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one target. Hit: 7 (1d8 + 3) bludgeoning damage plus 4 (1d8) piercing damage. If the target is Medium or smaller, it is grappled (escape DC 13) and restrained until the grapple ends. The otyugh has two tentacles, each of which can grapple one target.",attack_bonus:6,damage_dice:"1d8",damage_bonus:3},{name:"Tentacle Slam",desc:"The otyugh slams creatures grappled by it into each other or a solid surface. Each creature must succeed on a DC 14 Constitution saving throw or take 10 (2d6 + 3) bludgeoning damage and be stunned until the end of the otyugh's next turn. On a successful save, the target takes half the bludgeoning damage and isn't stunned.",attack_bonus:0}]},{name:"Owl",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:1,hit_dice:"1d4 + -2",speed:"5 ft., fly 60 ft.",stats:[3,13,8,2,12,7],skillsaves:[{perception:3},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 13",languages:"",cr:"0",bestiary:!0,traits:[{name:"Flyby",desc:"The owl doesn't provoke opportunity attacks when it flies out of an enemy's reach.",attack_bonus:0},{name:"Keen Hearing and Sight",desc:"The owl has advantage on Wisdom (Perception) checks that rely on hearing or sight.",attack_bonus:0}],actions:[{name:"Talons",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 1 slashing damage.",attack_bonus:3,damage_bonus:1}]},{name:"Owlbear",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"unaligned",ac:13,hp:59,hit_dice:"7d10 + 20",speed:"40 ft.",stats:[20,12,17,3,12,7],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 13",languages:"",cr:"3",bestiary:!0,traits:[{name:"Keen Sight and Smell",desc:"The owlbear has advantage on Wisdom (Perception) checks that rely on sight or smell.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The owlbear makes two attacks: one with its beak and one with its claws.",attack_bonus:0},{name:"Beak",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one creature. Hit: 10 (1d10 + 5) piercing damage.",attack_bonus:7,damage_dice:"1d10",damage_bonus:5},{name:"Claws",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 14 (2d8 + 5) slashing damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:5}]},{name:"Panther",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:13,hit_dice:"3d8 + -1",speed:"50 ft., climb 40 ft.",stats:[14,15,10,3,14,7],skillsaves:[{perception:4},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Keen Smell",desc:"The panther has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0},{name:"Pounce",desc:"If the panther moves at least 20 ft. straight toward a creature and then hits it with a claw attack on the same turn, that target must succeed on a DC 12 Strength saving throw or be knocked prone. If the target is prone, the panther can make one bite attack against it as a bonus action.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Claw",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 4 (1d4 + 2) slashing damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Pegasus",source:"5e SRD",size:"Large",type:"celestial",subtype:"",alignment:"chaotic good",ac:12,hp:59,hit_dice:"7d10 + 20",speed:"60 ft., fly 90 ft.",stats:[18,15,16,10,15,13],saves:[{dexterity:4},{wisdom:4},{charisma:3}],skillsaves:[{perception:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 16",languages:"understands Celestial, Common, Elvish, and Sylvan but can't speak",cr:"2",bestiary:!0,actions:[{name:"Hooves",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4}]},{name:"Phase Spider",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"unaligned",ac:13,hp:32,hit_dice:"5d10 + 4",speed:"30 ft., climb 30 ft.",stats:[15,15,12,6,10,6],skillsaves:[{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"",cr:"3",bestiary:!0,traits:[{name:"Ethereal Jaunt",desc:"As a bonus action, the spider can magically shift from the Material Plane to the Ethereal Plane, or vice versa.",attack_bonus:0},{name:"Spider Climb",desc:"The spider can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0},{name:"Web Walker",desc:"The spider ignores movement restrictions caused by webbing.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 7 (1d10 + 2) piercing damage, and the target must make a DC 11 Constitution saving throw, taking 18 (4d8) poison damage on a failed save, or half as much damage on a successful one. If the poison damage reduces the target to 0 hit points, the target is stable but poisoned for 1 hour, even after regaining hit points, and is paralyzed while poisoned in this way.",attack_bonus:4,damage_dice:"1d10",damage_bonus:2}]},{name:"Pit Fiend",source:"5e SRD",size:"Large",type:"fiend",subtype:"devil",alignment:"lawful evil",ac:19,hp:300,hit_dice:"24d10 + 168",speed:"30 ft., fly 60 ft.",stats:[26,14,24,22,18,24],saves:[{dexterity:8},{constitution:13},{wisdom:10}],damage_vulnerabilities:"",damage_resistances:"cold; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"truesight 120 ft., passive Perception 14",languages:"Infernal, telepathy 120 ft.",cr:"20",bestiary:!0,traits:[{name:"Fear Aura",desc:"Any creature hostile to the pit fiend that starts its turn within 20 feet of the pit fiend must make a DC 21 Wisdom saving throw, unless the pit fiend is incapacitated. On a failed save, the creature is frightened until the start of its next turn. If a creature's saving throw is successful, the creature is immune to the pit fiend's Fear Aura for the next 24 hours.",attack_bonus:0},{name:"Magic Resistance",desc:"The pit fiend has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Magic Weapons",desc:"The pit fiend's weapon attacks are magical.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The pit fiend's spellcasting ability is Charisma (spell save DC 21). The pit fiend can innately cast the following spells, requiring no material components: At will: detect magic, fireball 3/day each: hold monster, wall of fire`,attack_bonus:0}],actions:[{name:"Multiattack",desc:"The pit fiend makes four attacks: one with its bite, one with its claw, one with its mace, and one with its tail.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +14 to hit, reach 5 ft., one target. Hit: 22 (4d6 + 8) piercing damage. The target must succeed on a DC 21 Constitution saving throw or become poisoned. While poisoned in this way, the target can't regain hit points, and it takes 21 (6d6) poison damage at the start of each of its turns. The poisoned target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:14,damage_dice:"4d6",damage_bonus:8},{name:"Claw",desc:"Melee Weapon Attack: +14 to hit, reach 10 ft. , one target. Hit: 17 (2d8 + 8) slashing damage.",attack_bonus:14,damage_dice:"2d8",damage_bonus:8},{name:"Mace",desc:"Melee Weapon Attack: +14 to hit, reach 10ft., one target. Hit: 15 (2d6 + 8) bludgeoning damage plus 21 (6d6) fire damage.",attack_bonus:14,damage_dice:"2d6",damage_bonus:8},{name:"Tail",desc:"Melee Weapon Attack: +14 to hit, reach 10ft., one target. Hit: 24 (3d1O + 8) bludgeoning damage.",attack_bonus:14,damage_dice:"3d10",damage_bonus:8}]},{name:"Planetar",source:"5e SRD",size:"Large",type:"celestial",subtype:"",alignment:"lawful good",ac:19,hp:200,hit_dice:"16d10 + 112",speed:"40 ft., fly 120 ft.",stats:[24,20,24,19,22,25],saves:[{constitution:12},{wisdom:11},{charisma:12}],skillsaves:[{perception:11}],damage_vulnerabilities:"",damage_resistances:"radiant; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"",condition_immunities:"charmed, exhaustion, frightened",senses:"truesight 120 ft., passive Perception 21",languages:"all, telepathy 120 ft.",cr:"16",bestiary:!0,traits:[{name:"Angelic Weapons",desc:"The planetar's weapon attacks are magical. When the planetar hits with any weapon, the weapon deals an extra 5d8 radiant damage (included in the attack).",attack_bonus:0},{name:"Divine Awareness",desc:"The planetar knows if it hears a lie.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The planetar's spellcasting ability is Charisma (spell save DC 20). The planetar can innately cast the following spells, requiring no material components: At will: detect evil and good, invisibility (self only) 3/day each: blade barrier, dispel evil and good, flame strike, raise dead 1/day each: commune, control weather, insect plague`,attack_bonus:0},{name:"Magic Resistance",desc:"The planetar has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The planetar makes two melee attacks.",attack_bonus:0},{name:"Greatsword",desc:"Melee Weapon Attack: +12 to hit, reach 5 ft., one target. Hit: 21 (4d6 + 7) slashing damage plus 22 (5d8) radiant damage.",attack_bonus:12,damage_dice:"4d6 + 5d8",damage_bonus:7},{name:"Healing Touch (4/Day)",desc:"The planetar touches another creature. The target magically regains 30 (6d8 + 3) hit points and is freed from any curse, disease, poison, blindness, or deafness.",attack_bonus:0}]},{name:"Plesiosaurus",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:68,hit_dice:"8d10 + 24",speed:"20 ft., swim 40 ft.",stats:[18,15,16,2,12,5],skillsaves:[{perception:3},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"2",bestiary:!0,traits:[{name:"Hold Breath",desc:"The plesiosaurus can hold its breath for 1 hour.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 10 ft., one target. Hit: 14 (3d6 + 4) piercing damage.",attack_bonus:6,damage_dice:"3d6",damage_bonus:4}]},{name:"Poisonous Snake",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:2,hit_dice:"1d4 + -1",speed:"30 ft., swim 30 ft.",stats:[2,16,11,1,10,3],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., passive Perception 10",languages:"",cr:"1/8",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 1 piercing damage, and the target must make a DC 10 Constitution saving throw, taking 5 (2d4) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:5,damage_bonus:1}]},{name:"Polar Bear",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:42,hit_dice:"5d10 + 14",speed:"40 ft., swim 30 ft.",stats:[20,10,16,2,13,7],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"2",bestiary:!0,traits:[{name:"Keen Smell",desc:"The bear has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The bear makes two attacks: one with its bite and one with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 9 (1d8 + 5) piercing damage.",attack_bonus:7,damage_dice:"1d8",damage_bonus:5},{name:"Claws",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 12 (2d6 + 5) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:5}]},{name:"Pony",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:11,hit_dice:"2d8 + 2",speed:"40 ft.",stats:[15,10,13,2,11,7],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"1/8",bestiary:!0,actions:[{name:"Hooves",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (2d4 + 2) bludgeoning damage.",attack_bonus:4,damage_dice:"2d4",damage_bonus:2}]},{name:"Priest",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:13,hp:27,hit_dice:"5d8 + 4",speed:"25 ft.",stats:[10,10,12,13,16,13],skillsaves:[{medicine:7},{persuasion:3},{religion:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"any two languages",cr:"2",bestiary:!0,traits:[{name:"Divine Eminence",desc:"As a bonus action, the priest can expend a spell slot to cause its melee weapon attacks to magically deal an extra 10 (3d6) radiant damage to a target on a hit. This benefit lasts until the end of the turn. If the priest expends a spell slot of 2nd level or higher, the extra damage increases by 1d6 for each level above 1st.",attack_bonus:0,damage_dice:"3d6"}],actions:[{name:"Mace",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 3 (1d6) bludgeoning damage.",attack_bonus:2,damage_dice:"1d6"}],spells:["The priest is a 5th-level spellcaster. Its spellcasting ability is Wisdom (spell save DC 13, +5 to hit with spell attacks). The priest has the following cleric spells prepared:",{"Cantrips (at will)":"light, sacred flame, thaumaturgy"},{"1st level (4 slots)":"cure wounds, guiding bolt, sanctuary"},{"2nd level (3 slots)":"lesser restoration, spiritual weapon"},{"3rd level (2 slots)":"dispel magic, spirit guardians"}]},{name:"Pseudodragon",source:"5e SRD",size:"Tiny",type:"dragon",subtype:"",alignment:"neutral good",ac:13,hp:7,hit_dice:"2d4 + 2",speed:"15 ft., fly 60 ft.",stats:[6,15,13,10,12,10],skillsaves:[{perception:3},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 13",languages:"understands Common and Draconic but can't speak",cr:"1/4",bestiary:!0,traits:[{name:"Keen Senses",desc:"The pseudodragon has advantage on Wisdom (Perception) checks that rely on sight, hearing, or smell.",attack_bonus:0},{name:"Magic Resistance",desc:"The pseudodragon has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Limited Telepathy",desc:"The pseudodragon can magically communicate simple ideas, emotions, and images telepathically with any creature within 100 ft. of it that can understand a language.",attack_bonus:0},{name:"Variant: Familiar",desc:"The pseudodragon can serve another creature as a familiar, forming a magic, telepathic bond with that willing companion. While the two are bonded, the companion can sense what the pseudodragon senses as long as they are within 1 mile of each other. While the pseudodragon is within 10 feet of its companion, the companion shares the pseudodragon's Magic Resistance trait. At any time and for any reason, the pseudodragon can end its service as a familiar, ending the telepathic bond.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 4 (1d4 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2},{name:"Sting",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 4 (1d4 + 2) piercing damage, and the target must succeed on a DC 11 Constitution saving throw or become poisoned for 1 hour. If the saving throw fails by 5 or more, the target falls unconscious for the same duration, or until it takes damage or another creature uses an action to shake it awake.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2}]},{name:"Purple Worm",source:"5e SRD",size:"Gargantuan",type:"monstrosity",subtype:"",alignment:"unaligned",ac:18,hp:247,hit_dice:"15d20 + 89",speed:"50 ft., burrow 30 ft.",stats:[28,7,22,1,8,4],saves:[{constitution:11},{wisdom:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 30 ft., tremorsense 60 ft., passive Perception 9",languages:"",cr:"15",bestiary:!0,traits:[{name:"Tunneler",desc:"The worm can burrow through solid rock at half its burrow speed and leaves a 10-foot-diameter tunnel in its wake.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The worm makes two attacks: one with its bite and one with its stinger.",attack_bonus:0},{name:"Bite",desc:`Melee Weapon Attack: +9 to hit, reach 10 ft., one target. Hit: 22 (3d8 + 9) piercing damage. If the target is a Large or smaller creature, it must succeed on a DC 19 Dexterity saving throw or be swallowed by the worm. A swallowed creature is blinded and restrained, it has total cover against attacks and other effects outside the worm, and it takes 21 (6d6) acid damage at the start of each of the worm's turns. If the worm takes 30 damage or more on a single turn from a creature inside it, the worm must succeed on a DC 21 Constitution saving throw at the end of that turn or regurgitate all swallowed creatures, which fall prone in a space within 10 feet of the worm. If the worm dies, a swallowed creature is no longer restrained by it and can escape from the corpse by using 20 feet of movement, exiting prone.`,attack_bonus:9,damage_dice:"3d8",damage_bonus:9},{name:"Tail Stinger",desc:"Melee Weapon Attack: +9 to hit, reach 10 ft., one creature. Hit: 19 (3d6 + 9) piercing damage, and the target must make a DC 19 Constitution saving throw, taking 42 (12d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:9,damage_dice:"3d6",damage_bonus:9}]},{name:"Quasit",source:"5e SRD",size:"Tiny",type:"fiend",subtype:"demon",alignment:"chaotic evil",ac:13,hp:7,hit_dice:"3d4 + -1",speed:"40 ft.",stats:[5,17,10,7,10,10],skillsaves:[{stealth:5}],damage_vulnerabilities:"",damage_resistances:"cold; fire; lightning; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"poisoned",senses:"darkvision 120 ft., passive Perception 10",languages:"Abyssal, Common",cr:"1",bestiary:!0,traits:[{name:"Shapechanger",desc:"The quasit can use its action to polymorph into a beast form that resembles a bat (speed 10 ft. fly 40 ft.), a centipede (40 ft., climb 40 ft.), or a toad (40 ft., swim 40 ft.), or back into its true form . Its statistics are the same in each form, except for the speed changes noted. Any equipment it is wearing or carrying isn't transformed . It reverts to its true form if it dies.",attack_bonus:0},{name:"Magic Resistance",desc:"The quasit has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Variant: Familiar",desc:"The quasit can serve another creature as a familiar, forming a telepathic bond with its willing master. While the two are bonded, the master can sense what the quasit senses as long as they are within 1 mile of each other. While the quasit is within 10 feet of its master, the master shares the quasit's Magic Resistance trait. At any time and for any reason, the quasit can end its service as a familiar, ending the telepathic bond.",attack_bonus:0}],actions:[{name:"Claw (Bite in Beast Form)",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft ., one target. Hit: 5 (1d4 + 3) piercing damage, and the target must succeed on a DC 10 Constitution saving throw or take 5 (2d4) poison damage and become poisoned for 1 minute. The target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:4,damage_dice:"1d4",damage_bonus:3},{name:"Scare (1/day)",desc:"One creature of the quasit's choice within 20 ft. of it must succeed on a DC 10 Wisdom saving throw or be frightened for 1 minute. The target can repeat the saving throw at the end of each of its turns, with disadvantage if the quasit is within line of sight, ending the effect on itself on a success.",attack_bonus:0},{name:"Invisibility",desc:"The quasit magically turns invisible until it attacks or uses Scare, or until its concentration ends (as if concentrating on a spell). Any equipment the quasit wears or carries is invisible with it.",attack_bonus:0}]},{name:"Quipper",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:1,hit_dice:"1d4 + -2",speed:"swim 40 ft.",stats:[2,16,9,1,7,2],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 8",languages:"",cr:"0",bestiary:!0,traits:[{name:"Blood Frenzy",desc:"The quipper has advantage on melee attack rolls against any creature that doesn't have all its hit points.",attack_bonus:0},{name:"Water Breathing",desc:"The quipper can breathe only underwater.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 1 piercing damage.",attack_bonus:5,damage_bonus:1}]},{name:"Rakshasa",source:"5e SRD",size:"Medium",type:"fiend",subtype:"",alignment:"lawful evil",ac:16,hp:110,hit_dice:"13d8 + 51",speed:"40 ft.",stats:[14,17,18,13,16,20],skillsaves:[{deception:10},{insight:8}],damage_vulnerabilities:"piercing from magic weapons wielded by good creatures",damage_resistances:"",damage_immunities:"bludgeoning, piercing, and slashing from nonmagical weapons",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 13",languages:"Common, Infernal",cr:"13",bestiary:!0,traits:[{name:"Limited Magic Immunity",desc:"The rakshasa can't be affected or detected by spells of 6th level or lower unless it wishes to be. It has advantage on saving throws against all other spells and magical effects.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The rakshasa's innate spellcasting ability is Charisma (spell save DC 18, +10 to hit with spell attacks). The rakshasa can innately cast the following spells, requiring no material components: At will: detect thoughts, disguise self, mage hand, minor illusion 3/day each: charm person, detect magic, invisibility, major image, suggestion 1/day each: dominate person, fly, plane shift, true seeing`,attack_bonus:0}],actions:[{name:"Multiattack",desc:"The rakshasa makes two claw attacks",attack_bonus:0},{name:"Claw",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 9 (2d6 + 2) slashing damage, and the target is cursed if it is a creature. The magical curse takes effect whenever the target takes a short or long rest, filling the target's thoughts with horrible images and dreams. The cursed target gains no benefit from finishing a short or long rest. The curse lasts until it is lifted by a remove curse spell or similar magic.",attack_bonus:7,damage_dice:"2d6",damage_bonus:2}]},{name:"Rat",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:1,hit_dice:"1d4 + -2",speed:"20 ft.",stats:[2,11,9,2,10,4],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 10",languages:"",cr:"0",bestiary:!0,traits:[{name:"Keen Smell",desc:"The rat has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +0 to hit, reach 5 ft., one target. Hit: 1 piercing damage.",attack_bonus:0,damage_bonus:1}]},{name:"Raven",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:1,hit_dice:"1d4 + -2",speed:"10 ft., fly 50 ft.",stats:[2,14,8,2,12,6],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"0",bestiary:!0,traits:[{name:"Mimicry",desc:"The raven can mimic simple sounds it has heard, such as a person whispering, a baby crying, or an animal chittering. A creature that hears the sounds can tell they are imitations with a successful DC 10 Wisdom (Insight) check.",attack_bonus:0}],actions:[{name:"Beak",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 1 piercing damage.",attack_bonus:0}]},{name:"Red Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"chaotic evil",ac:17,hp:75,hit_dice:"10d8 + 30",speed:"30 ft., climb 30 ft., fly 60 ft.",stats:[19,10,17,12,11,15],saves:[{dexterity:2},{constitution:5},{wisdom:2},{charisma:4}],skillsaves:[{perception:4},{stealth:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"4",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 9 (1d10 + 4) piercing damage plus 3 (1d6) fire damage.",attack_bonus:6,damage_dice:"1d10 + 1d6",damage_bonus:4},{name:"Fire Breath (Recharge 5-6)",desc:"The dragon exhales fire in a 15-foot cone. Each creature in that area must make a DC 13 Dexterity saving throw, taking 24 (7d6) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"7d6"}]},{name:"Reef Shark",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:22,hit_dice:"4d8 + 4",speed:"swim 40 ft.",stats:[14,13,13,1,10,4],skillsaves:[{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 30 ft., passive Perception 12",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Pack Tactics",desc:"The shark has advantage on an attack roll against a creature if at least one of the shark's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0},{name:"Water Breathing",desc:"The shark can breathe only underwater.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 6 (1d8 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2}]},{name:"Remorhaz",source:"5e SRD",size:"Huge",type:"monstrosity",subtype:"",alignment:"unaligned",ac:17,hp:195,hit_dice:"17d12 + 84",speed:"30 ft., burrow 20 ft.",stats:[24,13,21,4,10,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold, fire",condition_immunities:"",senses:"darkvision 60 ft., tremorsense 60 ft., passive Perception 10",languages:"",cr:"11",bestiary:!0,traits:[{name:"Heated Body",desc:"A creature that touches the remorhaz or hits it with a melee attack while within 5 feet of it takes 10 (3d6) fire damage.",attack_bonus:0,damage_dice:"3d6"}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +11 to hit, reach 10 ft., one target. Hit: 40 (6d10 + 7) piercing damage plus 10 (3d6) fire damage. If the target is a creature, it is grappled (escape DC 17). Until this grapple ends, the target is restrained, and the remorhaz can't bite another target.",attack_bonus:11,damage_dice:"6d10 + 3d6",damage_bonus:7},{name:"Swallow",desc:`The remorhaz makes one bite attack against a Medium or smaller creature it is grappling. If the attack hits, that creature takes the bite's damage and is swallowed, and the grapple ends. While swallowed, the creature is blinded and restrained, it has total cover against attacks and other effects outside the remorhaz, and it takes 21 (6d6) acid damage at the start of each of the remorhaz's turns. If the remorhaz takes 30 damage or more on a single turn from a creature inside it, the remorhaz must succeed on a DC 15 Constitution saving throw at the end of that turn or regurgitate all swallowed creatures, which fall prone in a space within 10 feet oft he remorhaz. If the remorhaz dies, a swallowed creature is no longer restrained by it and can escape from the corpse using 15 feet of movement, exiting prone.`,attack_bonus:0}]},{name:"Rhinoceros",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:45,hit_dice:"6d10 + 12",speed:"40 ft.",stats:[21,8,15,2,12,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 11",languages:"",cr:"2",bestiary:!0,traits:[{name:"Charge",desc:"If the rhinoceros moves at least 20 ft. straight toward a target and then hits it with a gore attack on the same turn, the target takes an extra 9 (2d8) bludgeoning damage. If the target is a creature, it must succeed on a DC 15 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"2d8"}],actions:[{name:"Gore",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 14 (2d8 + 5) bludgeoning damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:5}]},{name:"Riding Horse",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:13,hit_dice:"2d10 + 2",speed:"60 ft.",stats:[16,10,12,2,11,7],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"1/4",bestiary:!0,actions:[{name:"Hooves",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 8 (2d4 + 3) bludgeoning damage.",attack_bonus:5,damage_dice:"2d4",damage_bonus:3}]},{name:"Roc",source:"5e SRD",size:"Gargantuan",type:"monstrosity",subtype:"",alignment:"unaligned",ac:15,hp:248,hit_dice:"16d20 + 80",speed:"20 ft., fly 120 ft.",stats:[28,10,20,3,10,9],saves:[{dexterity:4},{constitution:9},{wisdom:4},{charisma:3}],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"",cr:"11",bestiary:!0,traits:[{name:"Keen Sight",desc:"The roc has advantage on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The roc makes two attacks: one with its beak and one with its talons.",attack_bonus:0},{name:"Beak",desc:"Melee Weapon Attack: +13 to hit, reach 10 ft., one target. Hit: 27 (4d8 + 9) piercing damage.",attack_bonus:13,damage_dice:"4d8",damage_bonus:9},{name:"Talons",desc:"Melee Weapon Attack: +13 to hit, reach 5 ft., one target. Hit: 23 (4d6 + 9) slashing damage, and the target is grappled (escape DC 19). Until this grapple ends, the target is restrained, and the roc can't use its talons on another target.",attack_bonus:13,damage_dice:"4d6",damage_bonus:9}]},{name:"Roper",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"neutral evil",ac:20,hp:93,hit_dice:"11d10 + 32",speed:"10 ft., climb 10 ft.",stats:[18,8,17,7,16,6],skillsaves:[{perception:6},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 16",languages:"",cr:"5",bestiary:!0,traits:[{name:"False Appearance",desc:"While the roper remains motionless, it is indistinguishable from a normal cave formation, such as a stalagmite.",attack_bonus:0},{name:"Grasping Tendrils",desc:"The roper can have up to six tendrils at a time. Each tendril can be attacked (AC 20; 10 hit points; immunity to poison and psychic damage). Destroying a tendril deals no damage to the roper, which can extrude a replacement tendril on its next turn. A tendril can also be broken if a creature takes an action and succeeds on a DC 15 Strength check against it.",attack_bonus:0},{name:"Spider Climb",desc:"The roper can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The roper makes four attacks with its tendrils, uses Reel, and makes one attack with its bite.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 22 (4d8 + 4) piercing damage.",attack_bonus:7,damage_dice:"4d8",damage_bonus:4},{name:"Tendril",desc:"Melee Weapon Attack: +7 to hit, reach 50 ft., one creature. Hit: The target is grappled (escape DC 15). Until the grapple ends, the target is restrained and has disadvantage on Strength checks and Strength saving throws, and the roper can't use the same tendril on another target.",attack_bonus:7},{name:"Reel",desc:"The roper pulls each creature grappled by it up to 25 ft. straight toward it.",attack_bonus:0}]},{name:"Rug of Smothering",source:"5e SRD",size:"Large",type:"construct",subtype:"",alignment:"unaligned",ac:12,hp:33,hit_dice:"6d10",speed:"10 ft.",stats:[17,14,10,1,3,1],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison, psychic",condition_immunities:"blinded, charmed, deafened, frightened, paralyzed, petrified, poisoned",senses:"blindsight 60 ft. (blind beyond this radius), passive Perception 6",languages:"",cr:"2",bestiary:!0,traits:[{name:"Antimagic Susceptibility",desc:"The rug is incapacitated while in the area of an antimagic field. If targeted by dispel magic, the rug must succeed on a Constitution saving throw against the caster's spell save DC or fall unconscious for 1 minute.",attack_bonus:0},{name:"Damage Transfer",desc:"While it is grappling a creature, the rug takes only half the damage dealt to it, and the creature grappled by the rug takes the other half.",attack_bonus:0},{name:"False Appearance",desc:"While the rug remains motionless, it is indistinguishable from a normal rug.",attack_bonus:0}],actions:[{name:"Smother",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one Medium or smaller creature. Hit: The creature is grappled (escape DC 13). Until this grapple ends, the target is restrained, blinded, and at risk of suffocating, and the rug can't smother another target. In addition, at the start of each of the target's turns, the target takes 10 (2d6 + 3) bludgeoning damage.",attack_bonus:0,damage_dice:"2d6",damage_bonus:3}]},{name:"Rust Monster",source:"5e SRD",size:"Medium",type:"monstrosity",subtype:"",alignment:"unaligned",ac:14,hp:27,hit_dice:"5d8 + 4",speed:"40 ft.",stats:[13,12,13,2,13,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 11",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Iron Scent",desc:"The rust monster can pinpoint, by scent, the location of ferrous metal within 30 feet of it.",attack_bonus:0},{name:"Rust Metal",desc:"Any nonmagical weapon made of metal that hits the rust monster corrodes. After dealing damage, the weapon takes a permanent and cumulative -1 penalty to damage rolls. If its penalty drops to -5, the weapon is destroyed. Non magical ammunition made of metal that hits the rust monster is destroyed after dealing damage.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 5 (1d8 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d8",damage_bonus:1},{name:"Antennae",desc:`The rust monster corrodes a nonmagical ferrous metal object it can see within 5 feet of it. If the object isn't being worn or carried, the touch destroys a 1-foot cube of it. If the object is being worn or carried by a creature, the creature can make a DC 11 Dexterity saving throw to avoid the rust monster's touch. If the object touched is either metal armor or a metal shield being worn or carried, its takes a permanent and cumulative -1 penalty to the AC it offers. Armor reduced to an AC of 10 or a shield that drops to a +0 bonus is destroyed. If the object touched is a held metal weapon, it rusts as described in the Rust Metal trait.`,attack_bonus:0}]},{name:"Saber-Toothed Tiger",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:52,hit_dice:"7d10 + 13",speed:"40 ft.",stats:[18,14,15,3,12,8],skillsaves:[{perception:3},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"2",bestiary:!0,traits:[{name:"Keen Smell",desc:"The tiger has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0},{name:"Pounce",desc:"If the tiger moves at least 20 ft. straight toward a creature and then hits it with a claw attack on the same turn, that target must succeed on a DC 14 Strength saving throw or be knocked prone. If the target is prone, the tiger can make one bite attack against it as a bonus action.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 10 (1d10 + 5) piercing damage.",attack_bonus:6,damage_dice:"1d10",damage_bonus:5},{name:"Claw",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 12 (2d6 + 5) slashing damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:5}]},{name:"Sahuagin",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"sahuagin",alignment:"lawful evil",ac:12,hp:22,hit_dice:"4d8 + 4",speed:"30 ft., swim 40 ft.",stats:[13,11,12,12,13,9],skillsaves:[{perception:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 15",languages:"Sahuagin",cr:"1/2",bestiary:!0,traits:[{name:"Blood Frenzy",desc:"The sahuagin has advantage on melee attack rolls against any creature that doesn't have all its hit points.",attack_bonus:0},{name:"Limited Amphibiousness",desc:"The sahuagin can breathe air and water, but it needs to be submerged at least once every 4 hours to avoid suffocating.",attack_bonus:0},{name:"Shark Telepathy",desc:"The sahuagin can magically command any shark within 120 feet of it, using a limited telepathy.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The sahuagin makes two melee attacks: one with its bite and one with its claws or spear.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 3 (1d4 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d4",damage_bonus:1},{name:"Claws",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 3 (1d4 + 1) slashing damage.",attack_bonus:3,damage_dice:"1d4",damage_bonus:1},{name:"Spear",desc:"Melee or Ranged Weapon Attack: +3 to hit, reach 5 ft. or range 20/60 ft., one target. Hit: 4 (1d6 + 1) piercing damage, or 5 (1d8 + 1) piercing damage if used with two hands to make a melee attack.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Salamander",source:"5e SRD",size:"Large",type:"elemental",subtype:"",alignment:"neutral evil",ac:15,hp:90,hit_dice:"12d10 + 24",speed:"30 ft.",stats:[18,14,15,11,10,12],damage_vulnerabilities:"cold",damage_resistances:"bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"fire",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 10",languages:"Ignan",cr:"5",bestiary:!0,traits:[{name:"Heated Body",desc:"A creature that touches the salamander or hits it with a melee attack while within 5 ft. of it takes 7 (2d6) fire damage.",attack_bonus:0,damage_dice:"2d6"},{name:"Heated Weapons",desc:"Any metal melee weapon the salamander wields deals an extra 3 (1d6) fire damage on a hit (included in the attack).",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The salamander makes two attacks: one with its spear and one with its tail.",attack_bonus:0},{name:"Spear",desc:"Melee or Ranged Weapon Attack: +7 to hit, reach 5 ft. or range 20 ft./60 ft., one target. Hit: 11 (2d6 + 4) piercing damage, or 13 (2d8 + 4) piercing damage if used with two hands to make a melee attack, plus 3 (1d6) fire damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Tail",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one target. Hit: 11 (2d6 + 4) bludgeoning damage plus 7 (2d6) fire damage, and the target is grappled (escape DC 14). Until this grapple ends, the target is restrained, the salamander can automatically hit the target with its tail, and the salamander can't make tail attacks against other targets.",attack_bonus:7,damage_dice:"2d6 + 2d6",damage_bonus:4}]},{name:"Satyr",source:"5e SRD",size:"Medium",type:"fey",subtype:"",alignment:"chaotic neutral",ac:14,hp:31,hit_dice:"7d8 + -1",speed:"40 ft.",stats:[12,16,11,12,10,14],skillsaves:[{perception:2},{performance:6},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 12",languages:"Common, Elvish, Sylvan",cr:"1/2",bestiary:!0,traits:[{name:"Magic Resistance",desc:"The satyr has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Ram",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 6 (2d4 + 1) bludgeoning damage.",attack_bonus:3,damage_dice:"2d4",damage_bonus:1},{name:"Shortsword",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1 d6 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Shortbow",desc:"Ranged Weapon Attack: +5 to hit, range 80/320 ft., one target. Hit: 6 (1d6 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Variant: Panpipes",desc:"Gentle Lullaby. The creature falls asleep and is unconscious for 1 minute. The effect ends if the creature takes damage or if someone takes an action to shake the creature awake.",attack_bonus:0}]},{name:"Scorpion",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:1,hit_dice:"1d4 + -2",speed:"10 ft.",stats:[2,11,8,1,8,2],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"blindsight 10 ft., passive Perception 9",languages:"",cr:"0",bestiary:!0,actions:[{name:"Sting",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one creature. Hit: 1 piercing damage, and the target must make a DC 9 Constitution saving throw, taking 4 (1d8) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:2,damage_bonus:1}]},{name:"Scout",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:13,hp:16,hit_dice:"3d8 + 2",speed:"30 ft.",stats:[11,14,12,11,13,11],skillsaves:[{nature:4},{perception:5},{stealth:6},{survival:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 15",languages:"any one language (usually Common)",cr:"1/2",bestiary:!0,traits:[{name:"Keen Hearing and Sight",desc:"The scout has advantage on Wisdom (Perception) checks that rely on hearing or sight.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The scout makes two melee attacks or two ranged attacks.",attack_bonus:0},{name:"Shortsword",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Longbow",desc:"Ranged Weapon Attack: +4 to hit, ranged 150/600 ft., one target. Hit: 6 (1d8 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2}]},{name:"Sea Hag",source:"5e SRD",size:"Medium",type:"fey",subtype:"",alignment:"chaotic evil",ac:14,hp:52,hit_dice:"7d8 + 20",speed:"30 ft., swim 40 ft.",stats:[16,13,16,12,12,13],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 11",languages:"Aquan, Common, Giant",cr:"2",bestiary:!0,traits:[{name:"Amphibious",desc:"The hag can breathe air and water.",attack_bonus:0},{name:"Horrific Appearance",desc:`Any humanoid that starts its turn within 30 feet of the hag and can see the hag's true form must make a DC 11 Wisdom saving throw. On a failed save, the creature is frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, with disadvantage if the hag is within line of sight, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the hag's Horrific Appearance for the next 24 hours. Unless the target is surprised or the revelation of the hag's true form is sudden, the target can avert its eyes and avoid making the initial saving throw. Until the start of its next turn, a creature that averts its eyes has disadvantage on attack rolls against the hag.`,attack_bonus:0},{name:"Hag Coven",desc:`When hags must work together, they form covens, in spite of their selfish natures. A coven is made up of hags of any type, all of whom are equals within the group. However, each of the hags continues to desire more personal power. A coven consists of three hags so that any arguments between two hags can be settled by the third. If more than three hags ever come together, as might happen if two covens come into conflict, the result is usually chaos.`,attack_bonus:0},{name:"Shared Spellcasting (Coven Only)",desc:`While all three members of a hag coven are within 30 feet of one another, they can each cast the following spells from the wizard's spell list but must share the spell slots among themselves: \u2022 1st level (4 slots): identify, ray of sickness \u2022 2nd level (3 slots): hold person, locate object \u2022 3rd level (3 slots): bestow curse, counterspell, lightning bolt \u2022 4th level (3 slots): phantasmal killer, polymorph \u2022 5th level (2 slots): contact other plane, scrying \u2022 6th level (1 slot): eye bite For casting these spells, each hag is a 12th-level spellcaster that uses Intelligence as her spellcasting ability. The spell save DC is 12+the hag's Intelligence modifier, and the spell attack bonus is 4+the hag's Intelligence modifier.`,attack_bonus:0},{name:"Hag Eye (Coven Only)",desc:`A hag coven can craft a magic item called a hag eye, which is made from a real eye coated in varnish and often fitted to a pendant or other wearable item. The hag eye is usually entrusted to a minion for safekeeping and transport. A hag in the coven can take an action to see what the hag eye sees if the hag eye is on the same plane of existence. A hag eye has AC 10, 1 hit point, and darkvision with a radius of 60 feet. If it is destroyed, each coven member takes 3d10 psychic damage and is blinded for 24 hours. A hag coven can have only one hag eye at a time, and creating a new one requires all three members of the coven to perform a ritual. The ritual takes 1 hour, and the hags can't perform it while blinded. During the ritual, if the hags take any action other than performing the ritual, they must start over.`,attack_bonus:0}],actions:[{name:"Claws",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3},{name:"Death Glare",desc:"The hag targets one frightened creature she can see within 30 ft. of her. If the target can see the hag, it must succeed on a DC 11 Wisdom saving throw against this magic or drop to 0 hit points.",attack_bonus:0},{name:"Illusory Appearance",desc:`The hag covers herself and anything she is wearing or carrying with a magical illusion that makes her look like an ugly creature of her general size and humanoid shape. The effect ends if the hag takes a bonus action to end it or if she dies. The changes wrought by this effect fail to hold up to physical inspection. For example, the hag could appear to have no claws, but someone touching her hand might feel the claws. Otherwise, a creature must take an action to visually inspect the illusion and succeed on a DC 16 Intelligence (Investigation) check to discern that the hag is disguised.`,attack_bonus:0}]},{name:"Sea Horse",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:1,hit_dice:"1d4 + -2",speed:"swim 20 ft.",stats:[1,12,8,1,10,2],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"0",bestiary:!0,traits:[{name:"Water Breathing",desc:"The sea horse can breathe only underwater.",attack_bonus:0}]},{name:"Shadow",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"chaotic evil",ac:12,hp:16,hit_dice:"3d8 + 2",speed:"40 ft.",stats:[6,14,13,6,10,8],skillsaves:[{stealth:4}],damage_vulnerabilities:"radiant",damage_resistances:"acid, cold, fire, lightning, thunder; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"necrotic, poison",condition_immunities:"exhaustion, frightened, grappled, paralyzed, petrified, poisoned, prone, restrained",senses:"darkvision 60 ft., passive Perception 10",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Amorphous",desc:"The shadow can move through a space as narrow as 1 inch wide without squeezing.",attack_bonus:0},{name:"Shadow Stealth",desc:"While in dim light or darkness, the shadow can take the Hide action as a bonus action. Its stealth bonus is also improved to +6.",attack_bonus:0},{name:"Sunlight Weakness",desc:"While in sunlight, the shadow has disadvantage on attack rolls, ability checks, and saving throws.",attack_bonus:0}],actions:[{name:"Strength Drain",desc:`Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 9 (2d6 + 2) necrotic damage, and the target's Strength score is reduced by 1d4. The target dies if this reduces its Strength to 0. Otherwise, the reduction lasts until the target finishes a short or long rest. If a non-evil humanoid dies from this attack, a new shadow rises from the corpse 1d4 hours later.`,attack_bonus:4,damage_dice:"2d6",damage_bonus:2}]},{name:"Shambling Mound",source:"5e SRD",size:"Large",type:"plant",subtype:"",alignment:"unaligned",ac:15,hp:136,hit_dice:"16d10 + 48",speed:"20 ft., swim 20 ft.",stats:[18,8,16,5,10,5],skillsaves:[{stealth:2}],damage_vulnerabilities:"",damage_resistances:"cold, fire",damage_immunities:"lightning",condition_immunities:"blinded, deafened, exhaustion",senses:"blindsight 60 ft. (blind beyond this radius), passive Perception 10",languages:"",cr:"5",bestiary:!0,traits:[{name:"Lightning Absorption",desc:"Whenever the shambling mound is subjected to lightning damage, it takes no damage and regains a number of hit points equal to the lightning damage dealt.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The shambling mound makes two slam attacks. If both attacks hit a Medium or smaller target, the target is grappled (escape DC 14), and the shambling mound uses its Engulf on it.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) bludgeoning damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:4},{name:"Engulf",desc:"The shambling mound engulfs a Medium or smaller creature grappled by it. The engulfed target is blinded, restrained, and unable to breathe, and it must succeed on a DC 14 Constitution saving throw at the start of each of the mound's turns or take 13 (2d8 + 4) bludgeoning damage. If the mound moves, the engulfed target moves with it. The mound can have only one creature engulfed at a time.",attack_bonus:0}]},{name:"Shield Guardian",source:"5e SRD",size:"Large",type:"construct",subtype:"",alignment:"unaligned",ac:17,hp:142,hit_dice:"15d10 + 59",speed:"30 ft.",stats:[18,8,18,7,10,3],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"charmed, exhaustion, frightened, paralyzed, poisoned",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 10",languages:"understands commands given in any language but can't speak",cr:"7",bestiary:!0,traits:[{name:"Bound",desc:"The shield guardian is magically bound to an amulet. As long as the guardian and its amulet are on the same plane of existence, the amulet's wearer can telepathically call the guardian to travel to it, and the guardian knows the distance and direction to the amulet. If the guardian is within 60 feet of the amulet's wearer, half of any damage the wearer takes (rounded up) is transferred to the guardian.",attack_bonus:0},{name:"Regeneration",desc:"The shield guardian regains 10 hit points at the start of its turn if it has at least 1 hit. point.",attack_bonus:0},{name:"Spell Storing",desc:"A spellcaster who wears the shield guardian's amulet can cause the guardian to store one spell of 4th level or lower. To do so, the wearer must cast the spell on the guardian. The spell has no effect but is stored within the guardian. When commanded to do so by the wearer or when a situation arises that was predefined by the spellcaster, the guardian casts the stored spell with any parameters set by the original caster, requiring no components. When the spell is cast or a new spell is stored, any previously stored spell is lost.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The guardian makes two fist attacks.",attack_bonus:0},{name:"Fist",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) bludgeoning damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4}],reactions:[{name:"Shield",desc:"When a creature makes an attack against the wearer of the guardian's amulet, the guardian grants a +2 bonus to the wearer's AC if the guardian is within 5 feet of the wearer.",attack_bonus:0}]},{name:"Shrieker",source:"5e SRD",size:"Medium",type:"plant",subtype:"",alignment:"unaligned",ac:5,hp:13,hit_dice:"3d8 + -1",speed:"0 ft.",stats:[1,1,10,1,3,1],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"blinded, deafened, frightened",senses:"blindsight 30 ft. (blind beyond this radius), passive Perception 6",languages:"",cr:"0",bestiary:!0,traits:[{name:"False Appearance",desc:"While the shrieker remains motionless, it is indistinguishable from an ordinary fungus.",attack_bonus:0}],actions:[{name:"Shriek",desc:"When bright light or a creature is within 30 feet of the shrieker, it emits a shriek audible within 300 feet of it. The shrieker continues to shriek until the disturbance moves out of range and for 1d4 of the shrieker's turns afterward",attack_bonus:0}]},{name:"Silver Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"lawful good",ac:17,hp:45,hit_dice:"6d8 + 18",speed:"30 ft., fly 60 ft.",stats:[19,10,17,12,11,15],saves:[{dexterity:2},{constitution:5},{wisdom:2},{charisma:4}],skillsaves:[{perception:4},{stealth:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"2",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 9 (1d10 + 4) piercing damage.",attack_bonus:6,damage_dice:"1d10",damage_bonus:4},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Cold Breath. The dragon exhales an icy blast in a 15-foot cone. Each creature in that area must make a DC 13 Constitution saving throw, taking 18 (4d8) cold damage on a failed save, or half as much damage on a successful one. Paralyzing Breath. The dragon exhales paralyzing gas in a 15-foot cone. Each creature in that area must succeed on a DC 13 Constitution saving throw or be paralyzed for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.`,attack_bonus:0,damage_dice:"4d8"}]},{name:"Skeleton",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"lawful evil",ac:13,hp:13,hit_dice:"2d8 + 4",speed:"30 ft.",stats:[10,14,15,6,8,5],damage_vulnerabilities:"bludgeoning",damage_resistances:"",damage_immunities:"",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 9",languages:"understands all languages it spoke in life but can't speak",cr:"1/4",bestiary:!0,actions:[{name:"Shortsword",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Shortbow",desc:"Ranged Weapon Attack: +4 to hit, range 80/320 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Solar",source:"5e SRD",size:"Large",type:"celestial",subtype:"",alignment:"lawful good",ac:21,hp:243,hit_dice:"18d10 + 144",speed:"50 ft., fly 150 ft.",stats:[26,22,26,25,25,30],saves:[{intelligence:14},{wisdom:14},{charisma:17}],skillsaves:[{perception:14}],damage_vulnerabilities:"",damage_resistances:"radiant; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"necrotic, poison",condition_immunities:"charmed, exhaustion, frightened, poisoned",senses:"truesight 120 ft., passive Perception 24",languages:"all, telepathy 120 ft.",cr:"21",bestiary:!0,traits:[{name:"Angelic Weapons",desc:"The solar's weapon attacks are magical. When the solar hits with any weapon, the weapon deals an extra 6d8 radiant damage (included in the attack).",attack_bonus:0},{name:"Divine Awareness",desc:"The solar knows if it hears a lie.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The solar's spell casting ability is Charisma (spell save DC 25). It can innately cast the following spells, requiring no material components: At will: detect evil and good, invisibility (self only) 3/day each: blade barrier, dispel evil and good, resurrection 1/day each: commune, control weather`,attack_bonus:0},{name:"Magic Resistance",desc:"The solar has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The solar makes two greatsword attacks.",attack_bonus:0},{name:"Greatsword",desc:"Melee Weapon Attack: +15 to hit, reach 5 ft., one target. Hit: 22 (4d6 + 8) slashing damage plus 27 (6d8) radiant damage.",attack_bonus:15,damage_dice:"4d6 + 6d8",damage_bonus:8},{name:"Slaying Longbow",desc:"Ranged Weapon Attack: +13 to hit, range 150/600 ft., one target. Hit: 15 (2d8 + 6) piercing damage plus 27 (6d8) radiant damage. If the target is a creature that has 190 hit points or fewer, it must succeed on a DC 15 Constitution saving throw or die.",attack_bonus:13,damage_dice:"2d8 + 6d8",damage_bonus:6},{name:"Flying Sword",desc:"The solar releases its greatsword to hover magically in an unoccupied space within 5 ft. of it. If the solar can see the sword, the solar can mentally command it as a bonus action to fly up to 50 ft. and either make one attack against a target or return to the solar's hands. If the hovering sword is targeted by any effect, the solar is considered to be holding it. The hovering sword falls if the solar dies.",attack_bonus:0},{name:"Healing Touch (4/Day)",desc:"The solar touches another creature. The target magically regains 40 (8d8 + 4) hit points and is freed from any curse, disease, poison, blindness, or deafness.",attack_bonus:0}],legendary_actions:[{name:"Teleport",desc:"The solar magically teleports, along with any equipment it is wearing or carrying, up to 120 ft. to an unoccupied space it can see.",attack_bonus:0},{name:"Searing Burst (Costs 2 Actions)",desc:"The solar emits magical, divine energy. Each creature of its choice in a 10 -foot radius must make a DC 23 Dexterity saving throw, taking 14 (4d6) fire damage plus 14 (4d6) radiant damage on a failed save, or half as much damage on a successful one.",attack_bonus:0},{name:"Blinding Gaze (Costs 3 Actions)",desc:"The solar targets one creature it can see within 30 ft. of it. If the target can see it, the target must succeed on a DC 15 Constitution saving throw or be blinded until magic such as the lesser restoration spell removes the blindness.",attack_bonus:0}]},{name:"Specter",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"chaotic evil",ac:12,hp:22,hit_dice:"5d8 + -1",speed:"0 ft., fly 50 ft. (hover)",stats:[1,14,11,10,10,11],damage_vulnerabilities:"",damage_resistances:"acid, cold, fire, lightning, thunder; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"necrotic, poison",condition_immunities:"charmed, exhaustion, grappled, paralyzed, petrified, poisoned, prone, restrained, unconscious",senses:"darkvision 60 ft., passive Perception 10",languages:"understands all languages it knew in life but can't speak",cr:"1",bestiary:!0,traits:[{name:"Incorporeal Movement",desc:"The specter can move through other creatures and objects as if they were difficult terrain. It takes 5 (1d10) force damage if it ends its turn inside an object.",attack_bonus:0},{name:"Sunlight Sensitivity",desc:"While in sunlight, the specter has disadvantage on attack rolls, as well as on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Life Drain",desc:"Melee Spell Attack: +4 to hit, reach 5 ft., one creature. Hit: 10 (3d6) necrotic damage. The target must succeed on a DC 10 Constitution saving throw or its hit point maximum is reduced by an amount equal to the damage taken. This reduction lasts until the creature finishes a long rest. The target dies if this effect reduces its hit point maximum to 0.",attack_bonus:4,damage_dice:"3d6"}]},{name:"Spider",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:1,hit_dice:"1d4 + -2",speed:"20 ft., climb 20 ft.",stats:[2,14,8,1,10,2],skillsaves:[{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 30 ft., passive Perception 12",languages:"",cr:"0",bestiary:!0,traits:[{name:"Spider Climb",desc:"The spider can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0},{name:"Web Sense",desc:"While in contact with a web, the spider knows the exact location of any other creature in contact with the same web.",attack_bonus:0},{name:"Web Walker",desc:"The spider ignores movement restrictions caused by webbing.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 1 piercing damage, and the target must succeed on a DC 9 Constitution saving throw or take 2 (1d4) poison damage.",attack_bonus:4,damage_bonus:1}]},{name:"Spirit Naga",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"chaotic evil",ac:15,hp:75,hit_dice:"10d10 + 20",speed:"40 ft.",stats:[18,17,14,16,15,16],saves:[{dexterity:6},{constitution:5},{wisdom:5},{charisma:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"charmed, poisoned",senses:"darkvision 60 ft., passive Perception 12",languages:"Abyssal, Common",cr:"8",bestiary:!0,traits:[{name:"Rejuvenation",desc:"If it dies, the naga returns to life in 1d6 days and regains all its hit points. Only a wish spell can prevent this trait from functioning.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one creature. Hit: 7 (1d6 + 4) piercing damage, and the target must make a DC 13 Constitution saving throw, taking 31 (7d8) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:7,damage_dice:"1d6",damage_bonus:4}],spells:["The naga is a 10th-level spellcaster. Its spellcasting ability is Intelligence (spell save DC 14, +6 to hit with spell attacks), and it needs only verbal components to cast its spells. It has the following wizard spells prepared:",{"Cantrips (at will)":"mage hand, minor illusion, ray of frost"},{"1st level (4 slots)":"charm person, detect magic, sleep"},{"2nd level (3 slots)":"detect thoughts, hold person"},{"3rd level (3 slots)":"lightning bolt, water breathing"},{"4th level (3 slots)":"blight, dimension door"},{"5th level (2 slots)":"dominate person"}]},{name:"Sprite",source:"5e SRD",size:"Tiny",type:"fey",subtype:"",alignment:"neutral good",ac:15,hp:2,hit_dice:"1d4 + -1",speed:"10 ft., fly 40 ft.",stats:[3,18,10,14,13,11],skillsaves:[{perception:3},{stealth:8}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"Common, Elvish, Sylvan",cr:"1/4",bestiary:!0,actions:[{name:"Longsword",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 1 slashing damage.",attack_bonus:2,damage_bonus:1},{name:"Shortbow",desc:"Ranged Weapon Attack: +6 to hit, range 40/160 ft., one target. Hit: 1 piercing damage, and the target must succeed on a DC 10 Constitution saving throw or become poisoned for 1 minute. If its saving throw result is 5 or lower, the poisoned target falls unconscious for the same duration, or until it takes damage or another creature takes an action to shake it awake.",attack_bonus:6,damage_bonus:1},{name:"Heart Sight",desc:"The sprite touches a creature and magically knows the creature's current emotional state. If the target fails a DC 10 Charisma saving throw, the sprite also knows the creature's alignment. Celestials, fiends, and undead automatically fail the saving throw.",attack_bonus:0},{name:"Invisibility",desc:"The sprite magically turns invisible until it attacks or casts a spell, or until its concentration ends (as if concentrating on a spell). Any equipment the sprite wears or carries is invisible with it.",attack_bonus:0}]},{name:"Spy",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:12,hp:27,hit_dice:"6d8",speed:"30 ft.",stats:[10,15,10,12,14,16],skillsaves:[{deception:5},{insight:4},{investigation:5},{perception:6},{persuasion:5},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 16",languages:"any two languages",cr:"1",bestiary:!0,traits:[{name:"Cunning Action",desc:"On each of its turns, the spy can use a bonus action to take the Dash, Disengage, or Hide action.",attack_bonus:0},{name:"Sneak Attack (1/Turn)",desc:"The spy deals an extra 7 (2d6) damage when it hits a target with a weapon attack and has advantage on the attack roll, or when the target is within 5 ft. of an ally of the spy that isn't incapacitated and the spy doesn't have disadvantage on the attack roll.",attack_bonus:0,damage_dice:"2d6"}],actions:[{name:"Multiattack",desc:"The spy makes two melee attacks.",attack_bonus:0},{name:"Shortsword",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Hand Crossbow",desc:"Ranged Weapon Attack: +4 to hit, range 30/120 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Steam Mephit",source:"5e SRD",size:"Small",type:"elemental",subtype:"",alignment:"neutral evil",ac:10,hp:21,hit_dice:"6d6",speed:"30 ft., fly 30 ft.",stats:[5,11,10,11,10,12],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire, poison",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 10",languages:"Aquan, Ignan",cr:"1/4",bestiary:!0,traits:[{name:"Death Burst",desc:"When the mephit dies, it explodes in a cloud of steam. Each creature within 5 ft. of the mephit must succeed on a DC 10 Dexterity saving throw or take 4 (1d8) fire damage.",attack_bonus:0,damage_dice:"1d8"},{name:"Innate Spellcasting (1/Day)",desc:"The mephit can innately cast blur, requiring no material components. Its innate spellcasting ability is Charisma.",attack_bonus:0}],actions:[{name:"Claws",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one creature. Hit: 2 (1d4) slashing damage plus 2 (1d4) fire damage.",attack_bonus:2,damage_dice:"2d4"},{name:"Steam Breath (Recharge 6)",desc:"The mephit exhales a 15-foot cone of scalding steam. Each creature in that area must succeed on a DC 10 Dexterity saving throw, taking 4 (1d8) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0},{name:"Variant: Summon Mephits (1/Day)",desc:"The mephit has a 25 percent chance of summoning 1d4 mephits of its kind. A summoned mephit appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other mephits. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.",attack_bonus:0}]},{name:"Stirge",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:14,hp:2,hit_dice:"1d4 + -1",speed:"10 ft., fly 40 ft.",stats:[4,16,11,2,8,6],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 9",languages:"",cr:"1/8",bestiary:!0,actions:[{name:"Blood Drain",desc:`Melee Weapon Attack: +5 to hit, reach 5 ft., one creature. Hit: 5 (1d4 + 3) piercing damage, and the stirge attaches to the target. While attached, the stirge doesn't attack. Instead, at the start of each of the stirge's turns, the target loses 5 (1d4 + 3) hit points due to blood loss. The stirge can detach itself by spending 5 feet of its movement. It does so after it drains 10 hit points of blood from the target or the target dies. A creature, including the target, can use its action to detach the stirge.`,attack_bonus:5,damage_dice:"1d4",damage_bonus:3}]},{name:"Stone Giant",source:"5e SRD",size:"Huge",type:"giant",subtype:"",alignment:"neutral",ac:17,hp:126,hit_dice:"11d12 + 54",speed:"40 ft.",stats:[23,15,20,10,12,9],saves:[{dexterity:5},{constitution:8},{wisdom:4}],skillsaves:[{athletics:12},{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"Giant",cr:"7",bestiary:!0,traits:[{name:"Stone Camouflage",desc:"The giant has advantage on Dexterity (Stealth) checks made to hide in rocky terrain.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The giant makes two greatclub attacks.",attack_bonus:0},{name:"Greatclub",desc:"Melee Weapon Attack: +9 to hit, reach 15 ft., one target. Hit: 19 (3d8 + 6) bludgeoning damage.",attack_bonus:9,damage_dice:"3d8",damage_bonus:6},{name:"Rock",desc:"Ranged Weapon Attack: +9 to hit, range 60/240 ft., one target. Hit: 28 (4d10 + 6) bludgeoning damage. If the target is a creature, it must succeed on a DC 17 Strength saving throw or be knocked prone.",attack_bonus:9,damage_dice:"4d10",damage_bonus:6}],reactions:[{name:"Rock Catching",desc:"If a rock or similar object is hurled at the giant, the giant can, with a successful DC 10 Dexterity saving throw, catch the missile and take no bludgeoning damage from it.",attack_bonus:0}]},{name:"Stone Golem",source:"5e SRD",size:"Large",type:"construct",subtype:"",alignment:"unaligned",ac:17,hp:178,hit_dice:"17d10 + 84",speed:"30 ft.",stats:[22,9,20,3,11,1],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison, psychic; bludgeoning, piercing, and slashing from nonmagical weapons that aren't adamantine",condition_immunities:"charmed, exhaustion, frightened, paralyzed, petrified, poisoned",senses:"darkvision 120 ft., passive Perception 10",languages:"understands the languages of its creator but can't speak",cr:"10",bestiary:!0,traits:[{name:"Immutable Form",desc:"The golem is immune to any spell or effect that would alter its form.",attack_bonus:0},{name:"Magic Resistance",desc:"The golem has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Magic Weapons",desc:"The golem's weapon attacks are magical.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The golem makes two slam attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one target. Hit: 19 (3d8 + 6) bludgeoning damage.",attack_bonus:10,damage_dice:"3d8",damage_bonus:6},{name:"Slow (Recharge 5-6)",desc:"The golem targets one or more creatures it can see within 10 ft. of it. Each target must make a DC 17 Wisdom saving throw against this magic. On a failed save, a target can't use reactions, its speed is halved, and it can't make more than one attack on its turn. In addition, the target can take either an action or a bonus action on its turn, not both. These effects last for 1 minute. A target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.",attack_bonus:0}]},{name:"Storm Giant",source:"5e SRD",size:"Huge",type:"giant",subtype:"",alignment:"chaotic good",ac:16,hp:230,hit_dice:"20d12 + 100",speed:"50 ft., swim 50 ft.",stats:[29,14,20,16,18,18],saves:[{strength:14},{constitution:10},{wisdom:9},{charisma:9}],skillsaves:[{arcana:8},{athletics:14},{history:8},{perception:9}],damage_vulnerabilities:"",damage_resistances:"cold",damage_immunities:"lightning, thunder",condition_immunities:"",senses:"passive Perception 19",languages:"Common, Giant",cr:"13",bestiary:!0,traits:[{name:"Amphibious",desc:"The giant can breathe air and water.",attack_bonus:0},{name:"Innate Spellcasting",desc:`The giant's innate spellcasting ability is Charisma (spell save DC 17). It can innately cast the following spells, requiring no material components: At will: detect magic, feather fall, levitate, light 3/day each: control weather, water breathing`,attack_bonus:0}],actions:[{name:"Multiattack",desc:"The giant makes two greatsword attacks.",attack_bonus:0},{name:"Greatsword",desc:"Melee Weapon Attack: +14 to hit, reach 10 ft., one target. Hit: 30 (6d6 + 9) slashing damage.",attack_bonus:14,damage_dice:"6d6",damage_bonus:9},{name:"Rock",desc:"Ranged Weapon Attack: +14 to hit, range 60/240 ft., one target. Hit: 35 (4d12 + 9) bludgeoning damage.",attack_bonus:14,damage_dice:"4d12",damage_bonus:9},{name:"Lightning Strike (Recharge 5-6)",desc:"The giant hurls a magical lightning bolt at a point it can see within 500 feet of it. Each creature within 10 feet of that point must make a DC 17 Dexterity saving throw, taking 54 (12d8) lightning damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"12d8"}]},{name:"Succubus/Incubus",source:"5e SRD",size:"Medium",type:"fiend",subtype:"shapechanger",alignment:"neutral evil",ac:15,hp:66,hit_dice:"12d8 + 12",speed:"30 ft., fly 60 ft.",stats:[8,17,13,15,12,20],skillsaves:[{deception:9},{insight:5},{perception:5},{persuasion:9},{stealth:7}],damage_vulnerabilities:"",damage_resistances:"cold, fire, lightning, poison; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 15",languages:"Abyssal, Common, Infernal, telepathy 60 ft.",cr:"4",bestiary:!0,traits:[{name:"Telepathic Bond",desc:"The fiend ignores the range restriction on its telepathy when communicating with a creature it has charmed. The two don't even need to be on the same plane of existence.",attack_bonus:0},{name:"Shapechanger",desc:"The fiend can use its action to polymorph into a Small or Medium humanoid, or back into its true form. Without wings, the fiend loses its flying speed. Other than its size and speed, its statistics are the same in each form. Any equipment it is wearing or carrying isn't transformed. It reverts to its true form if it dies.",attack_bonus:0}],actions:[{name:"Claw (Fiend Form Only)",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Charm",desc:`One humanoid the fiend can see within 30 feet of it must succeed on a DC 15 Wisdom saving throw or be magically charmed for 1 day. The charmed target obeys the fiend's verbal or telepathic commands. If the target suffers any harm or receives a suicidal command, it can repeat the saving throw, ending the effect on a success. If the target successfully saves against the effect, or if the effect on it ends, the target is immune to this fiend's Charm for the next 24 hours. The fiend can have only one target charmed at a time. If it charms another, the effect on the previous target ends.`,attack_bonus:0},{name:"Draining Kiss",desc:"The fiend kisses a creature charmed by it or a willing creature. The target must make a DC 15 Constitution saving throw against this magic, taking 32 (5d10 + 5) psychic damage on a failed save, or half as much damage on a successful one. The target's hit point maximum is reduced by an amount equal to the damage taken. This reduction lasts until the target finishes a long rest. The target dies if this effect reduces its hit point maximum to 0.",attack_bonus:0,damage_dice:"5d10",damage_bonus:5},{name:"Etherealness",desc:"The fiend magically enters the Ethereal Plane from the Material Plane, or vice versa.",attack_bonus:0}]},{name:"Swarm of Bats",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:12,hp:22,hit_dice:"5d8 + -1",speed:"0 ft., fly 30 ft.",stats:[5,15,10,2,12,4],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, grappled, paralyzed, petrified, prone, restrained, stunned",senses:"blindsight 60 ft., passive Perception 11",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Echolocation",desc:"The swarm can't use its blindsight while deafened.",attack_bonus:0},{name:"Keen Hearing",desc:"The swarm has advantage on Wisdom (Perception) checks that rely on hearing.",attack_bonus:0},{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny bat. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0}],actions:[{name:"Bites",desc:"Melee Weapon Attack: +4 to hit, reach 0 ft., one creature in the swarm's space. Hit: 5 (2d4) piercing damage, or 2 (1d4) piercing damage if the swarm has half of its hit points or fewer.",attack_bonus:4,damage_dice:"2d4"}]},{name:"Swarm of Beetles",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:12,hp:22,hit_dice:"5d8 + -1",speed:"20 ft., burrow 5 ft., climb 20 ft.",stats:[3,13,10,1,7,1],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, grappled, paralyzed, petrified, prone, restrained, stunned",senses:"blindsight 10 ft., passive Perception 8",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny insect. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0}],actions:[{name:"Bites",desc:"Melee Weapon Attack: +3 to hit, reach 0 ft., one target in the swarm's space. Hit: 10 (4d4) piercing damage, or 5 (2d4) piercing damage if the swarm has half of its hit points or fewer.",attack_bonus:3,damage_dice:"4d4"}]},{name:"Swarm of Centipedes",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:12,hp:22,hit_dice:"5d8 + -1",speed:"20 ft., climb 20 ft.",stats:[3,13,10,1,7,1],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, grappled, paralyzed, petrified, prone, restrained, stunned",senses:"blindsight 10 ft., passive Perception 8",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny insect. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0}],actions:[{name:"Bites",desc:`Melee Weapon Attack: +3 to hit, reach 0 ft., one target in the swarm's space. Hit: 10 (4d4) piercing damage, or 5 (2d4) piercing damage if the swarm has half of its hit points or fewer. A creature reduced to 0 hit points by a swarm of centipedes is stable but poisoned for 1 hour, even after regaining hit points, and paralyzed while poisoned in this way.`,attack_bonus:3,damage_dice:"4d4"}]},{name:"Swarm of Insects",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:12,hp:22,hit_dice:"5d8 + -1",speed:"20 ft., climb 20 ft.",stats:[3,13,10,1,7,1],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, grappled, paralyzed, petrified, prone, restrained, stunned",senses:"blindsight 10 ft., passive Perception 8",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny insect. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0}],actions:[{name:"Bites",desc:"Melee Weapon Attack: +3 to hit, reach 0 ft., one target in the swarm's space. Hit: 10 (4d4) piercing damage, or 5 (2d4) piercing damage if the swarm has half of its hit points or fewer.",attack_bonus:3,damage_dice:"4d4"}]},{name:"Swarm of Poisonous Snakes",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:14,hp:36,hit_dice:"8d8",speed:"30 ft., swim 30 ft.",stats:[8,18,11,1,10,3],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, grappled, paralyzed, petrified, prone, restrained, stunned",senses:"blindsight 10 ft., passive Perception 10",languages:"",cr:"2",bestiary:!0,traits:[{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny snake. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0}],actions:[{name:"Bites",desc:"Melee Weapon Attack: +6 to hit, reach 0 ft., one creature in the swarm's space. Hit: 7 (2d6) piercing damage, or 3 (1d6) piercing damage if the swarm has half of its hit points or fewer. The target must make a DC 10 Constitution saving throw, taking 14 (4d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:6,damage_dice:"2d6"}]},{name:"Swarm of Quippers",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:13,hp:28,hit_dice:"8d8 + -8",speed:"0 ft., swim 40 ft.",stats:[13,16,9,1,7,2],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, grappled, paralyzed, petrified, prone, restrained, stunned",senses:"darkvision 60 ft., passive Perception 8",languages:"",cr:"1",bestiary:!0,traits:[{name:"Blood Frenzy",desc:"The swarm has advantage on melee attack rolls against any creature that doesn't have all its hit points.",attack_bonus:0},{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny quipper. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0},{name:"Water Breathing",desc:"The swarm can breathe only underwater.",attack_bonus:0}],actions:[{name:"Bites",desc:"Melee Weapon Attack: +5 to hit, reach 0 ft., one creature in the swarm's space. Hit: 14 (4d6) piercing damage, or 7 (2d6) piercing damage if the swarm has half of its hit points or fewer.",attack_bonus:5,damage_dice:"4d6"}]},{name:"Swarm of Rats",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:10,hp:24,hit_dice:"7d8 + -8",speed:"30 ft.",stats:[9,11,9,2,10,3],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, grappled, paralyzed, petrified, prone, restrained, stunned",senses:"darkvision 30 ft., passive Perception 10",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Keen Smell",desc:"The swarm has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0},{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny rat. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0}],actions:[{name:"Bites",desc:"Melee Weapon Attack: +2 to hit, reach 0 ft., one target in the swarm's space. Hit: 7 (2d6) piercing damage, or 3 (1d6) piercing damage if the swarm has half of its hit points or fewer.",attack_bonus:2,damage_dice:"2d6"}]},{name:"Swarm of Ravens",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:12,hp:24,hit_dice:"7d8 + -8",speed:"10 ft., fly 50 ft.",stats:[6,14,8,3,12,6],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, grappled, paralyzed, petrified, prone, restrained, stunned",senses:"passive Perception 15",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny raven. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0}],actions:[{name:"Beaks",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target in the swarm's space. Hit: 7 (2d6) piercing damage, or 3 (1d6) piercing damage if the swarm has half of its hit points or fewer.",attack_bonus:4,damage_dice:"2d6"}]},{name:"Swarm of Spiders",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:12,hp:22,hit_dice:"5d8 + -1",speed:"20 ft., climb 20 ft.",stats:[3,13,10,1,7,1],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, paralyzed, petrified, prone, restrained, stunned",senses:"blindsight 10 ft., passive Perception 8",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny insect. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0},{name:"Spider Climb",desc:"The swarm can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0},{name:"Web Sense",desc:"While in contact with a web, the swarm knows the exact location of any other creature in contact with the same web.",attack_bonus:0},{name:"Web Walker",desc:"The swarm ignores movement restrictions caused by webbing.",attack_bonus:0}],actions:[{name:"Bites",desc:"Melee Weapon Attack: +3 to hit, reach 0 ft., one target in the swarm's space. Hit: 10 (4d4) piercing damage, or 5 (2d4) piercing damage if the swarm has half of its hit points or fewer.",attack_bonus:3,damage_dice:"4d4"}]},{name:"Swarm of Wasps",source:"5e SRD",size:"Medium",type:"swarm of Tiny beasts",subtype:"",alignment:"unaligned",ac:12,hp:22,hit_dice:"5d8 + -1",speed:"5 ft., fly 30 ft.",stats:[3,13,10,1,7,1],damage_vulnerabilities:"",damage_resistances:"bludgeoning, piercing, slashing",damage_immunities:"",condition_immunities:"charmed, frightened, grappled, paralyzed, petrified, prone, restrained, stunned",senses:"blindsight 10 ft., passive Perception 8",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Swarm",desc:"The swarm can occupy another creature's space and vice versa, and the swarm can move through any opening large enough for a Tiny insect. The swarm can't regain hit points or gain temporary hit points.",attack_bonus:0}],actions:[{name:"Bites",desc:"Melee Weapon Attack: +3 to hit, reach 0 ft., one target in the swarm's space. Hit: 10 (4d4) piercing damage, or 5 (2d4) piercing damage if the swarm has half of its hit points or fewer.",attack_bonus:3,damage_dice:"4d4"}]},{name:"Tarrasque",source:"5e SRD",size:"Gargantuan",type:"monstrosity",subtype:"titan",alignment:"unaligned",ac:25,hp:676,hit_dice:"33d20 + 329",speed:"40 ft.",stats:[30,11,30,3,11,11],saves:[{intelligence:5},{wisdom:9},{charisma:9}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire, poison; bludgeoning, piercing, and slashing from nonmagical weapons",condition_immunities:"charmed, frightened, paralyzed, poisoned",senses:"blindsight 120 ft., passive Perception 10",languages:"",cr:"30",bestiary:!0,traits:[{name:"Legendary Resistance (3/Day)",desc:"If the tarrasque fails a saving throw, it can choose to succeed instead.",attack_bonus:0},{name:"Magic Resistance",desc:"The tarrasque has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Reflective Carapace",desc:"Any time the tarrasque is targeted by a magic missile spell, a line spell, or a spell that requires a ranged attack roll, roll a d6. On a 1 to 5, the tarrasque is unaffected. On a 6, the tarrasque is unaffected, and the effect is reflected back at the caster as though it originated from the tarrasque, turning the caster into the target.",attack_bonus:0},{name:"Siege Monster",desc:"The tarrasque deals double damage to objects and structures.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The tarrasque can use its Frightful Presence. It then makes five attacks: one with its bite, two with its claws, one with its horns, and one with its tai l. It can use its Swallow instead of its bite.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +19 to hit, reach 10 ft., one target. Hit: 36 (4d12 + 10) piercing damage. If the target is a creature, it is grappled (escape DC 20). Until this grapple ends, the target is restrained, and the tarrasque can't bite another target.",attack_bonus:19,damage_dice:"4d12",damage_bonus:10},{name:"Claw",desc:"Melee Weapon Attack: +19 to hit, reach 15 ft., one target. Hit: 28 (4d8 + 10) slashing damage.",attack_bonus:19,damage_dice:"4d8",damage_bonus:10},{name:"Horns",desc:"Melee Weapon Attack: +19 to hit, reach 10 ft., one target. Hit: 32 (4d10 + 10) piercing damage.",attack_bonus:19,damage_dice:"4d10",damage_bonus:10},{name:"Tail",desc:"Melee Weapon Attack: +19 to hit, reach 20 ft., one target. Hit: 24 (4d6 + 10) bludgeoning damage. If the target is a creature, it must succeed on a DC 20 Strength saving throw or be knocked prone.",attack_bonus:19,damage_dice:"4d6",damage_bonus:10},{name:"Frightful Presence",desc:"Each creature of the tarrasque's choice within 120 feet of it and aware of it must succeed on a DC 17 Wisdom saving throw or become frightened for 1 minute. A creature can repeat the saving throw at the end of each of its turns, with disadvantage if the tarrasque is within line of sight, ending the effect on itself on a success. If a creature's saving throw is successful or the effect ends for it, the creature is immune to the tarrasque's Frightful Presence for the next 24 hours.",attack_bonus:0},{name:"Swallow",desc:`The tarrasque makes one bite attack against a Large or smaller creature it is grappling. If the attack hits, the target takes the bite's damage, the target is swallowed, and the grapple ends. While swallowed, the creature is blinded and restrained, it has total cover against attacks and other effects outside the tarrasque, and it takes 56 (16d6) acid damage at the start of each of the tarrasque's turns. If the tarrasque takes 60 damage or more on a single turn from a creature inside it, the tarrasque must succeed on a DC 20 Constitution saving throw at the end of that turn or regurgitate all swallowed creatures, which fall prone in a space within 10 feet of the tarrasque. If the tarrasque dies, a swallowed creature is no longer restrained by it and can escape from the corpse by using 30 feet of movement, exiting prone.`,attack_bonus:0}],legendary_actions:[{name:"Attack",desc:"The tarrasque makes one claw attack or tail attack.",attack_bonus:0},{name:"Move",desc:"The tarrasque moves up to half its speed.",attack_bonus:0},{name:"Chomp (Costs 2 Actions)",desc:"The tarrasque makes one bite attack or uses its Swallow.",attack_bonus:0}]},{name:"Thug",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any non-good alignment",ac:11,hp:32,hit_dice:"5d8 + 9",speed:"30 ft.",stats:[15,11,14,10,10,11],skillsaves:[{intimidation:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"any one language (usually Common)",cr:"1/2",bestiary:!0,traits:[{name:"Pack Tactics",desc:"The thug has advantage on an attack roll against a creature if at least one of the thug's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The thug makes two melee attacks.",attack_bonus:0},{name:"Mace",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 5 (1d6 + 2) bludgeoning damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Heavy Crossbow",desc:"Ranged Weapon Attack: +2 to hit, range 100/400 ft., one target. Hit: 5 (1d10) piercing damage.",attack_bonus:2,damage_dice:"1d10"}]},{name:"Tiger",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:12,hp:37,hit_dice:"5d10 + 9",speed:"40 ft.",stats:[17,15,14,3,12,8],skillsaves:[{perception:3},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 13",languages:"",cr:"1",bestiary:!0,traits:[{name:"Keen Smell",desc:"The tiger has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0},{name:"Pounce",desc:"If the tiger moves at least 20 ft. straight toward a creature and then hits it with a claw attack on the same turn, that target must succeed on a DC 13 Strength saving throw or be knocked prone. If the target is prone, the tiger can make one bite attack against it as a bonus action.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 8 (1d10 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d10",damage_bonus:3},{name:"Claw",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) slashing damage.",attack_bonus:0}]},{name:"Treant",source:"5e SRD",size:"Huge",type:"plant",subtype:"",alignment:"chaotic good",ac:16,hp:138,hit_dice:"12d12 + 60",speed:"30 ft.",stats:[23,8,21,12,16,12],damage_vulnerabilities:"fire",damage_resistances:"bludgeoning, piercing",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"Common, Druidic, Elvish, Sylvan",cr:"9",bestiary:!0,traits:[{name:"False Appearance",desc:"While the treant remains motionless, it is indistinguishable from a normal tree.",attack_bonus:0},{name:"Siege Monster",desc:"The treant deals double damage to objects and structures.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The treant makes two slam attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one target. Hit: 16 (3d6 + 6) bludgeoning damage.",attack_bonus:10,damage_dice:"3d6",damage_bonus:6},{name:"Rock",desc:"Ranged Weapon Attack: +10 to hit, range 60/180 ft., one target. Hit: 28 (4d10 + 6) bludgeoning damage.",attack_bonus:10,damage_dice:"4d10",damage_bonus:6},{name:"Animate Trees (1/Day)",desc:"The treant magically animates one or two trees it can see within 60 feet of it. These trees have the same statistics as a treant, except they have Intelligence and Charisma scores of 1, they can't speak, and they have only the Slam action option. An animated tree acts as an ally of the treant. The tree remains animate for 1 day or until it dies; until the treant dies or is more than 120 feet from the tree; or until the treant takes a bonus action to turn it back into an inanimate tree. The tree then takes root if possible.",attack_bonus:0}]},{name:"Tribal Warrior",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:12,hp:11,hit_dice:"2d8 + 2",speed:"30 ft.",stats:[13,11,12,8,11,8],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"any one language",cr:"1/8",bestiary:!0,traits:[{name:"Pack Tactics",desc:"The warrior has advantage on an attack roll against a creature if at least one of the warrior's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Spear",desc:"Melee or Ranged Weapon Attack: +3 to hit, reach 5 ft. or range 20/60 ft., one target. Hit: 4 (1d6 + 1) piercing damage, or 5 (1d8 + 1) piercing damage if used with two hands to make a melee attack.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]},{name:"Triceratops",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:95,hit_dice:"10d12 + 30",speed:"50 ft.",stats:[22,9,17,2,11,5],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 10",languages:"",cr:"5",bestiary:!0,traits:[{name:"Trampling Charge",desc:"If the triceratops moves at least 20 ft. straight toward a creature and then hits it with a gore attack on the same turn, that target must succeed on a DC 13 Strength saving throw or be knocked prone. If the target is prone, the triceratops can make one stomp attack against it as a bonus action.",attack_bonus:0}],actions:[{name:"Gore",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one target. Hit: 24 (4d8 + 6) piercing damage.",attack_bonus:9,damage_dice:"4d8",damage_bonus:6},{name:"Stomp",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one prone creature. Hit: 22 (3d10 + 6) bludgeoning damage",attack_bonus:9,damage_dice:"3d10",damage_bonus:6}]},{name:"Troll",source:"5e SRD",size:"Large",type:"giant",subtype:"",alignment:"chaotic evil",ac:15,hp:84,hit_dice:"8d10 + 40",speed:"30 ft.",stats:[18,13,20,7,9,7],skillsaves:[{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 12",languages:"Giant",cr:"5",bestiary:!0,traits:[{name:"Keen Smell",desc:"The troll has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0},{name:"Regeneration",desc:"The troll regains 10 hit points at the start of its turn. If the troll takes acid or fire damage, this trait doesn't function at the start of the troll's next turn. The troll dies only if it starts its turn with 0 hit points and doesn't regenerate.",attack_bonus:0},{name:"Variant: Loathsome Limbs",desc:`Whenever the troll takes at least 15 slashing damage at one time, roll a d20 to determine what else happens to it: 1-10: Nothing else happens. 11-14: One leg is severed from the troll if it has any legs left. 15- 18: One arm is severed from the troll if it has any arms left. 19-20: The troll is decapitated, but the troll dies only if it can't regenerate. If it dies, so does the severed head. If the troll finishes a short or long rest without reattaching a severed limb or head, the part regrows. At that point, the severed part dies. Until then, a severed part acts on the troll's initiative and has its own action and movement. A severed part has AC 13, 10 hit points, and the troll's Regeneration trait. A severed leg is unable to attack and has a speed of 5 feet. A severed arm has a speed of 5 feet and can make one claw attack on its turn, with disadvantage on the attack roll unless the troll can see the arm and its target. Each time the troll loses an arm, it loses a claw attack. If its head is severed, the troll loses its bite attack and its body is blinded unless the head can see it. The severed head has a speed of 0 feet and the troll's Keen Smell trait. It can make a bite attack but only against a target in its space. The troll's speed is halved if it's missing a leg. If it loses both legs, it falls prone. If it has both arms, it can crawl. With only one arm, it can still crawl, but its speed is halved. With no arms or legs, its speed is 0, and it can't benefit from bonuses to speed.`,attack_bonus:0}],actions:[{name:"Multiattack",desc:"The troll makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 7 (1d6 + 4) piercing damage.",attack_bonus:7,damage_dice:"1d6",damage_bonus:4},{name:"Claw",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4}]},{name:"Tyrannosaurus Rex",source:"5e SRD",size:"Huge",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:136,hit_dice:"13d12 + 51",speed:"50 ft.",stats:[25,10,19,2,12,9],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 14",languages:"",cr:"8",bestiary:!0,actions:[{name:"Multiattack",desc:"The tyrannosaurus makes two attacks: one with its bite and one with its tail. It can't make both attacks against the same target.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 33 (4d12 + 7) piercing damage. If the target is a Medium or smaller creature, it is grappled (escape DC 17). Until this grapple ends, the target is restrained, and the tyrannosaurus can't bite another target.",attack_bonus:10,damage_dice:"4d12",damage_bonus:7},{name:"Tail",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 20 (3d8 + 7) bludgeoning damage.",attack_bonus:10,damage_dice:"3d8",damage_bonus:7}]},{name:"Unicorn",source:"5e SRD",size:"Large",type:"celestial",subtype:"",alignment:"lawful good",ac:12,hp:67,hit_dice:"9d10 + 17",speed:"50 ft.",stats:[18,14,15,11,17,16],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"charmed, paralyzed, poisoned",senses:"darkvision 60 ft., passive Perception 13",languages:"Celestial, Elvish, Sylvan, telepathy 60 ft.",cr:"5",bestiary:!0,traits:[{name:"Charge",desc:"If the unicorn moves at least 20 ft. straight toward a target and then hits it with a horn attack on the same turn, the target takes an extra 9 (2d8) piercing damage. If the target is a creature, it must succeed on a DC 15 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"2d8"},{name:"Innate Spellcasting",desc:`The unicorn's innate spellcasting ability is Charisma (spell save DC 14). The unicorn can innately cast the following spells, requiring no components: At will: detect evil and good, druidcraft, pass without trace 1/day each: calm emotions, dispel evil and good, entangle`,attack_bonus:0},{name:"Magic Resistance",desc:"The unicorn has advantage on saving throws against spells and other magical effects.",attack_bonus:0},{name:"Magic Weapons",desc:"The unicorn's weapon attacks are magical.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The unicorn makes two attacks: one with its hooves and one with its horn.",attack_bonus:0},{name:"Hooves",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft ., one target. Hit: 11 (2d6 + 4) bludgeoning damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Horn",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft ., one target. Hit: 8 (1d8 + 4) piercing damage.",attack_bonus:7,damage_dice:"1d8",damage_bonus:4},{name:"Healing Touch (3/Day)",desc:"The unicorn touches another creature with its horn. The target magically regains 11 (2d8 + 2) hit points. In addition, the touch removes all diseases and neutralizes all poisons afflicting the target.",attack_bonus:0},{name:"Teleport (1/Day)",desc:"The unicorn magically teleports itself and up to three willing creatures it can see within 5 ft. of it, along with any equipment they are wearing or carrying, to a location the unicorn is familiar with, up to 1 mile away.",attack_bonus:0}],legendary_actions:[{name:"Hooves",desc:"The unicorn makes one attack with its hooves.",attack_bonus:0},{name:"Shimmering Shield (Costs 2 Actions)",desc:"The unicorn creates a shimmering, magical field around itself or another creature it can see within 60 ft. of it. The target gains a +2 bonus to AC until the end of the unicorn's next turn.",attack_bonus:0},{name:"Heal Self (Costs 3 Actions)",desc:"The unicorn magically regains 11 (2d8 + 2) hit points.",attack_bonus:0}]},{name:"Vampire",source:"5e SRD",size:"Medium",type:"undead",subtype:"shapechanger",alignment:"lawful evil",ac:16,hp:144,hit_dice:"17d8 + 67",speed:"30 ft.",stats:[18,18,18,17,15,18],saves:[{dexterity:9},{wisdom:7},{charisma:9}],skillsaves:[{perception:7},{stealth:9}],damage_vulnerabilities:"",damage_resistances:"necrotic; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"",condition_immunities:"",senses:"darkvision 120 ft., passive Perception 17",languages:"the languages it knew in life",cr:"13",bestiary:!0,traits:[{name:"Shapechanger",desc:`If the vampire isn't in sun light or running water, it can use its action to polymorph into a Tiny bat or a Medium cloud of mist, or back into its true form. While in bat form, the vampire can't speak, its walking speed is 5 feet, and it has a flying speed of 30 feet. Its statistics, other than its size and speed, are unchanged. Anything it is wearing transforms with it, but nothing it is carrying does. It reverts to its true form if it dies. While in mist form, the vampire can't take any actions, speak, or manipulate objects. It is weightless, has a flying speed of 20 feet, can hover, and can enter a hostile creature's space and stop there. In addition, if air can pass through a space, the mist can do so without squeezing, and it can't pass through water. It has advantage on Strength, Dexterity, and Constitution saving throws, and it is immune to all nonmagical damage, except the damage it takes from sunlight.`,attack_bonus:0},{name:"Legendary Resistance (3/Day)",desc:"If the vampire fails a saving throw, it can choose to succeed instead.",attack_bonus:0},{name:"Misty Escape",desc:`When it drops to 0 hit points outside its resting place, the vampire transforms into a cloud of mist (as in the Shapechanger trait) instead of falling unconscious, provided that it isn't in sunlight or running water. If it can't transform, it is destroyed. While it has 0 hit points in mist form, it can't revert to its vampire form, and it must reach its resting place within 2 hours or be destroyed. Once in its resting place, it reverts to its vampire form. It is then paralyzed until it regains at least 1 hit point. After spending 1 hour in its resting place with 0 hit points, it regains 1 hit point.`,attack_bonus:0},{name:"Regeneration",desc:"The vampire regains 20 hit points at the start of its turn if it has at least 1 hit point and isn't in sunlight or running water. If the vampire takes radiant damage or damage from holy water, this trait doesn't function at the start of the vampire's next turn.",attack_bonus:0},{name:"Spider Climb",desc:"The vampire can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0},{name:"Vampire Weaknesses",desc:`The vampire has the following flaws: Forbiddance. The vampire can't enter a residence without an invitation from one of the occupants. Harmed by Running Water. The vampire takes 20 acid damage if it ends its turn in running water. Stake to the Heart. If a piercing weapon made of wood is driven into the vampire's heart while the vampire is incapacitated in its resting place, the vampire is paralyzed until the stake is removed. Sunlight Hypersensitivity. The vampire takes 20 radiant damage when it starts its turn in sunlight. While in sunlight, it has disadvantage on attack rolls and ability checks.`,attack_bonus:0}],actions:[{name:"Multiattack (Vampire Form Only)",desc:"The vampire makes two attacks, only one of which can be a bite attack.",attack_bonus:0},{name:"Unarmed Strike (Vampire Form Only)",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one creature. Hit: 8 (1d8 + 4) bludgeoning damage. Instead of dealing damage, the vampire can grapple the target (escape DC 18).",attack_bonus:9,damage_dice:"1d8",damage_bonus:4},{name:"Bite (Bat or Vampire Form Only)",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one willing creature, or a creature that is grappled by the vampire, incapacitated, or restrained. Hit: 7 (1d6 + 4) piercing damage plus 10 (3d6) necrotic damage. The target's hit point maximum is reduced by an amount equal to the necrotic damage taken, and the vampire regains hit points equal to that amount. The reduction lasts until the target finishes a long rest. The target dies if this effect reduces its hit point maximum to 0. A humanoid slain in this way and then buried in the ground rises the following night as a vampire spawn under the vampire's control.",attack_bonus:9,damage_dice:"1d6 + 3d6",damage_bonus:4},{name:"Charm",desc:`The vampire targets one humanoid it can see within 30 ft. of it. If the target can see the vampire, the target must succeed on a DC 17 Wisdom saving throw against this magic or be charmed by the vampire. The charmed target regards the vampire as a trusted friend to be heeded and protected. Although the target isn't under the vampire's control, it takes the vampire's requests or actions in the most favorable way it can, and it is a willing target for the vampire's bit attack. Each time the vampire or the vampire's companions do anything harmful to the target, it can repeat the saving throw, ending the effect on itself on a success. Otherwise, the effect lasts 24 hours or until the vampire is destroyed, is on a different plane of existence than the target, or takes a bonus action to end the effect.`,attack_bonus:0},{name:"Children of the Night (1/Day)",desc:"The vampire magically calls 2d4 swarms of bats or rats, provided that the sun isn't up. While outdoors, the vampire can call 3d6 wolves instead. The called creatures arrive in 1d4 rounds, acting as allies of the vampire and obeying its spoken commands. The beasts remain for 1 hour, until the vampire dies, or until the vampire dismisses them as a bonus action.",attack_bonus:0}],legendary_actions:[{name:"Move",desc:"The vampire moves up to its speed without provoking opportunity attacks.",attack_bonus:0},{name:"Unarmed Strike",desc:"The vampire makes one unarmed strike.",attack_bonus:0},{name:"Bite (Costs 2 Actions)",desc:"The vampire makes one bite attack.",attack_bonus:0}]},{name:"Vampire Spawn",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"neutral evil",ac:15,hp:82,hit_dice:"11d8 + 32",speed:"30 ft.",stats:[16,16,16,11,10,12],saves:[{dexterity:6},{wisdom:3}],skillsaves:[{perception:3},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"necrotic; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 13",languages:"the languages it knew in life",cr:"5",bestiary:!0,traits:[{name:"Regeneration",desc:"The vampire regains 10 hit points at the start of its turn if it has at least 1 hit point and isn't in sunlight or running water. If the vampire takes radiant damage or damage from holy water, this trait doesn't function at the start of the vampire's next turn.",attack_bonus:0},{name:"Spider Climb",desc:"The vampire can climb difficult surfaces, including upside down on ceilings, without needing to make an ability check.",attack_bonus:0},{name:"Vampire Weaknesses",desc:`The vampire has the following flaws: Forbiddance. The vampire can't enter a residence without an invitation from one of the occupants. Harmed by Running Water. The vampire takes 20 acid damage when it ends its turn in running water. Stake to the Heart. The vampire is destroyed if a piercing weapon made of wood is driven into its heart while it is incapacitated in its resting place. Sunlight Hypersensitivity. The vampire takes 20 radiant damage when it starts its turn in sunlight. While in sunlight, it has disadvantage on attack rolls and ability checks.`,attack_bonus:0}],actions:[{name:"Multiattack",desc:"The vampire makes two attacks, only one of which can be a bite attack.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one willing creature, or a creature that is grappled by the vampire, incapacitated, or restrained. Hit: 6 (1d6 + 3) piercing damage plus 7 (2d6) necrotic damage. The target's hit point maximum is reduced by an amount equal to the necrotic damage taken, and the vampire regains hit points equal to that amount. The reduction lasts until the target finishes a long rest. The target dies if this effect reduces its hit point maximum to 0.",attack_bonus:61},{name:"Claws",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one creature. Hit: 8 (2d4 + 3) slashing damage. Instead of dealing damage, the vampire can grapple the target (escape DC 13).",attack_bonus:6,damage_dice:"2d4",damage_bonus:3}]},{name:"Veteran",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"any race",alignment:"any alignment",ac:17,hp:58,hit_dice:"9d8 + 17",speed:"30 ft.",stats:[16,13,14,10,11,10],skillsaves:[{athletics:5},{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 12",languages:"any one language (usually Common)",cr:"3",bestiary:!0,actions:[{name:"Multiattack",desc:"The veteran makes two longsword attacks. If it has a shortsword drawn, it can also make a shortsword attack.",attack_bonus:0},{name:"Longsword",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) slashing damage, or 8 (1d10 + 3) slashing damage if used with two hands.",attack_bonus:5,damage_dice:"1d8",damage_bonus:3},{name:"Shortsword",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) piercing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Heavy Crossbow",desc:"Ranged Weapon Attack: +3 to hit, range 100/400 ft., one target. Hit: 6 (1d10 + 1) piercing damage.",attack_bonus:3,damage_dice:"1d10",damage_bonus:1}]},{name:"Violet Fungus",source:"5e SRD",size:"Medium",type:"plant",subtype:"",alignment:"unaligned",ac:5,hp:18,hit_dice:"4d8",speed:"5 ft.",stats:[3,1,10,1,3,1],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"blinded, deafened, frightened",senses:"blindsight 30 ft. (blind beyond this radius), passive Perception 6",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"False Appearance",desc:"While the violet fungus remains motionless, it is indistinguishable from an ordinary fungus.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The fungus makes 1d4 Rotting Touch attacks.",attack_bonus:0},{name:"Rotting Touch",desc:"Melee Weapon Attack: +2 to hit, reach 10 ft., one creature. Hit: 4 (1d8) necrotic damage.",attack_bonus:2,damage_dice:"1d8"}]},{name:"Vrock",source:"5e SRD",size:"Large",type:"fiend",subtype:"demon",alignment:"chaotic evil",ac:15,hp:104,hit_dice:"11d10 + 43",speed:"40 ft., fly 60 ft.",stats:[17,15,18,8,13,8],saves:[{dexterity:5},{wisdom:4},{charisma:2}],damage_vulnerabilities:"",damage_resistances:"cold, fire, lightning; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"poisoned",senses:"darkvision 120 ft., passive Perception 11",languages:"Abyssal, telepathy 120 ft.",cr:"6",bestiary:!0,traits:[{name:"Magic Resistance",desc:"The vrock has advantage on saving throws against spells and other magical effects.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The vrock makes two attacks: one with its beak and one with its talons.",attack_bonus:0},{name:"Beak",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) piercing damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:3},{name:"Talons",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 14 (2d10 + 3) slashing damage.",attack_bonus:6,damage_dice:"2d10",damage_bonus:3},{name:"Spores (Recharge 6)",desc:"A 15-foot-radius cloud of toxic spores extends out from the vrock. The spores spread around corners. Each creature in that area must succeed on a DC 14 Constitution saving throw or become poisoned. While poisoned in this way, a target takes 5 (1d10) poison damage at the start of each of its turns. A target can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. Emptying a vial of holy water on the target also ends the effect on it.",attack_bonus:0},{name:"Stunning Screech (1/Day)",desc:"The vrock emits a horrific screech. Each creature within 20 feet of it that can hear it and that isn't a demon must succeed on a DC 14 Constitution saving throw or be stunned until the end of the vrock's next turn .",attack_bonus:0},{name:"Variant: Summon Demon (1/Day)",desc:`The demon chooses what to summon and attempts a magical summoning. A vrock has a 30 percent chance of summoning 2d4 dretches or one vrock. A summoned demon appears in an unoccupied space within 60 feet of its summoner, acts as an ally of its summoner, and can't summon other demons. It remains for 1 minute, until it or its summoner dies, or until its summoner dismisses it as an action.`,attack_bonus:0}]},{name:"Vulture",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:10,hp:5,hit_dice:"1d8",speed:"10 ft., fly 50 ft.",stats:[7,10,13,2,12,4],skillsaves:[{perception:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"0",bestiary:!0,traits:[{name:"Keen Sight and Smell",desc:"The vulture has advantage on Wisdom (Perception) checks that rely on sight or smell.",attack_bonus:0},{name:"Pack Tactics",desc:"The vulture has advantage on an attack roll against a creature if at least one of the vulture's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Beak",desc:"Melee Weapon Attack: +2 to hit, reach 5 ft., one target. Hit: 2 (1d4) piercing damage.",attack_bonus:2,damage_dice:"1d4"}]},{name:"Warhorse",source:"5e SRD",size:"Large",type:"beast",subtype:"",alignment:"unaligned",ac:11,hp:19,hit_dice:"3d10 + 2",speed:"60 ft.",stats:[18,12,13,2,12,7],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 11",languages:"",cr:"1/2",bestiary:!0,traits:[{name:"Trampling Charge",desc:"If the horse moves at least 20 ft. straight toward a creature and then hits it with a hooves attack on the same turn, that target must succeed on a DC 14 Strength saving throw or be knocked prone. If the target is prone, the horse can make another attack with its hooves against it as a bonus action.",attack_bonus:0}],actions:[{name:"Hooves",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4}]},{name:"Warhorse Skeleton",source:"5e SRD",size:"Large",type:"undead",subtype:"",alignment:"lawful evil",ac:13,hp:22,hit_dice:"3d10 + 5",speed:"60 ft.",stats:[18,12,15,2,8,5],damage_vulnerabilities:"bludgeoning",damage_resistances:"",damage_immunities:"poison",condition_immunities:"exhaustion, poisoned",senses:"darkvision 60 ft., passive Perception 9",languages:"",cr:"1/2",bestiary:!0,actions:[{name:"Hooves",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) bludgeoning damage.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4}]},{name:"Water Elemental",source:"5e SRD",size:"Large",type:"elemental",subtype:"",alignment:"neutral",ac:14,hp:114,hit_dice:"12d10 + 48",speed:"30 ft., swim 90 ft.",stats:[18,14,18,5,10,8],damage_vulnerabilities:"",damage_resistances:"acid; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"poison",condition_immunities:"exhaustion, grappled, paralyzed, petrified, poisoned, prone, restrained, unconscious",senses:"darkvision 60 ft., passive Perception 10",languages:"Aquan",cr:"5",bestiary:!0,traits:[{name:"Water Form",desc:"The elemental can enter a hostile creature's space and stop there. It can move through a space as narrow as 1 inch wide without squeezing.",attack_bonus:0},{name:"Freeze",desc:"If the elemental takes cold damage, it partially freezes; its speed is reduced by 20 ft. until the end of its next turn.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The elemental makes two slam attacks.",attack_bonus:0},{name:"Slam",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) bludgeoning damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:4},{name:"Whelm (Recharge 4-6)",desc:`Each creature in the elemental's space must make a DC 15 Strength saving throw. On a failure, a target takes 13 (2d8 + 4) bludgeoning damage. If it is Large or smaller, it is also grappled (escape DC 14). Until this grapple ends, the target is restrained and unable to breathe unless it can breathe water. If the saving throw is successful, the target is pushed out of the elemental's space. The elemental can grapple one Large creature or up to two Medium or smaller creatures at one time. At the start of each of the elemental's turns, each target grappled by it takes 13 (2d8 + 4) bludgeoning damage. A creature within 5 feet of the elemental can pull a creature or object out of it by taking an action to make a DC 14 Strength and succeeding.`,attack_bonus:0}]},{name:"Weasel",source:"5e SRD",size:"Tiny",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:1,hit_dice:"1d4 + -2",speed:"30 ft.",stats:[3,16,8,2,12,3],skillsaves:[{perception:3},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"0",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The weasel has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one creature. Hit: 1 piercing damage.",attack_bonus:5,damage_bonus:1}]},{name:"Werebear",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"human",alignment:"neutral good",ac:10,hp:135,hit_dice:"18d8 + 54",speed:"30 ft. (40 ft., climb 30 ft. in bear or hybrid form)",stats:[19,10,17,11,12,12],skillsaves:[{perception:7}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"bludgeoning, piercing, and slashing damage from nonmagical weapons that aren't silvered",condition_immunities:"",senses:"passive Perception 17",languages:"Common (can't speak in bear form)",cr:"5",bestiary:!0,traits:[{name:"Shapechanger",desc:"The werebear can use its action to polymorph into a Large bear-humanoid hybrid or into a Large bear, or back into its true form, which is humanoid. Its statistics, other than its size and AC, are the same in each form. Any equipment it. is wearing or carrying isn't transformed. It reverts to its true form if it dies.",attack_bonus:0},{name:"Keen Smell",desc:"The werebear has advantage on WisGlom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"In bear form, the werebear makes two claw attacks. In humanoid form, it makes two greataxe attacks. In hybrid form, it can attack like a bear or a humanoid.",attack_bonus:0},{name:"Bite (Bear or Hybrid Form Only)",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 15 (2d10 + 4) piercing damage. If the target is a humanoid, it must succeed on a DC 14 Constitution saving throw or be cursed with were bear lycanthropy.",attack_bonus:7,damage_dice:"2d10",damage_bonus:4},{name:"Claw (Bear or Hybrid Form Only)",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:4},{name:"Greataxe (Humanoid or Hybrid Form Only)",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 10 (1d12 + 4) slashing damage.",attack_bonus:7,damage_dice:"1d12",damage_bonus:4}]},{name:"Wereboar",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"human",alignment:"neutral evil",ac:10,hp:78,hit_dice:"12d8 + 24",speed:"30 ft. (40 ft. in boar form)",stats:[17,10,15,10,11,8],skillsaves:[{perception:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"bludgeoning, piercing, and slashing damage from nonmagical weapons that aren't silvered",condition_immunities:"",senses:"passive Perception 12",languages:"Common (can't speak in boar form)",cr:"4",bestiary:!0,traits:[{name:"Shapechanger",desc:"The wereboar can use its action to polymorph into a boar-humanoid hybrid or into a boar, or back into its true form, which is humanoid. Its statistics, other than its AC, are the same in each form. Any equipment it is wearing or carrying isn't transformed. It reverts to its true form if it dies.",attack_bonus:0},{name:"Charge (Boar or Hybrid Form Only)",desc:"If the wereboar moves at least 15 feet straight toward a target and then hits it with its tusks on the same turn, the target takes an extra 7 (2d6) slashing damage. If the target is a creature, it must succeed on a DC 13 Strength saving throw or be knocked prone.",attack_bonus:0,damage_dice:"2d6"},{name:"Relentless (Recharges after a Short or Long Rest)",desc:"If the wereboar takes 14 damage or less that would reduce it to 0 hit points, it is reduced to 1 hit point instead.",attack_bonus:0}],actions:[{name:"Multiattack (Humanoid or Hybrid Form Only)",desc:"The wereboar makes two attacks, only one of which can be with its tusks.",attack_bonus:0},{name:"Maul (Humanoid or Hybrid Form Only)",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) bludgeoning damage.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3},{name:"Tusks (Boar or Hybrid Form Only)",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) slashing damage. If the target is a humanoid, it must succeed on a DC 12 Constitution saving throw or be cursed with wereboar lycanthropy.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3}]},{name:"Wererat",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"human",alignment:"lawful evil",ac:12,hp:33,hit_dice:"6d8 + 6",speed:"30 ft.",stats:[10,15,12,11,10,8],skillsaves:[{perception:2},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"bludgeoning, piercing, and slashing damage from nonmagical weapons that aren't silvered",condition_immunities:"",senses:"darkvision 60 ft. (rat form only), passive Perception 12",languages:"Common (can't speak in rat form)",cr:"2",bestiary:!0,traits:[{name:"Shapechanger",desc:"The wererat can use its action to polymorph into a rat-humanoid hybrid or into a giant rat, or back into its true form, which is humanoid. Its statistics, other than its size, are the same in each form. Any equipment it is wearing or carrying isn't transformed. It reverts to its true form if it dies.",attack_bonus:0},{name:"Keen Smell",desc:"The wererat has advantage on Wisdom (Perception) checks that rely on smell.",attack_bonus:0}],actions:[{name:"Multiattack (Humanoid or Hybrid Form Only)",desc:"The wererat makes two attacks, only one of which can be a bite.",attack_bonus:0},{name:"Bite (Rat or Hybrid Form Only).",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 4 (1d4 + 2) piercing damage. If the target is a humanoid, it must succeed on a DC 11 Constitution saving throw or be cursed with wererat lycanthropy.",attack_bonus:4,damage_dice:"1d4",damage_bonus:2},{name:"Shortsword (Humanoid or Hybrid Form Only)",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Hand Crossbow (Humanoid or Hybrid Form Only)",desc:"Ranged Weapon Attack: +4 to hit, range 30/120 ft., one target. Hit: 5 (1d6 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d6",damage_bonus:2}]},{name:"Weretiger",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"human",alignment:"neutral",ac:12,hp:120,hit_dice:"16d8 + 48",speed:"30 ft. (40 ft. in tiger form)",stats:[17,15,16,10,13,11],skillsaves:[{perception:5},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"bludgeoning, piercing, and slashing damage from nonmagical weapons that aren't silvered",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 15",languages:"Common (can't speak in tiger form)",cr:"4",bestiary:!0,traits:[{name:"Shapechanger",desc:"The weretiger can use its action to polymorph into a tiger-humanoid hybrid or into a tiger, or back into its true form, which is humanoid. Its statistics, other than its size, are the same in each form. Any equipment it is wearing or carrying isn't transformed. It reverts to its true form if it dies.",attack_bonus:0},{name:"Keen Hearing and Smell",desc:"The weretiger has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0},{name:"Pounce (Tiger or Hybrid Form Only)",desc:"If the weretiger moves at least 15 feet straight toward a creature and then hits it with a claw attack on the same turn, that target must succeed on a DC 14 Strength saving throw or be knocked prone. If the target is prone, the weretiger can make one bite attack against it as a bonus action.",attack_bonus:0}],actions:[{name:"Multiattack (Humanoid or Hybrid Form Only)",desc:"In humanoid form, the weretiger makes two scimitar attacks or two longbow attacks. In hybrid form, it can attack like a humanoid or make two claw attacks.",attack_bonus:0},{name:"Bite (Tiger or Hybrid Form Only)",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 8 (1d10 + 3) piercing damage. If the target is a humanoid, it must succeed on a DC 13 Constitution saving throw or be cursed with weretiger lycanthropy.",attack_bonus:5,damage_dice:"1d10",damage_bonus:3},{name:"Claw (Tiger or Hybrid Form Only)",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 7 (1d8 + 3) slashing damage.",attack_bonus:5,damage_dice:"1d8",damage_bonus:3},{name:"Scimitar (Humanoid or Hybrid Form Only)",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) slashing damage.",attack_bonus:5,damage_dice:"1d6",damage_bonus:3},{name:"Longbow (Humanoid or Hybrid Form Only)",desc:"Ranged Weapon Attack: +4 to hit, range 150/600 ft., one target. Hit: 6 (1d8 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2}]},{name:"Werewolf",source:"5e SRD",size:"Medium",type:"humanoid",subtype:"human",alignment:"chaotic evil",ac:11,hp:58,hit_dice:"9d8 + 17",speed:"30 ft. (40 ft. in wolf form)",stats:[15,13,14,10,11,10],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"bludgeoning, piercing, and slashing damage from nonmagical weapons that aren't silvered",condition_immunities:"",senses:"passive Perception 14",languages:"Common (can't speak in wolf form)",cr:"3",bestiary:!0,traits:[{name:"Shapechanger",desc:"The werewolf can use its action to polymorph into a wolf-humanoid hybrid or into a wolf, or back into its true form, which is humanoid. Its statistics, other than its AC, are the same in each form. Any equipment it is wearing or carrying isn't transformed. It reverts to its true form if it dies.",attack_bonus:0},{name:"Keen Hearing and Smell",desc:"The werewolf has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0}],actions:[{name:"Multiattack (Humanoid or Hybrid Form Only)",desc:"The werewolf makes two attacks: one with its bite and one with its claws or spear.",attack_bonus:0},{name:"Bite (Wolf or Hybrid Form Only)",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 6 (1d8 + 2) piercing damage. If the target is a humanoid, it must succeed on a DC 12 Constitution saving throw or be cursed with werewolf lycanthropy.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2},{name:"Claws (Hybrid Form Only)",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 7 (2d4 + 2) slashing damage.",attack_bonus:4,damage_dice:"2d4",damage_bonus:2},{name:"Spear (Humanoid Form Only)",desc:"Melee or Ranged Weapon Attack: +4 to hit, reach 5 ft. or range 20/60 ft., one creature. Hit: 5 (1d6 + 2) piercing damage, or 6 (1d8 + 2) piercing damage if used with two hands to make a melee attack.",attack_bonus:4,damage_dice:"1d6",damage_bonus:-2}]},{name:"White Dragon Wyrmling",source:"5e SRD",size:"Medium",type:"dragon",subtype:"",alignment:"chaotic evil",ac:16,hp:32,hit_dice:"5d8 + 9",speed:"30 ft., burrow 15 ft., fly 60 ft., swim 30 ft.",stats:[14,10,14,5,10,11],saves:[{dexterity:2},{constitution:4},{wisdom:2},{charisma:2}],skillsaves:[{perception:4},{stealth:2}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"blindsight 10 ft., darkvision 60 ft., passive Perception 14",languages:"Draconic",cr:"2",bestiary:!0,actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (1d10 + 2) piercing damage plus 2 (1d4) cold damage.",attack_bonus:4,damage_dice:"1d10 + 1d4",damage_bonus:2},{name:"Cold Breath (Recharge 5-6)",desc:"The dragon exhales an icy blast of hail in a 15-foot cone. Each creature in that area must make a DC 12 Constitution saving throw, taking 22 (5d8) cold damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"5d8"}]},{name:"Wight",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"neutral evil",ac:14,hp:45,hit_dice:"6d8 + 18",speed:"30 ft.",stats:[15,14,16,10,13,15],skillsaves:[{perception:3},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"necrotic; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 13",languages:"the languages it knew in life",cr:"3",bestiary:!0,traits:[{name:"Sunlight Sensitivity",desc:"While in sunlight, the wight has disadvantage on attack rolls, as well as on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The wight makes two longsword attacks or two longbow attacks. It can use its Life Drain in place of one longsword attack.",attack_bonus:0},{name:"Life Drain",desc:`Melee Weapon Attack: +4 to hit, reach 5 ft., one creature. Hit: 5 (1d6 + 2) necrotic damage. The target must succeed on a DC 13 Constitution saving throw or its hit point maximum is reduced by an amount equal to the damage taken. This reduction lasts until the target finishes a long rest. The target dies if this effect reduces its hit point maximum to 0. A humanoid slain by this attack rises 24 hours later as a zombie under the wight's control, unless the humanoid is restored to life or its body is destroyed. The wight can have no more than twelve zombies under its control at one time.`,attack_bonus:4,damage_dice:"1d6",damage_bonus:2},{name:"Longsword",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 6 (1d8 + 2) slashing damage, or 7 (1d10 + 2) slashing damage if used with two hands.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2},{name:"Longbow",desc:"Ranged Weapon Attack: +4 to hit, range 150/600 ft., one target. Hit: 6 (1d8 + 2) piercing damage.",attack_bonus:4,damage_dice:"1d8",damage_bonus:2}]},{name:"Will-o'-Wisp",source:"5e SRD",size:"Tiny",type:"undead",subtype:"",alignment:"chaotic evil",ac:19,hp:22,hit_dice:"9d4 + -1",speed:"0 ft., fly 50 ft. (hover)",stats:[1,28,10,13,14,11],damage_vulnerabilities:"",damage_resistances:"acid, cold, fire, necrotic, thunder; bludgeoning, piercing, and slashing from nonmagical weapons",damage_immunities:"lightning, poison",condition_immunities:"exhaustion, grappled, paralyzed, poisoned, prone, restrained, unconscious",senses:"darkvision 120 ft., passive Perception 12",languages:"the languages it knew in life",cr:"2",bestiary:!0,traits:[{name:"Consume Life",desc:"As a bonus action, the will-o'-wisp can target one creature it can see within 5 ft. of it that has 0 hit points and is still alive. The target must succeed on a DC 10 Constitution saving throw against this magic or die. If the target dies, the will-o'-wisp regains 10 (3d6) hit points.",attack_bonus:0},{name:"Ephemeral",desc:"The will-o'-wisp can't wear or carry anything.",attack_bonus:0},{name:"Incorporeal Movement",desc:"The will-o'-wisp can move through other creatures and objects as if they were difficult terrain. It takes 5 (1d10) force damage if it ends its turn inside an object.",attack_bonus:0},{name:"Variable Illumination",desc:"The will-o'-wisp sheds bright light in a 5- to 20-foot radius and dim light for an additional number of ft. equal to the chosen radius. The will-o'-wisp can alter the radius as a bonus action.",attack_bonus:0}],actions:[{name:"Shock",desc:"Melee Spell Attack: +4 to hit, reach 5 ft., one creature. Hit: 9 (2d8) lightning damage.",attack_bonus:4,damage_dice:"2d8"},{name:"Invisibility",desc:"The will-o'-wisp and its light magically become invisible until it attacks or uses its Consume Life, or until its concentration ends (as if concentrating on a spell).",attack_bonus:0}]},{name:"Winter Wolf",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"neutral evil",ac:13,hp:75,hit_dice:"10d10 + 20",speed:"50 ft.",stats:[18,13,14,7,12,8],skillsaves:[{perception:5},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"passive Perception 15",languages:"Common, Giant, Winter Wolf",cr:"3",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The wolf has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0},{name:"Pack Tactics",desc:"The wolf has advantage on an attack roll against a creature if at least one of the wolf's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0},{name:"Snow Camouflage",desc:"The wolf has advantage on Dexterity (Stealth) checks made to hide in snowy terrain.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) piercing damage. If the target is a creature, it must succeed on a DC 14 Strength saving throw or be knocked prone.",attack_bonus:6,damage_dice:"2d6",damage_bonus:4},{name:"Cold Breath (Recharge 5-6)",desc:"The wolf exhales a blast of freezing wind in a 15-foot cone. Each creature in that area must make a DC 12 Dexterity saving throw, taking 18 (4d8) cold damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"4d8"}]},{name:"Wolf",source:"5e SRD",size:"Medium",type:"beast",subtype:"",alignment:"unaligned",ac:13,hp:11,hit_dice:"2d8 + 2",speed:"40 ft.",stats:[12,15,12,3,12,6],skillsaves:[{perception:3},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"passive Perception 13",languages:"",cr:"1/4",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The wolf has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0},{name:"Pack Tactics",desc:"The wolf has advantage on an attack roll against a creature if at least one of the wolf's allies is within 5 ft. of the creature and the ally isn't incapacitated.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +4 to hit, reach 5 ft., one target. Hit: 7 (2d4 + 2) piercing damage. If the target is a creature, it must succeed on a DC 11 Strength saving throw or be knocked prone.",attack_bonus:4,damage_dice:"2d4",damage_bonus:2}]},{name:"Worg",source:"5e SRD",size:"Large",type:"monstrosity",subtype:"",alignment:"neutral evil",ac:13,hp:26,hit_dice:"4d10 + 4",speed:"50 ft.",stats:[16,13,13,7,11,8],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"Goblin, Worg",cr:"1/2",bestiary:!0,traits:[{name:"Keen Hearing and Smell",desc:"The worg has advantage on Wisdom (Perception) checks that rely on hearing or smell.",attack_bonus:0}],actions:[{name:"Bite",desc:"Melee Weapon Attack: +5 to hit, reach 5 ft., one target. Hit: 10 (2d6 + 3) piercing damage. If the target is a creature, it must succeed on a DC 13 Strength saving throw or be knocked prone.",attack_bonus:5,damage_dice:"2d6",damage_bonus:3}]},{name:"Wraith",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"neutral evil",ac:13,hp:67,hit_dice:"9d8 + 26",speed:"0 ft., fly 60 ft. (hover)",stats:[6,16,16,12,14,15],damage_vulnerabilities:"",damage_resistances:"acid, cold, fire, lightning, thunder; bludgeoning, piercing, and slashing from nonmagical weapons that aren't silvered",damage_immunities:"necrotic, poison",condition_immunities:"charmed, exhaustion, grappled, paralyzed, petrified, poisoned, prone, restrained",senses:"darkvision 60 ft., passive Perception 12",languages:"the languages it knew in life",cr:"5",bestiary:!0,traits:[{name:"Incorporeal Movement",desc:"The wraith can move through other creatures and objects as if they were difficult terrain. It takes 5 (1d10) force damage if it ends its turn inside an object.",attack_bonus:0},{name:"Sunlight Sensitivity",desc:"While in sunlight, the wraith has disadvantage on attack rolls, as well as on Wisdom (Perception) checks that rely on sight.",attack_bonus:0}],actions:[{name:"Life Drain",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one creature. Hit: 21 (4d8 + 3) necrotic damage. The target must succeed on a DC 14 Constitution saving throw or its hit point maximum is reduced by an amount equal to the damage taken. This reduction lasts until the target finishes a long rest. The target dies if this effect reduces its hit point maximum to 0.",attack_bonus:6,damage_dice:"4d8",damage_bonus:3},{name:"Create Specter",desc:"The wraith targets a humanoid within 10 feet of it that has been dead for no longer than 1 minute and died violently. The target's spirit rises as a specter in the space of its corpse or in the nearest unoccupied space. The specter is under the wraith's control. The wraith can have no more than seven specters under its control at one time.",attack_bonus:0}]},{name:"Wyvern",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"unaligned",ac:13,hp:110,hit_dice:"13d10 + 38",speed:"20 ft., fly 80 ft.",stats:[19,10,16,5,12,6],skillsaves:[{perception:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., passive Perception 14",languages:"",cr:"6",bestiary:!0,actions:[{name:"Multiattack",desc:"The wyvern makes two attacks: one with its bite and one with its stinger. While flying, it can use its claws in place of one other attack.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one creature. Hit: 11 (2d6 + 4) piercing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Claws",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 13 (2d8 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d8",damage_bonus:4},{name:"Stinger",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one creature. Hit: 11 (2d6 + 4) piercing damage. The target must make a DC 15 Constitution saving throw, taking 24 (7d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4}]},{name:"Xorn",source:"5e SRD",size:"Medium",type:"elemental",subtype:"",alignment:"neutral",ac:19,hp:73,hit_dice:"7d8 + 41",speed:"20 ft., burrow 20 ft.",stats:[17,10,22,11,10,11],skillsaves:[{perception:6},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"piercing and slashing from nonmagical weapons that aren't adamantine",damage_immunities:"",condition_immunities:"",senses:"darkvision 60 ft., tremorsense 60 ft., passive Perception 16",languages:"Terran",cr:"5",bestiary:!0,traits:[{name:"Earth Glide",desc:"The xorn can burrow through nonmagical, unworked earth and stone. While doing so, the xorn doesn't disturb the material it moves through.",attack_bonus:0},{name:"Stone Camouflage",desc:"The xorn has advantage on Dexterity (Stealth) checks made to hide in rocky terrain.",attack_bonus:0},{name:"Treasure Sense",desc:"The xorn can pinpoint, by scent, the location of precious metals and stones, such as coins and gems, within 60 ft. of it.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The xorn makes three claw attacks and one bite attack.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 13 (3d6 + 3) piercing damage.",attack_bonus:6,damage_dice:"3d6",damage_bonus:3},{name:"Claw",desc:"Melee Weapon Attack: +6 to hit, reach 5 ft., one target. Hit: 6 (1d6 + 3) slashing damage.",attack_bonus:6,damage_dice:"1d6",damage_bonus:3}]},{name:"Young Black Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"chaotic evil",ac:18,hp:127,hit_dice:"15d10 + 44",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[19,14,17,12,11,15],saves:[{dexterity:5},{constitution:6},{wisdom:3},{charisma:5}],skillsaves:[{perception:6},{stealth:5}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid",condition_immunities:"",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 16",languages:"Common, Draconic",cr:"7",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one target. Hit: 15 (2d10 + 4) piercing damage plus 4 (1d8) acid damage.",attack_bonus:7,damage_dice:"2d10 + 1d8",damage_bonus:4},{name:"Claw",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Acid Breath (Recharge 5-6)",desc:"The dragon exhales acid in a 30-foot line that is 5 feet wide. Each creature in that line must make a DC 14 Dexterity saving throw, taking 49 (11d8) acid damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"11d8"}]},{name:"Young Blue Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"lawful evil",ac:18,hp:152,hit_dice:"16d10 + 64",speed:"40 ft., burrow 40 ft., fly 80 ft.",stats:[21,10,19,14,13,17],saves:[{dexterity:4},{constitution:8},{wisdom:5},{charisma:7}],skillsaves:[{perception:9},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning",condition_immunities:"",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 19",languages:"Common, Draconic",cr:"9",bestiary:!0,actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +9 to hit, reach 10 ft., one target. Hit: 16 (2d10 + 5) piercing damage plus 5 (1d10) lightning damage.",attack_bonus:9,damage_dice:"2d10 + 1d10",damage_bonus:5},{name:"Claw",desc:"Melee Weapon Attack: +9 to hit, reach 5 ft., one target. Hit: 12 (2d6 + 5) slashing damage.",attack_bonus:9,damage_dice:"2d6",damage_bonus:5},{name:"Lightning Breath (Recharge 5-6)",desc:"The dragon exhales lightning in an 60-foot line that is 5 feet wide. Each creature in that line must make a DC 16 Dexterity saving throw, taking 55 (10d10) lightning damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"10d10"}]},{name:"Young Brass Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"chaotic good",ac:17,hp:110,hit_dice:"13d10 + 38",speed:"40 ft., burrow 20 ft., fly 80 ft.",stats:[19,10,17,12,11,15],saves:[{dexterity:3},{constitution:6},{wisdom:3},{charisma:5}],skillsaves:[{perception:6},{persuasion:5},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 16",languages:"Common, Draconic",cr:"6",bestiary:!0,actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one target. Hit: 15 (2d10 + 4) piercing damage.",attack_bonus:7,damage_dice:"2d10",damage_bonus:4},{name:"Claw",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Fire Breath. The dragon exhales fire in a 40-foot line that is 5 feet wide. Each creature in that line must make a DC 14 Dexterity saving throw, taking 42 (12d6) fire damage on a failed save, or half as much damage on a successful one. Sleep Breath. The dragon exhales sleep gas in a 30-foot cone. Each creature in that area must succeed on a DC 14 Constitution saving throw or fall unconscious for 5 minutes. This effect ends for a creature if the creature takes damage or someone uses an action to wake it.`,attack_bonus:0,damage_dice:"12d6"}]},{name:"Young Bronze Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"lawful good",ac:18,hp:142,hit_dice:"15d10 + 59",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[21,10,19,14,13,17],saves:[{dexterity:3},{constitution:7},{wisdom:4},{charisma:6}],skillsaves:[{insight:4},{perception:7},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"lightning",condition_immunities:"",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 17",languages:"Common, Draconic",cr:"8",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +8 to hit, reach 10 ft., one target. Hit: 16 (2d10 + 5) piercing damage.",attack_bonus:8,damage_dice:"2d10",damage_bonus:5},{name:"Claw",desc:"Melee Weapon Attack: +8 to hit, reach 5 ft., one target. Hit: 12 (2d6 + 5) slashing damage.",attack_bonus:8,damage_dice:"2d6",damage_bonus:5},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Lightning Breath. The dragon exhales lightning in a 60-foot line that is 5 feet wide. Each creature in that line must make a DC 15 Dexterity saving throw, taking 55 (10d10) lightning damage on a failed save, or half as much damage on a successful one. Repulsion Breath. The dragon exhales repulsion energy in a 30-foot cone. Each creature in that area must succeed on a DC 15 Strength saving throw. On a failed save, the creature is pushed 40 feet away from the dragon.`,attack_bonus:0,damage_dice:"10d10"}]},{name:"Young Copper Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"chaotic good",ac:17,hp:119,hit_dice:"14d10 + 42",speed:"40 ft., climb 40 ft., fly 80 ft.",stats:[19,12,17,16,13,15],saves:[{dexterity:4},{constitution:6},{wisdom:4},{charisma:5}],skillsaves:[{deception:5},{perception:7},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"acid",condition_immunities:"",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 17",languages:"Common, Draconic",cr:"7",bestiary:!0,actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one target. Hit: 15 (2d10 + 4) piercing damage.",attack_bonus:7,damage_dice:"2d10",damage_bonus:4},{name:"Claw",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Acid Breath. The dragon exhales acid in an 40-foot line that is 5 feet wide. Each creature in that line must make a DC 14 Dexterity saving throw, taking 40 (9d8) acid damage on a failed save, or half as much damage on a successful one. Slowing Breath. The dragon exhales gas in a 30-foot cone. Each creature in that area must succeed on a DC 14 Constitution saving throw. On a failed save, the creature can't use reactions, its speed is halved, and it can't make more than one attack on its turn. In addition, the creature can use either an action or a bonus action on its turn, but not both. These effects last for 1 minute. The creature can repeat the saving throw at the end of each of its turns, ending the effect on itself with a successful save.`,attack_bonus:0,damage_dice:"9d8"}]},{name:"Young Gold Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"lawful good",ac:18,hp:178,hit_dice:"17d10 + 84",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[23,14,21,16,13,20],saves:[{dexterity:6},{constitution:9},{wisdom:5},{charisma:9}],skillsaves:[{insight:5},{perception:9},{persuasion:9},{stealth:6}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 19",languages:"Common, Draconic",cr:"10",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 17 (2d10 + 6) piercing damage.",attack_bonus:10,damage_dice:"2d10",damage_bonus:6},{name:"Claw",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one target. Hit: 13 (2d6 + 6) slashing damage.",attack_bonus:10,damage_dice:"2d6",damage_bonus:6},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Fire Breath. The dragon exhales fire in a 30-foot cone. Each creature in that area must make a DC 17 Dexterity saving throw, taking 55 (10d10) fire damage on a failed save, or half as much damage on a successful one. Weakening Breath. The dragon exhales gas in a 30-foot cone. Each creature in that area must succeed on a DC 17 Strength saving throw or have disadvantage on Strength-based attack rolls, Strength checks, and Strength saving throws for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.`,attack_bonus:0,damage_dice:"10d10"}]},{name:"Young Green Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"lawful evil",ac:18,hp:136,hit_dice:"16d10 + 48",speed:"40 ft., fly 80 ft., swim 40 ft.",stats:[19,12,17,16,13,15],saves:[{dexterity:4},{constitution:6},{wisdom:4},{charisma:5}],skillsaves:[{deception:5},{perception:7},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"poison",condition_immunities:"poisoned",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 17",languages:"Common, Draconic",cr:"8",bestiary:!0,traits:[{name:"Amphibious",desc:"The dragon can breathe air and water.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one target. Hit: 15 (2d10 + 4) piercing damage plus 7 (2d6) poison damage.",attack_bonus:7,damage_dice:"2d10 + 2d6",damage_bonus:4},{name:"Claw",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Poison Breath (Recharge 5-6)",desc:"The dragon exhales poisonous gas in a 30-foot cone. Each creature in that area must make a DC 14 Constitution saving throw, taking 42 (12d6) poison damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"12d6"}]},{name:"Young Red Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"chaotic evil",ac:18,hp:178,hit_dice:"17d10 + 84",speed:"40 ft., climb 40 ft., fly 80 ft.",stats:[23,10,21,14,11,19],saves:[{dexterity:4},{constitution:9},{wisdom:4},{charisma:8}],skillsaves:[{perception:8},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"fire",condition_immunities:"",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 18",languages:"Common, Draconic",cr:"10",bestiary:!0,actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 17 (2d10 + 6) piercing damage plus 3 (1d6) fire damage.",attack_bonus:10,damage_dice:"2d10 + 1d6",damage_bonus:6},{name:"Claw",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one target. Hit: 13 (2d6 + 6) slashing damage.",attack_bonus:10,damage_dice:"2d6",damage_bonus:6},{name:"Fire Breath (Recharge 5-6)",desc:"The dragon exhales fire in a 30-foot cone. Each creature in that area must make a DC 17 Dexterity saving throw, taking 56 (16d6) fire damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"16d6"}]},{name:"Young Silver Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"lawful good",ac:18,hp:168,hit_dice:"16d10 + 80",speed:"40 ft., fly 80 ft.",stats:[23,10,21,14,11,19],saves:[{dexterity:4},{constitution:9},{wisdom:4},{charisma:8}],skillsaves:[{arcana:6},{history:6},{perception:8},{stealth:4}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 18",languages:"Common, Draconic",cr:"9",bestiary:!0,actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +10 to hit, reach 10 ft., one target. Hit: 17 (2d10 + 6) piercing damage.",attack_bonus:10,damage_dice:"2d10",damage_bonus:6},{name:"Claw",desc:"Melee Weapon Attack: +10 to hit, reach 5 ft., one target. Hit: 13 (2d6 + 6) slashing damage.",attack_bonus:10,damage_dice:"2d6",damage_bonus:6},{name:"Breath Weapons (Recharge 5-6)",desc:`The dragon uses one of the following breath weapons. Cold Breath. The dragon exhales an icy blast in a 30-foot cone. Each creature in that area must make a DC 17 Constitution saving throw, taking 54 (12d8) cold damage on a failed save, or half as much damage on a successful one. Paralyzing Breath. The dragon exhales paralyzing gas in a 30-foot cone. Each creature in that area must succeed on a DC 17 Constitution saving throw or be paralyzed for 1 minute. A creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success.`,attack_bonus:0,damage_dice:"12d8"}]},{name:"Young White Dragon",source:"5e SRD",size:"Large",type:"dragon",subtype:"",alignment:"chaotic evil",ac:17,hp:133,hit_dice:"14d10 + 56",speed:"40 ft., burrow 20 ft., fly 80 ft., swim 40 ft.",stats:[18,10,18,6,11,12],saves:[{dexterity:3},{constitution:7},{wisdom:3},{charisma:4}],skillsaves:[{perception:6},{stealth:3}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"cold",condition_immunities:"",senses:"blindsight 30 ft., darkvision 120 ft., passive Perception 16",languages:"Common, Draconic",cr:"6",bestiary:!0,traits:[{name:"Ice Walk",desc:"The dragon can move across and climb icy surfaces without needing to make an ability check. Additionally, difficult terrain composed of ice or snow doesn't cost it extra moment.",attack_bonus:0}],actions:[{name:"Multiattack",desc:"The dragon makes three attacks: one with its bite and two with its claws.",attack_bonus:0},{name:"Bite",desc:"Melee Weapon Attack: +7 to hit, reach 10 ft., one target. Hit: 15 (2d10 + 4) piercing damage plus 4 (1d8) cold damage.",attack_bonus:7,damage_dice:"2d10 + 1d8",damage_bonus:4},{name:"Claw",desc:"Melee Weapon Attack: +7 to hit, reach 5 ft., one target. Hit: 11 (2d6 + 4) slashing damage.",attack_bonus:7,damage_dice:"2d6",damage_bonus:4},{name:"Cold Breath (Recharge 5-6)",desc:"The dragon exhales an icy blast in a 30-foot cone. Each creature in that area must make a DC 15 Constitution saving throw, taking 45 (10d8) cold damage on a failed save, or half as much damage on a successful one.",attack_bonus:0,damage_dice:"10d8"}]},{name:"Zombie",source:"5e SRD",size:"Medium",type:"undead",subtype:"",alignment:"neutral evil",ac:8,hp:22,hit_dice:"3d8 + 8",speed:"20 ft.",stats:[13,6,16,3,6,5],saves:[{wisdom:0}],damage_vulnerabilities:"",damage_resistances:"",damage_immunities:"",condition_immunities:"poisoned",senses:"darkvision 60 ft., passive Perception 8",languages:"understands all languages it spoke in life but can't speak",cr:"1/4",bestiary:!0,traits:[{name:"Undead Fortitude",desc:"If damage reduces the zombie to 0 hit points, it must make a Constitution saving throw with a DC of 5+the damage taken, unless the damage is radiant or from a critical hit. On a success, the zombie drops to 1 hit point instead.",attack_bonus:0}],actions:[{name:"Slam",desc:"Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) bludgeoning damage.",attack_bonus:3,damage_dice:"1d6",damage_bonus:1}]}],ia=new Map(Kp.map(n=>[n.name,n]));var Ne,Wt,On,aa,un,Qn,sa,$e,Xn,tt,oo,lo,Ti,ro=class{constructor(){Le(this,$e);Le(this,Ne,new Map);Le(this,Wt,new Map);Le(this,On,new Map);Le(this,aa,!1);Le(this,un,new Map);Le(this,Qn,new Map);Le(this,sa,new Map);Le(this,tt)}getSortedBy(e){return Q(this,sa).get(e)??[]}onSortedBy(e,t){let i=Q(this,tt).on(`fantasy-statblocks:bestiary:sorted:${e}`,a=>t(a));return()=>{Q(this,tt).offref(i)}}registerSorter(e,t){Q(this,Qn).has(e)||Q(this,Qn).set(e,t),Oe(this,$e,Xn).call(this,e)}getIndices(){return Q(this,un)}getIndex(e){return Q(this,un).get(e)??new Map}registerIndex(e){Q(this,un).has(e)||Q(this,un).set(e,new Map)}onIndexUpdated(e,t){if(!Q(this,un).has(e))return()=>{};let i=Q(this,tt).on(`fantasy-statblocks:bestiary:indexed:${e}`,()=>t());return()=>{Q(this,tt).offref(i)}}initialize(e){this.registerIndex("source"),this.registerSorter("name",(t,i)=>t.name.localeCompare(i.name)),nn(this,tt,e.app.workspace),kn.initialize(e).load(),e.addCommand({id:"parse-frontmatter",name:"Parse Frontmatter for Creatures",callback:()=>{kn.start(!0)}}),e.register(()=>kn.unload()),e.registerEvent(e.app.workspace.on("fantasy-statblocks:srd-change",t=>{this.enableSRD=t,t?nn(this,Ne,new Map([...ia,...Q(this,Ne)])):nn(this,Ne,new Map([...Q(this,Wt),...Q(this,On)]))})),this.enableSRD=!e.settings.disableSRD,this.enableSRD&&nn(this,Ne,new Map(ia));for(let[,t]of e.settings.monsters)this.addLocalCreature(t)}hasLocal(e){return Q(this,Wt).has(e)}getLocal(e){return Q(this,Wt).get(e)}isLocal(e){return Q(this,Wt).has(e)&&Q(this,Ne).get(e)===Q(this,Wt).get(e)}addLocalCreature(e){e.name&&(Q(this,Wt).set(e.name,e),Q(this,Ne).set(e.name,e),Oe(this,$e,oo).call(this,e),Oe(this,$e,Ti).call(this),Oe(this,$e,Xn).call(this))}removeLocalCreature(e){Q(this,Ne).has(e)&&Q(this,Ne).get(e)===Q(this,Wt).get(e)&&Q(this,Ne).delete(e),Oe(this,$e,lo).call(this,Q(this,Wt).get(e)),Q(this,Wt).delete(e),Q(this,On).has(e)?Q(this,Ne).set(e,Q(this,On).get(e)):this.enableSRD&&ia.has(e)&&Q(this,Ne).set(e,ia.get(e)),Oe(this,$e,Ti).call(this),Oe(this,$e,Xn).call(this)}addEphemeralCreature(e){e.name&&(Q(this,On).set(e.name,e),Q(this,Ne).set(e.name,e),Q(this,tt).trigger("fantasy-statblocks:bestiary:creature-added",e),Oe(this,$e,oo).call(this,e),Oe(this,$e,Xn).call(this),Oe(this,$e,Ti).call(this))}removeEphemeralCreature(e){Oe(this,$e,lo).call(this,Q(this,Ne).get(e)),Q(this,Ne).delete(e),Q(this,On).delete(e),Oe(this,$e,Ti).call(this),Oe(this,$e,Xn).call(this)}removeCreatures(...e){for(let t of e)this.isLocal(t)?this.removeLocalCreature(t):this.removeEphemeralCreature(t)}isResolved(){return Q(this,aa)}setResolved(e){nn(this,aa,e),e&&(Q(this,tt).trigger("fantasy-statblocks:bestiary:resolved"),Oe(this,$e,Ti).call(this),Oe(this,$e,Xn).call(this))}onResolved(e){let t;return this.isResolved()?e():t=Q(this,tt).on("fantasy-statblocks:bestiary:resolved",()=>e()),()=>{t&&Q(this,tt).offref(t)}}onUpdated(e){let t;return this.isResolved()?e():t=Q(this,tt).on("fantasy-statblocks:bestiary:updated",()=>e()),()=>{t&&Q(this,tt).offref(t)}}size(){return Q(this,Ne).size}getBestiary(){return Q(this,Ne)}getBestiaryCreatures(){return Array.from(Q(this,Ne).values())}getBestiaryNames(){return Array.from(Q(this,Ne).keys()).sort()}hasCreature(e){return Q(this,Ne).has(e)}getExtensions(e,t){let i=[Ze(e)];if(!("extends"in e)||!(Array.isArray(e.extends)||typeof e.extends=="string"))return i;if(e.extends&&e.extends.length)for(let a of[e.extends].flat()){if(t.has(a)){console.info("Circular extend dependency detected in "+[...t]);continue}t.add(e.name);let s=Q(this,Ne).get(a);s&&i.push(...this.getExtensions(s,t))}return i}getExtensionNames(e,t){let i=[e.name];if(!("extends"in e)||!(Array.isArray(e.extends)||typeof e.extends=="string"))return i;if(e.extends&&e.extends.length)for(let a of[e.extends].flat()){if(t.has(a)){console.info("Circular extend dependency detected in "+[...t]);continue}t.add(e.name);let s=Q(this,Ne).get(a);s&&i.push(...this.getExtensionNames(s,t))}return i}async getCreatureFromBestiary(e){return new Promise(t=>{this.onResolved(()=>{this.hasCreature(e)||t(null);let i=Q(this,Ne).get(e);t(Object.assign({},...this.getExtensions(i,new Set(i.name)),i))})})}getCreatureFromBestiarySync(e){if(!this.isResolved())throw new Error("The bestiary is not fully resolved.");if(!this.hasCreature(e))return null;let t=Q(this,Ne).get(e);return Object.assign({},...this.getExtensions(t,new Set(t.name)),t)}get(e){return Q(this,Ne).get(e)}};Ne=new WeakMap,Wt=new WeakMap,On=new WeakMap,aa=new WeakMap,un=new WeakMap,Qn=new WeakMap,sa=new WeakMap,$e=new WeakSet,Xn=function(...e){this.isResolved()&&setTimeout(()=>{for(let t of e&&e.length?e:[...Q(this,Qn).keys()])Q(this,sa).set(t,this.getBestiaryCreatures().sort((i,a)=>Q(this,Qn).get(t)(i,a))),Q(this,tt).trigger(`fantasy-statblocks:bestiary:sorted:${t}`,this.getSortedBy(t))},0)},tt=new WeakMap,oo=function(e){setTimeout(()=>{for(let[t,i]of Q(this,un))if(t in e){let a=[];if(Array.isArray(e[t]))for(let s of e[t])a.push(be(s));else a.push(be(e[t]));for(let s of a)i.has(s)?i.get(s).add(e.name):i.set(s,new Set([e.name]));Q(this,tt).trigger(`fantasy-statblocks:bestiary:indexed:${t}`)}},0)},lo=function(e){setTimeout(()=>{for(let[t,i]of Q(this,un))if(t in e){let a=be(e[t]);i.has(a)&&i.get(a).delete(e.name),Q(this,tt).trigger(`fantasy-statblocks:bestiary:indexed:${t}`)}},0)},Ti=function(){this.isResolved()&&Q(this,tt).trigger("fantasy-statblocks:bestiary:updated")};var ve=new ro;var $t=class extends Ou.MarkdownRenderChild{constructor(t,i=!0){super(t.container);this.rendererParameters=t;this.icons=i;this.loaded=!1;this.container=t.container,this.plugin=t.plugin,this.context=t.context??"",this.setCreature(t),this.setLayout(),this.init()}setLayout(){this.layout=this.rendererParameters.layout??this.plugin.manager.getAllLayouts().find(t=>t.name==(this.params.layout??this.monster.layout)||t.name==(this.params.statblock??this.monster.statblock))??this.plugin.manager.getDefaultLayout()}get canSave(){return"name"in this.params}async build(){let t=Object.assign({},this.monster??{},this.params??{});if(Object.values(t).length||(t=Object.assign({},t,{note:this.context})),t.note){let a=Array.isArray(t.note)?t.note.flat(1/0).pop():t.note,s=await this.plugin.app.metadataCache.getFirstLinkpathDest(`${a}`,this.context??"");if(s&&s instanceof St.TFile){let r=(0,St.getFrontMatterInfo)(await this.plugin.app.vault.cachedRead(s));r.exists&&Object.assign(t,Ze((0,St.parseYaml)(ut.transformYamlSource(r.frontmatter))??{}),this.params)}}"image"in t&&Array.isArray(t.image)&&(t.image=t.image.flat(2).join(""));let i=ve.getExtensions(t,new Set);for(let a of i.reverse())t=Object.assign(t,a);t=Object.assign(t,this.monster??{},this.params??{});for(let a of this.unwrapBlocks(this.layout.blocks))if("properties"in a){for(let s of a.properties)if(!(!(s in t)&&!(`${s}+`in t)&&!(`${s}-`in t)))switch(a.type){case"traits":{let r=new Map,o=[];for(let l of[...i]){for(let c of co(`${s}-`,l))r.delete(c.name);for(let c of co(s,l))r.set(c.name,c);for(let c of co(`${s}+`,l))o.push(c)}Object.assign(t,{[s]:[...r.values(),...o]});break}case"saves":{let r=t[s]??[];s in t&&!Array.isArray(t[s])&&typeof t[s]=="object"&&(r=Object.entries(t[s]??{}).map(([l,c])=>({[l]:c}))),Object.assign(t,{[s]:r});let o=[];`${s}+`in t&&!Array.isArray(t[`${s}+`])&&typeof t[`${s}+`]=="object"&&(o=Object.entries(t[s]??{}).map(([l,c])=>({[l]:c}))),o.length&&Object.assign(t,{[s]:wr(t[s],o)});break}default:if(`${s}+`in t&&s in t){let r=wr(t[s],t[`${s}+`]);r&&Object.assign(t,{[s]:r})}}}return t=this.transformLinks(t),"image"in t&&Array.isArray(t.image)&&(t.image=t.image.flat(2).join("")),t}unwrapBlocks(t){let i=[];for(let a of t)switch(a.type){case"group":case"inline":case"collapse":{i.push(...this.unwrapBlocks(a.nested));break}case"layout":case"ifelse":case"javascript":continue;default:i.push(a);break}return i}setCreature(t){"params"in t?(this.params=t.params,this.monster=Object.assign({},ve.get(this.params.monster)??ve.get(this.params.creature))):(this.params={},this.monster=t.monster)}async init(){this.containerEl.empty(),this.monster=await this.build(),this.$ui=new Iu({target:this.containerEl,props:{context:this.context,monster:this.monster,statblock:this.layout.blocks,layout:this.layout,plugin:this.plugin,renderer:this,canSave:this.canSave,icons:this.icons??!0}}),this.$ui.$on("save",async()=>{ve.hasCreature(this.monster.name)&&!await ho(this.plugin.app,"This will overwrite an existing monster in settings. Are you sure?")||this.plugin.saveMonster({...Ze(this.monster),source:this.monster.source??"Homebrew",layout:this.layout.name})}),this.$ui.$on("export",()=>{this.plugin.exportAsPng(this.monster.name,this.containerEl.firstElementChild)});let t=ve.getExtensionNames(this.monster,new Set);this.plugin.registerEvent(this.plugin.app.workspace.on("fantasy-statblocks:bestiary:creature-added",async i=>{t.includes(i.name)&&(this.monster=Ze(i),this.monster=await this.build(),this.$ui.$set({monster:this.monster}))}))}transformLinks(t){return(0,St.parseYaml)(ut.transformYamlSource((0,St.stringifyYaml)(t).replace(/\\#/g,"#")))}};async function ho(n,e,t={cta:"Yes",secondary:"No"}){return new Promise((i,a)=>{let s=new uo(n,e,t);s.onClose=()=>{i(s.confirmed)},s.open()})}var uo=class extends St.Modal{constructor(t,i,a){super(t);this.text=i;this.buttons=a;this.confirmed=!1}async display(){new Promise(t=>{this.contentEl.empty(),this.contentEl.addClass("confirm-modal"),this.contentEl.createEl("p",{text:this.text});let i=this.contentEl.createDiv("fantasy-calendar-confirm-buttons");new St.ButtonComponent(i).setButtonText(this.buttons.cta).setCta().onClick(()=>{this.confirmed=!0,this.close()}),new St.ButtonComponent(i).setButtonText(this.buttons.secondary).onClick(()=>{this.close()})})}onOpen(){this.display()}};function co(n,e){let t=[];if(n in e&&Array.isArray(e[n]))for(let i of e[n])!Array.isArray(i)&&typeof i=="object"&&"name"in i&&t.push(i),Array.isArray(i)&&i.length>=1&&t.push({name:i[0],desc:i.slice(1).join("")});return t}var ke=require("obsidian");var tn=require("obsidian");var ra=[["group","Group"],["inline","Inline Group"],["ifelse","If/Else"],["collapse","Collapsible"],["javascript","JavaScript"],["layout","Layout"],["action","Action"],[null,"separator"],["heading","Heading"],["image","Image"],["property","Property Line"],["saves","Saves"],["spells","Spells"],["subheading","Subheading"],["table","Table"],["text","Text"],["traits","Traits"]];function os(n){let e=n-1;return e*e*e+1}function Pn(n,{from:e,to:t},i={}){let a=getComputedStyle(n),s=a.transform==="none"?"":a.transform,[r,o]=a.transformOrigin.split(" ").map(parseFloat),l=e.left+e.width*r/t.width-(t.left+r),c=e.top+e.height*o/t.height-(t.top+o),{delay:d=0,duration:u=m=>Math.sqrt(m)*120,easing:h=os}=i;return{delay:d,duration:Pe(u)?u(Math.sqrt(l*l+c*c)):u,easing:h,css:(m,f)=>{let p=f*l,b=f*c,_=m+f*e.width/t.width,S=m+f*e.height/t.height;return`transform: ${s} translate(${p}px, ${b}px) scale(${_}, ${S});`}}}function Pu(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,i)}return t}function us(n){for(var e=1;e=0)&&(t[a]=n[a]);return t}function Yp(n,e){if(n==null)return{};var t=$p(n,e),i,a;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(n,i)&&(t[i]=n[i])}return t}function Jp(n,e){return Qp(n)||e1(n,e)||_o(n,e)||n1()}function zt(n){return Xp(n)||Zp(n)||_o(n)||t1()}function Xp(n){if(Array.isArray(n))return mo(n)}function Qp(n){if(Array.isArray(n))return n}function Zp(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function e1(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var i=[],a=!0,s=!1,r,o;try{for(t=t.call(n);!(a=(r=t.next()).done)&&(i.push(r.value),!(e&&i.length===e));a=!0);}catch(l){s=!0,o=l}finally{try{!a&&t.return!=null&&t.return()}finally{if(s)throw o}}return i}}function _o(n,e){if(n){if(typeof n=="string")return mo(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return mo(n,e)}}function mo(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=new Array(e);t=n.length?{done:!0}:{done:!1,value:n[i++]}},e:function(l){throw l},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,r=!1,o;return{s:function(){t=t.call(n)},n:function(){var l=t.next();return s=l.done,l},e:function(l){r=!0,o=l},f:function(){try{!s&&t.return!=null&&t.return()}finally{if(r)throw o}}}}var i1="finalize",a1="consider";function Ii(n,e,t){n.dispatchEvent(new CustomEvent(i1,{detail:{items:e,info:t}}))}function Fn(n,e,t){n.dispatchEvent(new CustomEvent(a1,{detail:{items:e,info:t}}))}var ys="draggedEntered",ma="draggedLeft",vs="draggedOverIndex",So="draggedLeftDocument",ds={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function s1(n,e,t){n.dispatchEvent(new CustomEvent(ys,{detail:{indexObj:e,draggedEl:t}}))}function r1(n,e,t){n.dispatchEvent(new CustomEvent(ma,{detail:{draggedEl:e,type:ds.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function o1(n,e){n.dispatchEvent(new CustomEvent(ma,{detail:{draggedEl:e,type:ds.OUTSIDE_OF_ANY}}))}function l1(n,e,t){n.dispatchEvent(new CustomEvent(vs,{detail:{indexObj:e,draggedEl:t}}))}function c1(n){window.dispatchEvent(new CustomEvent(So,{detail:{draggedEl:n}}))}var Ye={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:ys,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:vs,DRAGGED_LEFT:ma,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},qe={POINTER:"pointer",KEYBOARD:"keyboard"},ks="isDndShadowItem",Co="data-is-dnd-shadow-item-internal",u1="data-is-dnd-shadow-item-hint",ni="id:dnd-shadow-placeholder-0000",d1="dnd-action-dragged-el",nt="id",go=0;function Gu(){go++}function Ku(){if(go===0)throw new Error("Bug! trying to decrement when there are no dropzones");go--}var xo=typeof window>"u",xe=function(){};function po(n){var e,t=n.getBoundingClientRect(),i=getComputedStyle(n),a=i.transform;if(a){var s,r,o,l;if(a.startsWith("matrix3d("))e=a.slice(9,-1).split(/, /),s=+e[0],r=+e[5],o=+e[12],l=+e[13];else if(a.startsWith("matrix("))e=a.slice(7,-1).split(/, /),s=+e[0],r=+e[3],o=+e[4],l=+e[5];else return t;var c=i.transformOrigin,d=t.x-o-(1-s)*parseFloat(c),u=t.y-l-(1-r)*parseFloat(c.slice(c.indexOf(" ")+1)),h=s?t.width/s:n.offsetWidth,m=r?t.height/r:n.offsetHeight;return{x:d,y:u,width:h,height:m,top:u,right:d+h,bottom:u+m,left:d}}else return t}function $u(n){var e=po(n);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function Yu(n){var e=n.getBoundingClientRect();return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function Ju(n){return{x:(n.left+n.right)/2,y:(n.top+n.bottom)/2}}function h1(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function ws(n,e){return n.y<=e.bottom&&n.y>=e.top&&n.x>=e.left&&n.x<=e.right}function ua(n){return Ju(Yu(n))}function Ru(n,e){var t=ua(n),i=$u(e);return ws(t,i)}function f1(n,e){var t=ua(n),i=ua(e);return h1(t,i)}function m1(n){var e=Yu(n);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}var Di;function Ao(){xe(function(){return"resetting indexes cache"}),Di=new Map}Ao();function g1(n){var e=Array.from(n.children).findIndex(function(t){return t.getAttribute(Co)});if(e>=0)return Di.has(n)||Di.set(n,new Map),Di.get(n).set(e,$u(n.children[e])),e}function p1(n,e){if(!Ru(n,e))return null;var t=e.children;if(t.length===0)return{index:0,isProximityBased:!0};for(var i=g1(e),a=0;a1&&arguments[1]!==void 0?arguments[1]:0;return n.parentElement?Xu(n.parentElement,e+1):e-1}function b1(n,e){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(!{}.hasOwnProperty.call(e,t)||e[t]!==n[t])return!1;return!0}function y1(n,e){if(n.length!==e.length)return!1;for(var t=0;t2&&arguments[2]!==void 0?arguments[2]:v1,i=arguments.length>3?arguments[3]:void 0,a,s,r=!1,o,l=Array.from(e).sort(function(d,u){return hs(u)-hs(d)});function c(){var d=ua(n),u=i.multiScrollIfNeeded();if(!u&&o&&Math.abs(o.x-d.x)r.clientHeight&&(o.bottomr.clientWidth&&(o.right0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0;xe(function(){return"creating multi-scroller"});var t=A1(n),i=Array.from(t).sort(function(l,c){return hs(c)-hs(l)}),a=_1(),s=a.scrollIfNeeded,r=a.resetScrolling;function o(){var l=e();if(!l||!i)return!1;for(var c=i.filter(function(h){return ws(l,h.getBoundingClientRect())||h===document.scrollingElement}),d=0;d0?o:function(){return!1},destroy:function(){return r()}}}function x1(n){if(!n)return[];for(var e=[],t=n;t;){var i=window.getComputedStyle(t),a=i.overflow;a.split(" ").some(function(s){return s.includes("auto")||s.includes("scroll")})&&e.push(t),t=t.parentElement}return e}function A1(n){var e=new Set,t=fa(n),i;try{for(t.s();!(i=t.n()).done;){var a=i.value;x1(a).forEach(function(s){return e.add(s)})}}catch(s){t.e(s)}finally{t.f()}return(document.scrollingElement.scrollHeight>document.scrollingElement.clientHeight||document.scrollingElement.scrollWidth>document.scrollingElement.clientHeight)&&e.add(document.scrollingElement),e}function T1(n){var e=n.cloneNode(!0),t=[],i=n.tagName==="SELECT",a=i?[n]:zt(n.querySelectorAll("select")),s=fa(a),r;try{for(s.s();!(r=s.n()).done;){var o=r.value;t.push(o.value)}}catch(C){s.e(C)}finally{s.f()}if(a.length>0)for(var l=i?[e]:zt(e.querySelectorAll("select")),c=0;c0)for(var p=m?[e]:zt(e.querySelectorAll("canvas")),b=0;b0&&_.height>0&&S.getContext("2d").drawImage(_,0,0)}return e}var da=Object.freeze({USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT:"USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT"}),D1=Mi({},da.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT,!1);function Qu(n){if(!da[n])throw new Error("Can't get non existing feature flag ".concat(n,"! Supported flags: ").concat(Object.keys(da)));return D1[n]}var E1=.2;function Zn(n){return"".concat(n," ").concat(E1,"s ease")}function M1(n,e){var t=n.getBoundingClientRect(),i=T1(n);Zu(n,i),i.id=d1,i.style.position="fixed";var a=t.top,s=t.left;if(i.style.top="".concat(a,"px"),i.style.left="".concat(s,"px"),e){var r=Ju(t);a-=r.y-e.y,s-=r.x-e.x,window.setTimeout(function(){i.style.top="".concat(a,"px"),i.style.left="".concat(s,"px")},0)}return i.style.margin="0",i.style.boxSizing="border-box",i.style.height="".concat(t.height,"px"),i.style.width="".concat(t.width,"px"),i.style.transition="".concat(Zn("top"),", ").concat(Zn("left"),", ").concat(Zn("background-color"),", ").concat(Zn("opacity"),", ").concat(Zn("color")," "),window.setTimeout(function(){return i.style.transition+=", ".concat(Zn("width"),", ").concat(Zn("height"))},0),i.style.zIndex="9999",i.style.cursor="grabbing",i}function I1(n){n.style.cursor="grab"}function O1(n,e,t,i){Zu(e,n);var a=e.getBoundingClientRect(),s=n.getBoundingClientRect(),r=a.width-s.width,o=a.height-s.height;if(r||o){var l={left:(t-s.left)/s.width,top:(i-s.top)/s.height};Qu(da.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)||(n.style.height="".concat(a.height,"px"),n.style.width="".concat(a.width,"px")),n.style.left="".concat(parseFloat(n.style.left)-l.left*r,"px"),n.style.top="".concat(parseFloat(n.style.top)-l.top*o,"px")}}function Zu(n,e){var t=window.getComputedStyle(n);Array.from(t).filter(function(i){return i.startsWith("background")||i.startsWith("padding")||i.startsWith("font")||i.startsWith("text")||i.startsWith("align")||i.startsWith("justify")||i.startsWith("display")||i.startsWith("flex")||i.startsWith("border")||i==="opacity"||i==="color"||i==="list-style-type"||Qu(da.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)&&(i==="width"||i==="height")}).forEach(function(i){return e.style.setProperty(i,t.getPropertyValue(i),t.getPropertyPriority(i))})}function P1(n,e){n.draggable=!1,n.ondragstart=function(){return!1},e?(n.style.userSelect="",n.style.WebkitUserSelect="",n.style.cursor=""):(n.style.userSelect="none",n.style.WebkitUserSelect="none",n.style.cursor="grab")}function ed(n){n.style.display="none",n.style.position="fixed",n.style.zIndex="-5"}function R1(n){n.style.visibility="hidden",n.setAttribute(Co,"true")}function N1(n){n.style.visibility="",n.removeAttribute(Co)}function cs(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};n.forEach(function(i){var a=e(i);Object.keys(a).forEach(function(s){i.style[s]=a[s]}),t(i).forEach(function(s){return i.classList.add(s)})})}function fs(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};n.forEach(function(i){var a=e(i);Object.keys(a).forEach(function(s){i.style[s]=""}),t(i).forEach(function(s){return i.classList.contains(s)&&i.classList.remove(s)})})}function L1(n){var e=n.style.minHeight;n.style.minHeight=window.getComputedStyle(n).getPropertyValue("height");var t=n.style.minWidth;return n.style.minWidth=window.getComputedStyle(n).getPropertyValue("width"),function(){n.style.minHeight=e,n.style.minWidth=t}}var B1="--any--",F1=100,W1=20,Lu=3,Bu={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Fu="data-is-dnd-original-dragged-item",Yt,ft,Ct,_s,ze,Ss,Bn,ht,Nn,It,Rn=!1,To=!1,Do,ga=!1,la=[],ms,Qt=new Map,Xe=new Map,fo=new WeakMap;function H1(n,e){xe(function(){return"registering drop-zone if absent"}),Qt.has(e)||Qt.set(e,new Set),Qt.get(e).has(n)||(Qt.get(e).add(n),Gu())}function Wu(n,e){Qt.get(e).delete(n),Ku(),Qt.get(e).size===0&&Qt.delete(e)}function z1(){xe(function(){return"watching dragged element"});var n=Qt.get(_s),e=fa(n),t;try{for(e.s();!(t=e.n()).done;){var i=t.value;i.addEventListener(ys,td),i.addEventListener(ma,nd),i.addEventListener(vs,id)}}catch(r){e.e(r)}finally{e.f()}window.addEventListener(So,Oi);var a=Math.max.apply(Math,zt(Array.from(n.keys()).map(function(r){return Xe.get(r).dropAnimationDurationMs}))),s=a===0?W1:Math.max(a,F1);ms=C1(n,function(){return It}),k1(ft,n,s*1.07,ms)}function q1(){xe(function(){return"unwatching dragged element"});var n=Qt.get(_s),e=fa(n),t;try{for(e.s();!(t=e.n()).done;){var i=t.value;i.removeEventListener(ys,td),i.removeEventListener(ma,nd),i.removeEventListener(vs,id)}}catch(a){e.e(a)}finally{e.f()}window.removeEventListener(So,Oi),ms.destroy(),ms=void 0,w1()}function Cs(n){return n.findIndex(function(e){return!!e[ks]})}function j1(n){var e;return us(us({},n),{},(e={},Mi(e,ks,!0),Mi(e,nt,ni),e))}function td(n){xe(function(){return["dragged entered",n.currentTarget,n.detail]});var e=Xe.get(n.currentTarget),t=e.items,i=e.dropFromOthersDisabled;if(i&&n.currentTarget!==ze){xe(function(){return"ignoring dragged entered because drop is currently disabled"});return}if(ga=!1,t=t.filter(function(d){return d[nt]!==Bn[nt]}),xe(function(){return"dragged entered items ".concat(dn(t))}),ze!==n.currentTarget){var a=Xe.get(ze).items,s=a.filter(function(d){return!d[ks]});Fn(ze,s,{trigger:Ye.DRAGGED_ENTERED_ANOTHER,id:Ct[nt],source:qe.POINTER})}var r=n.detail.indexObj,o=r.index,l=r.isProximityBased,c=l&&o===n.currentTarget.children.length-1?o+1:o;ht=n.currentTarget,t.splice(c,0,Bn),Fn(n.currentTarget,t,{trigger:Ye.DRAGGED_ENTERED,id:Ct[nt],source:qe.POINTER})}function nd(n){if(Rn){xe(function(){return["dragged left",n.currentTarget,n.detail]});var e=Xe.get(n.currentTarget),t=e.items,i=e.dropFromOthersDisabled;if(i&&n.currentTarget!==ze&&n.currentTarget!==ht){xe(function(){return"drop is currently disabled"});return}var a=zt(t),s=Cs(a);s!==-1&&a.splice(s,1);var r=ht;ht=void 0;var o=n.detail,l=o.type,c=o.theOtherDz;if(l===ds.OUTSIDE_OF_ANY||l===ds.LEFT_FOR_ANOTHER&&c!==ze&&Xe.get(c).dropFromOthersDisabled){xe(function(){return"dragged left all, putting shadow element back in the origin dz"}),ga=!0,ht=ze;var d=r===ze?a:zt(Xe.get(ze).items);d.splice(Ss,0,Bn),Fn(ze,d,{trigger:Ye.DRAGGED_LEFT_ALL,id:Ct[nt],source:qe.POINTER})}Fn(n.currentTarget,a,{trigger:Ye.DRAGGED_LEFT,id:Ct[nt],source:qe.POINTER})}}function id(n){xe(function(){return["dragged is over index",n.currentTarget,n.detail]});var e=Xe.get(n.currentTarget),t=e.items,i=e.dropFromOthersDisabled;if(i&&n.currentTarget!==ze){xe(function(){return"drop is currently disabled"});return}var a=zt(t);ga=!1;var s=n.detail.indexObj.index,r=Cs(a);r!==-1&&a.splice(r,1),a.splice(s,0,Bn),Fn(n.currentTarget,a,{trigger:Ye.DRAGGED_OVER_INDEX,id:Ct[nt],source:qe.POINTER})}function gs(n){n.preventDefault();var e=n.touches?n.touches[0]:n;It={x:e.clientX,y:e.clientY},ft.style.transform="translate3d(".concat(It.x-Nn.x,"px, ").concat(It.y-Nn.y,"px, 0)")}function Oi(){xe(function(){return"dropped"}),To=!0,window.removeEventListener("mousemove",gs),window.removeEventListener("touchmove",gs),window.removeEventListener("mouseup",Oi),window.removeEventListener("touchend",Oi),q1(),I1(ft),ht||(xe(function(){return"element was dropped right after it left origin but before entering somewhere else"}),ht=ze),xe(function(){return["dropped in dz",ht]});var n=Xe.get(ht),e=n.items,t=n.type;fs(Qt.get(t),function(s){return Xe.get(s).dropTargetStyle},function(s){return Xe.get(s).dropTargetClasses});var i=Cs(e);i===-1&&ht===ze&&(i=Ss),e=e.map(function(s){return s[ks]?Ct:s});function a(){Do(),Ii(ht,e,{trigger:ga?Ye.DROPPED_OUTSIDE_OF_ANY:Ye.DROPPED_INTO_ZONE,id:Ct[nt],source:qe.POINTER}),ht!==ze&&Ii(ze,Xe.get(ze).items,{trigger:Ye.DROPPED_INTO_ANOTHER,id:Ct[nt],source:qe.POINTER}),i!==-1&&N1(ht.children[i]),G1()}V1(i,a)}function V1(n,e){var t=n>-1?po(ht.children[n]):po(ht),i={x:t.left-parseFloat(ft.style.left),y:t.top-parseFloat(ft.style.top)},a=Xe.get(ht),s=a.dropAnimationDurationMs,r="transform ".concat(s,"ms ease");ft.style.transition=ft.style.transition?ft.style.transition+","+r:r,ft.style.transform="translate3d(".concat(i.x,"px, ").concat(i.y,"px, 0)"),window.setTimeout(e,s)}function U1(n,e){la.push({dz:n,destroy:e}),window.requestAnimationFrame(function(){ed(n),document.body.appendChild(n)})}function G1(){ft.remove(),Yt.remove(),la.length&&(xe(function(){return["will destroy zones that were removed during drag",la]}),la.forEach(function(n){var e=n.dz,t=n.destroy;t(),e.remove()}),la=[]),ft=void 0,Yt=void 0,Ct=void 0,_s=void 0,ze=void 0,Ss=void 0,Bn=void 0,ht=void 0,Nn=void 0,It=void 0,Rn=!1,To=!1,Do=void 0,ga=!1}function K1(n,e){var t=!1,i={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:Bu,dropTargetClasses:[],transformDraggedElement:function(){},centreDraggedOnCursor:!1};xe(function(){return["dndzone good to go options: ".concat(dn(e),", config: ").concat(dn(i)),{node:n}]});var a=new Map;function s(){window.addEventListener("mousemove",l,{passive:!1}),window.addEventListener("touchmove",l,{passive:!1,capture:!1}),window.addEventListener("mouseup",o,{passive:!1}),window.addEventListener("touchend",o,{passive:!1})}function r(){window.removeEventListener("mousemove",l),window.removeEventListener("touchmove",l),window.removeEventListener("mouseup",o),window.removeEventListener("touchend",o)}function o(h){r(),Yt=void 0,Nn=void 0,It=void 0,h.type==="touchend"&&h.target.click()}function l(h){h.preventDefault();var m=h.touches?h.touches[0]:h;It={x:m.clientX,y:m.clientY},(Math.abs(It.x-Nn.x)>=Lu||Math.abs(It.y-Nn.y)>=Lu)&&(r(),d())}function c(h){if(h.target!==h.currentTarget&&(h.target.value!==void 0||h.target.isContentEditable)){xe(function(){return"won't initiate drag on a nested input element"});return}if(h.button){xe(function(){return"ignoring none left click button: ".concat(h.button)});return}if(Rn){xe(function(){return"cannot start a new drag before finalizing previous one"});return}h.preventDefault(),h.stopPropagation();var m=h.touches?h.touches[0]:h;Nn={x:m.clientX,y:m.clientY},It=us({},Nn),Yt=h.currentTarget,s()}function d(){xe(function(){return["drag start config: ".concat(dn(i)),Yt]}),Rn=!0;var h=a.get(Yt);Ss=h,ze=Yt.parentElement;var m=ze.closest("dialog")||ze.getRootNode(),f=m.body||m,p=i.items,b=i.type,_=i.centreDraggedOnCursor,S=zt(p);Ct=S[h],_s=b,Bn=j1(Ct),ft=M1(Yt,_&&It),Yt.setAttribute(Fu,!0);function C(){ft.parentElement?window.requestAnimationFrame(C):(f.appendChild(ft),ft.focus(),z1(),ed(Yt),f.appendChild(Yt),Bn[nt]=Ct[nt])}window.requestAnimationFrame(C),cs(Array.from(Qt.get(i.type)).filter(function(M){return M===ze||!Xe.get(M).dropFromOthersDisabled}),function(M){return Xe.get(M).dropTargetStyle},function(M){return Xe.get(M).dropTargetClasses}),S.splice(h,1,Bn),Do=L1(ze),Fn(ze,S,{trigger:Ye.DRAG_STARTED,id:Ct[nt],source:qe.POINTER}),window.addEventListener("mousemove",gs,{passive:!1}),window.addEventListener("touchmove",gs,{passive:!1,capture:!1}),window.addEventListener("mouseup",Oi,{passive:!1}),window.addEventListener("touchend",Oi,{passive:!1})}function u(h){var m=h.items,f=m===void 0?void 0:m,p=h.flipDurationMs,b=p===void 0?0:p,_=h.type,S=_===void 0?B1:_,C=h.dragDisabled,M=C===void 0?!1:C,w=h.morphDisabled,k=w===void 0?!1:w,A=h.dropFromOthersDisabled,P=A===void 0?!1:A,L=h.dropTargetStyle,B=L===void 0?Bu:L,O=h.dropTargetClasses,q=O===void 0?[]:O,Z=h.transformDraggedElement,ee=Z===void 0?function(){}:Z,se=h.centreDraggedOnCursor,$=se===void 0?!1:se;i.dropAnimationDurationMs=b,i.type&&S!==i.type&&Wu(n,i.type),i.type=S,i.items=zt(f),i.dragDisabled=M,i.morphDisabled=k,i.transformDraggedElement=ee,i.centreDraggedOnCursor=$,t&&Rn&&!To&&(!b1(B,i.dropTargetStyle)||!y1(q,i.dropTargetClasses))&&(fs([n],function(){return i.dropTargetStyle},function(){return q}),cs([n],function(){return B},function(){return q})),i.dropTargetStyle=B,i.dropTargetClasses=zt(q);function W(Y,de){return Xe.get(Y)?Xe.get(Y)[de]:i[de]}t&&Rn&&i.dropFromOthersDisabled!==P&&(P?fs([n],function(Y){return W(Y,"dropTargetStyle")},function(Y){return W(Y,"dropTargetClasses")}):cs([n],function(Y){return W(Y,"dropTargetStyle")},function(Y){return W(Y,"dropTargetClasses")})),i.dropFromOthersDisabled=P,Xe.set(n,i),H1(n,S);for(var J=Rn?Cs(i.items):-1,F=0;F".concat(e,"

"),t.style.display="none",t.style.position="fixed",t.style.zIndex="-5",t}function Ei(n){if(!xo){Je||vo(),Je.innerHTML="";var e=document.createTextNode(n);Je.appendChild(e),Je.style.display="none",Je.style.display="inline"}}var Q1="--any--",Hu={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Ht=!1,ko,mt,ti="",ei,Jt,Ln="",ps=new WeakSet,zu=new WeakMap,qu=new WeakMap,wo=new Map,dt=new Map,Xt=new Map,bs;function Z1(n,e){xe(function(){return"registering drop-zone if absent"}),Xt.size===0&&(xe(function(){return"adding global keydown and click handlers"}),bs=Y1(),window.addEventListener("keydown",sd),window.addEventListener("click",rd)),Xt.has(e)||Xt.set(e,new Set),Xt.get(e).has(n)||(Xt.get(e).add(n),Gu())}function ju(n,e){xe(function(){return"unregistering drop-zone"}),mt===n&&ha(),Xt.get(e).delete(n),Ku(),Xt.get(e).size===0&&Xt.delete(e),Xt.size===0&&(xe(function(){return"removing global keydown and click handlers"}),window.removeEventListener("keydown",sd),window.removeEventListener("click",rd),bs=void 0,J1())}function sd(n){if(Ht)switch(n.key){case"Escape":{ha();break}}}function rd(){Ht&&(ps.has(document.activeElement)||(xe(function(){return"clicked outside of any draggable"}),ha()))}function eb(n){if(xe(function(){return"zone focus"}),!!Ht){var e=n.currentTarget;if(e!==mt){ti=e.getAttribute("aria-label")||"";var t=dt.get(mt),i=t.items,a=i.find(function(u){return u[nt]===Jt}),s=i.indexOf(a),r=i.splice(s,1)[0],o=dt.get(e),l=o.items,c=o.autoAriaDisabled;e.getBoundingClientRect().top0&&arguments[0]!==void 0?arguments[0]:!0;xe(function(){return"drop"}),dt.get(mt).autoAriaDisabled||Ei("Stopped dragging item ".concat(Ln)),ps.has(document.activeElement)&&document.activeElement.blur(),n&&Fn(mt,dt.get(mt).items,{trigger:Ye.DRAG_STOPPED,id:Jt,source:qe.KEYBOARD}),fs(Xt.get(ko),function(e){return dt.get(e).dropTargetStyle},function(e){return dt.get(e).dropTargetClasses}),ei=null,Jt=null,Ln="",ko=null,mt=null,ti="",Ht=!1,od()}function tb(n,e){var t={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Hu,dropTargetClasses:[],autoAriaDisabled:!1};function i(d,u,h){d.length<=1||d.splice(h,1,d.splice(u,1,d[h])[0])}function a(d){switch(xe(function(){return["handling key down",d.key]}),d.key){case"Enter":case" ":{if((d.target.disabled!==void 0||d.target.href||d.target.isContentEditable)&&!ps.has(d.target))return;d.preventDefault(),d.stopPropagation(),Ht?ha():s(d);break}case"ArrowDown":case"ArrowRight":{if(!Ht)return;d.preventDefault(),d.stopPropagation();var u=dt.get(n),h=u.items,m=Array.from(n.children),f=m.indexOf(d.currentTarget);xe(function(){return["arrow down",f]}),f0&&(t.autoAriaDisabled||Ei("Moved item ".concat(Ln," to position ").concat(S," in the list ").concat(ti)),i(b,S,S-1),Ii(n,b,{trigger:Ye.DROPPED_INTO_ZONE,id:Jt,source:qe.KEYBOARD}));break}}}function s(d){xe(function(){return"drag start"}),o(d.currentTarget),mt=n,ko=t.type,Ht=!0;var u=Array.from(Xt.get(t.type)).filter(function(m){return m===mt||!dt.get(m).dropFromOthersDisabled});if(cs(u,function(m){return dt.get(m).dropTargetStyle},function(m){return dt.get(m).dropTargetClasses}),!t.autoAriaDisabled){var h="Started dragging item ".concat(Ln,". Use the arrow keys to move it within its list ").concat(ti);u.length>1&&(h+=", or tab to another list in order to move the item into it"),Ei(h)}Fn(n,dt.get(n).items,{trigger:Ye.DRAG_STARTED,id:Jt,source:qe.KEYBOARD}),od()}function r(d){Ht&&d.currentTarget!==ei&&(d.stopPropagation(),ha(!1),s(d))}function o(d){var u=dt.get(n),h=u.items,m=Array.from(n.children),f=m.indexOf(d);ei=d,ei.tabIndex=t.zoneItemTabIndex,Jt=h[f][nt],Ln=m[f].getAttribute("aria-label")||""}function l(d){var u=d.items,h=u===void 0?[]:u,m=d.type,f=m===void 0?Q1:m,p=d.dragDisabled,b=p===void 0?!1:p,_=d.zoneTabIndex,S=_===void 0?0:_,C=d.zoneItemTabIndex,M=C===void 0?0:C,w=d.dropFromOthersDisabled,k=w===void 0?!1:w,A=d.dropTargetStyle,P=A===void 0?Hu:A,L=d.dropTargetClasses,B=L===void 0?[]:L,O=d.autoAriaDisabled,q=O===void 0?!1:O;t.items=zt(h),t.dragDisabled=b,t.dropFromOthersDisabled=k,t.zoneTabIndex=S,t.zoneItemTabIndex=M,t.dropTargetStyle=P,t.dropTargetClasses=B,t.autoAriaDisabled=q,t.type&&f!==t.type&&ju(n,t.type),t.type=f,Z1(n,f),q||(n.setAttribute("aria-disabled",b),n.setAttribute("role","list"),n.setAttribute("aria-describedby",b?bs.DND_ZONE_DRAG_DISABLED:bs.DND_ZONE_ACTIVE)),dt.set(n,t),Ht?n.tabIndex=n===mt||ei.contains(n)||t.dropFromOthersDisabled||mt&&t.type!==dt.get(mt).type?-1:0:n.tabIndex=t.zoneTabIndex,n.addEventListener("focus",eb);for(var Z=function($){var W=n.children[$];ps.add(W),W.tabIndex=Ht?-1:t.zoneItemTabIndex,q||W.setAttribute("role","listitem"),W.removeEventListener("keydown",zu.get(W)),W.removeEventListener("click",qu.get(W)),b||(W.addEventListener("keydown",a),zu.set(W,a),W.addEventListener("click",r),qu.set(W,r)),Ht&&t.items[$][nt]===Jt&&(xe(function(){return["focusing on",{i:$,focusedItemId:Jt}]}),ei=W,ei.tabIndex=t.zoneItemTabIndex,W.focus())},ee=0;ee0&&console.warn("dndzone will ignore unknown options",f),!e)throw new Error("no 'items' key provided to dndzone");var p=e.find(function(b){return!{}.hasOwnProperty.call(b,nt)});if(p)throw new Error("missing '".concat(nt,"' property for item ").concat(dn(p)));if(d&&!Array.isArray(d))throw new Error("dropTargetClasses should be an array but instead it is a ".concat(ca(d),", ").concat(dn(d)));if(o&&!Uu(o))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(ca(o),", ").concat(dn(o)));if(l&&!Uu(l))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(ca(l),", ").concat(dn(l)))}function Uu(n){return!isNaN(n)&&function(e){return(e|0)===e}(parseFloat(n))}function ab(n){var e=n,t=new Set;return{get:function(){return e},set:function(a){e=a,Array.from(t).forEach(function(s){return s(e)})},subscribe:function(a){t.add(a),a(e)},unsubscribe:function(a){t.delete(a)}}}var ES=ab(!0);var xs=require("obsidian");var ld=require("@codemirror/view"),Fe=(n,e)=>{(0,xs.setIcon)(n,e)};function pa(n,e,t,i,a="js"){let s=new xs.TextAreaComponent(n).setValue(e);return s.inputEl.addClasses(["statblock-textarea",...t]),jt(s.inputEl,ld.EditorView.updateListener.of(r=>{r.docChanged&&i(r.state.doc.toString())}),a)}function sb(n){re(n,"svelte-r3p86y",".property-block-container.svelte-r3p86y{display:flex;justify-content:space-between;align-items:center}.info.svelte-r3p86y{display:flex;flex-flow:column}.context.svelte-r3p86y{display:flex;align-items:center;gap:0.25rem;color:var(--text-muted)}.context-item.svelte-r3p86y{display:flex;align-items:center}")}function cd(n){let e,t,i=n[0].size+"",a,s;return{c(){e=v("span"),t=pe("(H"),a=pe(i),s=pe(")")},m(r,o){D(r,e,o),y(e,t),y(e,a),y(e,s)},p(r,o){o&1&&i!==(i=r[0].size+"")&&we(a,i)},d(r){r&&x(e)}}}function ud(n){let e,t,i=n[0].headers.join(" | ")+"",a,s;return{c(){e=v("strong"),t=pe("("),a=pe(i),s=pe(")")},m(r,o){D(r,e,o),y(e,t),y(e,a),y(e,s)},p(r,o){o&1&&i!==(i=r[0].headers.join(" | ")+"")&&we(a,i)},d(r){r&&x(e)}}}function rb(n){let e,t,i=n[2](n[0].layout)+"",a;return{c(){e=v("small"),t=v("em"),a=pe(i)},m(s,r){D(s,e,r),y(e,t),y(t,a)},p(s,r){r&1&&i!==(i=s[2](s[0].layout)+"")&&we(a,i)},d(s){s&&x(e)}}}function ob(n){let e,t,i=n[0].properties.join(", ")+"",a;return{c(){e=v("small"),t=v("em"),a=pe(i)},m(s,r){D(s,e,r),y(e,t),y(t,a)},p(s,r){r&1&&i!==(i=s[0].properties.join(", ")+"")&&we(a,i)},d(s){s&&x(e)}}}function dd(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","context-item heading svelte-r3p86y"),g(e,"aria-label","Has Heading")},m(s,r){D(s,e,r),i||(a=X(t=Fe.call(null,e,"heading-glyph")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function hd(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","context-item conditioned svelte-r3p86y"),g(e,"aria-label","Conditioned")},m(s,r){D(s,e,r),i||(a=X(t=Fe.call(null,e,"help-circle")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function fd(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","context-item callback svelte-r3p86y"),g(e,"aria-label","Has Callback")},m(s,r){D(s,e,r),i||(a=X(t=Fe.call(null,e,"code-glyph")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function md(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","context-item dice svelte-r3p86y"),g(e,"aria-label","Will Parse for Dice Rolls")},m(s,r){D(s,e,r),i||(a=X(t=Fe.call(null,e,"dices")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function gd(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","context-item dice svelte-r3p86y"),g(e,"aria-label","Render markdown enabled")},m(s,r){D(s,e,r),i||(a=X(t=Fe.call(null,e,"markdown-icon")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function lb(n){let e,t,i,a,s=n[1](n[0].type)+"",r,o,l,c,d,u,h,m,f,p,b=n[0].type=="heading"&&cd(n),_=n[0].type=="table"&&n[0].headers?.length&&ud(n);function S(B,O){return B[0].type!="layout"?ob:rb}let C=S(n,-1),M=C(n),w="heading"in n[0]&&dd(n),k=n[0].conditioned&&hd(n),A="callback"in n[0]&&fd(n),P=("dice"in n[0]&&n[0].dice||"diceCallback"in n[0]&&n[0].diceCallback?.length)&&md(n),L="markdown"in n[0]&&n[0].markdown&&gd(n);return{c(){e=v("div"),t=v("div"),i=v("div"),a=v("span"),r=pe(s),o=R(),b&&b.c(),l=R(),_&&_.c(),c=R(),M.c(),d=R(),u=v("small"),w&&w.c(),h=R(),k&&k.c(),m=R(),A&&A.c(),f=R(),P&&P.c(),p=R(),L&&L.c(),g(t,"class","info svelte-r3p86y"),g(u,"class","context svelte-r3p86y"),g(e,"class","property-block-container svelte-r3p86y")},m(B,O){D(B,e,O),y(e,t),y(t,i),y(i,a),y(a,r),y(i,o),b&&b.m(i,null),y(i,l),_&&_.m(i,null),y(t,c),M.m(t,null),y(e,d),y(e,u),w&&w.m(u,null),y(u,h),k&&k.m(u,null),y(u,m),A&&A.m(u,null),y(u,f),P&&P.m(u,null),y(u,p),L&&L.m(u,null)},p(B,[O]){O&1&&s!==(s=B[1](B[0].type)+"")&&we(r,s),B[0].type=="heading"?b?b.p(B,O):(b=cd(B),b.c(),b.m(i,l)):b&&(b.d(1),b=null),B[0].type=="table"&&B[0].headers?.length?_?_.p(B,O):(_=ud(B),_.c(),_.m(i,null)):_&&(_.d(1),_=null),C===(C=S(B,O))&&M?M.p(B,O):(M.d(1),M=C(B),M&&(M.c(),M.m(t,null))),"heading"in B[0]?w||(w=dd(B),w.c(),w.m(u,h)):w&&(w.d(1),w=null),B[0].conditioned?k||(k=hd(B),k.c(),k.m(u,m)):k&&(k.d(1),k=null),"callback"in B[0]?A||(A=fd(B),A.c(),A.m(u,f)):A&&(A.d(1),A=null),"dice"in B[0]&&B[0].dice||"diceCallback"in B[0]&&B[0].diceCallback?.length?P||(P=md(B),P.c(),P.m(u,p)):P&&(P.d(1),P=null),"markdown"in B[0]&&B[0].markdown?L||(L=gd(B),L.c(),L.m(u,null)):L&&(L.d(1),L=null)},i:N,o:N,d(B){B&&x(e),b&&b.d(),_&&_.d(),M.d(),w&&w.d(),k&&k.d(),A&&A.d(),P&&P.d(),L&&L.d()}}}function cb(n,e,t){let{block:i}=e,{plugin:a}=e;i.type=="heading"&&!i.size&&(i.size=1);let s=o=>"display"in i?`${i.display} (${o[0].toUpperCase()+o.slice(1).toLowerCase()})`:o[0].toUpperCase()+o.slice(1).toLowerCase(),r=o=>a.manager.getLayout(o)?.name??"No layout selected";return n.$$set=o=>{"block"in o&&t(0,i=o.block),"plugin"in o&&t(3,a=o.plugin)},[i,s,r,a]}var Eo=class extends G{constructor(e){super(),K(this,e,cb,lb,j,{block:0,plugin:3},sb)}},pd=Eo;var Ps=require("obsidian");var me=require("obsidian");var vd=require("obsidian");function ub(n){re(n,"svelte-1blh0v3",".creator-zone.svelte-1blh0v3{display:flex;justify-content:space-evenly;gap:1rem;flex-flow:row wrap}.header-container.svelte-1blh0v3{display:flex;align-items:center}")}function bd(n,e,t){let i=n.slice();return i[11]=e[t],i}function yd(n,e){let t,i,a=e[11].name+"",s,r,o,l,c,d,u=N,h,m;function f(){return e[8](e[11])}return{key:n,first:null,c(){t=v("div"),i=v("span"),s=pe(a),r=R(),o=v("div"),c=R(),g(i,"class","table-header"),g(t,"class","header-container svelte-1blh0v3"),this.first=t},m(p,b){D(p,t,b),y(t,i),y(i,s),y(t,r),y(t,o),y(t,c),h||(m=[X(l=e[5].call(null,o)),z(o,"click",f)],h=!0)},p(p,b){e=p,b&1&&a!==(a=e[11].name+"")&&we(s,a)},r(){d=t.getBoundingClientRect()},f(){Dn(t),u()},a(){u(),u=Tn(t,d,Pn,{duration:Mo})},d(p){p&&x(t),h=!1,le(m)}}}function db(n){let e,t,i=[],a=new Map,s,r,o,l=ye(n[0].filter(n[7])),c=d=>d[11].id;for(let d=0;d({name:f,id:U()})),r=!1;function o(f){let{items:p,info:{source:b,trigger:_}}=f.detail;t(0,s=[...p])}function l(f){let{items:p,info:{source:b}}=f.detail;t(0,s=[...p]),i("sorted",s)}function c(f){f.preventDefault(),t(1,r=!1)}let d=f=>{t(0,s=s.filter(p=>p.id!=f.id)),i("sorted",s)},u=f=>{new vd.ExtraButtonComponent(f).setIcon("cross-in-box")},h=f=>f.id!==ni,m=f=>d(f);return n.$$set=f=>{"headers"in f&&t(6,a=f.headers)},[s,r,o,l,d,u,a,h,m]}var Io=class extends G{constructor(e){super(),K(this,e,hb,db,j,{headers:6},ub)}},kd=Io;var As=require("obsidian");function fb(n){re(n,"svelte-mn2hp8",".setting-item.svelte-mn2hp8{align-items:center}.icon.svelte-mn2hp8{display:flex;align-items:center}")}function wd(n,e,t){let i=n.slice();return i[18]=e[t],i[19]=e,i[20]=t,i}function mb(n){let e,t=n[18].prop+"",i;return{c(){e=v("div"),i=pe(t),g(e,"class","setting-item-name")},m(a,s){D(a,e,s),y(e,i)},p(a,s){s&4&&t!==(t=a[18].prop+"")&&we(i,t)},d(a){a&&x(e)}}}function gb(n){let e,t,i,a;function s(){n[13].call(e,n[19],n[20])}return{c(){e=v("input"),g(e,"type","text"),g(e,"placeholder",t=String(n[18].prop))},m(r,o){D(r,e,o),ct(e,n[18].prop),i||(a=z(e,"input",s),i=!0)},p(r,o){n=r,o&4&&t!==(t=String(n[18].prop))&&g(e,"placeholder",t),o&4&&e.value!==n[18].prop&&ct(e,n[18].prop)},d(r){r&&x(e),i=!1,a()}}}function pb(n){let e,t,i,a;function s(){return n[15](n[18])}return{c(){e=v("div"),g(e,"class","edit")},m(r,o){D(r,e,o),i||(a=[z(e,"click",s),X(t=n[10].call(null,e))],i=!0)},p(r,o){n=r},d(r){r&&x(e),i=!1,le(a)}}}function bb(n){let e,t,i,a;function s(){return n[14](n[18])}return{c(){e=v("div"),g(e,"class","done")},m(r,o){D(r,e,o),i||(a=[z(e,"click",s),X(t=n[11].call(null,e))],i=!0)},p(r,o){n=r},d(r){r&&x(e),i=!1,le(a)}}}function _d(n,e){let t,i,a,s,r,o,l,c,d,u,h,m,f,p;function b(A,P){return A[1]==A[18].id?gb:mb}let _=b(e,-1),S=_(e);function C(A,P){return A[1]==A[18].id?bb:pb}let M=C(e,-1),w=M(e);function k(){return e[16](e[18])}return{key:n,first:null,c(){t=v("div"),i=v("div"),r=R(),o=v("div"),S.c(),l=R(),c=v("div"),w.c(),d=R(),u=v("div"),m=R(),g(i,"class","icon svelte-mn2hp8"),g(i,"style",a=e[0]?"cursor: grab":"cursor: grabbing"),g(o,"class","setting-item-info"),g(u,"class","delete"),g(c,"class","setting-item-control"),g(t,"class","setting-item svelte-mn2hp8"),this.first=t},m(A,P){D(A,t,P),y(t,i),y(t,r),y(t,o),S.m(o,null),y(t,l),y(t,c),w.m(c,null),y(c,d),y(c,u),y(t,m),f||(p=[X(s=Fe.call(null,i,"grip-vertical")),z(i,"mousedown",e[5]),z(i,"touchstart",e[5]),z(u,"click",k),X(h=e[7].call(null,u))],f=!0)},p(A,P){e=A,P&1&&a!==(a=e[0]?"cursor: grab":"cursor: grabbing")&&g(i,"style",a),_===(_=b(e,P))&&S?S.p(e,P):(S.d(1),S=_(e),S&&(S.c(),S.m(o,null))),M===(M=C(e,P))&&w?w.p(e,P):(w.d(1),w=M(e),w&&(w.c(),w.m(c,d)))},d(A){A&&x(t),S.d(),w.d(),f=!1,le(p)}}}function yb(n){let e,t=[],i=new Map,a,s,r,o=ye(n[2]),l=c=>c[18].id;for(let c=0;cP)),A===qe.POINTER&&t(0,r=!0)}function c(w){w.preventDefault(),t(0,r=!1)}let d=w=>{t(2,i=i.filter(k=>k.id!=w.id)),s("sorted",i.map(({prop:k})=>k))},u=w=>{new As.ExtraButtonComponent(w).setIcon("trash")},h,m=w=>{t(1,h=w.id)},f=w=>{t(2,i=i.map(k=>k.id==w.id?{id:w.id,prop:w.prop}:k)),t(1,h=null),s("sorted",i.map(({prop:k})=>k))},p=w=>{new As.ExtraButtonComponent(w).setIcon("pencil")},b=w=>{new As.ExtraButtonComponent(w).setIcon("check")};function _(w,k){w[k].prop=this.value,t(2,i),t(12,a)}let S=w=>f(w),C=w=>m(w),M=w=>d(w);return n.$$set=w=>{"properties"in w&&t(12,a=w.properties)},n.$$.update=()=>{n.$$.dirty&4096&&t(2,i=[...a])},[r,h,i,o,l,c,d,u,m,f,p,b,a,_,S,C,M]}var Oo=class extends G{constructor(e){super(),K(this,e,vb,yb,j,{properties:12},fb)}},Cd=Oo;var Rd=require("obsidian");function Pi(n,{delay:e=0,duration:t=400,easing:i=os,axis:a="y"}={}){let s=getComputedStyle(n),r=+s.opacity,o=a==="y"?"height":"width",l=parseFloat(s[o]),c=a==="y"?["top","bottom"]:["left","right"],d=c.map(_=>`${_[0].toUpperCase()}${_.slice(1)}`),u=parseFloat(s[`padding${d[0]}`]),h=parseFloat(s[`padding${d[1]}`]),m=parseFloat(s[`margin${d[0]}`]),f=parseFloat(s[`margin${d[1]}`]),p=parseFloat(s[`border${d[0]}Width`]),b=parseFloat(s[`border${d[1]}Width`]);return{delay:e,duration:t,easing:i,css:_=>`overflow: hidden;opacity: ${Math.min(_*20,1)*r};${o}: ${_*l}px;padding-${c[0]}: ${_*u}px;padding-${c[1]}: ${_*h}px;margin-${c[0]}: ${_*m}px;margin-${c[1]}: ${_*f}px;border-${c[0]}-width: ${_*p}px;border-${c[1]}-width: ${_*b}px;`}}var Id=require("obsidian");var kb=require("obsidian");function ii(n){switch(n){case"inline":case"group":return{type:n,id:U(),properties:[],nested:[]};case"heading":return{type:"heading",id:U(),properties:[],size:1};case"property":return{type:"property",id:U(),properties:[]};case"saves":return{type:"saves",id:U(),properties:[]};case"traits":return{type:"traits",id:U(),properties:[]};case"spells":return{type:"spells",id:U(),properties:[]};case"subheading":return{type:"subheading",id:U(),properties:[]};case"image":return{type:"image",id:U(),properties:[]};case"table":return{type:"table",id:U(),properties:[],headers:[],calculate:!0};case"text":return{type:"text",id:U(),properties:[],text:null};case"ifelse":return{type:"ifelse",id:U(),conditions:[]};case"collapse":return{type:"collapse",id:U(),heading:null,hasRule:!1,conditioned:!1,nested:[ii("group")],open:!1};case"javascript":return{type:"javascript",id:U(),conditioned:!1,code:""};case"layout":return{type:"layout",id:U(),layout:null};case"action":return{type:"action",id:U(),icon:"clapperboard"}}}var Ri=require("obsidian");var xd=require("@codemirror/view");function wb(n){re(n,"svelte-1ss6215",".setting-item-info.svelte-1ss6215{width:100%}.setting-item-name.svelte-1ss6215{display:flex;align-items:center;gap:0.25rem}")}function _b(n){let e;function t(s,r){return!s[0]||!s[0].condition?xb:Cb}let i=t(n,-1),a=i(n);return{c(){e=v("div"),a.c(),g(e,"class","setting-item-name svelte-1ss6215")},m(s,r){D(s,e,r),a.m(e,null)},p(s,r){i===(i=t(s,r))&&a?a.p(s,r):(a.d(1),a=i(s),a&&(a.c(),a.m(e,null)))},d(s){s&&x(e),a.d()}}}function Sb(n){let e,t,i,a;return{c(){e=v("div")},m(s,r){D(s,e,r),i||(a=X(t=n[4].call(null,e)),i=!0)},p:N,d(s){s&&x(e),i=!1,a()}}}function Cb(n){let e,t=n[0].condition+"",i;return{c(){e=v("code"),i=pe(t)},m(a,s){D(a,e,s),y(e,i)},p(a,s){s&1&&t!==(t=a[0].condition+"")&&we(i,t)},d(a){a&&x(e)}}}function xb(n){let e,t,i,a,s,r;return{c(){e=v("div"),i=R(),a=v("em"),a.textContent="No condition set"},m(o,l){D(o,e,l),D(o,i,l),D(o,a,l),s||(r=X(t=Fe.call(null,e,"alert-triangle")),s=!0)},p:N,d(o){o&&(x(e),x(i),x(a)),s=!1,r()}}}function Ab(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","edit")},m(s,r){D(s,e,r),i||(a=[z(e,"click",n[8]),X(t=n[5].call(null,e))],i=!0)},p:N,d(s){s&&x(e),i=!1,le(a)}}}function Tb(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","done")},m(s,r){D(s,e,r),i||(a=[z(e,"click",n[3]),X(t=n[6].call(null,e))],i=!0)},p:N,d(s){s&&x(e),i=!1,le(a)}}}function Db(n){let e,t,i,a,s,r,o,l;function c(p,b){return p[1]?Sb:_b}let d=c(n,-1),u=d(n);function h(p,b){return p[1]?Tb:Ab}let m=h(n,-1),f=m(n);return{c(){e=v("div"),u.c(),t=R(),i=v("div"),f.c(),a=R(),s=v("div"),g(e,"class","setting-item-info svelte-1ss6215"),g(s,"class","delete"),g(i,"class","setting-item-control")},m(p,b){D(p,e,b),u.m(e,null),D(p,t,b),D(p,i,b),f.m(i,null),y(i,a),y(i,s),o||(l=[z(s,"click",n[9]),X(r=n[7].call(null,s))],o=!0)},p(p,[b]){d===(d=c(p,b))&&u?u.p(p,b):(u.d(1),u=d(p),u&&(u.c(),u.m(e,null))),m===(m=h(p,b))&&f?f.p(p,b):(f.d(1),f=m(p),f&&(f.c(),f.m(i,a)))},i:N,o:N,d(p){p&&(x(e),x(t),x(i)),u.d(),f.d(),o=!1,le(l)}}}function Eb(n,e,t){let i=Me(),{condition:a}=e,{editing:s=!1}=e,r;function o(){r&&(t(0,a.condition=r.state.doc.toString(),a),r.destroy()),i("done")}let l=f=>{let p=new Ri.TextAreaComponent(f).setValue(a?.condition?a.condition:"");r=jt(p.inputEl,xd.EditorView.updateListener.of(b=>{b.docChanged&&t(0,a.condition=b.state.doc.toString(),a)}))},c=f=>{new Ri.ExtraButtonComponent(f).setIcon("pencil")},d=f=>{new Ri.ExtraButtonComponent(f).setIcon("check")},u=f=>{new Ri.ExtraButtonComponent(f).setIcon("trash")};bn(()=>{r?.destroy()});let h=()=>i("edit"),m=()=>i("delete");return n.$$set=f=>{"condition"in f&&t(0,a=f.condition),"editing"in f&&t(1,s=f.editing)},[a,s,i,o,l,c,d,u,h,m]}var Po=class extends G{constructor(e){super(),K(this,e,Eb,Db,j,{condition:0,editing:1},wb)}},Ad=Po;function Mb(n){re(n,"svelte-mn2hp8",".setting-item.svelte-mn2hp8{align-items:center}.icon.svelte-mn2hp8{display:flex;align-items:center}")}function Td(n,e,t){let i=n.slice();return i[15]=e[t],i}function Dd(n){let e,t,i,a,s,r,o,l,c,d;function u(){return n[11](n[15])}function h(){return n[12](n[15])}function m(){return n[13](n[15])}return r=new Ad({props:{condition:n[15].prop,editing:n[1]==n[15].id}}),r.$on("delete",u),r.$on("edit",h),r.$on("done",m),{c(){e=v("div"),t=v("div"),s=R(),ae(r.$$.fragment),o=R(),g(t,"class","icon svelte-mn2hp8"),g(t,"style",i=n[2]?"cursor: grab":"cursor: grabbing"),g(e,"class","setting-item svelte-mn2hp8")},m(f,p){D(f,e,p),y(e,t),y(e,s),te(r,e,null),y(e,o),l=!0,c||(d=[X(a=Fe.call(null,t,"grip-vertical")),z(t,"mousedown",n[6]),z(t,"touchstart",n[6])],c=!0)},p(f,p){n=f,(!l||p&4&&i!==(i=n[2]?"cursor: grab":"cursor: grabbing"))&&g(t,"style",i);let b={};p&8&&(b.condition=n[15].prop),p&10&&(b.editing=n[1]==n[15].id),r.$set(b)},i(f){l||(E(r.$$.fragment,f),l=!0)},o(f){I(r.$$.fragment,f),l=!1},d(f){f&&x(e),ne(r),c=!1,le(d)}}}function Ed(n,e){let t,i=e[1],a,s,r=Dd(e);return{key:n,first:null,c(){t=_e(),r.c(),a=_e(),this.first=t},m(o,l){D(o,t,l),r.m(o,l),D(o,a,l),s=!0},p(o,l){e=o,l&2&&j(i,i=e[1])?(ce(),I(r,1,1,N),ue(),r=Dd(e),r.c(),E(r,1),r.m(a.parentNode,a)):r.p(e,l)},i(o){s||(E(r),s=!0)},o(o){I(r),s=!1},d(o){o&&(x(t),x(a)),r.d(o)}}}function Ib(n){let e,t,i,a,s,r=[],o=new Map,l,c,d,u,h=ye(n[3]),m=f=>f[15].id;for(let f=0;f(s(),s=Tt(o,M=>t(10,a=M)),o);n.$$.on_destroy.push(()=>s());let{conditions:o}=e;r();let l=null,c=Me(),d=!0;function u(M){let{items:w,info:{source:k,trigger:A}}=M.detail;t(3,i=[...w]),k===qe.KEYBOARD&&A===Ye.DRAG_STOPPED&&t(2,d=!0)}function h(M){let{items:w,info:{source:k}}=M.detail;t(3,i=[...w]),c("sorted",i.map(({prop:A})=>A)),k===qe.POINTER&&t(2,d=!0)}function m(M){M.preventDefault(),t(2,d=!1)}let f=M=>{t(3,i=i.filter(w=>w.id!=M.id)),c("sorted",i.map(({prop:w})=>w))},p=M=>{t(3,i=i.map(w=>w.id==M.id?{id:M.id,prop:M.prop}:w)),t(1,l=null),c("sorted",i.map(({prop:w})=>w))},b=M=>{new Id.Setting(M).setName("Add new condition").addButton(w=>w.setIcon("plus").onClick(()=>{let k=U();t(1,l=k),t(3,i=[...i,{prop:{nested:[ii("group")],condition:null},id:k}]),c("sorted",i.map(({prop:A})=>A))}))},_=M=>f(M),S=M=>t(1,l=M.id),C=M=>p(M);return n.$$set=M=>{"conditions"in M&&r(t(0,o=M.conditions))},n.$$.update=()=>{n.$$.dirty&1024&&t(3,i=a.map(M=>({prop:M,id:U()})))},[o,l,d,i,u,h,m,f,p,b,a,_,S,C]}var Ro=class extends G{constructor(e){super(),K(this,e,Ob,Ib,j,{conditions:0},Mb)}},Od=Ro;function Pb(n){re(n,"svelte-131x181",".condition-builder-container.svelte-131x181 .setting-item.svelte-131x181{align-items:flex-start}")}function Pd(n){let e,t,i;return{c(){e=v("div"),e.innerHTML=`Conditions are used to determine what block is rendered. Conditions are evaluated top to bottom - the first to evaluate to true is the condition that will be used. If the last condition is left blank and no others were true, it will be used.

The expression receives the monster parameter, which can be used to access properties of the monster being rendered.

All conditions must return a true/false value. For example: return monster.ac > 1`,g(e,"class","setting-item-description")},m(a,s){D(a,e,s),i=!0},i(a){i||(a&&Mt(()=>{i&&(t||(t=Yn(e,Pi,{},!0)),t.run(1))}),i=!0)},o(a){a&&(t||(t=Yn(e,Pi,{},!1)),t.run(0)),i=!1},d(a){a&&x(e),a&&t&&t.end()}}}function Rb(n){let e,t,i,a,s,r,o,l,c,d,u,h,m=n[1]&&Pd(n);return c=new Od({props:{conditions:n[2]}}),c.$on("sorted",n[7]),{c(){e=v("div"),t=v("div"),i=v("div"),m&&m.c(),a=R(),s=v("div"),r=v("div"),l=R(),ae(c.$$.fragment),g(i,"class","setting-item-info"),g(s,"class","setting-item-control"),g(t,"class","setting-item svelte-131x181"),g(e,"class","condition-builder-container svelte-131x181")},m(f,p){D(f,e,p),y(e,t),y(t,i),m&&m.m(i,null),y(t,a),y(t,s),y(s,r),y(e,l),te(c,e,null),d=!0,u||(h=[X(o=n[4].call(null,r)),z(r,"click",n[6])],u=!0)},p(f,[p]){f[1]?m?p&2&&E(m,1):(m=Pd(f),m.c(),E(m,1),m.m(i,null)):m&&(ce(),I(m,1,1,()=>{m=null}),ue())},i(f){d||(E(m),E(c.$$.fragment,f),d=!0)},o(f){I(m),I(c.$$.fragment,f),d=!1},d(f){f&&x(e),m&&m.d(),ne(c),u=!1,le(h)}}}function Nb(n,e,t){let i,{plugin:a}=e,{block:s}=e,r=Be(s.conditions),o=async()=>{t(5,a.settings.hideConditionHelp=!a.settings.hideConditionHelp,a),await a.saveSettings()},l=u=>{new Rd.ExtraButtonComponent(u).setIcon("help-circle")},c=()=>o(),d=u=>t(0,s.conditions=[...u.detail],s);return n.$$set=u=>{"plugin"in u&&t(5,a=u.plugin),"block"in u&&t(0,s=u.block)},n.$$.update=()=>{n.$$.dirty&32&&t(1,i=a.settings.hideConditionHelp)},[s,i,r,o,l,a,c,d]}var No=class extends G{constructor(e){super(),K(this,e,Nb,Rb,j,{plugin:5,block:0},Pb)}},Nd=No;var ri=require("@codemirror/view");var Wo=La(Ts()),Ds=class extends Wo.FuzzyInputSuggest{getItemText(e){return e.name}renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item.name,t.match.matches)}},Es=class extends Wo.FuzzyInputSuggest{renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item,t.match.matches)}getItemText(e){return e}};var zd=require("obsidian"),wt=class extends zd.Modal{constructor(t){super(t.app);this.plugin=t;this.modalEl.addClass("fantasy-statblocks-modal"),t.register(()=>this.close())}};function Os(n,e,t){switch(e.type){case"group":case"inline":return new Ho(n,e);case"action":return new Uo(n,e);case"collapse":return new zo(n,e);case"ifelse":return new Vo(n,e);case"javascript":return new qo(n,e);case"heading":return new Go(n,e);case"layout":return new jo(n,e,t);case"property":return new Ko(n,e);case"saves":return new $o(n,e);case"spells":return new Yo(n,e);case"subheading":return new Jo(n,e);case"table":return new Xo(n,e);case"traits":return new Qo(n,e);case"text":return new Zo(n,e);default:return new ai(n,e)}}var Wn=class extends wt{constructor(t,i){super(t);this.plugin=t;i&&(this.block=Ze(i)),this.containerEl.addClass("statblock-edit-block")}onOpen(){this.titleEl.setText("Edit Block"),this.display()}buildButtons(t){t.empty(),new me.Setting(t).addButton(i=>i.setCta().setIcon("checkmark").setTooltip("Save").onClick(()=>{this.saved=!0,this.close()})).addExtraButton(i=>i.setIcon("cross").setTooltip("Cancel").onClick(()=>{this.close()}))}buildProperty(t){}},Ho=class extends Wn{async display(){this.contentEl.empty(),new me.Setting(this.contentEl).setName("Section Heading").setDesc("This text will be used for the section heading. Can be left blank.").addText(e=>{e.setValue(this.block.heading).onChange(t=>this.block.heading=t)}),new me.Setting(this.contentEl).setName("Has Rule").setDesc("If present, the block will have a horizontal rule placed after it.").addToggle(e=>{e.setValue(this.block.hasRule).onChange(t=>this.block.hasRule=t)}),new me.Setting(this.contentEl).setName("CSS Container Class").setDesc("All nested elements inside this group container will receive this CSS class. If blank, no class will be applied.").addText(e=>{e.setValue(this.block.cls).onChange(t=>this.block.cls=t)}),this.buildConditions(this.contentEl.createDiv()),this.buildButtons(this.contentEl.createDiv())}buildConditions(e){e.empty();let t=this.block;new me.Setting(e).setName("Conditional").setDesc("The block will not be added if the associated properties are not present.").addToggle(i=>{i.setValue(t.conditioned).onChange(a=>{t.conditioned=a,this.buildConditions(e)})})}},zo=class extends Wn{async display(){this.contentEl.empty(),new me.Setting(this.contentEl).setName("Section Heading").setDesc("This text will be used for the section heading. Can be left blank.").addText(e=>{e.setValue(this.block.heading).onChange(t=>this.block.heading=t)}),new me.Setting(this.contentEl).setName("Open by Default").setDesc("The block will start open.").addToggle(e=>{e.setValue(this.block.open).onChange(t=>this.block.open=t)}),new me.Setting(this.contentEl).setName("Has Rule").setDesc("If present, the block will have a horizontal rule placed after it.").addToggle(e=>{e.setValue(this.block.hasRule).onChange(t=>this.block.hasRule=t)}),this.buildButtons(this.contentEl.createDiv())}},qo=class extends Wn{async display(){this.contentEl.empty(),new me.Setting(this.contentEl).setName("JavaScript").setHeading().setDesc(createFragment(t=>{t.createSpan({text:"JavaScript blocks can be used to do highly advanced HTML elements. The JavaScript code will be provided the "}),t.createEl("code",{text:"monster"}),t.createSpan({text:" and "}),t.createEl("code",{text:"property"}),t.createSpan({text:"parameters and should return a HTML element, which will be attached to the block's container element."})}));let e=new me.TextAreaComponent(this.contentEl).setValue(this.block.code);e.inputEl.addClass("statblock-textarea"),this.editor=jt(e.inputEl,ri.EditorView.updateListener.of(t=>{t.docChanged&&(this.block.code=t.state.doc.toString())})),this.buildButtons(this.contentEl.createDiv())}},jo=class extends Wn{constructor(t,i,a){super(t,i);this.layout=a}hasLayoutNestedAlready(t){for(let i of t)if(i.type=="layout"&&i.layout==this.layout||"nested"in i&&this.hasLayoutNestedAlready(i.nested))return!0;return!1}async display(){this.contentEl.empty(),new me.Setting(this.contentEl).setName("Layout to Insert").addDropdown(t=>{for(let i of this.plugin.manager.getAllLayouts())i.id!=this.layout&&(this.hasLayoutNestedAlready(i.blocks)||t.addOption(i.id,i.name));this.block.layout&&t.setValue(this.block.layout),t.onChange(i=>{this.block.layout=i})}),this.buildButtons(this.contentEl.createDiv())}},Vo=class extends Wn{async display(){this.contentEl.empty(),this.buildConditions(this.contentEl.createDiv()),this.buildButtons(this.contentEl.createDiv())}buildConditions(e){new Nd({target:e,props:{plugin:this.plugin,block:this.block}})}},Is,qd,Ms=class extends Wn{constructor(){super(...arguments);Le(this,Is);this.propertiesEl=createDiv("block-properties-container");this.separatorEl=createDiv("block-separator-container");this.conditionsEl=createDiv("block-conditions-container");this.diceEl=createDiv("block-dice-container");this.advancedEl=createEl("details",{cls:"statblock-nested-settings",attr:{...this.plugin.settings.showAdvanced?{open:!0}:{}}});this.buttonsEl=createDiv("block-buttons-container")}async display(){this.containerEl.addClass("statblock-block-editor"),this.contentEl.empty(),this.contentEl.appendChild(this.propertiesEl),this.contentEl.appendChild(this.separatorEl),this.contentEl.appendChild(this.conditionsEl),this.contentEl.appendChild(this.diceEl),this.contentEl.appendChild(this.advancedEl),this.contentEl.appendChild(this.buttonsEl),this.buildProperties(this.propertiesEl),this.buildSeparator(this.separatorEl),this.buildConditions(this.conditionsEl),this.buildDice(this.diceEl),Oe(this,Is,qd).call(this,this.advancedEl),this.buildButtons(this.buttonsEl)}onClose(){this.editor?.destroy()}buildProperties(t){}buildSeparator(t){}buildConditions(t){}buildDice(t){}};Is=new WeakSet,qd=function(t){t.empty(),t.ontoggle=()=>{this.plugin.settings.showAdvanced=t.open,this.plugin.saveSettings()};let i=t.createEl("summary");new me.Setting(i).setHeading().setName("Advanced Settings"),i.createDiv("collapser").createDiv("handle"),this.buildAdvanced(t.createDiv())};var Uo=class extends Ms{buildProperties(e){e.empty(),new me.Setting(e).setName("Icon").setDesc("Choose the icon to use for the button.").addText(t=>{t.setValue(this.block.icon);let i=(0,me.getIconIds)().map(s=>s.replace(/^lucide-/,""));new Es(this.app,t,i).onSelect(async s=>{this.block.icon=s.item,this.buildProperties(e)}),t.inputEl.onblur=async()=>{let s=t.inputEl.value?.trim()?t.inputEl.value.trim():"/";this.block.icon=s,this.buildProperties(e)}}).addExtraButton(t=>{t.setIcon(this.block.icon).setDisabled(!0)}),new me.Setting(e).setName("Action").setDesc("Choose a Command to run when this action is executed.").addText(t=>{t.setValue(this.block.action);let i=this.app.commands.listCommands();new Ds(this.app,t,i).onSelect(async s=>{this.block.action=s.item.id}),t.inputEl.onblur=async()=>{let s=t.inputEl.value?.trim()?t.inputEl.value.trim():"/";this.block.action=i.find(r=>r.name.toLowerCase()===s?.toLowerCase())?.id}})}buildAdvanced(e){e.empty(),new me.Setting(e).setHeading().setName("Callback").setDesc(createFragment(i=>{i.createSpan({text:"Executing the action will run the callback. Any registered commands will "}),i.createEl("strong",{text:"not"}),i.createSpan({text:" be ran."}),i.createEl("br"),i.createSpan({text:"The callback will receive the "}),i.createEl("code",{text:"monster"}),i.createSpan({text:" parameter. "})}));let t=new me.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=jt(t.inputEl,ri.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}},ai=class extends Ms{buildProperties(e){e.empty();let t=this.block;new me.Setting(e).setName("Link Monster Property").addText(i=>i.setValue(t.properties[0]).onChange(a=>{t.properties[0]=a}))}buildAdvanced(e){if(e.empty(),this.plugin.canUseDiceRoller){new me.Setting(e).setHeading().setName("Dice Callback").setDesc(createFragment(i=>{i.createSpan({text:"The block will run the callback and use the returned values for the dice strings."}),i.createEl("br"),i.createSpan({text:"The callback will receive the "}),i.createEl("code",{text:"monster"}),i.createSpan({text:" and "}),i.createEl("code",{text:"property"}),i.createSpan({text:"parameters. Dice callbacks should return an array of strings and objects, with the objects defining the dice rolls:"}),i.createEl("br"),me.MarkdownRenderer.render(this.plugin.app,"```ts\ninterface DiceCallbackObject {\n text: string // string to be parsed into a dice roll\n original?: string // optional, shown in parenthesis\n}\n```",i.createDiv(),"",new me.Component),i.createEl("br"),i.createEl("span",{text:"For example: "}),i.createEl("br"),me.MarkdownRenderer.render(this.plugin.app,'```ts\nconst diceText = monster.stats[5] + "d20 + 2";\nreturn ["The monster guesses you have: ", { text: diceText }, " freckles."];\n```',i.createDiv(),"",new me.Component)}));let t=new me.TextAreaComponent(e).setValue(this.block.diceCallback);t.inputEl.addClasses(["statblock-textarea","statblock-textarea-small"]),this.editor=jt(t.inputEl,ri.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.diceCallback=i.state.doc.toString())}))}}buildSeparator(e){}buildConditions(e){e.empty();let t=this.block;new me.Setting(e).setName("Conditional").setDesc("The block will not be added if the associated properties are not present.").addToggle(i=>{i.setValue(t.conditioned).onChange(a=>{t.conditioned=a,this.buildConditions(e)})}),this.block.conditioned||new me.Setting(e).setName("Fallback").setDesc("If not present, this text will be displayed.").addText(i=>{t.fallback||(t.fallback="-"),i.setValue(t.fallback).onChange(a=>{t.fallback=a})}),new me.Setting(e).setName("Has Rule").setDesc("If present, the block will have a horizontal rule placed after it.").addToggle(i=>{i.setValue(t.hasRule).onChange(a=>t.hasRule=a)})}buildDice(e){e.empty();let t=this.block;this.plugin.canUseDiceRoller&&(new me.Setting(e).setName("Parse for Dice").setDesc("The plugin will attempt to add dice rollers as specified.").addToggle(i=>i.setValue(t.dice).onChange(a=>{t.dice=a,this.buildDice(e)})),t.dice&&new me.Setting(e.createDiv()).setName("Link Dice to Property").setDesc("The dice roller will parse this property instead of the original.").addText(i=>{i.setValue(`${t.diceProperty}`).onChange(a=>{t.diceProperty=a})}))}},si=class extends ai{buildAdvanced(e){super.buildAdvanced(e)}},Go=class extends ai{buildProperties(e){super.buildProperties(e),new me.Setting(e).setName("Header Size").setDesc("The heading will use this size.").addDropdown(t=>{this.block.size||this.block.size==1,t.addOptions({1:"H1",2:"H2",3:"H3",4:"H4",5:"H5",6:"H6"}).setValue(`${this.block.size}`).onChange(i=>this.block.size=Number(i))})}},Ko=class extends si{buildAdvanced(e){super.buildAdvanced(e),new me.Setting(e).setHeading().setName("Callback").setDesc(createFragment(i=>{i.createSpan({text:"The block will run the callback and use the returned string as the property."}),i.createEl("br"),i.createSpan({text:"The callback will receive the "}),i.createEl("code",{text:"monster"}),i.createSpan({text:" parameter. The callback should return a string. For example: "}),i.createEl("code",{text:"return monster.name"}),i.createEl("br"),i.createEl("strong",{text:"Please Note: This will not run if a dice callback is provided."})}));let t=new me.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=jt(t.inputEl,ri.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}onClose(){this.editor?.destroy()}buildProperties(e){super.buildProperties(e),new me.Setting(e).setName("Do Not Add Property as CSS Class").setDesc("Enable this to prevent adding the property to the containing HTML element as a CSS class. This can be used to avoid collisions with native Obsidian CSS.").addToggle(t=>{t.setValue(this.block.doNotAddClass).onChange(i=>{this.block.doNotAddClass=i,this.display()})}),new me.Setting(e).setName("Display Text").setDesc("This text will be used for the property name.").addText(t=>{t.setValue(this.block.display).onChange(i=>this.block.display=i)})}},$o=class extends si{buildProperties(e){super.buildProperties(e),new me.Setting(e).setName("Display Text").setDesc("This text will be used for the property name.").addText(t=>{t.setValue(this.block.display).onChange(i=>this.block.display=i)})}},Yo=class extends si{buildProperties(e){super.buildProperties(e),new me.Setting(e).setName("Trait Name").setDesc("Name to display for the Spellcasting trait. Defaults to Spellcasting if not provided.").addText(t=>{t.setValue(this.block.heading).onChange(i=>this.block.heading=i)})}},Jo=class extends ai{buildProperties(e){e.empty();let t=this.block,i=e.createDiv("statblock-additional-container"),a="";new me.Setting(i).setHeading().setName("Link Monster Properties").addText(o=>o.setPlaceholder("property").setValue(a).onChange(l=>a=l)).addExtraButton(o=>o.setIcon("plus-with-circle").onClick(()=>{if(!a||!a.length){new me.Notice("A valid property must be supplied.");return}t.properties.push(a),this.buildProperties(e)}));let s=i.createDiv("additional");new Cd({target:s,props:{properties:this.block.properties.map(o=>({prop:o,id:U()}))}}).$on("sorted",o=>{t.properties=[...o.detail]})}buildSeparator(e){e.empty(),new me.Setting(e).setName("Separator").setDesc("Text separating properties").addText(t=>{t.setValue(this.block.separator).onChange(i=>{if(i===" "){this.block.separator=i;return}this.block.separator=(i??"").trim().length===0?", ":i})})}},Xo=class extends ai{buildAdvanced(e){super.buildAdvanced(e),new me.Setting(e).setHeading().setName("Ability Modifier Calculation").setDesc(createFragment(i=>{i.createSpan({text:"Allows a custom modifier for the stat."}),i.createEl("br"),i.createSpan({text:"Variables "}),i.createEl("code",{text:"stat"}),i.createSpan({text:" and "}),i.createEl("code",{text:"monster"}),i.createSpan({text:"are accessible, use these to calculate the modifier."})}));let t=new me.TextAreaComponent(e).setValue(this.block.modifier);t.inputEl.addClasses(["statblock-textarea","statblock-textarea-small"]),this.editor=jt(t.inputEl,ri.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.modifier=i.state.doc.toString())}))}buildProperties(e){super.buildProperties(e);let t=e.createDiv("statblock-additional-container"),i="";new me.Setting(t).setHeading().setName("Table Headers").addText(s=>s.setPlaceholder("header").setValue(i).onChange(r=>i=r)).addExtraButton(s=>s.setIcon("plus-with-circle").onClick(()=>{if(!i||!i.length){new me.Notice("A valid property must be supplied.");return}this.block.headers.push(i),this.buildProperties(e)}));let a=t.createDiv("additional");new kd({target:a,props:{headers:this.block.headers}}).$on("sorted",s=>{this.block.headers=[...s.detail?.map(r=>r.name)??[]]}),new me.Setting(e).setName("Calculate Modifiers").setDesc("The block will attempt to calculate modifiers for table values.").addToggle(s=>{s.setValue(this.block.calculate).onChange(r=>{this.block.calculate=r})})}},Qo=class extends si{buildProperties(e){super.buildProperties(e),new me.Setting(e).setName("Do Not Add Property as CSS Class").setDesc("Disable this to prevent adding the property to the containing HTML element as a CSS class. This can be used to avoid collisions with native Obsidian CSS.").addToggle(i=>{i.setValue(this.block.doNotAddClass).onChange(a=>{this.block.doNotAddClass=a,this.display()})}),new me.Setting(e).setName("Use Monster Property for Heading").setDesc("The Section heading will be set to the value of the specified property.").addToggle(i=>{i.setValue(this.block.headingProp).onChange(a=>{this.block.headingProp=a,this.display()})}),new me.Setting(e).setName("Section Heading").setDesc(this.block.headingProp?"The section will use this property for the section heading. If the property does not exist or is blank, the section heading will not appear.":"This text will be used for the section heading. Can be left blank.").addText(i=>{i.setValue(this.block.heading).onChange(a=>this.block.heading=a)}),new me.Setting(e).setName("Section Subheading Text").setDesc(createFragment(i=>{i.createSpan({text:"Text entered here will appear directly after the section heading, before the actual traits. Use "}),i.createEl("code",{text:"{{monster}}"}),i.createSpan({text:" to insert the current monster's name."})})).controlEl.detach(),new me.TextAreaComponent(this.contentEl).setValue(this.block.subheadingText).onChange(i=>this.block.subheadingText=i)}buildAdvanced(e){super.buildAdvanced(e),new me.Setting(e).setHeading().setName("Callback").setDesc(createFragment(i=>{i.createSpan({text:"The block will run the callback and use the returned string as the property."}),i.createEl("br"),i.createSpan({text:"The callback will receive the "}),i.createEl("code",{text:"monster"}),i.createSpan({text:" and "}),i.createEl("code",{text:"property"}),i.createSpan({text:" parameters. The callback should return a string. For example: "}),i.createEl("code",{text:"return monster.name"}),i.createEl("br"),i.createEl("strong",{text:"Please Note: This will not run if a dice callback is provided."})}));let t=new me.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=jt(t.inputEl,ri.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}},Zo=class extends si{buildAdvanced(e){super.buildAdvanced(e),new me.Setting(e).setHeading().setName("Text to Show").setDesc(createFragment(t=>{t.createSpan({text:"The block will "}),t.createEl("strong",{text:"always"}),t.createSpan({text:" display the text entered here."})})),new me.TextAreaComponent(e).setValue(this.block.text).onChange(t=>{this.block.text=t})}buildProperties(e){super.buildProperties(e),new me.Setting(e).setName("Use Monster Property for Heading").setDesc("The Section heading will be set to the value of the specified property.").addToggle(t=>{t.setValue(this.block.headingProp).onChange(i=>{this.block.headingProp=i,this.display()})}),new me.Setting(e).setName("Section Heading").setDesc(this.block.headingProp?"The section will use this property for the section heading. If the property does not exist or is blank, the section heading will not appear.":"This text will be used for the section heading. Can be left blank.").addText(t=>{t.setValue(this.block.heading).onChange(i=>this.block.heading=i)})}};function Kb(n){re(n,"svelte-1e3b779",".statblock-creator-container.svelte-1e3b779.svelte-1e3b779{display:flex;justify-content:space-between;width:100%;height:100%;gap:0.25rem}body:not(.is-mobile) .statblock-creator-container.svelte-1e3b779:not(:hover)>.icons.svelte-1e3b779{visibility:hidden}.statblock-creator-block.svelte-1e3b779.svelte-1e3b779{width:100%}.icons.svelte-1e3b779.svelte-1e3b779{display:flex;justify-content:flex-end}.statblock-creator-container.svelte-1e3b779 .icons.svelte-1e3b779{align-items:center}.icon.svelte-1e3b779:not(:first-child) .clickable-icon{margin-left:0}.layout.svelte-1e3b779.svelte-1e3b779{border:2px dashed grey}")}function $b(n){let e,t;return e=new pd({props:{block:n[0],plugin:n[1]}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,a){let s={};a&1&&(s.block=i[0]),a&2&&(s.plugin=i[1]),e.$set(s)},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function Yb(n){let e;return{c(){e=pe("JavaScript")},m(t,i){D(t,e,i)},p:N,i:N,o:N,d(t){t&&x(e)}}}function jd(n){let e,t,i,a,s=[Yb,$b],r=[];function o(l,c){return l[0].type=="javascript"?0:l[0].type!="ifelse"&&l[0].type!="collapse"?1:-1}return~(t=o(n,-1))&&(i=r[t]=s[t](n)),{c(){e=v("div"),i&&i.c(),g(e,"class","statblock-creator-block svelte-1e3b779"),oe(e,"layout",n[0].type=="layout")},m(l,c){D(l,e,c),~t&&r[t].m(e,null),a=!0},p(l,c){let d=t;t=o(l,c),t===d?~t&&r[t].p(l,c):(i&&(ce(),I(r[d],1,1,()=>{r[d]=null}),ue()),~t?(i=r[t],i?i.p(l,c):(i=r[t]=s[t](l),i.c()),E(i,1),i.m(e,null)):i=null),(!a||c&1)&&oe(e,"layout",l[0].type=="layout")},i(l){a||(E(i),a=!0)},o(l){I(i),a=!1},d(l){l&&x(e),~t&&r[t].d()}}}function Jb(n){let e,t=n[0],i,a,s,r,o,l,c,d,u,h,m=jd(n);return{c(){e=v("div"),m.c(),i=R(),a=v("div"),s=v("div"),o=R(),l=v("div"),g(s,"class","icon svelte-1e3b779"),g(l,"class","icon svelte-1e3b779"),g(a,"class","icons svelte-1e3b779"),g(e,"class","statblock-creator-container svelte-1e3b779")},m(f,p){D(f,e,p),m.m(e,null),y(e,i),y(e,a),y(a,s),y(a,o),y(a,l),d=!0,u||(h=[X(r=n[2].call(null,s)),X(c=n[3].call(null,l))],u=!0)},p(f,[p]){p&1&&j(t,t=f[0])?(ce(),I(m,1,1,N),ue(),m=jd(f),m.c(),E(m,1),m.m(e,i)):m.p(f,p)},i(f){d||(E(m),d=!0)},o(f){I(m),d=!1},d(f){f&&x(e),m.d(f),u=!1,le(h)}}}function Xb(n,e,t){let{block:i}=e,{plugin:a}=e,{layout:s}=e,r=Me(),o=()=>{let u=Os(a,i,s);u.onClose=()=>{u.saved&&r("edited",u.block)},u.open()},l=u=>{new Ps.ExtraButtonComponent(u).setIcon("pencil").setTooltip("Edit Block").onClick(()=>{o()})},c=u=>{new Ps.ExtraButtonComponent(u).setIcon("plus").setTooltip("Add Condition").onClick(()=>{})},d=u=>{new Ps.ExtraButtonComponent(u).setIcon("trash").setTooltip("Delete Block").onClick(()=>r("trash",i))};return n.$$set=u=>{"block"in u&&t(0,i=u.block),"plugin"in u&&t(1,a=u.plugin),"layout"in u&&t(4,s=u.layout)},[i,a,l,d,s]}var el=class extends G{constructor(e){super(),K(this,e,Xb,Jb,j,{block:0,plugin:1,layout:4},Kb)}},Vd=el;var oi=require("obsidian");function Qb(n){re(n,"svelte-1swdhxf",".min-height{min-height:2rem}.block.svelte-1swdhxf.svelte-1swdhxf{display:flex;justify-content:flex-start;align-items:center}.item.svelte-1swdhxf.svelte-1swdhxf{display:grid;grid-template-columns:1fr;width:100%;padding:2px;margin:2px}.group.svelte-1swdhxf.svelte-1swdhxf{display:grid;grid-template-columns:1fr;border:2px dashed grey;min-height:2rem}.dropdown-icon.svelte-1swdhxf.svelte-1swdhxf{align-self:flex-start}.inline.svelte-1swdhxf.svelte-1swdhxf{display:flex;justify-content:space-between;flex-wrap:wrap;width:100%;height:100%;min-width:2rem}.action-icon.svelte-1swdhxf.svelte-1swdhxf{display:flex;align-items:center}.icon.svelte-1swdhxf.svelte-1swdhxf{display:flex}.statblock-creator-container.svelte-1swdhxf.svelte-1swdhxf{display:flex;justify-content:space-between;width:100%;height:100%;gap:0.25rem}.statblock-creator-container.action-container.svelte-1swdhxf.svelte-1swdhxf{justify-content:flex-start}body:not(.is-mobile) .statblock-creator-container.svelte-1swdhxf:not(:hover)>.icons.svelte-1swdhxf{visibility:hidden}.statblock-creator-block.svelte-1swdhxf.svelte-1swdhxf{width:100%}.icons.svelte-1swdhxf.svelte-1swdhxf{display:flex;justify-content:flex-end}.statblock-creator-container.svelte-1swdhxf .icons.svelte-1swdhxf{align-items:center}.icon.svelte-1swdhxf:not(:first-child) .clickable-icon{margin-left:0}.if-else-block-container.svelte-1swdhxf.svelte-1swdhxf{display:grid;grid-template-columns:1fr;border:2px solid grey;border-radius:0.25rem;min-height:2rem;padding:0.25rem}.collapse-container.svelte-1swdhxf.svelte-1swdhxf{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:0.25rem}.collapsible.svelte-1swdhxf.svelte-1swdhxf{border-left:2px solid grey;padding-left:0.25rem}")}function Ud(n,e,t){let i=n.slice();return i[32]=e[t],i[33]=e,i[34]=t,i}function Gd(n,e,t){let i=n.slice();return i[35]=e[t].condition,i[36]=e[t].nested,i[37]=e,i[38]=t,i}function Kd(n){let e,t,i,a,s;return{c(){e=v("div"),g(e,"class","icon svelte-1swdhxf"),g(e,"style",t=n[5]?"cursor: grab":"cursor: grabbing")},m(r,o){D(r,e,o),a||(s=[X(i=Fe.call(null,e,"grip-vertical")),z(e,"mousedown",n[8]),z(e,"touchstart",n[8])],a=!0)},p(r,o){o[0]&32&&t!==(t=r[5]?"cursor: grab":"cursor: grabbing")&&g(e,"style",t)},d(r){r&&x(e),a=!1,le(s)}}}function Zb(n){let e,t,i;return t=new Vd({props:{plugin:n[1],block:n[32],layout:n[2]}}),t.$on("trash",n[28]),t.$on("edited",n[29]),{c(){e=v("div"),ae(t.$$.fragment),g(e,"class","item svelte-1swdhxf")},m(a,s){D(a,e,s),te(t,e,null),i=!0},p(a,s){let r={};s[0]&2&&(r.plugin=a[1]),s[0]&1&&(r.block=a[32]),s[0]&4&&(r.layout=a[2]),t.$set(r)},i(a){i||(E(t.$$.fragment,a),i=!0)},o(a){I(t.$$.fragment,a),i=!1},d(a){a&&x(e),ne(t)}}}function e0(n){let e,t,i,a,s,r,o,l,c,d,u=n[32].icon&&$d(n);function h(){return n[26](n[32])}function m(){return n[27](n[32])}return{c(){e=v("div"),u&&u.c(),t=R(),i=v("div"),a=v("div"),r=R(),o=v("div"),g(a,"class","icon svelte-1swdhxf"),g(o,"class","icon svelte-1swdhxf"),g(i,"class","icons svelte-1swdhxf"),g(e,"class","action-container statblock-creator-container svelte-1swdhxf")},m(f,p){D(f,e,p),u&&u.m(e,null),y(e,t),y(e,i),y(i,a),y(i,r),y(i,o),c||(d=[X(s=n[13].call(null,a)),z(a,"click",h),X(l=n[14].call(null,o)),z(o,"click",m)],c=!0)},p(f,p){n=f,n[32].icon?u?u.p(n,p):(u=$d(n),u.c(),u.m(e,t)):u&&(u.d(1),u=null)},i:N,o:N,d(f){f&&x(e),u&&u.d(),c=!1,le(d)}}}function t0(n){let e,t,i,a,s=[],r=new Map,o,l,c,d,u,h,m,f,p,b,_=ye(n[32].conditions),S=w=>w[35];for(let w=0;w<_.length;w+=1){let k=Gd(n,_,w),A=S(k);r.set(A,s[w]=Yd(A,k))}function C(){return n[24](n[32])}function M(){return n[25](n[32])}return{c(){e=v("div"),t=v("div"),i=v("div"),a=v("div");for(let w=0;wBt(c,"blocks",L)),Re.push(()=>Bt(c,"plugin",B));function q(){return n[20](n[32])}function Z(){return n[21](n[32])}return{c(){e=v("div"),t=v("div"),i=v("div"),a=v("div"),r=R(),o=v("div"),P.c(),l=R(),ae(c.$$.fragment),h=R(),m=v("div"),f=v("div"),b=R(),_=v("div"),g(o,"class","collapsible svelte-1swdhxf"),g(i,"class","statblock-creator-block collapse-container svelte-1swdhxf"),g(f,"class","icon svelte-1swdhxf"),g(_,"class","icon svelte-1swdhxf"),g(m,"class","icons svelte-1swdhxf"),g(t,"class","statblock-creator-container svelte-1swdhxf"),g(e,"class","item svelte-1swdhxf")},m(ee,se){D(ee,e,se),y(e,t),y(t,i),y(i,a),y(i,r),y(i,o),P.m(o,null),y(o,l),te(c,o,null),y(t,h),y(t,m),y(m,f),y(m,b),y(m,_),C=!0,M||(w=[X(s=Fe.call(null,a,"chevrons-down-up")),X(p=n[13].call(null,f)),z(f,"click",q),X(S=n[14].call(null,_)),z(_,"click",Z)],M=!0)},p(ee,se){n=ee,A===(A=k(n,se))&&P?P.p(n,se):(P.d(1),P=A(n),P&&(P.c(),P.m(o,l)));let $={};!d&&se[0]&1&&(d=!0,$.blocks=n[32].nested,Lt(()=>d=!1)),!u&&se[0]&2&&(u=!0,$.plugin=n[1],Lt(()=>u=!1)),c.$set($)},i(ee){C||(E(c.$$.fragment,ee),C=!0)},o(ee){I(c.$$.fragment,ee),C=!1},d(ee){ee&&x(e),P.d(),ne(c),M=!1,le(w)}}}function i0(n){let e,t,i,a,s,r=n[32],o,l;function c(m){n[16](m,n[32])}function d(m){n[17](m)}let u={inline:n[32].type=="inline"};n[32].nested!==void 0&&(u.blocks=n[32].nested),n[1]!==void 0&&(u.plugin=n[1]),t=new Ni({props:u}),Re.push(()=>Bt(t,"blocks",c)),Re.push(()=>Bt(t,"plugin",d));let h=Jd(n);return{c(){e=v("div"),ae(t.$$.fragment),s=R(),h.c(),o=_e(),g(e,"class","item svelte-1swdhxf"),oe(e,"group",n[32].type=="group"||n[32].type=="inline")},m(m,f){D(m,e,f),te(t,e,null),D(m,s,f),h.m(m,f),D(m,o,f),l=!0},p(m,f){n=m;let p={};f[0]&1&&(p.inline=n[32].type=="inline"),!i&&f[0]&1&&(i=!0,p.blocks=n[32].nested,Lt(()=>i=!1)),!a&&f[0]&2&&(a=!0,p.plugin=n[1],Lt(()=>a=!1)),t.$set(p),(!l||f[0]&1)&&oe(e,"group",n[32].type=="group"||n[32].type=="inline"),f[0]&1&&j(r,r=n[32])?(h.d(1),h=Jd(n),h.c(),h.m(o.parentNode,o)):h.p(n,f)},i(m){l||(E(t.$$.fragment,m),l=!0)},o(m){I(t.$$.fragment,m),l=!1},d(m){m&&(x(e),x(s),x(o)),ne(t),h.d(m)}}}function $d(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","action-icon svelte-1swdhxf")},m(s,r){D(s,e,r),i||(a=X(t=Fe.call(null,e,n[32].icon)),i=!0)},p(s,r){n=s,t&&Pe(t.update)&&r[0]&1&&t.update.call(null,n[32].icon)},d(s){s&&x(e),i=!1,a()}}}function Yd(n,e){let t,i,a,s,r=e[35]+"",o,l,c,d,u,h,m;function f(_){e[22](_,e[36],e[37],e[38])}function p(_){e[23](_)}let b={draggable:!1};return e[36]!==void 0&&(b.blocks=e[36]),e[1]!==void 0&&(b.plugin=e[1]),c=new Ni({props:b}),Re.push(()=>Bt(c,"blocks",f)),Re.push(()=>Bt(c,"plugin",p)),{key:n,first:null,c(){t=v("div"),i=v("div"),a=v("small"),s=v("code"),o=pe(r),l=R(),ae(c.$$.fragment),h=R(),g(i,"class","condition"),g(t,"class","condition-container"),this.first=t},m(_,S){D(_,t,S),y(t,i),y(i,a),y(a,s),y(s,o),y(i,l),te(c,i,null),y(t,h),m=!0},p(_,S){e=_,(!m||S[0]&1)&&r!==(r=e[35]+"")&&we(o,r);let C={};!d&&S[0]&1&&(d=!0,C.blocks=e[36],Lt(()=>d=!1)),!u&&S[0]&2&&(u=!0,C.plugin=e[1],Lt(()=>u=!1)),c.$set(C)},i(_){m||(E(c.$$.fragment,_),m=!0)},o(_){I(c.$$.fragment,_),m=!1},d(_){_&&x(t),ne(c)}}}function a0(n){let e;return{c(){e=v("span"),e.textContent="Collapse"},m(t,i){D(t,e,i)},p:N,d(t){t&&x(e)}}}function s0(n){let e,t=n[32].heading+"",i;return{c(){e=v("span"),i=pe(t)},m(a,s){D(a,e,s),y(e,i)},p(a,s){s[0]&1&&t!==(t=a[32].heading+"")&&we(i,t)},d(a){a&&x(e)}}}function Jd(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","dropdown-icon svelte-1swdhxf")},m(s,r){D(s,e,r),i||(a=X(t=n[12].call(null,e,n[32])),i=!0)},p(s,r){n=s,t&&Pe(t.update)&&r[0]&1&&t.update.call(null,n[32])},d(s){s&&x(e),i=!1,a()}}}function Xd(n){let e,t,i;return t=new rs({}),{c(){e=v("div"),ae(t.$$.fragment),g(e,"aria-label","Block Has Rule")},m(a,s){D(a,e,s),te(t,e,null),i=!0},i(a){i||(E(t.$$.fragment,a),i=!0)},o(a){I(t.$$.fragment,a),i=!1},d(a){a&&x(e),ne(t)}}}function Qd(n,e){let t,i,a,s,r,o,l,c,d,u=N,h,m=e[3]&&Kd(e),f=[i0,n0,t0,e0,Zb],p=[];function b(S,C){return S[32].type=="group"||S[32].type=="inline"?0:S[32].type=="collapse"?1:S[32].type=="ifelse"?2:S[32].type=="action"?3:4}r=b(e,[-1,-1]),o=p[r]=f[r](e);let _="hasRule"in e[32]&&e[32].hasRule&&Xd(e);return{key:n,first:null,c(){t=v("div"),i=v("div"),a=v("div"),m&&m.c(),s=R(),o.c(),l=R(),_&&_.c(),c=R(),g(a,"class","block svelte-1swdhxf"),g(i,"class","block-container"),this.first=t},m(S,C){D(S,t,C),y(t,i),y(i,a),m&&m.m(a,null),y(a,s),p[r].m(a,null),y(i,l),_&&_.m(i,null),y(t,c),h=!0},p(S,C){e=S,e[3]?m?m.p(e,C):(m=Kd(e),m.c(),m.m(a,s)):m&&(m.d(1),m=null);let M=r;r=b(e,C),r===M?p[r].p(e,C):(ce(),I(p[M],1,1,()=>{p[M]=null}),ue(),o=p[r],o?o.p(e,C):(o=p[r]=f[r](e),o.c()),E(o,1),o.m(a,null)),"hasRule"in e[32]&&e[32].hasRule?_?C[0]&1&&E(_,1):(_=Xd(e),_.c(),E(_,1),_.m(i,null)):_&&(ce(),I(_,1,1,()=>{_=null}),ue())},r(){d=t.getBoundingClientRect()},f(){Dn(t),u()},a(){u(),u=Tn(t,d,Pn,{duration:tl})},i(S){h||(E(o),E(_),h=!0)},o(S){I(o),I(_),h=!1},d(S){S&&x(t),m&&m.d(),p[r].d(),_&&_.d()}}}function r0(n){let e,t,i=[],a=new Map,s,r,o,l,c=ye(n[0].filter(n[15])),d=u=>u[32].id;for(let u=0;u{t(0,a=a.filter(ie=>ie.id!=F.id)),i("sorted",a)},f=F=>{let ie=a.findIndex(Y=>Y.id==F.id);a.splice(ie,1,F),t(0,a)},p=F=>{let ie=Os(l,F,s);ie.onClose=()=>{ie.saved&&f(ie.block)},ie.open()},b=async(F,ie)=>{if(!("nested"in F))return;let Y=new oi.Menu().setNoIcon();ra.forEach(de=>{if(de[1]=="separator"){Y.addSeparator();return}Y.addItem(V=>{V.setTitle(de[1]).onClick(()=>{let H=ii(de[0]);H&&(F.nested=[...F.nested,H],t(0,a),i("sorted",a))})})}),Y.showAtMouseEvent(ie)},_=(F,ie)=>{new oi.ExtraButtonComponent(F).setIcon(r?"vertical-three-dots":"plus-circle"),F.onclick=Y=>{r?new oi.Menu().addItem(de=>{de.setTitle("Add").setIcon("plus-with-circle").onClick(V=>{b(ie,Y)})}).addItem(de=>de.setTitle("Edit").setIcon("pencil").onClick(()=>{p(ie)})).addItem(de=>de.setTitle("Delete").setIcon("trash").onClick(()=>m(ie))).showAtMouseEvent(Y):b(ie,Y)}},S=F=>{new oi.ExtraButtonComponent(F).setIcon("pencil").setTooltip("Edit Block")},C=F=>{new oi.ExtraButtonComponent(F).setIcon("trash").setTooltip("Delete Block")},M=F=>F.id!==ni;function w(F,ie){n.$$.not_equal(ie.nested,F)&&(ie.nested=F,t(0,a))}function k(F){l=F,t(1,l)}function A(F,ie){n.$$.not_equal(ie.nested,F)&&(ie.nested=F,t(0,a))}function P(F){l=F,t(1,l)}let L=F=>p(F),B=F=>m(F);function O(F,ie,Y,de){Y[de].nested=F,t(0,a)}function q(F){l=F,t(1,l)}let Z=F=>p(F),ee=F=>m(F),se=F=>p(F),$=F=>m(F),W=F=>m(F.detail),J=F=>f(F.detail);return n.$$set=F=>{"blocks"in F&&t(0,a=F.blocks),"layout"in F&&t(2,s=F.layout),"draggable"in F&&t(3,r=F.draggable),"inline"in F&&t(4,o=F.inline),"plugin"in F&&t(1,l=F.plugin)},[a,l,s,r,o,c,d,u,h,m,f,p,_,S,C,M,w,k,A,P,L,B,O,q,Z,ee,se,$,W,J]}var Ni=class extends G{constructor(e){super(),K(this,e,o0,r0,j,{blocks:0,layout:2,draggable:3,inline:4,plugin:1},Qb,[-1,-1])}},Zd=Ni;var Rs=require("obsidian");function xt(n){return Ve(n)}function li(n,e){return Et(n,e)}function l0(n){let e,t,i,a,s,r,o,l;return s=new Zd({props:{blocks:n[1],plugin:n[3],layout:n[0].id}}),s.$on("sorted",n[4]),{c(){e=v("div"),t=v("div"),a=R(),ae(s.$$.fragment),g(e,"class","creator-container")},m(c,d){D(c,e,d),y(e,t),y(e,a),te(s,e,null),r=!0,o||(l=X(i=n[5].call(null,t)),o=!0)},p(c,[d]){let u={};d&2&&(u.blocks=c[1]),d&1&&(u.layout=c[0].id),s.$set(u)},i(c){r||(E(s.$$.fragment,c),r=!0)},o(c){I(s.$$.fragment,c),r=!1},d(c){c&&x(e),ne(s),o=!1,l()}}}function c0(n,e,t){let i,a,s=xt("layout");Se(n,s,d=>t(0,a=d));let r=xt("plugin"),o=d=>{Ae(s,a.blocks=[...d.detail],a)},l=d=>{new Rs.Setting(d).setHeading().setName("Blocks").addExtraButton(u=>{u.setIcon("plus-with-circle").setTooltip("Add Block").extraSettingsEl.onClickEvent(h=>c(h))})},c=async d=>{let u=new Rs.Menu().setNoIcon();ra.forEach(h=>{if(h[1]=="separator"){u.addSeparator();return}u.addItem(m=>{m.setTitle(h[1]).onClick(()=>{let f=ii(h[0]);f&&Ae(s,a.blocks=[...a.blocks,f],a)})})}),u.showAtMouseEvent(d)};return n.$$.update=()=>{n.$$.dirty&1&&t(1,i=a.blocks)},[a,i,s,r,o,l]}var nl=class extends G{constructor(e){super(),K(this,e,c0,l0,j,{})}},il=nl;var va=require("obsidian");var ba=require("obsidian");function u0(n){re(n,"svelte-1cgghnt",".drop-items.svelte-1cgghnt.svelte-1cgghnt{width:100%;margin:0.5rem 0}.drop-item-container.svelte-1cgghnt .icon.svelte-1cgghnt,.icons.svelte-1cgghnt.svelte-1cgghnt{display:flex;align-items:center}.drop-item-container.svelte-1cgghnt.svelte-1cgghnt{display:grid;grid-template-columns:auto 1fr auto;align-items:center;justify-content:space-between;gap:1rem;width:100%}.drop-item-container.svelte-1cgghnt.svelte-1cgghnt:not(.draggable){cursor:inherit !important}.drop-item-container.svelte-1cgghnt.svelte-1cgghnt:not(:last-child){margin-bottom:0.5rem}")}function eh(n,e,t){let i=n.slice();return i[15]=e[t],i}function th(n){let e,t,i,a,s;return{c(){e=v("div"),g(e,"class","icon svelte-1cgghnt"),g(e,"style",t=n[5]?"cursor: grab":"cursor: grabbing")},m(r,o){D(r,e,o),a||(s=[X(i=Fe.call(null,e,"grip-vertical")),z(e,"mousedown",n[6]),z(e,"touchstart",n[6])],a=!0)},p(r,o){o&32&&t!==(t=r[5]?"cursor: grab":"cursor: grabbing")&&g(e,"style",t)},d(r){r&&x(e),a=!1,le(s)}}}function nh(n){let e,t,i,a,s,r,o,l;return{c(){e=v("div"),t=v("div"),a=R(),s=v("div"),g(t,"class","icon svelte-1cgghnt"),g(s,"class","icon svelte-1cgghnt"),g(e,"class","icons svelte-1cgghnt")},m(c,d){D(c,e,d),y(e,t),y(e,a),y(e,s),o||(l=[X(i=n[9].call(null,t,n[15])),X(r=n[10].call(null,s,n[15]))],o=!0)},p(c,d){n=c,i&&Pe(i.update)&&d&1&&i.update.call(null,n[15]),r&&Pe(r.update)&&d&1&&r.update.call(null,n[15])},d(c){c&&x(e),o=!1,le(l)}}}function ih(n,e){let t,i,a,s,r,o,l,c=N,d,u=e[2]&&th(e);var h=e[4];function m(p,b){return{props:{item:p[15]}}}h&&(s=Cr(h,m(e)));let f=e[3]&&nh(e);return{key:n,first:null,c(){t=v("div"),u&&u.c(),i=R(),a=v("div"),s&&ae(s.$$.fragment),r=R(),f&&f.c(),o=R(),g(a,"class","drop-item"),oe(a,"type",e[1]),g(t,"class","drop-item-container svelte-1cgghnt"),oe(t,"draggable",e[2]),this.first=t},m(p,b){D(p,t,b),u&&u.m(t,null),y(t,i),y(t,a),s&&te(s,a,null),y(t,r),f&&f.m(t,null),y(t,o),d=!0},p(p,b){if(e=p,e[2]?u?u.p(e,b):(u=th(e),u.c(),u.m(t,i)):u&&(u.d(1),u=null),b&16&&h!==(h=e[4])){if(s){ce();let _=s;I(_.$$.fragment,1,0,()=>{ne(_,1)}),ue()}h?(s=Cr(h,m(e,b)),ae(s.$$.fragment),E(s.$$.fragment,1),te(s,a,null)):s=null}else if(h){let _={};b&1&&(_.item=e[15]),s.$set(_)}(!d||b&2)&&oe(a,"type",e[1]),e[3]?f?f.p(e,b):(f=nh(e),f.c(),f.m(t,o)):f&&(f.d(1),f=null),(!d||b&4)&&oe(t,"draggable",e[2])},r(){l=t.getBoundingClientRect()},f(){Dn(t),c()},a(){c(),c=Tn(t,l,Pn,{duration:al})},i(p){d||(s&&E(s.$$.fragment,p),d=!0)},o(p){s&&I(s.$$.fragment,p),d=!1},d(p){p&&x(t),u&&u.d(),s&&ne(s),f&&f.d()}}}function d0(n){let e,t=[],i=new Map,a,s,r,o,l=ye(n[0].filter(n[12])),c=d=>d[15].id;for(let d=0;d{new ba.ExtraButtonComponent(S).setIcon("wrench").onClick(()=>c("advanced",C))},b=(S,C)=>{new ba.ExtraButtonComponent(S).setIcon("trash").onClick(()=>c("trash",C))},_=S=>S.id!==ni;return n.$$set=S=>{"items"in S&&t(0,i=S.items),"type"in S&&t(1,a=S.type),"draggable"in S&&t(2,s=S.draggable),"showIcons"in S&&t(3,r=S.showIcons),"component"in S&&t(4,o=S.component),"onDrop"in S&&t(11,l=S.onDrop)},[i,a,s,r,o,h,u,m,f,p,b,l,_]}var sl=class extends G{constructor(e){super(),K(this,e,h0,d0,j,{items:0,type:1,draggable:2,showIcons:3,component:4,onDrop:11},u0)}},ah=sl;function sh(n){let e,t=n[0].desc+"",i;return{c(){e=v("div"),i=pe(t),g(e,"class","setting-item-description")},m(a,s){D(a,e,s),y(e,i)},p(a,s){s&1&&t!==(t=a[0].desc+"")&&we(i,t)},d(a){a&&x(e)}}}function f0(n){let e,t,i,a,s=n[0].regex+"",r,o,l,c=n[0].desc&&sh(n);return{c(){e=v("div"),t=v("div"),i=v("code"),a=pe("/"),r=pe(s),o=pe("/"),l=R(),c&&c.c(),g(t,"class","setting-item-name"),g(e,"class","dice-parsing setting-item-info")},m(d,u){D(d,e,u),y(e,t),y(t,i),y(i,a),y(i,r),y(i,o),y(e,l),c&&c.m(e,null)},p(d,[u]){u&1&&s!==(s=d[0].regex+"")&&we(r,s),d[0].desc?c?c.p(d,u):(c=sh(d),c.c(),c.m(e,null)):c&&(c.d(1),c=null)},i:N,o:N,d(d){d&&x(e),c&&c.d()}}}function m0(n,e,t){let{item:i}=e;return n.$$set=a=>{"item"in a&&t(0,i=a.item)},[i]}var rl=class extends G{constructor(e){super(),K(this,e,m0,f0,j,{item:0})}},rh=rl;var Zt=require("obsidian");var ya=class extends wt{constructor(t,i){super(t);this.item={regex:"",parser:"",id:U()};this.saved=!0;i?(this.editing=!0,this.item={...i}):this.editing=!1}onOpen(){this.titleEl.setText(this.editing?"Editing Dice Parser":"New Dice Parser"),this.display()}async display(){this.contentEl.empty(),new Zt.Setting(this.contentEl).setName("Example").setDesc("Add an example, for reference only.").addText(t=>{t.setValue(this.item.desc).onChange(i=>this.item.desc=i)}),this.buildRegEx(this.contentEl.createDiv()),this.buildParser(this.contentEl.createDiv()),this.buildTester(this.contentEl.createDiv()),new Zt.Setting(this.contentEl).addExtraButton(t=>t.setIcon("cross").setTooltip("Cancel").onClick(()=>{this.saved=!1,this.close()}))}buildTester(t){t.empty()}buildRegEx(t){t.empty(),new Zt.Setting(t).setHeading().setName("Regular Expression").setDesc(""),this.regex=pa(t,this.item.regex,["statblock-textarea-x-small"],i=>{this.item.regex=i})}getCallbackDescription(){return createFragment(t=>{t.createSpan({text:"The dice parser callback needs to parse the results of the regular expression and return the correct dice string to display."}),t.createEl("br"),t.createEl("br"),t.createSpan({text:"The callback will have the "}),t.createEl("code",{text:"original"}),t.createSpan({text:" (the matched text), "}),t.createEl("code",{text:"matches"}),t.createSpan({text:" (the RegExpMatchArray), and "}),t.createEl("code",{text:"monster"}),t.createSpan({text:" (current monster being rendered) parameters available in the callback."}),t.createEl("br"),t.createEl("br"),t.createSpan({text:"The callback should return an instance of:"}),Zt.MarkdownRenderer.render(this.plugin.app,"```ts\ninterface DiceCallbackObject {\n text: string // string to be parsed into a dice roll\n original?: string // optional, shown in parenthesis\n}\n```",t.createDiv(),"",new Zt.Component),t.createEl("br"),t.createEl("span",{text:"For example: "}),t.createEl("br"),Zt.MarkdownRenderer.render(this.plugin.app,'```ts\nreturn { text: "1d20 + 3" };\n```',t.createDiv(),"",new Zt.Component)})}buildParser(t){t.empty();let i=new Zt.Setting(t).setHeading().setName("Callback").addExtraButton(a=>{let s=!1;a.setIcon("help-circle").onClick(()=>{s?i.setDesc(""):i.setDesc(this.getCallbackDescription()),s=!s})});i.settingEl.style.alignItems="flex-start",this.parser=pa(t,this.item.parser,[],a=>{this.item.parser=a})}};function g0(n){re(n,"svelte-tnyfuy",".defaults.svelte-tnyfuy{color:var(--text-muted);font-style:italic;font-size:smaller}")}function p0(n){let e,t,i,a,s,r;return{c(){e=v("div"),i=R(),a=v("span"),a.textContent=`This layout does not have any dice parsers defined. Add one to begin parsing for dice.`,g(a,"class","defaults svelte-tnyfuy")},m(o,l){D(o,e,l),D(o,i,l),D(o,a,l),s||(r=X(t=n[7].call(null,e)),s=!0)},d(o){o&&(x(e),x(i),x(a)),s=!1,r()}}}function b0(n){let e,t,i,a,s,r;return{c(){e=v("div"),i=R(),a=v("span"),a.textContent=`This layout is currently using the default dice parsers. Add a custom dice parser to override this behavior.`,g(a,"class","defaults svelte-tnyfuy")},m(o,l){D(o,e,l),D(o,i,l),D(o,a,l),s||(r=X(t=n[7].call(null,e)),s=!0)},d(o){o&&(x(e),x(i),x(a)),s=!1,r()}}}function oh(n){let e,t;return e=new ah({props:{type:"dice",component:rh,items:n[1]??ns(),onDrop:n[3],showIcons:n[1]!=null,draggable:n[1]!=null}}),e.$on("advanced",n[11]),e.$on("trash",n[12]),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,a){let s={};a&2&&(s.items=i[1]??ns()),a&2&&(s.showIcons=i[1]!=null),a&2&&(s.draggable=i[1]!=null),e.$set(s)},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function y0(n){let e,t,i,a,s,r,o,l,c,d,u,h,m,f,p,b,_,S,C,M,w,k,A,P,L=n[1],B,O,q;function Z(W,J){if(!W[1])return b0;if(W[1].length==0)return p0}let ee=Z(n,-1),se=ee&&ee(n),$=oh(n);return{c(){e=v("div"),t=v("div"),t.innerHTML='
Columns
Always try to split into this many columns, regardless of height.
',i=R(),a=v("div"),s=v("input"),r=R(),o=v("div"),l=v("div"),l.innerHTML='
Column width
Width in pixels. Default: 400px
',c=R(),d=v("div"),u=v("input"),h=R(),m=v("div"),f=v("div"),f.innerHTML='
Force columns
Ignore available space when calculating columns.
',p=R(),b=v("div"),S=R(),C=v("div"),w=R(),k=v("div"),A=v("div"),se&&se.c(),P=R(),$.c(),g(t,"class","setting-item-info"),g(s,"type","number"),g(s,"min","0"),g(a,"class","setting-item-control"),g(e,"class","setting-item"),g(l,"class","setting-item-info"),g(u,"type","number"),g(u,"min","0"),g(d,"class","setting-item-control"),g(o,"class","setting-item"),g(f,"class","setting-item-info"),g(b,"class","setting-item-control"),g(m,"class","setting-item"),g(A,"class","additional"),g(k,"class","dice-parsing statblock-additional-container")},m(W,J){D(W,e,J),y(e,t),y(e,i),y(e,a),y(a,s),ct(s,n[0].columns),D(W,r,J),D(W,o,J),y(o,l),y(o,c),y(o,d),y(d,u),ct(u,n[0].columnWidth),D(W,h,J),D(W,m,J),y(m,f),y(m,p),y(m,b),D(W,S,J),D(W,C,J),D(W,w,J),D(W,k,J),y(k,A),se&&se.m(A,null),y(A,P),$.m(A,null),B=!0,O||(q=[z(s,"input",n[9]),z(u,"input",n[10]),X(_=n[8].call(null,b)),X(M=n[6].call(null,C))],O=!0)},p(W,[J]){J&1&&Kn(s.value)!==W[0].columns&&ct(s,W[0].columns),J&1&&Kn(u.value)!==W[0].columnWidth&&ct(u,W[0].columnWidth),ee!==(ee=Z(W,J))&&(se&&se.d(1),se=ee&&ee(W),se&&(se.c(),se.m(A,P))),J&2&&j(L,L=W[1])?(ce(),I($,1,1,N),ue(),$=oh(W),$.c(),E($,1),$.m(A,null)):$.p(W,J)},i(W){B||(E($),B=!0)},o(W){I($),B=!1},d(W){W&&(x(e),x(r),x(o),x(h),x(m),x(S),x(C),x(w),x(k)),se&&se.d(),$.d(W),O=!1,le(q)}}}function v0(n,e,t){let i,a,s=xt("layout");Se(n,s,_=>t(0,a=_));let r=xt("plugin");function o(_){Ae(s,a.diceParsing=[..._],a)}let l=_=>{let S=new ya(r,_);S.onClose=()=>{if(!S.saved)return;a.diceParsing==null&&Ae(s,a.diceParsing=[],a);let C=a.diceParsing.indexOf(_);C===-1?a.diceParsing.push(S.item):a.diceParsing.splice(C,1,S.item),s.set(a)},S.open()},c=_=>{t(1,i=i.filter(S=>S.id!=_.id)),Ae(s,a.diceParsing=[...i],a)},d=_=>{new va.Setting(_).setHeading().setName("Dice Parsing").setDesc(createFragment(S=>{S.createSpan({text:"Add "}),S.createEl("a",{href:"https://regex101.com",text:"regular expressions"}),S.createSpan({text:" to detect dice rolls inside your layout."}),S.createEl("br"),S.createSpan({text:"These are parsed in order, and the first one to trigger is what will be used."})})).addExtraButton(S=>{S.setIcon("plus-with-circle").onClick(()=>{l()})})},u=_=>{new va.Setting(_).setName(i==null?"Remove default parsers":"Restore default parsers").addButton(S=>{S.setIcon(i==null?"trash":"archive-restore").onClick(()=>{t(1,i=i==null?[]:null)})})},h=_=>{new va.ToggleComponent(_).setValue(a.forceColumns).onChange(()=>{Ae(s,a.forceColumns=!a.forceColumns,a)})};function m(){a.columns=Kn(this.value),s.set(a)}function f(){a.columnWidth=Kn(this.value),s.set(a)}let p=_=>l(_.detail),b=_=>c(_.detail);return n.$$.update=()=>{n.$$.dirty&1&&t(1,i=a.diceParsing?[...a.diceParsing]:null)},[a,i,s,o,l,c,d,u,h,m,f,p,b]}var ol=class extends G{constructor(e){super(),K(this,e,v0,y0,j,{},g0)}},ll=ol;var Jx=require("obsidian");var hl=require("obsidian");var wa=["primaryColor","ruleColor","backgroundColor","borderSize","borderColor","barColor","barBorderSize","barBorderColor","imageWidth","imageHeight","imageBorderSize","imageBorderColor","boxShadowColor","boxShadowXOffset","boxShadowYOffset","boxShadowBlur","fontColor","fontWeight","contentFont","contentFontSize","headingFont","headingFontColor","headingFontSize","headingFontVariant","headingFontWeight","propertyFont","propertyFontColor","propertyFontVariant","propertyFontSize","propertyFontWeight","propertyNameFont","propertyNameFontVariant","propertyNameFontSize","propertyNameFontColor","propertyNameFontWeight","sectionHeadingBorderSize","sectionHeadingBorderColor","sectionHeadingFont","sectionHeadingFontColor","sectionHeadingFontSize","sectionHeadingFontVariant","sectionHeadingFontWeight","subheadingFont","subheadingFontColor","subheadingFontSize","subheadingFontStyle","subheadingFontWeight","traitsFont","traitsFontColor","traitsFontSize","traitsFontWeight","traitsFontStyle","traitsNameFont","traitsNameFontColor","traitsNameFontSize","traitsNameFontWeight","traitsNameFontStyle"],cl={primaryColor:"#7a200d",ruleColor:"#922610",backgroundColor:"#fdf1dc",borderSize:"1px",borderColor:"#ddd",barColor:"#e69a28",barBorderSize:"1px",barBorderColor:"#000",imageWidth:"75px",imageHeight:"75px",imageBorderSize:"2px",imageBorderColor:"primaryColor",boxShadowColor:"#ddd",boxShadowXOffset:"0",boxShadowYOffset:"0",boxShadowBlur:"1.5em",fontColor:"primaryColor",fontWeight:"700",contentFont:'"Noto Sans", "Myriad Pro", Calibri, Helvetica, Arial, sans-serif',contentFontSize:"14px",headingFont:'"Libre Baskerville", "Lora", "Calisto MT", "Bookman Old Style", Bookman, "Goudy Old Style", Garamond, "Hoefler Text", "Bitstream Charter", Georgia, serif',headingFontColor:"fontColor",headingFontSize:"23px",headingFontVariant:"small-caps",headingFontWeight:"fontWeight",sectionHeadingBorderSize:"1px",sectionHeadingBorderColor:"primaryColor",sectionHeadingFont:null,sectionHeadingFontColor:"fontColor",sectionHeadingFontSize:"21px",sectionHeadingFontVariant:"small-caps",sectionHeadingFontWeight:"normal",subheadingFont:"contentFont",subheadingFontColor:"fontColor",subheadingFontSize:"12px",subheadingFontStyle:"italic",subheadingFontWeight:"normal",propertyFont:"contentFont",propertyFontColor:"fontColor",propertyFontVariant:"normal",propertyFontSize:"contentFontSize",propertyFontWeight:null,propertyNameFont:"contentFont",propertyNameFontColor:"fontColor",propertyNameFontWeight:null,propertyNameFontVariant:null,propertyNameFontSize:"contentFontSize",traitsFont:"contentFont",traitsFontColor:"fontColor",traitsFontSize:"contentFontSize",traitsFontWeight:null,traitsFontStyle:null,traitsNameFont:"contentFont",traitsNameFontColor:"fontColor",traitsNameFontSize:"contentFontSize",traitsNameFontWeight:"bold",traitsNameFontStyle:"italic"},Te={Light:"moonstone",Dark:"obsidian",None:"none"};function ul(n,e,t){let i=new Set,a=Li(n,e,t);for(;wa.includes(a)&&!i.has(a);)i.add(a),a=Li(n,a,t);return i}function lh(n,e,t){let i=Li(n,e,t);return i!=null&&wa.includes(i)}function Li(n,e,t){return(t!=Te.None?n?.[t]?.[e]:null)??n?.[e]??cl[e]??null}function Ns(n,e,t,i=new Set){i.add(e);let a=Li(n,e,t);return wa.includes(a)?i.has(a)?null:Ns(n,a,t,i):a}var ge=Object.freeze({Number:"Number",Color:"Color",Font:"Font",Size:"Size",Style:"Style",Variant:"Variant",Weight:"Weight"}),dl=[{name:"General",desc:"",properties:[{type:ge.Color,property:"primaryColor",desc:"This is used to derive several other properties by default.",name:"Primary color"},{type:ge.Color,property:"ruleColor",name:"Rule color"},{type:ge.Color,property:"backgroundColor",name:"Background color"},{type:ge.Color,property:"borderColor",name:"Border color"},{type:ge.Size,property:"borderSize",name:"Border size"}]},{name:"Content font",desc:"",properties:[{type:ge.Font,name:"Content font",desc:"This is the font used for most of the content in a statblock.",property:"contentFont"},{type:ge.Size,name:"Content font size",property:"contentFontSize"},{type:ge.Weight,name:"Content font weight",property:"fontWeight"},{type:ge.Color,name:"Content font color",property:"fontColor"}]},{name:"Bar",desc:"Control the appearance of the top and bottom bars.",properties:[{type:ge.Color,name:"Bar color",property:"barColor"},{type:ge.Color,name:"Bar border color",property:"barBorderColor"},{type:ge.Size,name:"Bar border size",property:"barBorderSize"}]},{name:"Images",desc:"",properties:[{type:ge.Size,name:"Image width",property:"imageWidth"},{type:ge.Size,name:"Image height",property:"imageHeight"},{type:ge.Size,name:"Image border size",property:"imageBorderSize"},{type:ge.Color,name:"Image border color",property:"imageBorderColor"}]},{name:"Shadow",desc:"",properties:[{type:ge.Color,name:"Shadow color",property:"boxShadowColor"},{type:ge.Size,name:"Shadow x offset",property:"boxShadowXOffset"},{type:ge.Size,name:"Shadow y offset",property:"boxShadowYOffset"},{type:ge.Size,name:"Shadow blur",property:"boxShadowBlur"}]},{name:"Headings",desc:"Anything related to heading blocks.",properties:[{type:ge.Font,property:"headingFont",name:"Heading font"},{type:ge.Color,property:"headingFontColor",name:"Heading font color"},{type:ge.Size,property:"headingFontSize",name:"Heading font size"},{type:ge.Variant,property:"headingFontVariant",name:"Heading font variant"},{type:ge.Weight,property:"headingFontWeight",name:"Heading font weight"}]},{name:"Properties",desc:"Anything related to property blocks.",properties:[{type:ge.Font,property:"propertyFont",name:"Property font"},{type:ge.Color,property:"propertyFontColor",name:"Property font color"},{type:ge.Size,property:"propertyFontSize",name:"Property font size"},{type:ge.Variant,property:"propertyFontVariant",name:"Property font variant"},{type:ge.Weight,property:"propertyFontWeight",name:"Property font weight"},{type:ge.Font,property:"propertyNameFont",name:"Property heading font"},{type:ge.Color,property:"propertyNameFontColor",name:"Property name font color"},{type:ge.Size,property:"propertyNameFontSize",name:"Property name font size"},{type:ge.Variant,property:"propertyNameFontVariant",name:"Property name font variant"},{type:ge.Weight,property:"propertyNameFontWeight",name:"Property name font weight"}]},{name:"Section headings",desc:"Anything related to section heading blocks.",properties:[{type:ge.Font,property:"sectionHeadingFont",name:"Section heading font"},{type:ge.Color,property:"sectionHeadingFontColor",name:"Section heading font color"},{type:ge.Size,property:"sectionHeadingFontSize",name:"Section heading font size"},{type:ge.Variant,property:"sectionHeadingFontVariant",name:"Section heading font variant"},{type:ge.Weight,property:"sectionHeadingFontWeight",name:"Section heading font weight"},{type:ge.Size,property:"sectionHeadingBorderSize",name:"Section heading border size"},{type:ge.Color,property:"sectionHeadingBorderColor",name:"Section heading border color"}]},{name:"Subheadings",desc:"",properties:[{type:ge.Font,property:"subheadingFont",name:"Subheading font"},{type:ge.Color,property:"subheadingFontColor",name:"Subheading font color"},{type:ge.Size,property:"subheadingFontSize",name:"Subheading font size"},{type:ge.Style,property:"subheadingFontStyle",name:"Subheading font style"},{type:ge.Weight,property:"subheadingFontWeight",name:"Subheading font weight"}]},{name:"Traits",desc:"",properties:[{type:ge.Font,property:"traitsFont",name:"Traits font"},{type:ge.Color,property:"traitsFontColor",name:"Traits font color"},{type:ge.Size,property:"traitsFontSize",name:"Traits font size"},{type:ge.Style,property:"traitsFontStyle",name:"Traits font style"},{type:ge.Weight,property:"traitsFontWeight",name:"Traits font weight"},{type:ge.Font,property:"traitsNameFont",name:"Trait name font"},{type:ge.Color,property:"traitsNameFontColor",name:"Trait name font color"},{type:ge.Size,property:"traitsNameFontSize",name:"Trait name font size"},{type:ge.Style,property:"traitsNameFontStyle",name:"Trait name font style"},{type:ge.Weight,property:"traitsNameFontWeight",name:"Trait name font weight"}]}],ka=new Map;for(let n of dl)for(let e of n.properties)ka.has(e.type)||ka.set(e.type,[]),ka.get(e.type).push(e);function ch(n,e,t){let i=n.slice();return i[19]=e[t],i}function k0(n){let e,t,i;return{c(){e=v("input"),g(e,"type","text"),g(e,"spellcheck","false"),e.value=n[4]},m(a,s){D(a,e,s),t||(i=z(e,"change",n[16]),t=!0)},p(a,s){s&16&&e.value!==a[4]&&(e.value=a[4])},d(a){a&&x(e),t=!1,i()}}}function w0(n){let e,t,i;return{c(){e=v("input"),g(e,"type","color"),e.value=n[4]},m(a,s){D(a,e,s),t||(i=z(e,"change",n[15]),t=!0)},p(a,s){s&16&&(e.value=a[4])},d(a){a&&x(e),t=!1,i()}}}function _0(n){let e,t,i,a=ye(n[1]),s=[];for(let r=0;rt(18,a=k));let u=xt("mode");Se(n,u,k=>t(17,i=k));let h=yt([d,u],([k,A])=>ka.get(c.type).filter(P=>P.property!=c.property&&!ul(k.cssProperties,P.property,A).has(c.property)));Se(n,h,k=>t(1,s=k));let m=yt([d,u],([k,A])=>Ns(k.cssProperties,c.property,A)??"");Se(n,m,k=>t(4,l=k));let f=yt([d,u,h],([k,A,P])=>Li(k.cssProperties,c.property,A)??P[0].property);Se(n,f,k=>t(3,o=k));let p=yt([d,u],([k,A])=>lh(k.cssProperties,c.property,A));Se(n,p,k=>t(2,r=k));let b=k=>{new hl.ExtraButtonComponent(k).setIcon(r?"unlink":"link").onClick(()=>{S(r?Ns(a.cssProperties,c.property,i):s.find(A=>!ul(a.cssProperties,A.property,i).has(c.property)).property)})},_=k=>{new hl.ExtraButtonComponent(k).setIcon("undo").onClick(()=>{i===Te.None?delete a.cssProperties?.[c.property]:delete a.cssProperties?.[i]?.[c.property],d.set(a)})},S=k=>{a.cssProperties||Ae(d,a.cssProperties={},a),i===Te.None?Ae(d,a.cssProperties[c.property]=k,a):(a.cssProperties[i]||Ae(d,a.cssProperties[i]={},a),Ae(d,a.cssProperties[i][c.property]=k,a))},C=k=>S(k.currentTarget.value),M=k=>S(k.currentTarget.value),w=k=>S(k.currentTarget.value);return n.$$set=k=>{"property"in k&&t(0,c=k.property)},[c,s,r,o,l,d,u,h,m,f,p,b,_,S,C,M,w]}var fl=class extends G{constructor(e){super(),K(this,e,C0,S0,j,{property:0})}},hh=fl;var fh=require("obsidian");function x0(n){re(n,"svelte-1tfzjob",'.always-open.svelte-1tfzjob.svelte-1tfzjob{pointer-events:none}.creator-settings-container.svelte-1tfzjob.svelte-1tfzjob{pointer-events:initial}.calendarium-nested-settings.svelte-1tfzjob.svelte-1tfzjob{position:relative}.calendarium-nested-summary.svelte-1tfzjob.svelte-1tfzjob{outline:none;list-style:none !important;list-style-type:none !important;min-height:1rem;border-top-left-radius:0.1rem;border-top-right-radius:0.1rem;cursor:pointer;background-color:var(--creator-background-color);margin-right:0;display:flex;justify-content:space-between}summary.svelte-1tfzjob.svelte-1tfzjob::-webkit-details-marker,summary.svelte-1tfzjob.svelte-1tfzjob::marker{display:none !important}.always-open.svelte-1tfzjob .handle.svelte-1tfzjob{display:none}.collapser.svelte-1tfzjob.svelte-1tfzjob{display:flex;flex-flow:column;justify-content:flex-start;align-items:flex-end;content:""}.handle.svelte-1tfzjob.svelte-1tfzjob{transform:rotate(0deg);transition:transform 0.25s;display:flex}details[open].svelte-1tfzjob .handle.svelte-1tfzjob{transform:rotate(90deg)}.creator-settings-container.svelte-1tfzjob.svelte-1tfzjob{padding:0.75em var(--size-4-3)}.calendarium-nested-settings.svelte-1tfzjob.svelte-1tfzjob{border-top:0px}')}function A0(n){let e,t,i,a,s,r,o,l,c,d,u,h,m,f,p,b,_,S,C,M=n[6].default,w=st(M,n,n[5],null);return{c(){e=v("details"),t=v("summary"),i=v("div"),a=v("div"),s=v("div"),r=pe(n[1]),o=R(),l=v("div"),c=pe(n[2]),d=R(),u=v("div"),h=v("div"),m=v("div"),p=R(),b=v("div"),w&&w.c(),g(s,"class","setting-item-name"),g(l,"class","setting-item-description"),g(a,"class","setting-item-info"),g(i,"class","setting-item setting-item-heading"),g(m,"class","handle svelte-1tfzjob"),g(h,"class","warning-container"),g(u,"class","collapser svelte-1tfzjob"),g(t,"class","calendarium-nested-summary svelte-1tfzjob"),g(b,"class","creator-settings-container svelte-1tfzjob"),g(e,"class","creator calendarium-nested-settings setting-item svelte-1tfzjob"),oe(e,"always-open",n[3])},m(k,A){D(k,e,A),y(e,t),y(t,i),y(i,a),y(a,s),y(s,r),y(a,o),y(a,l),y(l,c),y(t,d),y(t,u),y(u,h),y(h,m),y(e,p),y(e,b),w&&w.m(b,null),e.open=n[0],_=!0,S||(C=[X(f=n[4].call(null,m)),z(e,"toggle",n[7])],S=!0)},p(k,[A]){(!_||A&2)&&we(r,k[1]),(!_||A&4)&&we(c,k[2]),w&&w.p&&(!_||A&32)&&ot(w,M,k,k[5],_?rt(M,k[5],A,null):lt(k[5]),null),A&1&&(e.open=k[0]),(!_||A&8)&&oe(e,"always-open",k[3])},i(k){_||(E(w,k),_=!0)},o(k){I(w,k),_=!1},d(k){k&&x(e),w&&w.d(k),S=!1,le(C)}}}function T0(n,e,t){let{$$slots:i={},$$scope:a}=e,{open:s=!0}=e,{name:r}=e,{desc:o=""}=e,{alwaysOpen:l=!1}=e,c=u=>{(0,fh.setIcon)(u,"chevron-right")};function d(){s=this.open,t(0,s)}return n.$$set=u=>{"open"in u&&t(0,s=u.open),"name"in u&&t(1,r=u.name),"desc"in u&&t(2,o=u.desc),"alwaysOpen"in u&&t(3,l=u.alwaysOpen),"$$scope"in u&&t(5,a=u.$$scope)},[s,r,o,l,c,a,i,d]}var ml=class extends G{constructor(e){super(),K(this,e,T0,A0,j,{open:0,name:1,desc:2,alwaysOpen:3},x0)}},_a=ml;function mh(n,e,t){let i=n.slice();return i[1]=e[t],i}function gh(n){let e,t;return e=new hh({props:{property:n[1]}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,a){let s={};a&1&&(s.property=i[1]),e.$set(s)},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function D0(n){let e,t,i=ye(n[0].properties),a=[];for(let r=0;rI(a[r],1,1,()=>{a[r]=null});return{c(){for(let r=0;r{"group"in a&&t(0,i=a.group)},[i]}var gl=class extends G{constructor(e){super(),K(this,e,M0,E0,j,{group:0})}},ph=gl;function I0(n){re(n,"svelte-1obegcf",".appearance-parent.svelte-1obegcf{overflow:hidden}.property-groups.svelte-1obegcf{overflow:auto;height:100%}")}function O0(n,e,t){let i=n.slice();return i[5]=e[t],i}function P0(n){let e,t;return e=new ph({props:{group:n[5]}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p:N,i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function R0(n){let e,t,i,a,s,r,o,l,c,d,u,h,m,f,p,b,_,S=ye(dl),C=[];for(let M=0;MSet colors for...',a=R(),s=v("div"),r=v("button"),r.textContent="Both",o=R(),l=v("button"),d=R(),u=v("button"),m=R(),f=v("div");for(let M=0;Mt(0,i=l)),li("mode",a),[i,a,()=>Ae(a,i=Te.None,i),()=>Ae(a,i=Te.Light,i),()=>Ae(a,i=Te.Dark,i)]}var pl=class extends G{constructor(e){super(),K(this,e,N0,R0,j,{},I0)}},bh=pl;var en=require("obsidian");var bl=require("obsidian"),yh=La(Ts());var Bi=class extends yh.FuzzyInputSuggest{constructor(){super(...arguments);this.field="name"}getItemText(t){return be(t[this.field])}renderNote(t,i){let{item:a,match:s}=i;(0,bl.renderMatches)(t,be(a.source),s.matches)}renderTitle(t,i){let{item:a,match:s}=i;(0,bl.renderMatches)(t,be(a.name),s.matches)}};function L0(n){re(n,"svelte-1jv9opu",".previewer.svelte-1jv9opu{height:100%;display:grid;grid-template-rows:auto 1fr auto;gap:0.5rem}.preview.svelte-1jv9opu{overflow:hidden;position:relative}.inner.svelte-1jv9opu{overflow:auto;padding:var(--size-4-4);transform-origin:top left;scale:var(--scale, 0.625);width:calc(100% / var(--scale, 0.625));height:calc(100% / var(--scale, 0.625))}.definition.svelte-1jv9opu{display:flex;flex-flow:column nowrap;gap:0.25rem}.yaml-editor.svelte-1jv9opu{font-size:var(--font-smallest)}")}function B0(n){let e,t,i,a,s,r,o,l,c,d,u,h,m,f,p,b,_,S,C,M,w,k,A;return{c(){e=v("div"),t=v("div"),t.innerHTML='
Set theme mode
',i=R(),a=v("div"),s=v("button"),o=R(),l=v("button"),d=R(),u=v("div"),h=v("div"),m=v("div"),m.textContent="Scale preview",f=R(),p=v("div"),b=pe("Current: "),_=pe(n[1]),S=R(),C=v("div"),M=v("input"),g(t,"class","setting-item-info"),g(s,"aria-label","Light"),oe(s,"mod-cta",n[2]==Te.Light),g(l,"aria-label","Dark"),oe(l,"mod-cta",n[2]==Te.Dark),g(a,"class","setting-item-control"),g(e,"class","setting-item"),g(m,"class","setting-item-name"),g(p,"class","setting-item-description"),g(h,"class","setting-item-info"),g(M,"class","slider"),g(M,"type","range"),g(M,"min","0"),g(M,"max","1"),g(M,"step","0.1"),g(C,"class","setting-item-control"),g(u,"class","setting-item")},m(P,L){D(P,e,L),y(e,t),y(e,i),y(e,a),y(a,s),y(a,o),y(a,l),D(P,d,L),D(P,u,L),y(u,h),y(h,m),y(h,f),y(h,p),y(p,b),y(p,_),y(u,S),y(u,C),y(C,M),ct(M,n[1]),k||(A=[X(r=Fe.call(null,s,"sun")),z(s,"click",n[14]),X(c=Fe.call(null,l,"moon")),z(l,"click",n[15]),z(M,"change",n[16]),z(M,"input",n[16]),X(w=n[10].call(null,C))],k=!0)},p(P,L){L&4&&oe(s,"mod-cta",P[2]==Te.Light),L&4&&oe(l,"mod-cta",P[2]==Te.Dark),L&2&&we(_,P[1]),L&2&&ct(M,P[1])},d(P){P&&(x(e),x(d),x(u)),k=!1,le(A)}}}function F0(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","yaml-editor svelte-1jv9opu")},m(s,r){D(s,e,r),i||(a=X(t=n[6].call(null,e)),i=!0)},p:N,d(s){s&&x(e),i=!1,a()}}}function W0(n){let e,t,i,a,s,r,o,l,c,d,u,h,m,f,p,b,_;return d=new _a({props:{name:"Settings",desc:n[3],open:!1,$$slots:{default:[B0]},$$scope:{ctx:n}}}),m=new _a({props:{name:"Editor",open:!1,$$slots:{default:[F0]},$$scope:{ctx:n}}}),{c(){e=v("div"),t=v("div"),t.textContent=`Select a creature to preview the layout, or enter your own definition below.`,i=R(),a=v("div"),s=v("div"),r=R(),o=v("div"),c=R(),ae(d.$$.fragment),u=R(),h=v("div"),ae(m.$$.fragment),g(s,"class","preview-container inner svelte-1jv9opu"),g(a,"class","preview svelte-1jv9opu"),g(h,"class","definition svelte-1jv9opu"),g(e,"class","previewer svelte-1jv9opu"),g(e,"style",f=`--scale: ${n[1]}`),oe(e,"theme-light",n[2]===Te.Light),oe(e,"theme-dark",n[2]===Te.Dark)},m(S,C){D(S,e,C),y(e,t),y(e,i),y(e,a),y(a,s),n[13](s),y(e,r),y(e,o),y(e,c),te(d,e,null),y(e,u),y(e,h),te(m,h,null),p=!0,b||(_=X(l=n[5].call(null,o)),b=!0)},p(S,[C]){let M={};C&8&&(M.desc=S[3]),C&8388614&&(M.$$scope={dirty:C,ctx:S}),d.$set(M);let w={};C&8388608&&(w.$$scope={dirty:C,ctx:S}),m.$set(w),(!p||C&2&&f!==(f=`--scale: ${S[1]}`))&&g(e,"style",f),(!p||C&4)&&oe(e,"theme-light",S[2]===Te.Light),(!p||C&4)&&oe(e,"theme-dark",S[2]===Te.Dark)},i(S){p||(E(d.$$.fragment,S),E(m.$$.fragment,S),p=!0)},o(S){I(d.$$.fragment,S),I(m.$$.fragment,S),p=!1},d(S){S&&x(e),n[13](null),ne(d),ne(m),b=!1,_()}}}function H0(n,e,t){let i,a,s,r,{previewed:o}=e,l=xt("plugin"),c=xt("layout");Se(n,c,B=>t(19,s=B));let d=Me(),u=(B,O)=>{B.empty(),m.setCreature({monster:O}),m.init()},h,m;pn(()=>{let B={};try{B={...B,...(0,en.parseYaml)(o)}}catch{}m=new $t({plugin:l,container:h,layout:s,monster:B},!1)});let f=B=>{let O=new en.SearchComponent(B).setPlaceholder("Find a creature");new Bi(l.app,O,l.api.getBestiaryCreatures()).onSelect(async Z=>{if(Z.item){O.setValue("");let ee=(0,en.stringifyYaml)(Z.item);d("update",ee),p.dispatch({changes:[{from:0,to:p.state.doc.length,insert:ee}]})}})},p,b=B=>{p=pa(B,o,[],(0,en.debounce)(O=>{try{let q=(0,en.parseYaml)(O);d("update",O),u(h,q)}catch{}},500))},_=Be(Te.None);Se(n,_,B=>t(2,a=B));let S=B=>{a==B?Ae(_,a=Te.None,a):Ae(_,a=B,a)};bn(()=>{p&&p.destroy()});let C=Be(1);Se(n,C,B=>t(1,i=B));let M=B=>{new en.ExtraButtonComponent(B).setIcon("undo").onClick(()=>{Ae(C,i=1,i)})},w=yt([_,C],([B,O])=>{let q=[`Scale: ${O}`];return B===Te.Light&&q.push("Mode: Light"),B===Te.Dark&&q.push("Mode: Dark"),q.join(", ")});Se(n,w,B=>t(3,r=B));function k(B){Re[B?"unshift":"push"](()=>{h=B,t(0,h)})}let A=()=>S(Te.Light),P=()=>S(Te.Dark);function L(){i=Kn(this.value),C.set(i)}return n.$$set=B=>{"previewed"in B&&t(12,o=B.previewed)},[h,i,a,r,c,f,b,_,S,C,M,w,o,k,A,P,L]}var yl=class extends G{constructor(e){super(),K(this,e,H0,W0,j,{previewed:12},L0)}},vh=yl;function z0(n){re(n,"svelte-1idjk8u",".statblock-mobile.svelte-1idjk8u{display:flex;flex-flow:column;gap:0.25rem}.top.svelte-1idjk8u{display:flex;align-items:center;justify-content:space-between;padding:0.25rem}.buttons.svelte-1idjk8u{display:flex;align-items:center}.name.svelte-1idjk8u{display:flex;align-items:center}.name.svelte-1idjk8u .buttons{display:flex;justify-content:flex-end;align-items:center}.vertical-tab-header.svelte-1idjk8u{display:flex;flex-flow:column nowrap}.vertical-tab-content.svelte-1idjk8u{padding:var(--size-4-8)}.bottom.svelte-1idjk8u{display:flex;justify-content:flex-end;align-items:center;margin-top:auto}")}function kh(n,e,t){let i=n.slice();return i[16]=e[t],i}function q0(n){let e,t,i,a,s,r,o,l,c,d,u,h,m,f,p,b,_,S;return m=new ll({}),p=new il({}),{c(){e=v("div"),t=v("div"),i=v("div"),s=R(),r=v("div"),o=v("div"),c=R(),d=v("div"),h=R(),ae(m.$$.fragment),f=R(),ae(p.$$.fragment),g(i,"class","name svelte-1idjk8u"),g(o,"class","save"),g(d,"class","cancel"),g(r,"class","buttons svelte-1idjk8u"),g(t,"class","top svelte-1idjk8u"),g(e,"class","statblock-mobile svelte-1idjk8u")},m(C,M){D(C,e,M),y(e,t),y(t,i),y(t,s),y(t,r),y(r,o),y(r,c),y(r,d),y(e,h),te(m,e,null),y(e,f),te(p,e,null),b=!0,_||(S=[X(a=n[5].call(null,i)),X(l=n[6].call(null,o)),X(u=n[7].call(null,d))],_=!0)},p:N,i(C){b||(E(m.$$.fragment,C),E(p.$$.fragment,C),b=!0)},o(C){I(m.$$.fragment,C),I(p.$$.fragment,C),b=!1},d(C){C&&x(e),ne(m),ne(p),_=!1,le(S)}}}function j0(n){let e,t,i,a,s,r,o,l,c,d,u,h,m,f,p,b,_,S,C,M,w,k,A,P,L,B=ye(n[4]),O=[];for(let $=0;${q=null}),ue()),$[1]==="Appearance"?Z?W&2&&E(Z,1):(Z=Sh($),Z.c(),E(Z,1),Z.m(S,M)):Z&&(ce(),I(Z,1,1,()=>{Z=null}),ue()),$[1]==="Advanced"?ee?W&2&&E(ee,1):(ee=Ch($),ee.c(),E(ee,1),ee.m(S,w)):ee&&(ce(),I(ee,1,1,()=>{ee=null}),ue()),$[1]==="Previewer"?se?(se.p($,W),W&2&&E(se,1)):(se=xh($),se.c(),E(se,1),se.m(S,null)):se&&(ce(),I(se,1,1,()=>{se=null}),ue()),(!A||W&2&&k!==(k="vertical-tab-content-container "+$[1].toLowerCase()+"s svelte-1idjk8u"))&&g(_,"class",k)},i($){A||(E(q),E(Z),E(ee),E(se),A=!0)},o($){I(q),I(Z),I(ee),I(se),A=!1},d($){$&&(x(e),x(b),x(_)),Ke(O,$),q&&q.d(),Z&&Z.d(),ee&&ee.d(),se&&se.d(),P=!1,le(L)}}}function wh(n){let e,t,i;function a(){return n[11](n[16])}return{c(){e=v("div"),e.textContent=`${n[16]} `,g(e,"class","vertical-tab-nav-item"),oe(e,"is-active",n[1]===n[16])},m(s,r){D(s,e,r),t||(i=z(e,"click",a),t=!0)},p(s,r){n=s,r&18&&oe(e,"is-active",n[1]===n[16])},d(s){s&&x(e),t=!1,i()}}}function _h(n){let e,t;return e=new il({}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function Sh(n){let e,t;return e=new bh({}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function Ch(n){let e,t;return e=new ll({}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function xh(n){let e,t;return e=new vh({props:{previewed:n[0]}}),e.$on("update",n[12]),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,a){let s={};a&1&&(s.previewed=i[0]),e.$set(s)},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function V0(n){let e,t=``,i,a,s,r,o,l=[j0,q0],c=[];function d(u,h){return tn.Platform.isMobile?1:0}return a=d(n,-1),s=c[a]=l[a](n),{c(){e=new gn(!1),i=R(),s.c(),r=_e(),e.a=i},m(u,h){e.m(t,u,h),D(u,i,h),c[a].m(u,h),D(u,r,h),o=!0},p(u,[h]){(!o||h&4)&&t!==(t=``)&&e.p(t),s.p(u,h)},i(u){o||(E(s),o=!0)},o(u){I(s),o=!1},d(u){u&&(e.d(),x(i),x(r)),c[a].d(u)}}}function U0(n,e,t){let i,a,{layout:s}=e,{plugin:r}=e,o=Be(s);Se(n,o,C=>t(14,i=C)),li("plugin",r),li("layout",o);let l="",c=["General","Appearance","Advanced","Previewer"],d=c[0],u=!1,h=C=>{if(C.empty(),u){let M=i.name;new tn.TextComponent(C).setValue(M).onChange(k=>{M=k});let w=C.createDiv("buttons");new tn.ExtraButtonComponent(w).setIcon("checkmark").setTooltip("Save").onClick(()=>{u=!1,Ae(o,i.name=M,i),h(C)}),new tn.ExtraButtonComponent(w).setIcon("cross-in-box").setTooltip("Cancel").onClick(()=>{u=!1,h(C)})}else C.createEl("h5",{text:i.name}),new tn.ExtraButtonComponent(C.createDiv("buttons")).setIcon("pencil").setTooltip("Edit Name").onClick(()=>{u=!0,h(C)})},m=Me(),f=C=>{new tn.ButtonComponent(C).setIcon("checkmark").setCta().setTooltip("Save").onClick(()=>{m("saved")})},p=C=>{new tn.ExtraButtonComponent(C).setIcon("cross").setTooltip("Cancel").onClick(()=>{m("cancel")})},b=yt(o,C=>r.manager.getSheetRules(C));Se(n,b,C=>t(2,a=C));let _=C=>t(1,d=C),S=C=>t(0,l=C.detail);return n.$$set=C=>{"layout"in C&&t(9,s=C.layout),"plugin"in C&&t(10,r=C.plugin)},[l,d,a,o,c,h,f,p,b,s,r,_,S]}var vl=class extends G{constructor(e){super(),K(this,e,U0,V0,j,{layout:9,plugin:10},z0)}},Ah=vl;var Fi=(n=>(n.None="None",n.Average="Average",n.Roll="Roll",n))(Fi||{});var bf=La(Ts());function kl(){return na('var Vc=Object.create;var Il=Object.defineProperty;var qc=Object.getOwnPropertyDescriptor;var Uc=Object.getOwnPropertyNames;var Wc=Object.getPrototypeOf,zc=Object.prototype.hasOwnProperty;var St=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var jc=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Uc(e))!zc.call(i,n)&&n!==t&&Il(i,n,{get:()=>e[n],enumerable:!(r=qc(e,n))||r.enumerable});return i};var Gc=(i,e,t)=>(t=i!=null?Vc(Wc(i)):{},jc(e||!i||!i.__esModule?Il(t,"default",{value:i,enumerable:!0}):t,i));var ii=St(Ae=>{"use strict";function J0(i,e,t){if(t===void 0&&(t=Array.prototype),i&&typeof t.find=="function")return t.find.call(i,e);for(var r=0;r-1}var o2=Ti({HTML:"http://www.w3.org/1999/xhtml",SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});Ae.assign=Q0;Ae.find=J0;Ae.freeze=Ti;Ae.HTML_BOOLEAN_ATTRIBUTES=mh;Ae.HTML_RAW_TEXT_ELEMENTS=Cr;Ae.HTML_VOID_ELEMENTS=yh;Ae.hasDefaultHTMLNamespace=r2;Ae.hasOwn=ti;Ae.isHTMLBooleanAttribute=Z0;Ae.isHTMLRawTextElement=t2;Ae.isHTMLEscapableRawTextElement=i2;Ae.isHTMLMimeType=bh;Ae.isHTMLVoidElement=e2;Ae.isValidMimeType=s2;Ae.MIME_TYPE=Sr;Ae.NAMESPACE=o2});var kr=St(Tr=>{"use strict";var l2=ii();function wh(i,e){i.prototype=Object.create(Error.prototype,{constructor:{value:i},name:{value:i.name,enumerable:!0,writable:e}})}var Er=l2.freeze({Error:"Error",IndexSizeError:"IndexSizeError",DomstringSizeError:"DomstringSizeError",HierarchyRequestError:"HierarchyRequestError",WrongDocumentError:"WrongDocumentError",InvalidCharacterError:"InvalidCharacterError",NoDataAllowedError:"NoDataAllowedError",NoModificationAllowedError:"NoModificationAllowedError",NotFoundError:"NotFoundError",NotSupportedError:"NotSupportedError",InUseAttributeError:"InUseAttributeError",InvalidStateError:"InvalidStateError",SyntaxError:"SyntaxError",InvalidModificationError:"InvalidModificationError",NamespaceError:"NamespaceError",InvalidAccessError:"InvalidAccessError",ValidationError:"ValidationError",TypeMismatchError:"TypeMismatchError",SecurityError:"SecurityError",NetworkError:"NetworkError",AbortError:"AbortError",URLMismatchError:"URLMismatchError",QuotaExceededError:"QuotaExceededError",TimeoutError:"TimeoutError",InvalidNodeTypeError:"InvalidNodeTypeError",DataCloneError:"DataCloneError",EncodingError:"EncodingError",NotReadableError:"NotReadableError",UnknownError:"UnknownError",ConstraintError:"ConstraintError",DataError:"DataError",TransactionInactiveError:"TransactionInactiveError",ReadOnlyError:"ReadOnlyError",VersionError:"VersionError",OperationError:"OperationError",NotAllowedError:"NotAllowedError",OptOutError:"OptOutError"}),Ah=Object.keys(Er);function Ch(i){return typeof i=="number"&&i>=1&&i<=25}function a2(i){return typeof i=="string"&&i.substring(i.length-Er.Error.length)===Er.Error}function xr(i,e){Ch(i)?(this.name=Ah[i],this.message=e||""):(this.message=i,this.name=a2(e)?e:Er.Error),Error.captureStackTrace&&Error.captureStackTrace(this,xr)}wh(xr,!0);Object.defineProperties(xr.prototype,{code:{enumerable:!0,get:function(){var i=Ah.indexOf(this.name);return Ch(i)?i:0}}});var Sh={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25},tl=Object.entries(Sh);for(Dr=0;Dr{"use strict";function Rh(i){try{typeof i!="function"&&(i=RegExp);var e=new i("\\u{1D306}","u").exec("\\u{1D306}");return!!e&&e[0].length===2}catch(t){}return!1}var Br=Rh();function ri(i){if(i.source[0]!=="[")throw new Error(i+" can not be used with chars");return i.source.slice(1,i.source.lastIndexOf("]"))}function ki(i,e){if(i.source[0]!=="[")throw new Error("/"+i.source+"/ can not be used with chars_without");if(!e||typeof e!="string")throw new Error(JSON.stringify(e)+" is not a valid search");if(i.source.indexOf(e)===-1)throw new Error(\'"\'+e+\'" is not is /\'+i.source+"/");if(e==="-"&&i.source.indexOf(e)!==1)throw new Error(\'"\'+e+\'" is not at the first postion of /\'+i.source+"/");return new RegExp(i.source.replace(e,""),Br?"u":"")}function U(i){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(t){var r=typeof t=="string";if(r&&e===void 0&&t==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return r?t:t.source}).join(""),Br?"mu":"m")}function _(i){if(arguments.length===0)throw new Error("no parameters provided");return U.apply(_,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var u2="\\uFFFD",ni=/[-\\x09\\x0A\\x0D\\x20-\\x2C\\x2E-\\uD7FF\\uE000-\\uFFFD]/;Br&&(ni=U("[",ri(ni),"\\\\u{10000}-\\\\u{10FFFF}","]"));var rl=/[\\x20\\x09\\x0D\\x0A]/,h2=ri(rl),Q=U(rl,"+"),ne=U(rl,"*"),Mr=/[:_a-zA-Z\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02FF\\u0370-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]/;Br&&(Mr=U("[",ri(Mr),"\\\\u{10000}-\\\\u{10FFFF}","]"));var c2=ri(Mr),nl=U("[",c2,ri(/[-.0-9\\xB7]/),ri(/[\\u0300-\\u036F\\u203F-\\u2040]/),"]"),Ue=U(Mr,nl,"*"),Dh=U(nl,"+"),f2=U("&",Ue,";"),d2=_(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),Rr=_(f2,"|",d2),Nr=U("%",Ue,";"),sl=_(U(\'"\',_(/[^%&"]/,"|",Nr,"|",Rr),"*",\'"\'),"|",U("\'",_(/[^%&\']/,"|",Nr,"|",Rr),"*","\'")),p2=_(\'"\',_(/[^<&"]/,"|",Rr),"*",\'"\',"|","\'",_(/[^<&\']/,"|",Rr),"*","\'"),g2=ki(Mr,":"),m2=ki(nl,":"),Eh=U(g2,m2,"*"),Pr=U(Eh,_(":",Eh),"?"),y2=U("^",Pr,"$"),b2=U("(",Pr,")"),Or=_(/"[^"]*"|\'[^\']*\'/),v2=U(/^<\\?/,"(",Ue,")",_(Q,"(",ni,"*?)"),"?",/\\?>/),xh=/[\\x20\\x0D\\x0Aa-zA-Z0-9-\'()+,./:=?;!*#@$_%]/,Wn=_(\'"\',xh,\'*"\',"|","\'",ki(xh,"\'"),"*\'"),Nh="",w2=U(Nh,_(ki(ni,"-"),"|",U("-",ki(ni,"-"))),"*",Oh),Th="#PCDATA",A2=_(U(/\\(/,ne,Th,_(ne,/\\|/,ne,Pr),"*",ne,/\\)\\*/),"|",U(/\\(/,ne,Th,ne,/\\)/)),C2=/[?*+]?/,S2=U(/\\([^>]+\\)/,C2),D2=_("EMPTY","|","ANY","|",A2,"|",S2),E2=""),T2=U("NOTATION",Q,/\\(/,ne,Ue,_(ne,/\\|/,ne,Ue),"*",ne,/\\)/),k2=U(/\\(/,ne,Dh,_(ne,/\\|/,ne,Dh),"*",ne,/\\)/),M2=_(T2,"|",k2),R2=_(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",M2),N2=_(/#REQUIRED|#IMPLIED/,"|",_(_("#FIXED",Q),"?",p2)),O2=_(Q,Ue,Q,R2,Q,N2),B2=""),ol="SYSTEM",zn="PUBLIC",jn=_(_(ol,Q,Or),"|",_(zn,Q,Wn,Q,Or)),L2=U("^",_(_(ol,Q,"(?",Or,")"),"|",_(zn,Q,"(?",Wn,")",Q,"(?",Or,")"))),_2=_(Q,"NDATA",Q,Ue),I2=_(sl,"|",_(jn,_2,"?")),Bh=""),H2=_(sl,"|",jn),$2=U(Bh,Q,"%",Q,Ue,Q,H2,ne,">"),V2=_(F2,"|",$2),q2=U(zn,Q,Wn),U2=U(""),ll=U(ne,"=",ne),kh=/1[.]\\d+/,W2=U(Q,"version",ll,_("\'",kh,"\'","|",\'"\',kh,\'"\')),Mh=/[A-Za-z][-A-Za-z0-9._]*/,z2=_(Q,"encoding",ll,_(\'"\',Mh,\'"\',"|","\'",Mh,"\'")),j2=_(Q,"standalone",ll,_("\'",_("yes","|","no"),"\'","|",\'"\',_("yes","|","no"),\'"\')),G2=U(/^<\\?xml/,W2,z2,"?",j2,"?",ne,/\\?>/),K2="",J2=//,Z2=U(ni,"*?",Q2),ey=U(J2,Z2);V.chars=ri;V.chars_without=ki;V.detectUnicodeSupport=Rh;V.reg=U;V.regg=_;V.AttlistDecl=P2;V.CDATA_START=Y2;V.CDATA_END=X2;V.CDSect=ey;V.Char=ni;V.Comment=w2;V.COMMENT_START=Nh;V.COMMENT_END=Oh;V.DOCTYPE_DECL_START=K2;V.elementdecl=x2;V.EntityDecl=V2;V.EntityValue=sl;V.ExternalID=jn;V.ExternalID_match=L2;V.Name=Ue;V.NotationDecl=U2;V.Reference=Rr;V.PEReference=Nr;V.PI=v2;V.PUBLIC=zn;V.PubidLiteral=Wn;V.QName=Pr;V.QName_exact=y2;V.QName_group=b2;V.S=Q;V.SChar_s=h2;V.S_OPT=ne;V.SYSTEM=ol;V.SystemLiteral=Or;V.UNICODE_REPLACEMENT_CHARACTER=u2;V.UNICODE_SUPPORT=Br;V.XMLDecl=G2});var pl=St(ae=>{"use strict";var We=ii(),ct=We.find,ty=We.hasDefaultHTMLNamespace,Ri=We.hasOwn,iy=We.isHTMLMimeType,ry=We.isHTMLRawTextElement,ny=We.isHTMLVoidElement,Lr=We.MIME_TYPE,dt=We.NAMESPACE,Te=Symbol(),sy=kr(),L=sy.DOMException,wt=al();function Oe(i){if(i!==Te)throw new TypeError("Illegal constructor")}function oy(i){return i!==""}function ly(i){return i?i.split(/[\\t\\n\\f\\r ]+/).filter(oy):[]}function ay(i,e){return Ri(i,e)||(i[e]=!0),i}function Ph(i){if(!i)return[];var e=ly(i);return Object.keys(e.reduce(ay,{}))}function uy(i){return function(e){return i&&i.indexOf(e)!==-1}}function Vh(i){if(!wt.QName_exact.test(i))throw new L(L.INVALID_CHARACTER_ERR,\'invalid character in qualified name "\'+i+\'"\')}function hl(i,e){Vh(e),i=i||null;var t=null,r=e;if(e.indexOf(":")>=0){var n=e.split(":");t=n[0],r=n[1]}if(t!==null&&i===null)throw new L(L.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&i!==We.NAMESPACE.XML)throw new L(L.NAMESPACE_ERR,\'prefix is "xml" and namespace is not the XML namespace\');if((t==="xmlns"||e==="xmlns")&&i!==We.NAMESPACE.XMLNS)throw new L(L.NAMESPACE_ERR,\'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace\');if(i===We.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new L(L.NAMESPACE_ERR,\'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"\');return[i,t,r]}function Bi(i,e){for(var t in i)Ri(i,t)&&(e[t]=i[t])}function Be(i,e){var t=i.prototype;if(!(t instanceof e)){let r=function(){};r.prototype=e.prototype,r=new r,Bi(t,r),i.prototype=t=r}t.constructor!=i&&(typeof i!="function"&&console.error("unknown Class:"+i),t.constructor=i)}var Pe={},Ye=Pe.ELEMENT_NODE=1,Ni=Pe.ATTRIBUTE_NODE=2,Gn=Pe.TEXT_NODE=3,qh=Pe.CDATA_SECTION_NODE=4,Uh=Pe.ENTITY_REFERENCE_NODE=5,hy=Pe.ENTITY_NODE=6,Wh=Pe.PROCESSING_INSTRUCTION_NODE=7,zh=Pe.COMMENT_NODE=8,Ir=Pe.DOCUMENT_NODE=9,jh=Pe.DOCUMENT_TYPE_NODE=10,Lt=Pe.DOCUMENT_FRAGMENT_NODE=11,cy=Pe.NOTATION_NODE=12,be=We.freeze({DOCUMENT_POSITION_DISCONNECTED:1,DOCUMENT_POSITION_PRECEDING:2,DOCUMENT_POSITION_FOLLOWING:4,DOCUMENT_POSITION_CONTAINS:8,DOCUMENT_POSITION_CONTAINED_BY:16,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:32});function Lh(i){for(var e=[];i.parentNode||i.ownerElement;)i=i.parentNode||i.ownerElement,e.unshift(i);return e}function Gh(i,e){if(e.length=0&&i=0){for(var n=e.length-1;r<=n;)e[r]=e[++r];if(e.length=n,i){var s=i.ownerDocument;s&&Jh(s,i,t),t.ownerElement=null}}}Oi.prototype={length:0,item:Xe.prototype.item,getNamedItem:function(i){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(i=i.toLowerCase());for(var e=0;e_h(e.ownerDocument)?be.DOCUMENT_POSITION_FOLLOWING:be.DOCUMENT_POSITION_PRECEDING);var l=Lh(e),a=Lh(t);if(!r&&a.indexOf(e)>=0||n&&e===t)return be.DOCUMENT_POSITION_CONTAINS+be.DOCUMENT_POSITION_PRECEDING;if(!n&&l.indexOf(t)>=0||r&&e===t)return be.DOCUMENT_POSITION_CONTAINED_BY+be.DOCUMENT_POSITION_FOLLOWING;var u=Gh(a,l);for(var h in u.childNodes){var c=u.childNodes[h];if(c===t)return be.DOCUMENT_POSITION_FOLLOWING;if(c===e)return be.DOCUMENT_POSITION_PRECEDING;if(a.indexOf(c)>=0)return be.DOCUMENT_POSITION_FOLLOWING;if(l.indexOf(c)>=0)return be.DOCUMENT_POSITION_PRECEDING}return 0}};function Xh(i){return i=="<"&&"<"||i==">"&&">"||i=="&"&&"&"||i==\'"\'&&"""||"&#"+i.charCodeAt()+";"}Bi(Pe,X);Bi(Pe,X.prototype);Bi(be,X);Bi(be,X.prototype);function _r(i,e){if(e(i))return!0;if(i=i.firstChild)do if(_r(i,e))return!0;while(i=i.nextSibling)}function _t(i,e){Oe(i);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||Lr.XML_APPLICATION,this.type=iy(this.contentType)?"html":"xml"}function dy(i,e,t){i&&i._inc++;var r=t.namespaceURI;r===dt.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function Jh(i,e,t,r){i&&i._inc++;var n=t.namespaceURI;n===dt.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function Qh(i,e,t){if(i&&i._inc){i._inc++;var r=e.childNodes;if(t)r[r.length++]=t;else{for(var n=e.firstChild,s=0;n;)r[s++]=n,n=n.nextSibling;r.length=s,delete r[r.length]}}}function Zh(i,e){if(i!==e.parentNode)throw new L(L.NOT_FOUND_ERR,"child\'s parent is not parent");var t=e.previousSibling,r=e.nextSibling;return t?t.nextSibling=r:i.firstChild=r,r?r.previousSibling=t:i.lastChild=t,Qh(i.ownerDocument,i),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function py(i){return i&&(i.nodeType===X.DOCUMENT_NODE||i.nodeType===X.DOCUMENT_FRAGMENT_NODE||i.nodeType===X.ELEMENT_NODE)}function gy(i){return i&&(ft(i)||i instanceof Pi||At(i)||i.nodeType===X.DOCUMENT_FRAGMENT_NODE||i.nodeType===X.COMMENT_NODE||i.nodeType===X.PROCESSING_INSTRUCTION_NODE)}function At(i){return i&&i.nodeType===X.DOCUMENT_TYPE_NODE}function ft(i){return i&&i.nodeType===X.ELEMENT_NODE}function ec(i){return i&&i.nodeType===X.TEXT_NODE}function Fh(i,e){var t=i.childNodes||[];if(ct(t,ft)||At(e))return!1;var r=ct(t,At);return!(e&&r&&t.indexOf(r)>t.indexOf(e))}function Hh(i,e){var t=i.childNodes||[];function r(s){return ft(s)&&s!==e}if(ct(t,r))return!1;var n=ct(t,At);return!(e&&n&&t.indexOf(n)>t.indexOf(e))}function my(i,e,t){if(!py(i))throw new L(L.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+i.nodeType);if(t&&t.parentNode!==i)throw new L(L.NOT_FOUND_ERR,"child not in parent");if(!gy(e)||At(e)&&i.nodeType!==X.DOCUMENT_NODE)throw new L(L.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+i.nodeType)}function yy(i,e,t){var r=i.childNodes||[],n=e.childNodes||[];if(e.nodeType===X.DOCUMENT_FRAGMENT_NODE){var s=n.filter(ft);if(s.length>1||ct(n,ec))throw new L(L.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!Fh(i,t))throw new L(L.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(ft(e)&&!Fh(i,t))throw new L(L.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(At(e)){if(ct(r,At))throw new L(L.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=ct(r,ft);if(t&&r.indexOf(o)1||ct(n,ec))throw new L(L.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(s.length===1&&!Hh(i,t))throw new L(L.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(ft(e)&&!Hh(i,t))throw new L(L.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(At(e)){if(ct(r,function(a){return At(a)&&a!==t}))throw new L(L.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=ct(r,ft);if(t&&r.indexOf(o)0&&_r(t,function(n){if(n!==t&&n.nodeType===Ye){var s=n.getAttribute("class");if(s){var o=i===s;if(!o){var l=Ph(s);o=e.every(uy(l))}o&&r.push(n)}}}),r})},getElementsByTagName:function(i){var e=(this.nodeType===Ir?this:this.ownerDocument).type==="html",t=i.toLowerCase();return new si(this,function(r){var n=[];return _r(r,function(s){if(!(s===r||s.nodeType!==Ye))if(i==="*")n.push(s);else{var o=s.getQualifiedName(),l=e&&s.namespaceURI===dt.HTML?t:i;o===l&&n.push(s)}}),n})},getElementsByTagNameNS:function(i,e){return new si(this,function(t){var r=[];return _r(t,function(n){n!==t&&n.nodeType===Ye&&(i==="*"||n.namespaceURI===i)&&(e==="*"||n.localName==e)&&r.push(n)}),r})}};_t.prototype.getElementsByClassName=It.prototype.getElementsByClassName;_t.prototype.getElementsByTagName=It.prototype.getElementsByTagName;_t.prototype.getElementsByTagNameNS=It.prototype.getElementsByTagNameNS;Be(It,X);function oi(i){Oe(i),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}oi.prototype.nodeType=Ni;Be(oi,X);function Pi(i){Oe(i)}Pi.prototype={data:"",substringData:function(i,e){return this.data.substring(i,i+e)},appendData:function(i){i=this.data+i,this.nodeValue=this.data=i,this.length=i.length},insertData:function(i,e){this.replaceData(i,0,e)},deleteData:function(i,e){this.replaceData(i,e,"")},replaceData:function(i,e,t){var r=this.data.substring(0,i),n=this.data.substring(i+e);t=r+t+n,this.nodeValue=this.data=t,this.length=t.length}};Be(Pi,X);function Fr(i){Oe(i)}Fr.prototype={nodeName:"#text",nodeType:Gn,splitText:function(i){var e=this.data,t=e.substring(i);e=e.substring(0,i),this.data=this.nodeValue=e,this.length=e.length;var r=this.ownerDocument.createTextNode(t);return this.parentNode&&this.parentNode.insertBefore(r,this.nextSibling),r}};Be(Fr,Pi);function Xn(i){Oe(i)}Xn.prototype={nodeName:"#comment",nodeType:zh};Be(Xn,Pi);function Jn(i){Oe(i)}Jn.prototype={nodeName:"#cdata-section",nodeType:qh};Be(Jn,Fr);function Qn(i){Oe(i)}Qn.prototype.nodeType=jh;Be(Qn,X);function fl(i){Oe(i)}fl.prototype.nodeType=cy;Be(fl,X);function dl(i){Oe(i)}dl.prototype.nodeType=hy;Be(dl,X);function Zn(i){Oe(i)}Zn.prototype.nodeType=Uh;Be(Zn,X);function Hr(i){Oe(i)}Hr.prototype.nodeName="#document-fragment";Hr.prototype.nodeType=Lt;Be(Hr,X);function es(i){Oe(i)}es.prototype.nodeType=Wh;Be(es,X);function ic(){}ic.prototype.serializeToString=function(i,e){return rc.call(i,e)};X.prototype.toString=rc;function rc(i){var e=[],t=this.nodeType===Ir&&this.documentElement||this,r=t.prefix,n=t.namespaceURI;if(n&&r==null){var r=t.lookupPrefix(n);if(r==null)var s=[{namespace:n,prefix:null}]}return Mi(this,e,i,s),e.join("")}function $h(i,e,t){var r=i.prefix||"",n=i.namespaceURI;if(!n||r==="xml"&&n===dt.XML||n===dt.XMLNS)return!1;for(var s=t.length;s--;){var o=t[s];if(o.prefix===r)return o.namespace!==n}return!0}function ul(i,e,t){i.push(" ",e,\'="\',t.replace(/[<>&"\\t\\n\\r]/g,Xh),\'"\')}function Mi(i,e,t,r){r||(r=[]);var n=i.nodeType===Ir?i:i.ownerDocument,s=n.type==="html";if(t)if(i=t(i),i){if(typeof i=="string"){e.push(i);return}}else return;switch(i.nodeType){case Ye:var o=i.attributes,l=o.length,w=i.firstChild,a=i.tagName,u=a;if(!s&&!i.prefix&&i.namespaceURI){for(var h,c=0;c=0;f--){var d=r[f];if(d.prefix===""&&d.namespace===i.namespaceURI){h=d.namespace;break}}if(h!==i.namespaceURI)for(var f=r.length-1;f>=0;f--){var d=r[f];if(d.namespace===i.namespaceURI){d.prefix&&(u=d.prefix+":"+a);break}}}e.push("<",u);for(var p=0;p");else{if(e.push(">"),s&&ry(a))for(;w;)w.data?e.push(w.data):Mi(w,e,t,r.slice()),w=w.nextSibling;else for(;w;)Mi(w,e,t,r.slice()),w=w.nextSibling;e.push("")}return;case Ir:case Lt:for(var w=i.firstChild;w;)Mi(w,e,t,r.slice()),w=w.nextSibling;return;case Ni:return ul(e,i.name,i.value);case Gn:return e.push(i.data.replace(/[<&>]/g,Xh));case qh:return e.push(wt.CDATA_START,i.data,wt.CDATA_END);case zh:return e.push(wt.COMMENT_START,i.data,wt.COMMENT_END);case jh:var E=i.publicId,S=i.systemId;e.push(wt.DOCTYPE_DECL_START," ",i.name),E?(e.push(" ",wt.PUBLIC," ",E),S&&S!=="."&&e.push(" ",S)):S&&S!=="."&&e.push(" ",wt.SYSTEM," ",S),i.internalSubset&&e.push(" [",i.internalSubset,"]"),e.push(">");return;case Wh:return e.push("");case Uh:return e.push("&",i.nodeName,";");default:e.push("??",i.nodeName)}}function nc(i,e,t){var r;switch(e.nodeType){case Ye:r=e.cloneNode(!1),r.ownerDocument=i;case Lt:break;case Ni:t=!0;break}if(r||(r=e.cloneNode(!1)),r.ownerDocument=i,r.parentNode=null,t)for(var n=e.firstChild;n;)r.appendChild(nc(i,n,t)),n=n.nextSibling;return r}function cl(i,e,t){var r=new e.constructor(Te);for(var n in e)if(Ri(e,n)){var s=e[n];typeof s!="object"&&s!=r[n]&&(r[n]=s)}switch(e.childNodes&&(r.childNodes=new Xe),r.ownerDocument=i,r.nodeType){case Ye:var o=e.attributes,l=r.attributes=new Oi,a=o.length;l._ownerElement=r;for(var u=0;u{"use strict";var oc=ii().freeze;$r.XML_ENTITIES=oc({amp:"&",apos:"\'",gt:">",lt:"<",quot:\'"\'});$r.HTML_ENTITIES=oc({Aacute:"\\xC1",aacute:"\\xE1",Abreve:"\\u0102",abreve:"\\u0103",ac:"\\u223E",acd:"\\u223F",acE:"\\u223E\\u0333",Acirc:"\\xC2",acirc:"\\xE2",acute:"\\xB4",Acy:"\\u0410",acy:"\\u0430",AElig:"\\xC6",aelig:"\\xE6",af:"\\u2061",Afr:"\\u{1D504}",afr:"\\u{1D51E}",Agrave:"\\xC0",agrave:"\\xE0",alefsym:"\\u2135",aleph:"\\u2135",Alpha:"\\u0391",alpha:"\\u03B1",Amacr:"\\u0100",amacr:"\\u0101",amalg:"\\u2A3F",AMP:"&",amp:"&",And:"\\u2A53",and:"\\u2227",andand:"\\u2A55",andd:"\\u2A5C",andslope:"\\u2A58",andv:"\\u2A5A",ang:"\\u2220",ange:"\\u29A4",angle:"\\u2220",angmsd:"\\u2221",angmsdaa:"\\u29A8",angmsdab:"\\u29A9",angmsdac:"\\u29AA",angmsdad:"\\u29AB",angmsdae:"\\u29AC",angmsdaf:"\\u29AD",angmsdag:"\\u29AE",angmsdah:"\\u29AF",angrt:"\\u221F",angrtvb:"\\u22BE",angrtvbd:"\\u299D",angsph:"\\u2222",angst:"\\xC5",angzarr:"\\u237C",Aogon:"\\u0104",aogon:"\\u0105",Aopf:"\\u{1D538}",aopf:"\\u{1D552}",ap:"\\u2248",apacir:"\\u2A6F",apE:"\\u2A70",ape:"\\u224A",apid:"\\u224B",apos:"\'",ApplyFunction:"\\u2061",approx:"\\u2248",approxeq:"\\u224A",Aring:"\\xC5",aring:"\\xE5",Ascr:"\\u{1D49C}",ascr:"\\u{1D4B6}",Assign:"\\u2254",ast:"*",asymp:"\\u2248",asympeq:"\\u224D",Atilde:"\\xC3",atilde:"\\xE3",Auml:"\\xC4",auml:"\\xE4",awconint:"\\u2233",awint:"\\u2A11",backcong:"\\u224C",backepsilon:"\\u03F6",backprime:"\\u2035",backsim:"\\u223D",backsimeq:"\\u22CD",Backslash:"\\u2216",Barv:"\\u2AE7",barvee:"\\u22BD",Barwed:"\\u2306",barwed:"\\u2305",barwedge:"\\u2305",bbrk:"\\u23B5",bbrktbrk:"\\u23B6",bcong:"\\u224C",Bcy:"\\u0411",bcy:"\\u0431",bdquo:"\\u201E",becaus:"\\u2235",Because:"\\u2235",because:"\\u2235",bemptyv:"\\u29B0",bepsi:"\\u03F6",bernou:"\\u212C",Bernoullis:"\\u212C",Beta:"\\u0392",beta:"\\u03B2",beth:"\\u2136",between:"\\u226C",Bfr:"\\u{1D505}",bfr:"\\u{1D51F}",bigcap:"\\u22C2",bigcirc:"\\u25EF",bigcup:"\\u22C3",bigodot:"\\u2A00",bigoplus:"\\u2A01",bigotimes:"\\u2A02",bigsqcup:"\\u2A06",bigstar:"\\u2605",bigtriangledown:"\\u25BD",bigtriangleup:"\\u25B3",biguplus:"\\u2A04",bigvee:"\\u22C1",bigwedge:"\\u22C0",bkarow:"\\u290D",blacklozenge:"\\u29EB",blacksquare:"\\u25AA",blacktriangle:"\\u25B4",blacktriangledown:"\\u25BE",blacktriangleleft:"\\u25C2",blacktriangleright:"\\u25B8",blank:"\\u2423",blk12:"\\u2592",blk14:"\\u2591",blk34:"\\u2593",block:"\\u2588",bne:"=\\u20E5",bnequiv:"\\u2261\\u20E5",bNot:"\\u2AED",bnot:"\\u2310",Bopf:"\\u{1D539}",bopf:"\\u{1D553}",bot:"\\u22A5",bottom:"\\u22A5",bowtie:"\\u22C8",boxbox:"\\u29C9",boxDL:"\\u2557",boxDl:"\\u2556",boxdL:"\\u2555",boxdl:"\\u2510",boxDR:"\\u2554",boxDr:"\\u2553",boxdR:"\\u2552",boxdr:"\\u250C",boxH:"\\u2550",boxh:"\\u2500",boxHD:"\\u2566",boxHd:"\\u2564",boxhD:"\\u2565",boxhd:"\\u252C",boxHU:"\\u2569",boxHu:"\\u2567",boxhU:"\\u2568",boxhu:"\\u2534",boxminus:"\\u229F",boxplus:"\\u229E",boxtimes:"\\u22A0",boxUL:"\\u255D",boxUl:"\\u255C",boxuL:"\\u255B",boxul:"\\u2518",boxUR:"\\u255A",boxUr:"\\u2559",boxuR:"\\u2558",boxur:"\\u2514",boxV:"\\u2551",boxv:"\\u2502",boxVH:"\\u256C",boxVh:"\\u256B",boxvH:"\\u256A",boxvh:"\\u253C",boxVL:"\\u2563",boxVl:"\\u2562",boxvL:"\\u2561",boxvl:"\\u2524",boxVR:"\\u2560",boxVr:"\\u255F",boxvR:"\\u255E",boxvr:"\\u251C",bprime:"\\u2035",Breve:"\\u02D8",breve:"\\u02D8",brvbar:"\\xA6",Bscr:"\\u212C",bscr:"\\u{1D4B7}",bsemi:"\\u204F",bsim:"\\u223D",bsime:"\\u22CD",bsol:"\\\\",bsolb:"\\u29C5",bsolhsub:"\\u27C8",bull:"\\u2022",bullet:"\\u2022",bump:"\\u224E",bumpE:"\\u2AAE",bumpe:"\\u224F",Bumpeq:"\\u224E",bumpeq:"\\u224F",Cacute:"\\u0106",cacute:"\\u0107",Cap:"\\u22D2",cap:"\\u2229",capand:"\\u2A44",capbrcup:"\\u2A49",capcap:"\\u2A4B",capcup:"\\u2A47",capdot:"\\u2A40",CapitalDifferentialD:"\\u2145",caps:"\\u2229\\uFE00",caret:"\\u2041",caron:"\\u02C7",Cayleys:"\\u212D",ccaps:"\\u2A4D",Ccaron:"\\u010C",ccaron:"\\u010D",Ccedil:"\\xC7",ccedil:"\\xE7",Ccirc:"\\u0108",ccirc:"\\u0109",Cconint:"\\u2230",ccups:"\\u2A4C",ccupssm:"\\u2A50",Cdot:"\\u010A",cdot:"\\u010B",cedil:"\\xB8",Cedilla:"\\xB8",cemptyv:"\\u29B2",cent:"\\xA2",CenterDot:"\\xB7",centerdot:"\\xB7",Cfr:"\\u212D",cfr:"\\u{1D520}",CHcy:"\\u0427",chcy:"\\u0447",check:"\\u2713",checkmark:"\\u2713",Chi:"\\u03A7",chi:"\\u03C7",cir:"\\u25CB",circ:"\\u02C6",circeq:"\\u2257",circlearrowleft:"\\u21BA",circlearrowright:"\\u21BB",circledast:"\\u229B",circledcirc:"\\u229A",circleddash:"\\u229D",CircleDot:"\\u2299",circledR:"\\xAE",circledS:"\\u24C8",CircleMinus:"\\u2296",CirclePlus:"\\u2295",CircleTimes:"\\u2297",cirE:"\\u29C3",cire:"\\u2257",cirfnint:"\\u2A10",cirmid:"\\u2AEF",cirscir:"\\u29C2",ClockwiseContourIntegral:"\\u2232",CloseCurlyDoubleQuote:"\\u201D",CloseCurlyQuote:"\\u2019",clubs:"\\u2663",clubsuit:"\\u2663",Colon:"\\u2237",colon:":",Colone:"\\u2A74",colone:"\\u2254",coloneq:"\\u2254",comma:",",commat:"@",comp:"\\u2201",compfn:"\\u2218",complement:"\\u2201",complexes:"\\u2102",cong:"\\u2245",congdot:"\\u2A6D",Congruent:"\\u2261",Conint:"\\u222F",conint:"\\u222E",ContourIntegral:"\\u222E",Copf:"\\u2102",copf:"\\u{1D554}",coprod:"\\u2210",Coproduct:"\\u2210",COPY:"\\xA9",copy:"\\xA9",copysr:"\\u2117",CounterClockwiseContourIntegral:"\\u2233",crarr:"\\u21B5",Cross:"\\u2A2F",cross:"\\u2717",Cscr:"\\u{1D49E}",cscr:"\\u{1D4B8}",csub:"\\u2ACF",csube:"\\u2AD1",csup:"\\u2AD0",csupe:"\\u2AD2",ctdot:"\\u22EF",cudarrl:"\\u2938",cudarrr:"\\u2935",cuepr:"\\u22DE",cuesc:"\\u22DF",cularr:"\\u21B6",cularrp:"\\u293D",Cup:"\\u22D3",cup:"\\u222A",cupbrcap:"\\u2A48",CupCap:"\\u224D",cupcap:"\\u2A46",cupcup:"\\u2A4A",cupdot:"\\u228D",cupor:"\\u2A45",cups:"\\u222A\\uFE00",curarr:"\\u21B7",curarrm:"\\u293C",curlyeqprec:"\\u22DE",curlyeqsucc:"\\u22DF",curlyvee:"\\u22CE",curlywedge:"\\u22CF",curren:"\\xA4",curvearrowleft:"\\u21B6",curvearrowright:"\\u21B7",cuvee:"\\u22CE",cuwed:"\\u22CF",cwconint:"\\u2232",cwint:"\\u2231",cylcty:"\\u232D",Dagger:"\\u2021",dagger:"\\u2020",daleth:"\\u2138",Darr:"\\u21A1",dArr:"\\u21D3",darr:"\\u2193",dash:"\\u2010",Dashv:"\\u2AE4",dashv:"\\u22A3",dbkarow:"\\u290F",dblac:"\\u02DD",Dcaron:"\\u010E",dcaron:"\\u010F",Dcy:"\\u0414",dcy:"\\u0434",DD:"\\u2145",dd:"\\u2146",ddagger:"\\u2021",ddarr:"\\u21CA",DDotrahd:"\\u2911",ddotseq:"\\u2A77",deg:"\\xB0",Del:"\\u2207",Delta:"\\u0394",delta:"\\u03B4",demptyv:"\\u29B1",dfisht:"\\u297F",Dfr:"\\u{1D507}",dfr:"\\u{1D521}",dHar:"\\u2965",dharl:"\\u21C3",dharr:"\\u21C2",DiacriticalAcute:"\\xB4",DiacriticalDot:"\\u02D9",DiacriticalDoubleAcute:"\\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\\u02DC",diam:"\\u22C4",Diamond:"\\u22C4",diamond:"\\u22C4",diamondsuit:"\\u2666",diams:"\\u2666",die:"\\xA8",DifferentialD:"\\u2146",digamma:"\\u03DD",disin:"\\u22F2",div:"\\xF7",divide:"\\xF7",divideontimes:"\\u22C7",divonx:"\\u22C7",DJcy:"\\u0402",djcy:"\\u0452",dlcorn:"\\u231E",dlcrop:"\\u230D",dollar:"$",Dopf:"\\u{1D53B}",dopf:"\\u{1D555}",Dot:"\\xA8",dot:"\\u02D9",DotDot:"\\u20DC",doteq:"\\u2250",doteqdot:"\\u2251",DotEqual:"\\u2250",dotminus:"\\u2238",dotplus:"\\u2214",dotsquare:"\\u22A1",doublebarwedge:"\\u2306",DoubleContourIntegral:"\\u222F",DoubleDot:"\\xA8",DoubleDownArrow:"\\u21D3",DoubleLeftArrow:"\\u21D0",DoubleLeftRightArrow:"\\u21D4",DoubleLeftTee:"\\u2AE4",DoubleLongLeftArrow:"\\u27F8",DoubleLongLeftRightArrow:"\\u27FA",DoubleLongRightArrow:"\\u27F9",DoubleRightArrow:"\\u21D2",DoubleRightTee:"\\u22A8",DoubleUpArrow:"\\u21D1",DoubleUpDownArrow:"\\u21D5",DoubleVerticalBar:"\\u2225",DownArrow:"\\u2193",Downarrow:"\\u21D3",downarrow:"\\u2193",DownArrowBar:"\\u2913",DownArrowUpArrow:"\\u21F5",DownBreve:"\\u0311",downdownarrows:"\\u21CA",downharpoonleft:"\\u21C3",downharpoonright:"\\u21C2",DownLeftRightVector:"\\u2950",DownLeftTeeVector:"\\u295E",DownLeftVector:"\\u21BD",DownLeftVectorBar:"\\u2956",DownRightTeeVector:"\\u295F",DownRightVector:"\\u21C1",DownRightVectorBar:"\\u2957",DownTee:"\\u22A4",DownTeeArrow:"\\u21A7",drbkarow:"\\u2910",drcorn:"\\u231F",drcrop:"\\u230C",Dscr:"\\u{1D49F}",dscr:"\\u{1D4B9}",DScy:"\\u0405",dscy:"\\u0455",dsol:"\\u29F6",Dstrok:"\\u0110",dstrok:"\\u0111",dtdot:"\\u22F1",dtri:"\\u25BF",dtrif:"\\u25BE",duarr:"\\u21F5",duhar:"\\u296F",dwangle:"\\u29A6",DZcy:"\\u040F",dzcy:"\\u045F",dzigrarr:"\\u27FF",Eacute:"\\xC9",eacute:"\\xE9",easter:"\\u2A6E",Ecaron:"\\u011A",ecaron:"\\u011B",ecir:"\\u2256",Ecirc:"\\xCA",ecirc:"\\xEA",ecolon:"\\u2255",Ecy:"\\u042D",ecy:"\\u044D",eDDot:"\\u2A77",Edot:"\\u0116",eDot:"\\u2251",edot:"\\u0117",ee:"\\u2147",efDot:"\\u2252",Efr:"\\u{1D508}",efr:"\\u{1D522}",eg:"\\u2A9A",Egrave:"\\xC8",egrave:"\\xE8",egs:"\\u2A96",egsdot:"\\u2A98",el:"\\u2A99",Element:"\\u2208",elinters:"\\u23E7",ell:"\\u2113",els:"\\u2A95",elsdot:"\\u2A97",Emacr:"\\u0112",emacr:"\\u0113",empty:"\\u2205",emptyset:"\\u2205",EmptySmallSquare:"\\u25FB",emptyv:"\\u2205",EmptyVerySmallSquare:"\\u25AB",emsp:"\\u2003",emsp13:"\\u2004",emsp14:"\\u2005",ENG:"\\u014A",eng:"\\u014B",ensp:"\\u2002",Eogon:"\\u0118",eogon:"\\u0119",Eopf:"\\u{1D53C}",eopf:"\\u{1D556}",epar:"\\u22D5",eparsl:"\\u29E3",eplus:"\\u2A71",epsi:"\\u03B5",Epsilon:"\\u0395",epsilon:"\\u03B5",epsiv:"\\u03F5",eqcirc:"\\u2256",eqcolon:"\\u2255",eqsim:"\\u2242",eqslantgtr:"\\u2A96",eqslantless:"\\u2A95",Equal:"\\u2A75",equals:"=",EqualTilde:"\\u2242",equest:"\\u225F",Equilibrium:"\\u21CC",equiv:"\\u2261",equivDD:"\\u2A78",eqvparsl:"\\u29E5",erarr:"\\u2971",erDot:"\\u2253",Escr:"\\u2130",escr:"\\u212F",esdot:"\\u2250",Esim:"\\u2A73",esim:"\\u2242",Eta:"\\u0397",eta:"\\u03B7",ETH:"\\xD0",eth:"\\xF0",Euml:"\\xCB",euml:"\\xEB",euro:"\\u20AC",excl:"!",exist:"\\u2203",Exists:"\\u2203",expectation:"\\u2130",ExponentialE:"\\u2147",exponentiale:"\\u2147",fallingdotseq:"\\u2252",Fcy:"\\u0424",fcy:"\\u0444",female:"\\u2640",ffilig:"\\uFB03",fflig:"\\uFB00",ffllig:"\\uFB04",Ffr:"\\u{1D509}",ffr:"\\u{1D523}",filig:"\\uFB01",FilledSmallSquare:"\\u25FC",FilledVerySmallSquare:"\\u25AA",fjlig:"fj",flat:"\\u266D",fllig:"\\uFB02",fltns:"\\u25B1",fnof:"\\u0192",Fopf:"\\u{1D53D}",fopf:"\\u{1D557}",ForAll:"\\u2200",forall:"\\u2200",fork:"\\u22D4",forkv:"\\u2AD9",Fouriertrf:"\\u2131",fpartint:"\\u2A0D",frac12:"\\xBD",frac13:"\\u2153",frac14:"\\xBC",frac15:"\\u2155",frac16:"\\u2159",frac18:"\\u215B",frac23:"\\u2154",frac25:"\\u2156",frac34:"\\xBE",frac35:"\\u2157",frac38:"\\u215C",frac45:"\\u2158",frac56:"\\u215A",frac58:"\\u215D",frac78:"\\u215E",frasl:"\\u2044",frown:"\\u2322",Fscr:"\\u2131",fscr:"\\u{1D4BB}",gacute:"\\u01F5",Gamma:"\\u0393",gamma:"\\u03B3",Gammad:"\\u03DC",gammad:"\\u03DD",gap:"\\u2A86",Gbreve:"\\u011E",gbreve:"\\u011F",Gcedil:"\\u0122",Gcirc:"\\u011C",gcirc:"\\u011D",Gcy:"\\u0413",gcy:"\\u0433",Gdot:"\\u0120",gdot:"\\u0121",gE:"\\u2267",ge:"\\u2265",gEl:"\\u2A8C",gel:"\\u22DB",geq:"\\u2265",geqq:"\\u2267",geqslant:"\\u2A7E",ges:"\\u2A7E",gescc:"\\u2AA9",gesdot:"\\u2A80",gesdoto:"\\u2A82",gesdotol:"\\u2A84",gesl:"\\u22DB\\uFE00",gesles:"\\u2A94",Gfr:"\\u{1D50A}",gfr:"\\u{1D524}",Gg:"\\u22D9",gg:"\\u226B",ggg:"\\u22D9",gimel:"\\u2137",GJcy:"\\u0403",gjcy:"\\u0453",gl:"\\u2277",gla:"\\u2AA5",glE:"\\u2A92",glj:"\\u2AA4",gnap:"\\u2A8A",gnapprox:"\\u2A8A",gnE:"\\u2269",gne:"\\u2A88",gneq:"\\u2A88",gneqq:"\\u2269",gnsim:"\\u22E7",Gopf:"\\u{1D53E}",gopf:"\\u{1D558}",grave:"`",GreaterEqual:"\\u2265",GreaterEqualLess:"\\u22DB",GreaterFullEqual:"\\u2267",GreaterGreater:"\\u2AA2",GreaterLess:"\\u2277",GreaterSlantEqual:"\\u2A7E",GreaterTilde:"\\u2273",Gscr:"\\u{1D4A2}",gscr:"\\u210A",gsim:"\\u2273",gsime:"\\u2A8E",gsiml:"\\u2A90",Gt:"\\u226B",GT:">",gt:">",gtcc:"\\u2AA7",gtcir:"\\u2A7A",gtdot:"\\u22D7",gtlPar:"\\u2995",gtquest:"\\u2A7C",gtrapprox:"\\u2A86",gtrarr:"\\u2978",gtrdot:"\\u22D7",gtreqless:"\\u22DB",gtreqqless:"\\u2A8C",gtrless:"\\u2277",gtrsim:"\\u2273",gvertneqq:"\\u2269\\uFE00",gvnE:"\\u2269\\uFE00",Hacek:"\\u02C7",hairsp:"\\u200A",half:"\\xBD",hamilt:"\\u210B",HARDcy:"\\u042A",hardcy:"\\u044A",hArr:"\\u21D4",harr:"\\u2194",harrcir:"\\u2948",harrw:"\\u21AD",Hat:"^",hbar:"\\u210F",Hcirc:"\\u0124",hcirc:"\\u0125",hearts:"\\u2665",heartsuit:"\\u2665",hellip:"\\u2026",hercon:"\\u22B9",Hfr:"\\u210C",hfr:"\\u{1D525}",HilbertSpace:"\\u210B",hksearow:"\\u2925",hkswarow:"\\u2926",hoarr:"\\u21FF",homtht:"\\u223B",hookleftarrow:"\\u21A9",hookrightarrow:"\\u21AA",Hopf:"\\u210D",hopf:"\\u{1D559}",horbar:"\\u2015",HorizontalLine:"\\u2500",Hscr:"\\u210B",hscr:"\\u{1D4BD}",hslash:"\\u210F",Hstrok:"\\u0126",hstrok:"\\u0127",HumpDownHump:"\\u224E",HumpEqual:"\\u224F",hybull:"\\u2043",hyphen:"\\u2010",Iacute:"\\xCD",iacute:"\\xED",ic:"\\u2063",Icirc:"\\xCE",icirc:"\\xEE",Icy:"\\u0418",icy:"\\u0438",Idot:"\\u0130",IEcy:"\\u0415",iecy:"\\u0435",iexcl:"\\xA1",iff:"\\u21D4",Ifr:"\\u2111",ifr:"\\u{1D526}",Igrave:"\\xCC",igrave:"\\xEC",ii:"\\u2148",iiiint:"\\u2A0C",iiint:"\\u222D",iinfin:"\\u29DC",iiota:"\\u2129",IJlig:"\\u0132",ijlig:"\\u0133",Im:"\\u2111",Imacr:"\\u012A",imacr:"\\u012B",image:"\\u2111",ImaginaryI:"\\u2148",imagline:"\\u2110",imagpart:"\\u2111",imath:"\\u0131",imof:"\\u22B7",imped:"\\u01B5",Implies:"\\u21D2",in:"\\u2208",incare:"\\u2105",infin:"\\u221E",infintie:"\\u29DD",inodot:"\\u0131",Int:"\\u222C",int:"\\u222B",intcal:"\\u22BA",integers:"\\u2124",Integral:"\\u222B",intercal:"\\u22BA",Intersection:"\\u22C2",intlarhk:"\\u2A17",intprod:"\\u2A3C",InvisibleComma:"\\u2063",InvisibleTimes:"\\u2062",IOcy:"\\u0401",iocy:"\\u0451",Iogon:"\\u012E",iogon:"\\u012F",Iopf:"\\u{1D540}",iopf:"\\u{1D55A}",Iota:"\\u0399",iota:"\\u03B9",iprod:"\\u2A3C",iquest:"\\xBF",Iscr:"\\u2110",iscr:"\\u{1D4BE}",isin:"\\u2208",isindot:"\\u22F5",isinE:"\\u22F9",isins:"\\u22F4",isinsv:"\\u22F3",isinv:"\\u2208",it:"\\u2062",Itilde:"\\u0128",itilde:"\\u0129",Iukcy:"\\u0406",iukcy:"\\u0456",Iuml:"\\xCF",iuml:"\\xEF",Jcirc:"\\u0134",jcirc:"\\u0135",Jcy:"\\u0419",jcy:"\\u0439",Jfr:"\\u{1D50D}",jfr:"\\u{1D527}",jmath:"\\u0237",Jopf:"\\u{1D541}",jopf:"\\u{1D55B}",Jscr:"\\u{1D4A5}",jscr:"\\u{1D4BF}",Jsercy:"\\u0408",jsercy:"\\u0458",Jukcy:"\\u0404",jukcy:"\\u0454",Kappa:"\\u039A",kappa:"\\u03BA",kappav:"\\u03F0",Kcedil:"\\u0136",kcedil:"\\u0137",Kcy:"\\u041A",kcy:"\\u043A",Kfr:"\\u{1D50E}",kfr:"\\u{1D528}",kgreen:"\\u0138",KHcy:"\\u0425",khcy:"\\u0445",KJcy:"\\u040C",kjcy:"\\u045C",Kopf:"\\u{1D542}",kopf:"\\u{1D55C}",Kscr:"\\u{1D4A6}",kscr:"\\u{1D4C0}",lAarr:"\\u21DA",Lacute:"\\u0139",lacute:"\\u013A",laemptyv:"\\u29B4",lagran:"\\u2112",Lambda:"\\u039B",lambda:"\\u03BB",Lang:"\\u27EA",lang:"\\u27E8",langd:"\\u2991",langle:"\\u27E8",lap:"\\u2A85",Laplacetrf:"\\u2112",laquo:"\\xAB",Larr:"\\u219E",lArr:"\\u21D0",larr:"\\u2190",larrb:"\\u21E4",larrbfs:"\\u291F",larrfs:"\\u291D",larrhk:"\\u21A9",larrlp:"\\u21AB",larrpl:"\\u2939",larrsim:"\\u2973",larrtl:"\\u21A2",lat:"\\u2AAB",lAtail:"\\u291B",latail:"\\u2919",late:"\\u2AAD",lates:"\\u2AAD\\uFE00",lBarr:"\\u290E",lbarr:"\\u290C",lbbrk:"\\u2772",lbrace:"{",lbrack:"[",lbrke:"\\u298B",lbrksld:"\\u298F",lbrkslu:"\\u298D",Lcaron:"\\u013D",lcaron:"\\u013E",Lcedil:"\\u013B",lcedil:"\\u013C",lceil:"\\u2308",lcub:"{",Lcy:"\\u041B",lcy:"\\u043B",ldca:"\\u2936",ldquo:"\\u201C",ldquor:"\\u201E",ldrdhar:"\\u2967",ldrushar:"\\u294B",ldsh:"\\u21B2",lE:"\\u2266",le:"\\u2264",LeftAngleBracket:"\\u27E8",LeftArrow:"\\u2190",Leftarrow:"\\u21D0",leftarrow:"\\u2190",LeftArrowBar:"\\u21E4",LeftArrowRightArrow:"\\u21C6",leftarrowtail:"\\u21A2",LeftCeiling:"\\u2308",LeftDoubleBracket:"\\u27E6",LeftDownTeeVector:"\\u2961",LeftDownVector:"\\u21C3",LeftDownVectorBar:"\\u2959",LeftFloor:"\\u230A",leftharpoondown:"\\u21BD",leftharpoonup:"\\u21BC",leftleftarrows:"\\u21C7",LeftRightArrow:"\\u2194",Leftrightarrow:"\\u21D4",leftrightarrow:"\\u2194",leftrightarrows:"\\u21C6",leftrightharpoons:"\\u21CB",leftrightsquigarrow:"\\u21AD",LeftRightVector:"\\u294E",LeftTee:"\\u22A3",LeftTeeArrow:"\\u21A4",LeftTeeVector:"\\u295A",leftthreetimes:"\\u22CB",LeftTriangle:"\\u22B2",LeftTriangleBar:"\\u29CF",LeftTriangleEqual:"\\u22B4",LeftUpDownVector:"\\u2951",LeftUpTeeVector:"\\u2960",LeftUpVector:"\\u21BF",LeftUpVectorBar:"\\u2958",LeftVector:"\\u21BC",LeftVectorBar:"\\u2952",lEg:"\\u2A8B",leg:"\\u22DA",leq:"\\u2264",leqq:"\\u2266",leqslant:"\\u2A7D",les:"\\u2A7D",lescc:"\\u2AA8",lesdot:"\\u2A7F",lesdoto:"\\u2A81",lesdotor:"\\u2A83",lesg:"\\u22DA\\uFE00",lesges:"\\u2A93",lessapprox:"\\u2A85",lessdot:"\\u22D6",lesseqgtr:"\\u22DA",lesseqqgtr:"\\u2A8B",LessEqualGreater:"\\u22DA",LessFullEqual:"\\u2266",LessGreater:"\\u2276",lessgtr:"\\u2276",LessLess:"\\u2AA1",lesssim:"\\u2272",LessSlantEqual:"\\u2A7D",LessTilde:"\\u2272",lfisht:"\\u297C",lfloor:"\\u230A",Lfr:"\\u{1D50F}",lfr:"\\u{1D529}",lg:"\\u2276",lgE:"\\u2A91",lHar:"\\u2962",lhard:"\\u21BD",lharu:"\\u21BC",lharul:"\\u296A",lhblk:"\\u2584",LJcy:"\\u0409",ljcy:"\\u0459",Ll:"\\u22D8",ll:"\\u226A",llarr:"\\u21C7",llcorner:"\\u231E",Lleftarrow:"\\u21DA",llhard:"\\u296B",lltri:"\\u25FA",Lmidot:"\\u013F",lmidot:"\\u0140",lmoust:"\\u23B0",lmoustache:"\\u23B0",lnap:"\\u2A89",lnapprox:"\\u2A89",lnE:"\\u2268",lne:"\\u2A87",lneq:"\\u2A87",lneqq:"\\u2268",lnsim:"\\u22E6",loang:"\\u27EC",loarr:"\\u21FD",lobrk:"\\u27E6",LongLeftArrow:"\\u27F5",Longleftarrow:"\\u27F8",longleftarrow:"\\u27F5",LongLeftRightArrow:"\\u27F7",Longleftrightarrow:"\\u27FA",longleftrightarrow:"\\u27F7",longmapsto:"\\u27FC",LongRightArrow:"\\u27F6",Longrightarrow:"\\u27F9",longrightarrow:"\\u27F6",looparrowleft:"\\u21AB",looparrowright:"\\u21AC",lopar:"\\u2985",Lopf:"\\u{1D543}",lopf:"\\u{1D55D}",loplus:"\\u2A2D",lotimes:"\\u2A34",lowast:"\\u2217",lowbar:"_",LowerLeftArrow:"\\u2199",LowerRightArrow:"\\u2198",loz:"\\u25CA",lozenge:"\\u25CA",lozf:"\\u29EB",lpar:"(",lparlt:"\\u2993",lrarr:"\\u21C6",lrcorner:"\\u231F",lrhar:"\\u21CB",lrhard:"\\u296D",lrm:"\\u200E",lrtri:"\\u22BF",lsaquo:"\\u2039",Lscr:"\\u2112",lscr:"\\u{1D4C1}",Lsh:"\\u21B0",lsh:"\\u21B0",lsim:"\\u2272",lsime:"\\u2A8D",lsimg:"\\u2A8F",lsqb:"[",lsquo:"\\u2018",lsquor:"\\u201A",Lstrok:"\\u0141",lstrok:"\\u0142",Lt:"\\u226A",LT:"<",lt:"<",ltcc:"\\u2AA6",ltcir:"\\u2A79",ltdot:"\\u22D6",lthree:"\\u22CB",ltimes:"\\u22C9",ltlarr:"\\u2976",ltquest:"\\u2A7B",ltri:"\\u25C3",ltrie:"\\u22B4",ltrif:"\\u25C2",ltrPar:"\\u2996",lurdshar:"\\u294A",luruhar:"\\u2966",lvertneqq:"\\u2268\\uFE00",lvnE:"\\u2268\\uFE00",macr:"\\xAF",male:"\\u2642",malt:"\\u2720",maltese:"\\u2720",Map:"\\u2905",map:"\\u21A6",mapsto:"\\u21A6",mapstodown:"\\u21A7",mapstoleft:"\\u21A4",mapstoup:"\\u21A5",marker:"\\u25AE",mcomma:"\\u2A29",Mcy:"\\u041C",mcy:"\\u043C",mdash:"\\u2014",mDDot:"\\u223A",measuredangle:"\\u2221",MediumSpace:"\\u205F",Mellintrf:"\\u2133",Mfr:"\\u{1D510}",mfr:"\\u{1D52A}",mho:"\\u2127",micro:"\\xB5",mid:"\\u2223",midast:"*",midcir:"\\u2AF0",middot:"\\xB7",minus:"\\u2212",minusb:"\\u229F",minusd:"\\u2238",minusdu:"\\u2A2A",MinusPlus:"\\u2213",mlcp:"\\u2ADB",mldr:"\\u2026",mnplus:"\\u2213",models:"\\u22A7",Mopf:"\\u{1D544}",mopf:"\\u{1D55E}",mp:"\\u2213",Mscr:"\\u2133",mscr:"\\u{1D4C2}",mstpos:"\\u223E",Mu:"\\u039C",mu:"\\u03BC",multimap:"\\u22B8",mumap:"\\u22B8",nabla:"\\u2207",Nacute:"\\u0143",nacute:"\\u0144",nang:"\\u2220\\u20D2",nap:"\\u2249",napE:"\\u2A70\\u0338",napid:"\\u224B\\u0338",napos:"\\u0149",napprox:"\\u2249",natur:"\\u266E",natural:"\\u266E",naturals:"\\u2115",nbsp:"\\xA0",nbump:"\\u224E\\u0338",nbumpe:"\\u224F\\u0338",ncap:"\\u2A43",Ncaron:"\\u0147",ncaron:"\\u0148",Ncedil:"\\u0145",ncedil:"\\u0146",ncong:"\\u2247",ncongdot:"\\u2A6D\\u0338",ncup:"\\u2A42",Ncy:"\\u041D",ncy:"\\u043D",ndash:"\\u2013",ne:"\\u2260",nearhk:"\\u2924",neArr:"\\u21D7",nearr:"\\u2197",nearrow:"\\u2197",nedot:"\\u2250\\u0338",NegativeMediumSpace:"\\u200B",NegativeThickSpace:"\\u200B",NegativeThinSpace:"\\u200B",NegativeVeryThinSpace:"\\u200B",nequiv:"\\u2262",nesear:"\\u2928",nesim:"\\u2242\\u0338",NestedGreaterGreater:"\\u226B",NestedLessLess:"\\u226A",NewLine:`\n`,nexist:"\\u2204",nexists:"\\u2204",Nfr:"\\u{1D511}",nfr:"\\u{1D52B}",ngE:"\\u2267\\u0338",nge:"\\u2271",ngeq:"\\u2271",ngeqq:"\\u2267\\u0338",ngeqslant:"\\u2A7E\\u0338",nges:"\\u2A7E\\u0338",nGg:"\\u22D9\\u0338",ngsim:"\\u2275",nGt:"\\u226B\\u20D2",ngt:"\\u226F",ngtr:"\\u226F",nGtv:"\\u226B\\u0338",nhArr:"\\u21CE",nharr:"\\u21AE",nhpar:"\\u2AF2",ni:"\\u220B",nis:"\\u22FC",nisd:"\\u22FA",niv:"\\u220B",NJcy:"\\u040A",njcy:"\\u045A",nlArr:"\\u21CD",nlarr:"\\u219A",nldr:"\\u2025",nlE:"\\u2266\\u0338",nle:"\\u2270",nLeftarrow:"\\u21CD",nleftarrow:"\\u219A",nLeftrightarrow:"\\u21CE",nleftrightarrow:"\\u21AE",nleq:"\\u2270",nleqq:"\\u2266\\u0338",nleqslant:"\\u2A7D\\u0338",nles:"\\u2A7D\\u0338",nless:"\\u226E",nLl:"\\u22D8\\u0338",nlsim:"\\u2274",nLt:"\\u226A\\u20D2",nlt:"\\u226E",nltri:"\\u22EA",nltrie:"\\u22EC",nLtv:"\\u226A\\u0338",nmid:"\\u2224",NoBreak:"\\u2060",NonBreakingSpace:"\\xA0",Nopf:"\\u2115",nopf:"\\u{1D55F}",Not:"\\u2AEC",not:"\\xAC",NotCongruent:"\\u2262",NotCupCap:"\\u226D",NotDoubleVerticalBar:"\\u2226",NotElement:"\\u2209",NotEqual:"\\u2260",NotEqualTilde:"\\u2242\\u0338",NotExists:"\\u2204",NotGreater:"\\u226F",NotGreaterEqual:"\\u2271",NotGreaterFullEqual:"\\u2267\\u0338",NotGreaterGreater:"\\u226B\\u0338",NotGreaterLess:"\\u2279",NotGreaterSlantEqual:"\\u2A7E\\u0338",NotGreaterTilde:"\\u2275",NotHumpDownHump:"\\u224E\\u0338",NotHumpEqual:"\\u224F\\u0338",notin:"\\u2209",notindot:"\\u22F5\\u0338",notinE:"\\u22F9\\u0338",notinva:"\\u2209",notinvb:"\\u22F7",notinvc:"\\u22F6",NotLeftTriangle:"\\u22EA",NotLeftTriangleBar:"\\u29CF\\u0338",NotLeftTriangleEqual:"\\u22EC",NotLess:"\\u226E",NotLessEqual:"\\u2270",NotLessGreater:"\\u2278",NotLessLess:"\\u226A\\u0338",NotLessSlantEqual:"\\u2A7D\\u0338",NotLessTilde:"\\u2274",NotNestedGreaterGreater:"\\u2AA2\\u0338",NotNestedLessLess:"\\u2AA1\\u0338",notni:"\\u220C",notniva:"\\u220C",notnivb:"\\u22FE",notnivc:"\\u22FD",NotPrecedes:"\\u2280",NotPrecedesEqual:"\\u2AAF\\u0338",NotPrecedesSlantEqual:"\\u22E0",NotReverseElement:"\\u220C",NotRightTriangle:"\\u22EB",NotRightTriangleBar:"\\u29D0\\u0338",NotRightTriangleEqual:"\\u22ED",NotSquareSubset:"\\u228F\\u0338",NotSquareSubsetEqual:"\\u22E2",NotSquareSuperset:"\\u2290\\u0338",NotSquareSupersetEqual:"\\u22E3",NotSubset:"\\u2282\\u20D2",NotSubsetEqual:"\\u2288",NotSucceeds:"\\u2281",NotSucceedsEqual:"\\u2AB0\\u0338",NotSucceedsSlantEqual:"\\u22E1",NotSucceedsTilde:"\\u227F\\u0338",NotSuperset:"\\u2283\\u20D2",NotSupersetEqual:"\\u2289",NotTilde:"\\u2241",NotTildeEqual:"\\u2244",NotTildeFullEqual:"\\u2247",NotTildeTilde:"\\u2249",NotVerticalBar:"\\u2224",npar:"\\u2226",nparallel:"\\u2226",nparsl:"\\u2AFD\\u20E5",npart:"\\u2202\\u0338",npolint:"\\u2A14",npr:"\\u2280",nprcue:"\\u22E0",npre:"\\u2AAF\\u0338",nprec:"\\u2280",npreceq:"\\u2AAF\\u0338",nrArr:"\\u21CF",nrarr:"\\u219B",nrarrc:"\\u2933\\u0338",nrarrw:"\\u219D\\u0338",nRightarrow:"\\u21CF",nrightarrow:"\\u219B",nrtri:"\\u22EB",nrtrie:"\\u22ED",nsc:"\\u2281",nsccue:"\\u22E1",nsce:"\\u2AB0\\u0338",Nscr:"\\u{1D4A9}",nscr:"\\u{1D4C3}",nshortmid:"\\u2224",nshortparallel:"\\u2226",nsim:"\\u2241",nsime:"\\u2244",nsimeq:"\\u2244",nsmid:"\\u2224",nspar:"\\u2226",nsqsube:"\\u22E2",nsqsupe:"\\u22E3",nsub:"\\u2284",nsubE:"\\u2AC5\\u0338",nsube:"\\u2288",nsubset:"\\u2282\\u20D2",nsubseteq:"\\u2288",nsubseteqq:"\\u2AC5\\u0338",nsucc:"\\u2281",nsucceq:"\\u2AB0\\u0338",nsup:"\\u2285",nsupE:"\\u2AC6\\u0338",nsupe:"\\u2289",nsupset:"\\u2283\\u20D2",nsupseteq:"\\u2289",nsupseteqq:"\\u2AC6\\u0338",ntgl:"\\u2279",Ntilde:"\\xD1",ntilde:"\\xF1",ntlg:"\\u2278",ntriangleleft:"\\u22EA",ntrianglelefteq:"\\u22EC",ntriangleright:"\\u22EB",ntrianglerighteq:"\\u22ED",Nu:"\\u039D",nu:"\\u03BD",num:"#",numero:"\\u2116",numsp:"\\u2007",nvap:"\\u224D\\u20D2",nVDash:"\\u22AF",nVdash:"\\u22AE",nvDash:"\\u22AD",nvdash:"\\u22AC",nvge:"\\u2265\\u20D2",nvgt:">\\u20D2",nvHarr:"\\u2904",nvinfin:"\\u29DE",nvlArr:"\\u2902",nvle:"\\u2264\\u20D2",nvlt:"<\\u20D2",nvltrie:"\\u22B4\\u20D2",nvrArr:"\\u2903",nvrtrie:"\\u22B5\\u20D2",nvsim:"\\u223C\\u20D2",nwarhk:"\\u2923",nwArr:"\\u21D6",nwarr:"\\u2196",nwarrow:"\\u2196",nwnear:"\\u2927",Oacute:"\\xD3",oacute:"\\xF3",oast:"\\u229B",ocir:"\\u229A",Ocirc:"\\xD4",ocirc:"\\xF4",Ocy:"\\u041E",ocy:"\\u043E",odash:"\\u229D",Odblac:"\\u0150",odblac:"\\u0151",odiv:"\\u2A38",odot:"\\u2299",odsold:"\\u29BC",OElig:"\\u0152",oelig:"\\u0153",ofcir:"\\u29BF",Ofr:"\\u{1D512}",ofr:"\\u{1D52C}",ogon:"\\u02DB",Ograve:"\\xD2",ograve:"\\xF2",ogt:"\\u29C1",ohbar:"\\u29B5",ohm:"\\u03A9",oint:"\\u222E",olarr:"\\u21BA",olcir:"\\u29BE",olcross:"\\u29BB",oline:"\\u203E",olt:"\\u29C0",Omacr:"\\u014C",omacr:"\\u014D",Omega:"\\u03A9",omega:"\\u03C9",Omicron:"\\u039F",omicron:"\\u03BF",omid:"\\u29B6",ominus:"\\u2296",Oopf:"\\u{1D546}",oopf:"\\u{1D560}",opar:"\\u29B7",OpenCurlyDoubleQuote:"\\u201C",OpenCurlyQuote:"\\u2018",operp:"\\u29B9",oplus:"\\u2295",Or:"\\u2A54",or:"\\u2228",orarr:"\\u21BB",ord:"\\u2A5D",order:"\\u2134",orderof:"\\u2134",ordf:"\\xAA",ordm:"\\xBA",origof:"\\u22B6",oror:"\\u2A56",orslope:"\\u2A57",orv:"\\u2A5B",oS:"\\u24C8",Oscr:"\\u{1D4AA}",oscr:"\\u2134",Oslash:"\\xD8",oslash:"\\xF8",osol:"\\u2298",Otilde:"\\xD5",otilde:"\\xF5",Otimes:"\\u2A37",otimes:"\\u2297",otimesas:"\\u2A36",Ouml:"\\xD6",ouml:"\\xF6",ovbar:"\\u233D",OverBar:"\\u203E",OverBrace:"\\u23DE",OverBracket:"\\u23B4",OverParenthesis:"\\u23DC",par:"\\u2225",para:"\\xB6",parallel:"\\u2225",parsim:"\\u2AF3",parsl:"\\u2AFD",part:"\\u2202",PartialD:"\\u2202",Pcy:"\\u041F",pcy:"\\u043F",percnt:"%",period:".",permil:"\\u2030",perp:"\\u22A5",pertenk:"\\u2031",Pfr:"\\u{1D513}",pfr:"\\u{1D52D}",Phi:"\\u03A6",phi:"\\u03C6",phiv:"\\u03D5",phmmat:"\\u2133",phone:"\\u260E",Pi:"\\u03A0",pi:"\\u03C0",pitchfork:"\\u22D4",piv:"\\u03D6",planck:"\\u210F",planckh:"\\u210E",plankv:"\\u210F",plus:"+",plusacir:"\\u2A23",plusb:"\\u229E",pluscir:"\\u2A22",plusdo:"\\u2214",plusdu:"\\u2A25",pluse:"\\u2A72",PlusMinus:"\\xB1",plusmn:"\\xB1",plussim:"\\u2A26",plustwo:"\\u2A27",pm:"\\xB1",Poincareplane:"\\u210C",pointint:"\\u2A15",Popf:"\\u2119",popf:"\\u{1D561}",pound:"\\xA3",Pr:"\\u2ABB",pr:"\\u227A",prap:"\\u2AB7",prcue:"\\u227C",prE:"\\u2AB3",pre:"\\u2AAF",prec:"\\u227A",precapprox:"\\u2AB7",preccurlyeq:"\\u227C",Precedes:"\\u227A",PrecedesEqual:"\\u2AAF",PrecedesSlantEqual:"\\u227C",PrecedesTilde:"\\u227E",preceq:"\\u2AAF",precnapprox:"\\u2AB9",precneqq:"\\u2AB5",precnsim:"\\u22E8",precsim:"\\u227E",Prime:"\\u2033",prime:"\\u2032",primes:"\\u2119",prnap:"\\u2AB9",prnE:"\\u2AB5",prnsim:"\\u22E8",prod:"\\u220F",Product:"\\u220F",profalar:"\\u232E",profline:"\\u2312",profsurf:"\\u2313",prop:"\\u221D",Proportion:"\\u2237",Proportional:"\\u221D",propto:"\\u221D",prsim:"\\u227E",prurel:"\\u22B0",Pscr:"\\u{1D4AB}",pscr:"\\u{1D4C5}",Psi:"\\u03A8",psi:"\\u03C8",puncsp:"\\u2008",Qfr:"\\u{1D514}",qfr:"\\u{1D52E}",qint:"\\u2A0C",Qopf:"\\u211A",qopf:"\\u{1D562}",qprime:"\\u2057",Qscr:"\\u{1D4AC}",qscr:"\\u{1D4C6}",quaternions:"\\u210D",quatint:"\\u2A16",quest:"?",questeq:"\\u225F",QUOT:\'"\',quot:\'"\',rAarr:"\\u21DB",race:"\\u223D\\u0331",Racute:"\\u0154",racute:"\\u0155",radic:"\\u221A",raemptyv:"\\u29B3",Rang:"\\u27EB",rang:"\\u27E9",rangd:"\\u2992",range:"\\u29A5",rangle:"\\u27E9",raquo:"\\xBB",Rarr:"\\u21A0",rArr:"\\u21D2",rarr:"\\u2192",rarrap:"\\u2975",rarrb:"\\u21E5",rarrbfs:"\\u2920",rarrc:"\\u2933",rarrfs:"\\u291E",rarrhk:"\\u21AA",rarrlp:"\\u21AC",rarrpl:"\\u2945",rarrsim:"\\u2974",Rarrtl:"\\u2916",rarrtl:"\\u21A3",rarrw:"\\u219D",rAtail:"\\u291C",ratail:"\\u291A",ratio:"\\u2236",rationals:"\\u211A",RBarr:"\\u2910",rBarr:"\\u290F",rbarr:"\\u290D",rbbrk:"\\u2773",rbrace:"}",rbrack:"]",rbrke:"\\u298C",rbrksld:"\\u298E",rbrkslu:"\\u2990",Rcaron:"\\u0158",rcaron:"\\u0159",Rcedil:"\\u0156",rcedil:"\\u0157",rceil:"\\u2309",rcub:"}",Rcy:"\\u0420",rcy:"\\u0440",rdca:"\\u2937",rdldhar:"\\u2969",rdquo:"\\u201D",rdquor:"\\u201D",rdsh:"\\u21B3",Re:"\\u211C",real:"\\u211C",realine:"\\u211B",realpart:"\\u211C",reals:"\\u211D",rect:"\\u25AD",REG:"\\xAE",reg:"\\xAE",ReverseElement:"\\u220B",ReverseEquilibrium:"\\u21CB",ReverseUpEquilibrium:"\\u296F",rfisht:"\\u297D",rfloor:"\\u230B",Rfr:"\\u211C",rfr:"\\u{1D52F}",rHar:"\\u2964",rhard:"\\u21C1",rharu:"\\u21C0",rharul:"\\u296C",Rho:"\\u03A1",rho:"\\u03C1",rhov:"\\u03F1",RightAngleBracket:"\\u27E9",RightArrow:"\\u2192",Rightarrow:"\\u21D2",rightarrow:"\\u2192",RightArrowBar:"\\u21E5",RightArrowLeftArrow:"\\u21C4",rightarrowtail:"\\u21A3",RightCeiling:"\\u2309",RightDoubleBracket:"\\u27E7",RightDownTeeVector:"\\u295D",RightDownVector:"\\u21C2",RightDownVectorBar:"\\u2955",RightFloor:"\\u230B",rightharpoondown:"\\u21C1",rightharpoonup:"\\u21C0",rightleftarrows:"\\u21C4",rightleftharpoons:"\\u21CC",rightrightarrows:"\\u21C9",rightsquigarrow:"\\u219D",RightTee:"\\u22A2",RightTeeArrow:"\\u21A6",RightTeeVector:"\\u295B",rightthreetimes:"\\u22CC",RightTriangle:"\\u22B3",RightTriangleBar:"\\u29D0",RightTriangleEqual:"\\u22B5",RightUpDownVector:"\\u294F",RightUpTeeVector:"\\u295C",RightUpVector:"\\u21BE",RightUpVectorBar:"\\u2954",RightVector:"\\u21C0",RightVectorBar:"\\u2953",ring:"\\u02DA",risingdotseq:"\\u2253",rlarr:"\\u21C4",rlhar:"\\u21CC",rlm:"\\u200F",rmoust:"\\u23B1",rmoustache:"\\u23B1",rnmid:"\\u2AEE",roang:"\\u27ED",roarr:"\\u21FE",robrk:"\\u27E7",ropar:"\\u2986",Ropf:"\\u211D",ropf:"\\u{1D563}",roplus:"\\u2A2E",rotimes:"\\u2A35",RoundImplies:"\\u2970",rpar:")",rpargt:"\\u2994",rppolint:"\\u2A12",rrarr:"\\u21C9",Rrightarrow:"\\u21DB",rsaquo:"\\u203A",Rscr:"\\u211B",rscr:"\\u{1D4C7}",Rsh:"\\u21B1",rsh:"\\u21B1",rsqb:"]",rsquo:"\\u2019",rsquor:"\\u2019",rthree:"\\u22CC",rtimes:"\\u22CA",rtri:"\\u25B9",rtrie:"\\u22B5",rtrif:"\\u25B8",rtriltri:"\\u29CE",RuleDelayed:"\\u29F4",ruluhar:"\\u2968",rx:"\\u211E",Sacute:"\\u015A",sacute:"\\u015B",sbquo:"\\u201A",Sc:"\\u2ABC",sc:"\\u227B",scap:"\\u2AB8",Scaron:"\\u0160",scaron:"\\u0161",sccue:"\\u227D",scE:"\\u2AB4",sce:"\\u2AB0",Scedil:"\\u015E",scedil:"\\u015F",Scirc:"\\u015C",scirc:"\\u015D",scnap:"\\u2ABA",scnE:"\\u2AB6",scnsim:"\\u22E9",scpolint:"\\u2A13",scsim:"\\u227F",Scy:"\\u0421",scy:"\\u0441",sdot:"\\u22C5",sdotb:"\\u22A1",sdote:"\\u2A66",searhk:"\\u2925",seArr:"\\u21D8",searr:"\\u2198",searrow:"\\u2198",sect:"\\xA7",semi:";",seswar:"\\u2929",setminus:"\\u2216",setmn:"\\u2216",sext:"\\u2736",Sfr:"\\u{1D516}",sfr:"\\u{1D530}",sfrown:"\\u2322",sharp:"\\u266F",SHCHcy:"\\u0429",shchcy:"\\u0449",SHcy:"\\u0428",shcy:"\\u0448",ShortDownArrow:"\\u2193",ShortLeftArrow:"\\u2190",shortmid:"\\u2223",shortparallel:"\\u2225",ShortRightArrow:"\\u2192",ShortUpArrow:"\\u2191",shy:"\\xAD",Sigma:"\\u03A3",sigma:"\\u03C3",sigmaf:"\\u03C2",sigmav:"\\u03C2",sim:"\\u223C",simdot:"\\u2A6A",sime:"\\u2243",simeq:"\\u2243",simg:"\\u2A9E",simgE:"\\u2AA0",siml:"\\u2A9D",simlE:"\\u2A9F",simne:"\\u2246",simplus:"\\u2A24",simrarr:"\\u2972",slarr:"\\u2190",SmallCircle:"\\u2218",smallsetminus:"\\u2216",smashp:"\\u2A33",smeparsl:"\\u29E4",smid:"\\u2223",smile:"\\u2323",smt:"\\u2AAA",smte:"\\u2AAC",smtes:"\\u2AAC\\uFE00",SOFTcy:"\\u042C",softcy:"\\u044C",sol:"/",solb:"\\u29C4",solbar:"\\u233F",Sopf:"\\u{1D54A}",sopf:"\\u{1D564}",spades:"\\u2660",spadesuit:"\\u2660",spar:"\\u2225",sqcap:"\\u2293",sqcaps:"\\u2293\\uFE00",sqcup:"\\u2294",sqcups:"\\u2294\\uFE00",Sqrt:"\\u221A",sqsub:"\\u228F",sqsube:"\\u2291",sqsubset:"\\u228F",sqsubseteq:"\\u2291",sqsup:"\\u2290",sqsupe:"\\u2292",sqsupset:"\\u2290",sqsupseteq:"\\u2292",squ:"\\u25A1",Square:"\\u25A1",square:"\\u25A1",SquareIntersection:"\\u2293",SquareSubset:"\\u228F",SquareSubsetEqual:"\\u2291",SquareSuperset:"\\u2290",SquareSupersetEqual:"\\u2292",SquareUnion:"\\u2294",squarf:"\\u25AA",squf:"\\u25AA",srarr:"\\u2192",Sscr:"\\u{1D4AE}",sscr:"\\u{1D4C8}",ssetmn:"\\u2216",ssmile:"\\u2323",sstarf:"\\u22C6",Star:"\\u22C6",star:"\\u2606",starf:"\\u2605",straightepsilon:"\\u03F5",straightphi:"\\u03D5",strns:"\\xAF",Sub:"\\u22D0",sub:"\\u2282",subdot:"\\u2ABD",subE:"\\u2AC5",sube:"\\u2286",subedot:"\\u2AC3",submult:"\\u2AC1",subnE:"\\u2ACB",subne:"\\u228A",subplus:"\\u2ABF",subrarr:"\\u2979",Subset:"\\u22D0",subset:"\\u2282",subseteq:"\\u2286",subseteqq:"\\u2AC5",SubsetEqual:"\\u2286",subsetneq:"\\u228A",subsetneqq:"\\u2ACB",subsim:"\\u2AC7",subsub:"\\u2AD5",subsup:"\\u2AD3",succ:"\\u227B",succapprox:"\\u2AB8",succcurlyeq:"\\u227D",Succeeds:"\\u227B",SucceedsEqual:"\\u2AB0",SucceedsSlantEqual:"\\u227D",SucceedsTilde:"\\u227F",succeq:"\\u2AB0",succnapprox:"\\u2ABA",succneqq:"\\u2AB6",succnsim:"\\u22E9",succsim:"\\u227F",SuchThat:"\\u220B",Sum:"\\u2211",sum:"\\u2211",sung:"\\u266A",Sup:"\\u22D1",sup:"\\u2283",sup1:"\\xB9",sup2:"\\xB2",sup3:"\\xB3",supdot:"\\u2ABE",supdsub:"\\u2AD8",supE:"\\u2AC6",supe:"\\u2287",supedot:"\\u2AC4",Superset:"\\u2283",SupersetEqual:"\\u2287",suphsol:"\\u27C9",suphsub:"\\u2AD7",suplarr:"\\u297B",supmult:"\\u2AC2",supnE:"\\u2ACC",supne:"\\u228B",supplus:"\\u2AC0",Supset:"\\u22D1",supset:"\\u2283",supseteq:"\\u2287",supseteqq:"\\u2AC6",supsetneq:"\\u228B",supsetneqq:"\\u2ACC",supsim:"\\u2AC8",supsub:"\\u2AD4",supsup:"\\u2AD6",swarhk:"\\u2926",swArr:"\\u21D9",swarr:"\\u2199",swarrow:"\\u2199",swnwar:"\\u292A",szlig:"\\xDF",Tab:" ",target:"\\u2316",Tau:"\\u03A4",tau:"\\u03C4",tbrk:"\\u23B4",Tcaron:"\\u0164",tcaron:"\\u0165",Tcedil:"\\u0162",tcedil:"\\u0163",Tcy:"\\u0422",tcy:"\\u0442",tdot:"\\u20DB",telrec:"\\u2315",Tfr:"\\u{1D517}",tfr:"\\u{1D531}",there4:"\\u2234",Therefore:"\\u2234",therefore:"\\u2234",Theta:"\\u0398",theta:"\\u03B8",thetasym:"\\u03D1",thetav:"\\u03D1",thickapprox:"\\u2248",thicksim:"\\u223C",ThickSpace:"\\u205F\\u200A",thinsp:"\\u2009",ThinSpace:"\\u2009",thkap:"\\u2248",thksim:"\\u223C",THORN:"\\xDE",thorn:"\\xFE",Tilde:"\\u223C",tilde:"\\u02DC",TildeEqual:"\\u2243",TildeFullEqual:"\\u2245",TildeTilde:"\\u2248",times:"\\xD7",timesb:"\\u22A0",timesbar:"\\u2A31",timesd:"\\u2A30",tint:"\\u222D",toea:"\\u2928",top:"\\u22A4",topbot:"\\u2336",topcir:"\\u2AF1",Topf:"\\u{1D54B}",topf:"\\u{1D565}",topfork:"\\u2ADA",tosa:"\\u2929",tprime:"\\u2034",TRADE:"\\u2122",trade:"\\u2122",triangle:"\\u25B5",triangledown:"\\u25BF",triangleleft:"\\u25C3",trianglelefteq:"\\u22B4",triangleq:"\\u225C",triangleright:"\\u25B9",trianglerighteq:"\\u22B5",tridot:"\\u25EC",trie:"\\u225C",triminus:"\\u2A3A",TripleDot:"\\u20DB",triplus:"\\u2A39",trisb:"\\u29CD",tritime:"\\u2A3B",trpezium:"\\u23E2",Tscr:"\\u{1D4AF}",tscr:"\\u{1D4C9}",TScy:"\\u0426",tscy:"\\u0446",TSHcy:"\\u040B",tshcy:"\\u045B",Tstrok:"\\u0166",tstrok:"\\u0167",twixt:"\\u226C",twoheadleftarrow:"\\u219E",twoheadrightarrow:"\\u21A0",Uacute:"\\xDA",uacute:"\\xFA",Uarr:"\\u219F",uArr:"\\u21D1",uarr:"\\u2191",Uarrocir:"\\u2949",Ubrcy:"\\u040E",ubrcy:"\\u045E",Ubreve:"\\u016C",ubreve:"\\u016D",Ucirc:"\\xDB",ucirc:"\\xFB",Ucy:"\\u0423",ucy:"\\u0443",udarr:"\\u21C5",Udblac:"\\u0170",udblac:"\\u0171",udhar:"\\u296E",ufisht:"\\u297E",Ufr:"\\u{1D518}",ufr:"\\u{1D532}",Ugrave:"\\xD9",ugrave:"\\xF9",uHar:"\\u2963",uharl:"\\u21BF",uharr:"\\u21BE",uhblk:"\\u2580",ulcorn:"\\u231C",ulcorner:"\\u231C",ulcrop:"\\u230F",ultri:"\\u25F8",Umacr:"\\u016A",umacr:"\\u016B",uml:"\\xA8",UnderBar:"_",UnderBrace:"\\u23DF",UnderBracket:"\\u23B5",UnderParenthesis:"\\u23DD",Union:"\\u22C3",UnionPlus:"\\u228E",Uogon:"\\u0172",uogon:"\\u0173",Uopf:"\\u{1D54C}",uopf:"\\u{1D566}",UpArrow:"\\u2191",Uparrow:"\\u21D1",uparrow:"\\u2191",UpArrowBar:"\\u2912",UpArrowDownArrow:"\\u21C5",UpDownArrow:"\\u2195",Updownarrow:"\\u21D5",updownarrow:"\\u2195",UpEquilibrium:"\\u296E",upharpoonleft:"\\u21BF",upharpoonright:"\\u21BE",uplus:"\\u228E",UpperLeftArrow:"\\u2196",UpperRightArrow:"\\u2197",Upsi:"\\u03D2",upsi:"\\u03C5",upsih:"\\u03D2",Upsilon:"\\u03A5",upsilon:"\\u03C5",UpTee:"\\u22A5",UpTeeArrow:"\\u21A5",upuparrows:"\\u21C8",urcorn:"\\u231D",urcorner:"\\u231D",urcrop:"\\u230E",Uring:"\\u016E",uring:"\\u016F",urtri:"\\u25F9",Uscr:"\\u{1D4B0}",uscr:"\\u{1D4CA}",utdot:"\\u22F0",Utilde:"\\u0168",utilde:"\\u0169",utri:"\\u25B5",utrif:"\\u25B4",uuarr:"\\u21C8",Uuml:"\\xDC",uuml:"\\xFC",uwangle:"\\u29A7",vangrt:"\\u299C",varepsilon:"\\u03F5",varkappa:"\\u03F0",varnothing:"\\u2205",varphi:"\\u03D5",varpi:"\\u03D6",varpropto:"\\u221D",vArr:"\\u21D5",varr:"\\u2195",varrho:"\\u03F1",varsigma:"\\u03C2",varsubsetneq:"\\u228A\\uFE00",varsubsetneqq:"\\u2ACB\\uFE00",varsupsetneq:"\\u228B\\uFE00",varsupsetneqq:"\\u2ACC\\uFE00",vartheta:"\\u03D1",vartriangleleft:"\\u22B2",vartriangleright:"\\u22B3",Vbar:"\\u2AEB",vBar:"\\u2AE8",vBarv:"\\u2AE9",Vcy:"\\u0412",vcy:"\\u0432",VDash:"\\u22AB",Vdash:"\\u22A9",vDash:"\\u22A8",vdash:"\\u22A2",Vdashl:"\\u2AE6",Vee:"\\u22C1",vee:"\\u2228",veebar:"\\u22BB",veeeq:"\\u225A",vellip:"\\u22EE",Verbar:"\\u2016",verbar:"|",Vert:"\\u2016",vert:"|",VerticalBar:"\\u2223",VerticalLine:"|",VerticalSeparator:"\\u2758",VerticalTilde:"\\u2240",VeryThinSpace:"\\u200A",Vfr:"\\u{1D519}",vfr:"\\u{1D533}",vltri:"\\u22B2",vnsub:"\\u2282\\u20D2",vnsup:"\\u2283\\u20D2",Vopf:"\\u{1D54D}",vopf:"\\u{1D567}",vprop:"\\u221D",vrtri:"\\u22B3",Vscr:"\\u{1D4B1}",vscr:"\\u{1D4CB}",vsubnE:"\\u2ACB\\uFE00",vsubne:"\\u228A\\uFE00",vsupnE:"\\u2ACC\\uFE00",vsupne:"\\u228B\\uFE00",Vvdash:"\\u22AA",vzigzag:"\\u299A",Wcirc:"\\u0174",wcirc:"\\u0175",wedbar:"\\u2A5F",Wedge:"\\u22C0",wedge:"\\u2227",wedgeq:"\\u2259",weierp:"\\u2118",Wfr:"\\u{1D51A}",wfr:"\\u{1D534}",Wopf:"\\u{1D54E}",wopf:"\\u{1D568}",wp:"\\u2118",wr:"\\u2240",wreath:"\\u2240",Wscr:"\\u{1D4B2}",wscr:"\\u{1D4CC}",xcap:"\\u22C2",xcirc:"\\u25EF",xcup:"\\u22C3",xdtri:"\\u25BD",Xfr:"\\u{1D51B}",xfr:"\\u{1D535}",xhArr:"\\u27FA",xharr:"\\u27F7",Xi:"\\u039E",xi:"\\u03BE",xlArr:"\\u27F8",xlarr:"\\u27F5",xmap:"\\u27FC",xnis:"\\u22FB",xodot:"\\u2A00",Xopf:"\\u{1D54F}",xopf:"\\u{1D569}",xoplus:"\\u2A01",xotime:"\\u2A02",xrArr:"\\u27F9",xrarr:"\\u27F6",Xscr:"\\u{1D4B3}",xscr:"\\u{1D4CD}",xsqcup:"\\u2A06",xuplus:"\\u2A04",xutri:"\\u25B3",xvee:"\\u22C1",xwedge:"\\u22C0",Yacute:"\\xDD",yacute:"\\xFD",YAcy:"\\u042F",yacy:"\\u044F",Ycirc:"\\u0176",ycirc:"\\u0177",Ycy:"\\u042B",ycy:"\\u044B",yen:"\\xA5",Yfr:"\\u{1D51C}",yfr:"\\u{1D536}",YIcy:"\\u0407",yicy:"\\u0457",Yopf:"\\u{1D550}",yopf:"\\u{1D56A}",Yscr:"\\u{1D4B4}",yscr:"\\u{1D4CE}",YUcy:"\\u042E",yucy:"\\u044E",Yuml:"\\u0178",yuml:"\\xFF",Zacute:"\\u0179",zacute:"\\u017A",Zcaron:"\\u017D",zcaron:"\\u017E",Zcy:"\\u0417",zcy:"\\u0437",Zdot:"\\u017B",zdot:"\\u017C",zeetrf:"\\u2128",ZeroWidthSpace:"\\u200B",Zeta:"\\u0396",zeta:"\\u03B6",Zfr:"\\u2128",zfr:"\\u{1D537}",ZHcy:"\\u0416",zhcy:"\\u0436",zigrarr:"\\u21DD",Zopf:"\\u2124",zopf:"\\u{1D56B}",Zscr:"\\u{1D4B5}",zscr:"\\u{1D4CF}",zwj:"\\u200D",zwnj:"\\u200C"});$r.entityMap=$r.HTML_ENTITIES});var bc=St(is=>{"use strict";var Fi=ii(),z=al(),fc=kr(),by=Fi.isHTMLEscapableRawTextElement,vy=Fi.isHTMLMimeType,wy=Fi.isHTMLRawTextElement,Wr=Fi.hasOwn,ac=Fi.NAMESPACE,uc=fc.ParseError,Ay=fc.DOMException,Vr=0,Ft=1,Li=2,qr=3,_i=4,Ii=5,Ur=6,ts=7;function dc(){}dc.prototype={parse:function(i,e,t){var r=this.domBuilder;r.startDocument(),pc(e,e=Object.create(null)),Cy(i,e,t,r,this.errorHandler),r.endDocument()}};var gl=/&#?\\w+;?/g;function Cy(i,e,t,r,n){var s=vy(r.mimeType);if(i.indexOf(z.UNICODE_REPLACEMENT_CHARACTER)>=0)return n.fatalError("Unicode replacement character detected, source encoding issues?");function o(k){if(k>65535){k-=65536;var K=55296+(k>>10),ue=56320+(k&1023);return String.fromCharCode(K,ue)}else return String.fromCharCode(k)}function l(k){var K=k[k.length-1]===";"?k:k+";";if(!s&&K!==k)return n.error("EntityRef: expecting ;"),k;var ue=z.Reference.exec(K);if(!ue||ue[0].length!==K.length)return n.error("entity not matching Reference production: "+k),k;var pe=K.slice(1,-1);return Wr(t,pe)?t[pe]:pe.charAt(0)==="#"?o(parseInt(pe.substr(1).replace("x","0x"))):(n.error("entity not found:"+k),k)}function a(k){if(k>y){var K=i.substring(y,k).replace(gl,l);d&&u(y),r.characters(K,0,k-y),y=k}}function u(k,K){for(;k>=c&&(K=f.exec(i));)h=K.index,c=h+K[0].length,d.lineNumber++;d.columnNumber=k-h+1}for(var h=0,c=0,f=/.*(?:\\r\\n?|\\n)|.*$/g,d=r.locator,p=[{currentNSMap:e}],g=[],y=0;;){try{var b=i.indexOf("<",y);if(b<0){if(!s&&g.length>0)return n.fatalError("unclosed xml tag(s): "+g.join(", "));if(!i.substring(y).match(/^\\s*$/)){var A=r.doc,w=A.createTextNode(i.substr(y));if(A.documentElement)return n.error("Extra content at the end of the document");A.appendChild(w),r.currentElement=w}return}if(b>y){var E=i.substring(y,b);!s&&g.length===0&&(E=E.replace(new RegExp(z.S_OPT.source,"g"),""),E&&n.error("Unexpected content outside root element: \'"+E+"\'")),a(b)}switch(i.charAt(b+1)){case"/":var I=i.indexOf(">",b+2),S=i.substring(b+2,I>0?I:void 0);if(!S)return n.fatalError("end tag name missing");var N=I>0&&z.reg("^",z.QName_group,z.S_OPT,"$").exec(S);if(!N)return n.fatalError(\'end tag name contains invalid characters: "\'+S+\'"\');if(!r.currentElement&&!r.doc.documentElement)return;var M=g[g.length-1]||r.currentElement.tagName||r.doc.documentElement.tagName||"";if(M!==N[1]){var j=N[1].toLowerCase();if(!s||M.toLowerCase()!==j)return n.fatalError(\'Opening and ending tag mismatch: "\'+M+\'" != "\'+S+\'"\')}var D=p.pop();g.pop();var H=D.localNSMap;if(r.endElement(D.uri,D.localName,M),H)for(var B in H)Wr(H,B)&&r.endPrefixMapping(B);I++;break;case"?":d&&u(b),I=xy(i,b,r,n);break;case"!":d&&u(b),I=mc(i,b,r,n,s);break;default:d&&u(b);var O=new yc,W=p[p.length-1].currentNSMap,I=Sy(i,b,O,W,l,n,s),te=O.length;if(O.closed||(s&&Fi.isHTMLVoidElement(O.tagName)?O.closed=!0:g.push(O.tagName)),d&&te){for(var Ce=hc(d,{}),F=0;Fy?y=I:a(Math.max(b,y)+1)}}function hc(i,e){return e.lineNumber=i.lineNumber,e.columnNumber=i.columnNumber,e}function Sy(i,e,t,r,n,s,o){function l(d,p,g){if(Wr(t.attributeNames,d))return s.fatalError("Attribute "+d+" redefined");if(!o&&p.indexOf("<")>=0)return s.fatalError("Unescaped \'<\' not allowed in attributes values");t.addValue(d,p.replace(/[\\t\\n\\r]/g," ").replace(gl,n),g)}for(var a,u,h=++e,c=Vr;;){var f=i.charAt(h);switch(f){case"=":if(c===Ft)a=i.slice(e,h),c=qr;else if(c===Li)c=qr;else throw new Error("attribute equal must after attrName");break;case"\'":case\'"\':if(c===qr||c===Ft)if(c===Ft&&(s.warning(\'attribute value must after "="\'),a=i.slice(e,h)),e=h+1,h=i.indexOf(f,e),h>0)u=i.slice(e,h),l(a,u,e-1),c=Ii;else throw new Error("attribute value no end \'"+f+"\' match");else if(c==_i)u=i.slice(e,h),l(a,u,e),s.warning(\'attribute "\'+a+\'" missed start quot(\'+f+")!!"),e=h+1,c=Ii;else throw new Error(\'attribute value must after "="\');break;case"/":switch(c){case Vr:t.setTagName(i.slice(e,h));case Ii:case Ur:case ts:c=ts,t.closed=!0;case _i:case Ft:break;case Li:t.closed=!0;break;default:throw new Error("attribute invalid close char(\'/\')")}break;case"":return s.error("unexpected end of input"),c==Vr&&t.setTagName(i.slice(e,h)),h;case">":switch(c){case Vr:t.setTagName(i.slice(e,h));case Ii:case Ur:case ts:break;case _i:case Ft:u=i.slice(e,h),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case Li:c===Li&&(u=a),c==_i?(s.warning(\'attribute "\'+u+\'" missed quot(")!\'),l(a,u,e)):(o||s.warning(\'attribute "\'+u+\'" missed value!! "\'+u+\'" instead!!\'),l(u,u,e));break;case qr:if(!o)return s.fatalError(`AttValue: \' or " expected`)}return h;case"\\x80":f=" ";default:if(f<=" ")switch(c){case Vr:t.setTagName(i.slice(e,h)),c=Ur;break;case Ft:a=i.slice(e,h),c=Li;break;case _i:var u=i.slice(e,h);s.warning(\'attribute "\'+u+\'" missed quot(")!!\'),l(a,u,e);case Ii:c=Ur;break}else switch(c){case Li:o||s.warning(\'attribute "\'+a+\'" missed value!! "\'+a+\'" instead2!!\'),l(a,a,e),e=h,c=Ft;break;case Ii:s.warning(\'attribute space is required"\'+a+\'"!!\');case Ur:c=Ft,e=h;break;case qr:c=_i,e=h;break;case ts:throw new Error("elements closed character \'/\' and \'>\' must be connected to")}}h++}}function cc(i,e,t){for(var r=i.tagName,n=null,c=i.length;c--;){var s=i[c],o=s.qName,l=s.value,f=o.indexOf(":");if(f>0)var a=s.prefix=o.slice(0,f),u=o.slice(f+1),h=a==="xmlns"&&u;else u=o,a=null,h=o==="xmlns"&&"";s.localName=u,h!==!1&&(n==null&&(n=Object.create(null),pc(t,t=Object.create(null))),t[h]=n[h]=l,s.uri=ac.XMLNS,e.startPrefixMapping(h,l))}for(var c=i.length;c--;)s=i[c],s.prefix&&(s.prefix==="xml"&&(s.uri=ac.XML),s.prefix!=="xmlns"&&(s.uri=t[s.prefix]));var f=r.indexOf(":");f>0?(a=i.prefix=r.slice(0,f),u=i.localName=r.slice(f+1)):(a=null,u=i.localName=r);var d=i.uri=t[a||""];if(e.startElement(d,u,r,i),i.closed){if(e.endElement(d,u,r),n)for(a in n)Wr(n,a)&&e.endPrefixMapping(a)}else return i.currentNSMap=t,i.localNSMap=n,!0}function Dy(i,e,t,r,n){var s=by(t);if(s||wy(t)){var o=i.indexOf("",e),l=i.substring(e+1,o);return s&&(l=l.replace(gl,r)),n.characters(l,0,l.length),o}return e+1}function pc(i,e){for(var t in i)Wr(i,t)&&(e[t]=i[t])}function gc(i,e){var t=e;function r(u){return u=u||0,i.charAt(t+u)}function n(u){u=u||1,t+=u}function s(){for(var u=0;t"?r.fatalError("doctype not terminated with > at position "+s.getIndex()):(s.skip(1),t.startDTD(a.name,a.publicId,a.systemId,a.internalSubset),t.endDTD(),s.getIndex())}default:return r.fatalError(\'Not well-formed XML starting with "0)return r.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!z.XMLDecl.test(i.substring(e)))return r.fatalError("xml declaration is not well-formed")}return t.processingInstruction(n[1],n[2]),e+n[0].length}function yc(){this.attributeNames=Object.create(null)}yc.prototype={setTagName:function(i){if(!z.QName_exact.test(i))throw new Error("invalid tagName:"+i);this.tagName=i},addValue:function(i,e,t){if(!z.QName_exact.test(i))throw new Error("invalid attribute:"+i);this.attributeNames[i]=this.length,this[this.length++]={qName:i,value:e,offset:t}},length:0,getLocalName:function(i){return this[i].localName},getLocator:function(i){return this[i].locator},getQName:function(i){return this[i].qName},getURI:function(i){return this[i].uri},getValue:function(i){return this[i].value}};is.XMLReader=dc;is.parseUtils=gc;is.parseDoctypeCommentOrCData=mc});var Ec=St($i=>{"use strict";var li=ii(),Ty=pl(),ky=kr(),vc=lc(),My=bc(),Ry=Ty.DOMImplementation,Ny=li.hasDefaultHTMLNamespace,Oy=li.isHTMLMimeType,By=li.isValidMimeType,Cc=li.MIME_TYPE,ml=li.NAMESPACE,wc=ky.ParseError,Py=My.XMLReader;function Sc(i){return i.replace(/\\r[\\n\\u0085]/g,`\n`).replace(/[\\r\\u0085\\u2028]/g,`\n`)}function Dc(i){if(i=i||{locator:!0},this.assign=i.assign||li.assign,this.domHandler=i.domHandler||ns,this.onError=i.onError||i.errorHandler,i.errorHandler&&typeof i.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");i.errorHandler&&i.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=i.normalizeLineEndings||Sc,this.locator=!!i.locator,this.xmlns=this.assign(Object.create(null),i.xmlns)}Dc.prototype.parseFromString=function(i,e){if(!By(e))throw new TypeError(\'DOMParser.parseFromString: the provided mimeType "\'+e+\'" is not valid.\');var t=this.assign(Object.create(null),this.xmlns),r=vc.XML_ENTITIES,n=t[""]||null;Ny(e)?(r=vc.HTML_ENTITIES,n=ml.HTML):e===Cc.XML_SVG_IMAGE&&(n=ml.SVG),t[""]=n,t.xml=t.xml||ml.XML;var s=new this.domHandler({mimeType:e,defaultNamespace:n,onError:this.onError}),o=this.locator?{}:void 0;this.locator&&s.setDocumentLocator(o);var l=new Py;l.errorHandler=s,l.domBuilder=s;var a=!li.isHTMLMimeType(e);return a&&typeof i!="string"&&l.errorHandler.fatalError("source is not a string"),l.parse(this.normalizeLineEndings(String(i)),t,r),s.doc.documentElement||l.errorHandler.fatalError("missing root element"),s.doc};function ns(i){var e=i||{};this.mimeType=e.mimeType||Cc.XML_APPLICATION,this.defaultNamespace=e.defaultNamespace||null,this.cdata=!1,this.currentElement=void 0,this.doc=void 0,this.locator=void 0,this.onError=e.onError}function Hi(i,e){e.lineNumber=i.lineNumber,e.columnNumber=i.columnNumber}ns.prototype={startDocument:function(){var i=new Ry;this.doc=Oy(this.mimeType)?i.createHTMLDocument(!1):i.createDocument(this.defaultNamespace,"")},startElement:function(i,e,t,r){var n=this.doc,s=n.createElementNS(i,t||e),o=r.length;rs(this,s),this.currentElement=s,this.locator&&Hi(this.locator,s);for(var l=0;l=e+t||e?new java.lang.String(i,e,t)+"":i}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\\w+/g,function(i){ns.prototype[i]=function(){return null}});function rs(i,e){i.currentElement?i.currentElement.appendChild(e):i.doc.appendChild(e)}function _y(i){if(i==="error")throw"onErrorStopParsing"}function Iy(){throw"onWarningStopParsing"}$i.__DOMHandler=ns;$i.DOMParser=Dc;$i.normalizeLineEndings=Sc;$i.onErrorStopParsing=_y;$i.onWarningStopParsing=Iy});var xc=St(G=>{"use strict";var Vi=ii();G.assign=Vi.assign;G.hasDefaultHTMLNamespace=Vi.hasDefaultHTMLNamespace;G.isHTMLMimeType=Vi.isHTMLMimeType;G.isValidMimeType=Vi.isValidMimeType;G.MIME_TYPE=Vi.MIME_TYPE;G.NAMESPACE=Vi.NAMESPACE;var ss=kr();G.DOMException=ss.DOMException;G.DOMExceptionName=ss.DOMExceptionName;G.ExceptionCode=ss.ExceptionCode;G.ParseError=ss.ParseError;var de=pl();G.Attr=de.Attr;G.CDATASection=de.CDATASection;G.CharacterData=de.CharacterData;G.Comment=de.Comment;G.Document=de.Document;G.DocumentFragment=de.DocumentFragment;G.DocumentType=de.DocumentType;G.DOMImplementation=de.DOMImplementation;G.Element=de.Element;G.Entity=de.Entity;G.EntityReference=de.EntityReference;G.LiveNodeList=de.LiveNodeList;G.NamedNodeMap=de.NamedNodeMap;G.Node=de.Node;G.NodeList=de.NodeList;G.Notation=de.Notation;G.ProcessingInstruction=de.ProcessingInstruction;G.Text=de.Text;G.XMLSerializer=de.XMLSerializer;var yl=Ec();G.DOMParser=yl.DOMParser;G.onErrorStopParsing=yl.onErrorStopParsing;G.onWarningStopParsing=yl.onWarningStopParsing});var Y=class i{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,r){[e,t]=pi(this,e,t);let n=[];return this.decompose(0,e,n,2),r.length&&r.decompose(0,r.length,n,3),this.decompose(t,this.length,n,1),hi.from(n,this.length-(t-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=pi(this,e,t);let r=[];return this.decompose(e,t,r,0),hi.from(r,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),n=new qt(this),s=new qt(e);for(let o=t,l=t;;){if(n.next(o),s.next(o),o=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(l+=n.value.length,n.done||l>=r)return!0}}iter(e=1){return new qt(this,e)}iterRange(e,t=this.length){return new Xr(this,e,t)}iterLines(e,t){let r;if(e==null)r=this.iter();else{t==null&&(t=this.lines+1);let n=this.line(e).from;r=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Jr(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?i.empty:e.length<=32?new Le(e):hi.from(Le.split(e,[]))}},Le=class i extends Y{constructor(e,t=Kc(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,r,n){for(let s=0;;s++){let o=this.text[s],l=n+o.length;if((t?r:l)>=e)return new fs(n,l,r,o);n=l+1,r++}}decompose(e,t,r,n){let s=e<=0&&t>=this.length?this:new i(Fl(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let o=r.pop(),l=Kr(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new i(l,o.length+s.length));else{let a=l.length>>1;r.push(new i(l.slice(0,a)),new i(l.slice(a)))}}else r.push(s)}replace(e,t,r){if(!(r instanceof i))return super.replace(e,t,r);[e,t]=pi(this,e,t);let n=Kr(this.text,Kr(r.text,Fl(this.text,0,e)),t),s=this.length+r.length-(t-e);return n.length<=32?new i(n,s):hi.from(i.split(n,[]),s)}sliceString(e,t=this.length,r=`\n`){[e,t]=pi(this,e,t);let n="";for(let s=0,o=0;s<=t&&oe&&o&&(n+=r),es&&(n+=l.slice(Math.max(0,e-s),t-s)),s=a+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let r=[],n=-1;for(let s of e)r.push(s),n+=s.length+1,r.length==32&&(t.push(new i(r,n)),r=[],n=-1);return n>-1&&t.push(new i(r,n)),t}},hi=class i extends Y{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,t,r,n){for(let s=0;;s++){let o=this.children[s],l=n+o.length,a=r+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,r,n);n=l+1,r=a+1}}decompose(e,t,r,n){for(let s=0,o=0;o<=t&&s=o){let u=n&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!u?r.push(l):l.decompose(e-o,t-o,r,u)}o=a+1}}replace(e,t,r){if([e,t]=pi(this,e,t),r.lines=s&&t<=l){let a=o.replace(e-s,t-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let h=this.children.slice();return h[n]=a,new i(h,this.length-(t-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,t,r)}sliceString(e,t=this.length,r=`\n`){[e,t]=pi(this,e,t);let n="";for(let s=0,o=0;se&&s&&(n+=r),eo&&(n+=l.sliceString(e-o,t-o,r)),o=a+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i))return 0;let r=0,[n,s,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,s+=t){if(n==o||s==l)return r;let a=this.children[n],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,t);r+=a.length+1}}static from(e,t=e.reduce((r,n)=>r+n.length+1,-1)){let r=0;for(let d of e)r+=d.lines;if(r<32){let d=[];for(let p of e)p.flatten(d);return new Le(d,t)}let n=Math.max(32,r>>5),s=n<<1,o=n>>1,l=[],a=0,u=-1,h=[];function c(d){let p;if(d.lines>s&&d instanceof i)for(let g of d.children)c(g);else d.lines>o&&(a>o||!a)?(f(),l.push(d)):d instanceof Le&&a&&(p=h[h.length-1])instanceof Le&&d.lines+p.lines<=32?(a+=d.lines,u+=d.length+1,h[h.length-1]=new Le(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>n&&f(),a+=d.lines,u+=d.length+1,h.push(d))}function f(){a!=0&&(l.push(h.length==1?h[0]:i.from(h,u)),u=-1,a=h.length=0)}for(let d of e)c(d);return f(),l.length==1?l[0]:new i(l,t)}};Y.empty=new Le([""],0);function Kc(i){let e=-1;for(let t of i)e+=t.length+1;return e}function Kr(i,e,t=0,r=1e9){for(let n=0,s=0,o=!0;s=t&&(a>r&&(l=l.slice(0,r-n)),n0?1:(e instanceof Le?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,n=this.nodes[r],s=this.offsets[r],o=s>>1,l=n instanceof Le?n.text.length:n.children.length;if(o==(t>0?l:0)){if(r==0)return this.done=!0,this.value="",this;t>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[r]+=t,e==0)return this.lineBreak=!0,this.value=`\n`,this;e--}else if(n instanceof Le){let a=n.text[o+(t<0?-1:0)];if(this.offsets[r]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=n.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=t):(t<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof Le?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Xr=class{constructor(e,t,r){this.value="",this.done=!1,this.cursor=new qt(e,t>r?-1:1),this.pos=t>r?e.length:0,this.from=Math.min(t,r),this.to=Math.max(t,r)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let r=t<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=r?n:t<0?n.slice(n.length-r):n.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},Jr=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:r,value:n}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol!="undefined"&&(Y.prototype[Symbol.iterator]=function(){return this.iter()},qt.prototype[Symbol.iterator]=Xr.prototype[Symbol.iterator]=Jr.prototype[Symbol.iterator]=function(){return this});var fs=class{constructor(e,t,r,n){this.from=e,this.to=t,this.number=r,this.text=n}get length(){return this.to-this.from}};function pi(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}var ci="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(i=>i?parseInt(i,36):1);for(let i=1;ii)return ci[e-1]<=i;return!1}function Hl(i){return i>=127462&&i<=127487}var $l=8205;function Ze(i,e,t=!0,r=!0){return(t?jl:Xc)(i,e,r)}function jl(i,e,t){if(e==i.length)return e;e&&Gl(i.charCodeAt(e))&&Kl(i.charCodeAt(e-1))&&e--;let r=Yr(i,e);for(e+=ds(r);e=0&&Hl(Yr(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Xc(i,e,t){for(;e>0;){let r=jl(i,e-2,t);if(r=56320&&i<57344}function Kl(i){return i>=55296&&i<56320}function Yr(i,e){let t=i.charCodeAt(e);if(!Kl(t)||e+1==i.length)return t;let r=i.charCodeAt(e+1);return Gl(r)?(t-55296<<10)+(r-56320)+65536:t}function ds(i){return i<65536?1:2}var ps=/\\r\\n?|\\n/,Me=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(Me||(Me={})),Ut=class i{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-n);s+=l}else{if(r!=Me.Simple&&u>=e&&(r==Me.TrackDel&&ne||r==Me.TrackBefore&&ne))return null;if(u>e||u==e&&t<0&&!l)return e==n||t<0?s:s+a;s+=a}n=u}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return s}touchesRange(e,t=e){for(let r=0,n=0;r=0&&n<=t&&l>=e)return nt?"cover":!0;n=l}return!1}toString(){let e="";for(let t=0;t=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new i(e)}static create(e){return new i(e)}},_e=class i extends Ut{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return gs(this,(t,r,n,s,o)=>e=e.replace(n,n+(r-t),o),!1),e}mapDesc(e,t=!1){return ms(this,e,t,!0)}invert(e){let t=this.sections.slice(),r=[];for(let n=0,s=0;n=0){t[n]=l,t[n+1]=o;let a=n>>1;for(;r.length0&&Dt(r,t,s.text),s.forward(h),l+=h}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,r){let n=[],s=[],o=0,l=null;function a(h=!1){if(!h&&!n.length)return;of||c<0||f>t)throw new RangeError(`Invalid change range ${c} to ${f} (in doc of length ${t})`);let p=d?typeof d=="string"?Y.of(d.split(r||ps)):d:Y.empty,g=p.length;if(c==f&&g==0)return;co&&De(n,c-o,-1),De(n,f-c,g),Dt(s,n,p),o=f}}return u(e),a(!l),l}static empty(e){return new i(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],r=[];for(let n=0;nl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;r.length=0&&t<=0&&t==i[n+1]?i[n]+=e:e==0&&i[n]==0?i[n+1]+=t:r?(i[n]+=e,i[n+1]+=t):i.push(e,t)}function Dt(i,e,t){if(t.length==0)return;let r=e.length-2>>1;if(r>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)l=i.sections[o++],a=i.sections[o++];e(n,u,s,h,c),n=u,s=h}}}function ms(i,e,t,r=!1){let n=[],s=r?[]:null,o=new Wt(i),l=new Wt(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);De(n,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,h=o.len;for(;h;)if(l.ins==-1){let c=Math.min(h,l.len);u+=c,h-=c,l.forward(c)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}var Wt=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?Y.empty:e[t]}textBit(e){let{inserted:t}=this.set,r=this.i-2>>1;return r>=t.length&&!e?Y.empty:t[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},ui=class i{constructor(e,t,r){this.from=e,this.to=t,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let r,n;return this.empty?r=n=e.mapPos(this.from,t):(r=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),r==this.from&&n==this.to?this:new i(r,n,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return P.range(e,t);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return P.range(this.anchor,r)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return P.range(e.anchor,e.head)}static create(e,t,r){return new i(e,t,r)}},P=class i{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:i.create(this.ranges.map(r=>r.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new i(e.ranges.map(t=>ui.fromJSON(t)),e.main)}static single(e,t=e){return new i([i.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,n=0;ne?8:0)|s)}static normalized(e,t=0){let r=e[t];e.sort((n,s)=>n.from-s.from),t=e.indexOf(r);for(let n=1;ns.head?i.range(a,l):i.range(l,a))}}return new i(e,t)}};function Xl(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var xs=0,$=class i{constructor(e,t,r,n,s){this.combine=e,this.compareInput=t,this.compare=r,this.isStatic=n,this.id=xs++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new i(e.combine||(t=>t),e.compareInput||((t,r)=>t===r),e.compare||(e.combine?(t,r)=>t===r:Ts),!!e.static,e.enables)}of(e){return new fi([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can\'t compute a static facet");return new fi(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can\'t compute a static facet");return new fi(e,this,2,t)}from(e,t){return t||(t=r=>r),this.compute([e],r=>t(r.field(e)))}};function Ts(i,e){return i==e||i.length==e.length&&i.every((t,r)=>t===e[r])}var fi=class{constructor(e,t,r,n){this.dependencies=e,this.facet=t,this.type=r,this.value=n,this.id=xs++}dynamicSlot(e){var t;let r=this.value,n=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,h=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?u=!0:((t=e[c.id])!==null&&t!==void 0?t:1)&1||h.push(e[c.id]);return{create(c){return c.values[o]=r(c),1},update(c,f){if(a&&f.docChanged||u&&(f.docChanged||f.selection)||ys(c,h)){let d=r(c);if(l?!Vl(d,c.values[o],n):!n(d,c.values[o]))return c.values[o]=d,1}return 0},reconfigure:(c,f)=>{let d,p=f.config.address[s];if(p!=null){let g=tn(f,p);if(this.dependencies.every(y=>y instanceof $?f.facet(y)===c.facet(y):y instanceof gt?f.field(y,!1)==c.field(y,!1):!0)||(l?Vl(d=r(c),g,n):n(d=r(c),g)))return c.values[o]=g,0}else d=r(c);return c.values[o]=d,1}}}};function Vl(i,e,t){if(i.length!=e.length)return!1;for(let r=0;ri[a.id]),n=t.map(a=>a.type),s=r.filter(a=>!(a&1)),o=i[e.id]>>1;function l(a){let u=[];for(let h=0;hr===n),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ql).find(r=>r.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:r=>(r.values[t]=this.create(r),1),update:(r,n)=>{let s=r.values[t],o=this.updateF(s,n);return this.compareF(s,o)?0:(r.values[t]=o,1)},reconfigure:(r,n)=>n.config.address[this.id]!=null?(r.values[t]=n.field(this),0):(r.values[t]=this.create(r),1)}}init(e){return[this,ql.of({field:this,create:e})]}get extension(){return this}},$t={lowest:4,low:3,default:2,high:1,highest:0};function zi(i){return e=>new Qr(e,i)}var nn={highest:zi($t.highest),high:zi($t.high),default:zi($t.default),low:zi($t.low),lowest:zi($t.lowest)},Qr=class{constructor(e,t){this.inner=e,this.prec=t}},Zr=class i{of(e){return new Gi(this,e)}reconfigure(e){return i.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},Gi=class{constructor(e,t){this.compartment=e,this.inner=t}},en=class i{constructor(e,t,r,n,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=r,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,r){let n=[],s=Object.create(null),o=new Map;for(let f of Qc(e,t,o))f instanceof gt?n.push(f):(s[f.facet.id]||(s[f.facet.id]=[])).push(f);let l=Object.create(null),a=[],u=[];for(let f of n)l[f.id]=u.length<<1,u.push(d=>f.slot(d));let h=r==null?void 0:r.config.facets;for(let f in s){let d=s[f],p=d[0].facet,g=h&&h[f]||[];if(d.every(y=>y.type==0))if(l[p.id]=a.length<<1|1,Ts(g,d))a.push(r.facet(p));else{let y=p.combine(d.map(b=>b.value));a.push(r&&p.compare(y,r.facet(p))?r.facet(p):y)}else{for(let y of d)y.type==0?(l[y.id]=a.length<<1|1,a.push(y.value)):(l[y.id]=u.length<<1,u.push(b=>y.dynamicSlot(b)));l[p.id]=u.length<<1,u.push(y=>Jc(y,p,d))}}let c=u.map(f=>f(l));return new i(e,o,c,l,a,s)}};function Qc(i,e,t){let r=[[],[],[],[],[]],n=new Map;function s(o,l){let a=n.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof Gi&&t.delete(o.compartment)}if(n.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof Gi){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;t.set(o.compartment,u),s(u,l)}else if(o instanceof Qr)s(o.inner,o.prec);else if(o instanceof gt)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof fi)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,$t.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(i,$t.default),r.reduce((o,l)=>o.concat(l))}function ji(i,e){if(e&1)return 2;let t=e>>1,r=i.status[t];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;i.status[t]=4;let n=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|n}function tn(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}var Jl=$.define(),bs=$.define({combine:i=>i.some(e=>e),static:!0}),Ql=$.define({combine:i=>i.length?i[0]:void 0,static:!0}),Zl=$.define(),ea=$.define(),ta=$.define(),ia=$.define({combine:i=>i.length?i[0]:!1}),mt=class{constructor(e,t){this.type=e,this.value=t}static define(){return new vs}},vs=class{of(e){return new mt(this,e)}},ws=class{constructor(e){this.map=e}of(e){return new se(this,e)}},se=class i{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new i(this.type,t)}is(e){return this.type==e}static define(e={}){return new ws(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let r=[];for(let n of e){let s=n.map(t);s&&r.push(s)}return r}};se.reconfigure=se.define();se.appendConfig=se.define();var Re=class i{constructor(e,t,r,n,s,o){this.startState=e,this.changes=t,this.selection=r,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Xl(r,t.newLength),s.some(l=>l.type==i.time)||(this.annotations=s.concat(i.time.of(Date.now())))}static create(e,t,r,n,s,o){return new i(e,t,r,n,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(i.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}};Re.time=mt.define();Re.userEvent=mt.define();Re.addToHistory=mt.define();Re.remote=mt.define();function Zc(i,e){let t=[];for(let r=0,n=0;;){let s,o;if(r=i[r]))s=i[r++],o=i[r++];else if(n=0;n--){let s=r[n](i);s instanceof Re?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Re?i=s[0]:i=na(e,di(s),!1)}return i}function tf(i){let e=i.startState,t=e.facet(ta),r=i;for(let n=t.length-1;n>=0;n--){let s=t[n](i);s&&Object.keys(s).length&&(r=ra(r,As(e,s,i.changes.newLength),!0))}return r==i?i:Re.create(e,i.changes,i.selection,r.effects,r.annotations,r.scrollIntoView)}var rf=[];function di(i){return i==null?rf:Array.isArray(i)?i:[i]}var Qe=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(Qe||(Qe={})),nf=/[\\u00df\\u0587\\u0590-\\u05f4\\u0600-\\u06ff\\u3040-\\u309f\\u30a0-\\u30ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\uac00-\\ud7af]/,Cs;try{Cs=new RegExp("[\\\\p{Alphabetic}\\\\p{Number}_]","u")}catch(i){}function sf(i){if(Cs)return Cs.test(i);for(let e=0;e"\\x80"&&(t.toUpperCase()!=t.toLowerCase()||nf.test(t)))return!0}return!1}function of(i){return e=>{if(!/\\S/.test(e))return Qe.Space;if(sf(e))return Qe.Word;for(let t=0;t-1)return Qe.Word;return Qe.Other}}var oe=class i{constructor(e,t,r,n,s,o){this.config=e,this.doc=t,this.selection=r,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;ln.set(u,a)),t=null),n.set(l.value.compartment,l.value.extension)):l.is(se.reconfigure)?(t=null,r=l.value):l.is(se.appendConfig)&&(t=null,r=di(r).concat(l.value));let s;t?s=e.startState.values.slice():(t=en.resolve(r,n,this),s=new i(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(bs)?e.newSelection:e.newSelection.asSingle();new i(t,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:P.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,r=e(t.ranges[0]),n=this.changes(r.changes),s=[r.range],o=di(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return i.create({doc:e.doc,selection:P.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=en.resolve(e.extensions||[],new Map),r=e.doc instanceof Y?e.doc:Y.of((e.doc||"").split(t.staticFacet(i.lineSeparator)||ps)),n=e.selection?e.selection instanceof P?e.selection:P.single(e.selection.anchor,e.selection.head):P.single(0);return Xl(n,r.length),t.staticFacet(bs)||(n=n.asSingle()),new i(t,r,n,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(i.tabSize)}get lineBreak(){return this.facet(i.lineSeparator)||`\n`}get readOnly(){return this.facet(ia)}phrase(e,...t){for(let r of this.facet(i.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return t.length&&(e=e.replace(/\\$(\\$|\\d*)/g,(r,n)=>{if(n=="$")return"$";let s=+(n||1);return!s||s>t.length?r:t[s-1]})),e}languageDataAt(e,t,r=-1){let n=[];for(let s of this.facet(Jl))for(let o of s(this,t,r))Object.prototype.hasOwnProperty.call(o,e)&&n.push(o[e]);return n}charCategorizer(e){return of(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:r,length:n}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=Ze(t,o,!1);if(s(t.slice(a,o))!=Qe.Word)break;o=a}for(;li.length?i[0]:4});oe.lineSeparator=Ql;oe.readOnly=ia;oe.phrases=$.define({compare(i,e){let t=Object.keys(i),r=Object.keys(e);return t.length==r.length&&t.every(n=>i[n]==e[n])}});oe.languageData=Jl;oe.changeFilter=Zl;oe.transactionFilter=ea;oe.transactionExtender=ta;Zr.reconfigure=se.define();var yt=class{eq(e){return this==e}range(e,t=e){return Ki.create(e,t,this)}};yt.prototype.startSide=yt.prototype.endSide=0;yt.prototype.point=!1;yt.prototype.mapMode=Me.TrackDel;var Ki=class i{constructor(e,t,r){this.from=e,this.to=t,this.value=r}static create(e,t,r){return new i(e,t,r)}};function Ss(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var Ds=class i{constructor(e,t,r,n){this.from=e,this.to=t,this.value=r,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(e,t,r,n=0){let s=r?this.to:this.from;for(let o=n,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,t,r,n){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(r,1e9,!1,s);sd||f==d&&u.startSide>0&&u.endSide<=0)continue;(d-f||u.endSide-u.startSide)<0||(o<0&&(o=f),u.point&&(l=Math.max(l,d-f)),r.push(u),n.push(f-o),s.push(d-o))}return{mapped:r.length?new i(n,s,r,l):null,pos:o}}},he=class i{constructor(e,t,r,n){this.chunkPos=e,this.chunk=t,this.nextLayer=r,this.maxPoint=n}static create(e,t,r,n){return new i(e,t,r,n)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:r=!1,filterFrom:n=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(r&&(t=t.slice().sort(Ss)),this.isEmpty)return t.length?i.of(t):this;let l=new rn(this,null,-1).goto(0),a=0,u=[],h=new zt;for(;l.value||a=0){let c=t[a++];h.addInner(c.from,c.to,c.value)||u.push(c)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,t-s,r)===!1)return}this.nextLayer.between(e,t,r)}}iter(e=0){return Yi.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Yi.from(e).goto(t)}static compare(e,t,r,n,s=-1){let o=e.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),l=t.filter(c=>c.maxPoint>0||!c.isEmpty&&c.maxPoint>=s),a=Ul(o,l,r),u=new Vt(o,a,s),h=new Vt(l,a,s);r.iterGaps((c,f,d)=>Wl(u,c,h,f,d,n)),r.empty&&r.length==0&&Wl(u,0,h,0,0,n)}static eq(e,t,r=0,n){n==null&&(n=999999999);let s=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=Ul(s,o),a=new Vt(s,l,0).goto(r),u=new Vt(o,l,0).goto(r);for(;;){if(a.to!=u.to||!Es(a.active,u.active)||a.point&&(!u.point||!a.point.eq(u.point)))return!1;if(a.to>n)return!0;a.next(),u.next()}}static spans(e,t,r,n,s=-1){let o=new Vt(e,null,s).goto(t),l=t,a=o.openStart;for(;;){let u=Math.min(o.to,r);if(o.point){let h=o.activeForPoint(o.to),c=o.pointFroml&&(n.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,t=!1){let r=new zt;for(let n of e instanceof Ki?[e]:t?lf(e):e)r.add(n.from,n.to,n.value);return r.finish()}static join(e){if(!e.length)return i.empty;let t=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let n=e[r];n!=i.empty;n=n.nextLayer)t=new i(n.chunkPos,n.chunk,t,Math.max(n.maxPoint,t.maxPoint));return t}};he.empty=new he([],[],null,-1);function lf(i){if(i.length>1)for(let e=i[0],t=1;t0)return i.slice().sort(Ss);e=r}return i}he.empty.nextLayer=he.empty;var zt=class i{finishChunk(e){this.chunks.push(new Ds(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,r){this.addInner(e,t,r)||(this.nextLayer||(this.nextLayer=new i)).add(e,t,r)}addInner(e,t,r){let n=e-this.lastTo||r.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return n<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=t,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let r=t.value.length-1;return this.last=t.value[r],this.lastFrom=t.from[r]+e,this.lastTo=t.to[r]+e,!0}finish(){return this.finishInner(he.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=he.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function Ul(i,e,t){let r=new Map;for(let s of i)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&n.push(new rn(o,t,r,s));return n.length==1?n[0]:new i(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let r of this.heap)r.goto(e,t);for(let r=this.heap.length>>1;r>=0;r--)cs(this.heap,r);return this.next(),this}forward(e,t){for(let r of this.heap)r.forward(e,t);for(let r=this.heap.length>>1;r>=0;r--)cs(this.heap,r);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),cs(this.heap,0)}}};function cs(i,e){for(let t=i[e];;){let r=(e<<1)+1;if(r>=i.length)break;let n=i[r];if(r+1=0&&(n=i[r+1],r++),t.compare(n)<0)break;i[r]=t,i[e]=n,e=r}}var Vt=class{constructor(e,t,r){this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Yi.from(e,t,r)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){jr(this.active,e),jr(this.activeTo,e),jr(this.activeRank,e),this.minActive=zl(this.active,this.activeTo)}addActive(e){let t=0,{value:r,to:n,rank:s}=this.cursor;for(;t0;)t++;Gr(this.active,t,r),Gr(this.activeTo,t,n),Gr(this.activeRank,t,s),e&&Gr(e,t,this.cursor.from),this.minActive=zl(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>e){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),r&&jr(r,n)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(r),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&r[n]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&t.push(this.active[r]);return t.reverse()}openEnd(e){let t=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)t++;return t}};function Wl(i,e,t,r,n,s){i.goto(e),t.goto(r);let o=r+n,l=r,a=r-e;for(;;){let u=i.to+a-t.to||i.endSide-t.endSide,h=u<0?i.to+a:t.to,c=Math.min(h,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Es(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(l,c,i.point,t.point):c>l&&!Es(i.active,t.active)&&s.compareRange(l,c,i.active,t.active),h>o)break;l=h,u<=0&&i.next(),u>=0&&t.next()}}function Es(i,e){if(i.length!=e.length)return!1;for(let t=0;t=e;r--)i[r+1]=i[r];i[e]=t}function zl(i,e){let t=-1,r=1e9;for(let n=0;n=e)return n;if(n==i.length)break;s+=i.charCodeAt(n)==9?t-s%t:1,n=Ze(i,n)}return r===!0?-1:i.length}var ks="\\u037C",oa=typeof Symbol=="undefined"?"__"+ks:Symbol.for(ks),Ms=typeof Symbol=="undefined"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),la=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:{},He=class{constructor(e,t){this.rules=[];let{finish:r}=t||{};function n(o){return/^@/.test(o)?[o]:o.split(/,\\s*/)}function s(o,l,a,u){let h=[],c=/^@(\\w+)\\b/.exec(o[0]),f=c&&c[1]=="keyframes";if(c&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))s(d.split(/,\\s*/).map(g=>o.map(y=>g.replace(/&/,y))).reduce((g,y)=>g.concat(y)),p,a);else if(p&&typeof p=="object"){if(!c)throw new RangeError("The value of a property ("+d+") should be a primitive value.");s(n(d),p,h,f)}else p!=null&&h.push(d.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(h.length||f)&&a.push((r&&!c&&!u?o.map(r):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)s(n(o),e[o],this.rules)}getRules(){return this.rules.join(`\n`)}static newName(){let e=la[oa]||1;return la[oa]=e+1,ks+e.toString(36)}static mount(e,t,r){let n=e[Ms],s=r&&r.nonce;n?s&&n.setNonce(s):n=new Rs(e,s),n.mount(Array.isArray(t)?t:[t],e)}},aa=new Map,Rs=class{constructor(e,t){let r=e.ownerDocument||e,n=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let s=aa.get(r);if(s)return e[Ms]=s;this.sheet=new n.CSSStyleSheet,aa.set(r,this)}else this.styleTag=r.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Ms]=this}mount(e,t){let r=this.sheet,n=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),r)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:\'"\'},Db=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Eb=typeof navigator!="undefined"&&/MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent);for(ce=0;ce<10;ce++)jt[48+ce]=jt[96+ce]=String(ce);var ce;for(ce=1;ce<=24;ce++)jt[ce+111]="F"+ce;var ce;for(ce=65;ce<=90;ce++)jt[ce]=String.fromCharCode(ce+32),on[ce]=String.fromCharCode(ce);var ce;for(sn in jt)on.hasOwnProperty(sn)||(on[sn]=jt[sn]);var sn;function sr(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function Ls(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function hf(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function pn(i,e){if(!e.anchorNode)return!1;try{return Ls(i,e.anchorNode)}catch(t){return!1}}function or(i){return i.nodeType==3?Yt(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function er(i,e,t,r){return t?ua(i,e,t,r,-1)||ua(i,e,t,r,1):!1}function Kt(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function yn(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\\d|SECTION|PRE)$/.test(i.nodeName)}function ua(i,e,t,r,n){for(;;){if(i==t&&e==r)return!0;if(e==(n<0?0:bt(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=Kt(i)+(n<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(n<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=n<0?bt(i):0}else return!1}}function bt(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function kn(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function cf(i){let e=i.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function $a(i,e){let t=e.width/i.offsetWidth,r=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-i.offsetHeight)<1)&&(r=1),{scaleX:t,scaleY:r}}function ff(i,e,t,r,n,s,o,l){let a=i.ownerDocument,u=a.defaultView||window;for(let h=i,c=!1;h&&!c;)if(h.nodeType==1){let f,d=h==a.body,p=1,g=1;if(d)f=cf(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(c=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let A=h.getBoundingClientRect();({scaleX:p,scaleY:g}=$a(h,A)),f={left:A.left,right:A.left+h.clientWidth*p,top:A.top,bottom:A.top+h.clientHeight*g}}let y=0,b=0;if(n=="nearest")e.top0&&e.bottom>f.bottom+b&&(b=e.bottom-f.bottom+b+o)):e.bottom>f.bottom&&(b=e.bottom-f.bottom+o,t<0&&e.top-b0&&e.right>f.right+y&&(y=e.right-f.right+y+s)):e.right>f.right&&(y=e.right-f.right+s,t<0&&e.leftn.clientHeight&&(r=n),!t&&n.scrollWidth>n.clientWidth&&(t=n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;return{x:t,y:r}}var _s=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:r}=e;this.set(t,Math.min(e.anchorOffset,t?bt(t):0),r,Math.min(e.focusOffset,r?bt(r):0))}set(e,t,r,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=r,this.focusOffset=n}},gi=null;function Va(i){if(i.setActive)return i.setActive();if(gi)return i.focus(gi);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(gi==null?{get preventScroll(){return gi={preventScroll:!0},!0}}:void 0),!gi){gi=!1;for(let t=0;tMath.max(1,i.scrollHeight-i.clientHeight-4)}function Wa(i,e){for(let t=i,r=e;;){if(t.nodeType==3&&r>0)return{node:t,offset:r};if(t.nodeType==1&&r>0){if(t.contentEditable=="false")return null;t=t.childNodes[r-1],r=bt(t)}else if(t.parentNode&&!yn(t))r=Kt(t),t=t.parentNode;else return null}}function za(i,e){for(let t=i,r=e;;){if(t.nodeType==3&&rt)return c.domBoundsAround(e,t,u);if(f>=e&&n==-1&&(n=a,s=u),u>t&&c.dom.parentNode==this.dom){o=a,l=h;break}h=f,u=f+c.breakAfter}return{from:s,to:l<0?r+this.length:l,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,r=co){this.markDirty();for(let n=e;nthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let r=this.children[--this.i];this.pos-=r.length+r.breakAfter}}};function ja(i,e,t,r,n,s,o,l,a){let{children:u}=i,h=u.length?u[e]:null,c=s.length?s[s.length-1]:null,f=c?c.breakAfter:o;if(!(e==r&&h&&!o&&!f&&s.length<2&&h.merge(t,n,s.length?c:null,t==0,l,a))){if(r0&&(!o&&s.length&&h.merge(t,h.length,s[0],!1,l,0)?h.breakAfter=s.shift().breakAfter:(t2),R={mac:pa||/Mac/.test(Ne.platform),windows:/Win/.test(Ne.platform),linux:/Linux|X11/.test(Ne.platform),ie:Mn,ie_version:Ka?Is.documentMode||6:Hs?+Hs[1]:Fs?+Fs[1]:0,gecko:fa,gecko_version:fa?+(/Firefox\\/(\\d+)/.exec(Ne.userAgent)||[0,0])[1]:0,chrome:!!Ns,chrome_version:Ns?+Ns[1]:0,ios:pa,android:/Android\\b/.test(Ne.userAgent),webkit:da,safari:Ya,webkit_version:da?+(/\\bAppleWebKit\\/(\\d+)/.exec(Ne.userAgent)||[0,0])[1]:0,tabSize:Is.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},mf=256,st=class i extends ee{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,r){return this.flags&8||r&&(!(r instanceof i)||this.length-(t-e)+r.length>mf||r.flags&8)?!1:(this.text=this.text.slice(0,e)+(r?r.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new i(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new xe(this.dom,e)}domBoundsAround(e,t,r){return{from:r,to:r+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return yf(this.dom,e,t)}},Tt=class i extends ee{constructor(e,t=[],r=0){super(),this.mark=e,this.children=t,this.length=r;for(let n of t)n.setParent(this)}setAttrs(e){if(qa(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,r,n,s,o){return r&&(!(r instanceof i&&r.mark.eq(this.mark))||e&&s<=0||te&&t.push(r=e&&(n=s),r=a,s++}let o=this.length-e;return this.length=e,n>-1&&(this.children.length=n,this.markDirty()),new i(this.mark,t,o)}domAtPos(e){return Xa(this,e)}coordsAt(e,t){return Qa(this,e,t)}};function yf(i,e,t){let r=i.nodeValue.length;e>r&&(e=r);let n=e,s=e,o=0;e==0&&t<0||e==r&&t>=0?R.chrome||R.gecko||(e?(n--,o=1):s=0)?0:l.length-1];return R.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,u=>u.width)||a),o?kn(a,o<0):a||null}var vn=class i extends ee{static create(e,t,r){return new i(e,t,r)}constructor(e,t,r){super(),this.widget=e,this.length=t,this.side=r,this.prevWidget=null}split(e){let t=i.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,r,n,s,o){return r&&(!(r instanceof i)||!this.widget.compare(r.widget)||e>0&&s<=0||t0)?xe.before(this.dom):xe.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?n.length-1:0;s=n[l],!(e>0?l==0:l==n.length-1||s.top0?xe.before(this.dom):xe.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Y.empty}get isHidden(){return!0}};st.prototype.children=vn.prototype.children=lr.prototype.children=co;function Xa(i,e){let t=i.dom,{children:r}=i,n=0;for(let s=0;ns&&e0;s--){let o=r[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=n;s0&&e instanceof Tt&&n.length&&(r=n[n.length-1])instanceof Tt&&r.mark.eq(e.mark)?Ja(r,e.children[0],t-1):(n.push(e),e.setParent(i)),i.length+=e.length}function Qa(i,e,t){let r=null,n=-1,s=null,o=-1;function l(u,h){for(let c=0,f=0;c=h&&(d.children.length?l(d,h-f):(!s||s.isHidden&&t>0)&&(p>h||f==p&&d.getSide()>0)?(s=d,o=h-f):(f-1?1:0)!=n.length-(t&&n.indexOf(t)>-1?1:0))return!1;for(let s of r)if(s!=t&&(n.indexOf(s)==-1||i[s]!==e[s]))return!1;return!0}function Vs(i,e,t){let r=!1;if(e)for(let n in e)t&&n in t||(r=!0,n=="style"?i.style.cssText="":i.removeAttribute(n));if(t)for(let n in t)e&&e[n]==t[n]||(r=!0,n=="style"?i.style.cssText=t[n]:i.setAttribute(n,t[n]));return r}function vf(i){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new kt(e,t,t,r,e.widget||null,!1)}static replace(e){let t=!!e.block,r,n;if(e.isBlockGap)r=-5e8,n=4e8;else{let{start:s,end:o}=Za(e,t);r=(s?t?-3e8:-1:5e8)-1,n=(o?t?2e8:1:-6e8)+1}return new kt(e,r,n,t,e.widget||null,!0)}static line(e){return new ur(e)}static set(e,t=!1){return he.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};le.none=he.empty;var ar=class i extends le{constructor(e){let{start:t,end:r}=Za(e);super(t?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,r;return this==e||e instanceof i&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((r=e.attrs)===null||r===void 0?void 0:r.class))&&wn(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}};ar.prototype.point=!1;var ur=class i extends le{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof i&&this.spec.class==e.spec.class&&wn(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}};ur.prototype.mapMode=Me.TrackBefore;ur.prototype.point=!0;var kt=class i extends le{constructor(e,t,r,n,s,o){super(t,r,s,e),this.block=n,this.isReplace=o,this.mapMode=n?t<=0?Me.TrackBefore:Me.TrackAfter:Me.TrackDel}get type(){return this.startSide!=this.endSide?rt.WidgetRange:this.startSide<=0?rt.WidgetBefore:rt.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof i&&wf(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}};kt.prototype.point=!0;function Za(i,e=!1){let{inclusiveStart:t,inclusiveEnd:r}=i;return t==null&&(t=i.inclusive),r==null&&(r=i.inclusive),{start:t!=null?t:e,end:r!=null?r:e}}function wf(i,e){return i==e||!!(i&&e&&i.compare(e))}function qs(i,e,t,r=0){let n=t.length-1;n>=0&&t[n]+r>=i?t[n]=Math.max(t[n],e):t.push(i,e)}var we=class i extends ee{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,r,n,s,o){if(r){if(!(r instanceof i))return!1;this.dom||r.transferDOM(this)}return n&&this.setDeco(r?r.attrs:null),Ga(this,e,t,r?r.children.slice():[],s,o),!0}split(e){let t=new i;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:r,off:n}=this.childPos(e);n&&(t.append(this.children[r].split(n),0),this.children[r].merge(n,this.children[r].length,null,!1,0,0),r++);for(let s=r;s0&&this.children[r-1].length==0;)this.children[--r].destroy();return this.children.length=r,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){wn(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){Ja(this,e,t)}addLineDeco(e){let t=e.spec.attributes,r=e.spec.class;t&&(this.attrs=$s(t,this.attrs||{})),r&&(this.attrs=$s({class:r},this.attrs||{}))}domAtPos(e){return Xa(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var r;this.dom?this.flags&4&&(qa(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Vs(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let n=this.dom.lastChild;for(;n&&ee.get(n)instanceof Tt;)n=n.lastChild;if(!n||!this.length||n.nodeName!="BR"&&((r=ee.get(n))===null||r===void 0?void 0:r.isEditable)==!1&&(!R.ios||!this.children.some(s=>s instanceof st))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let r of this.children){if(!(r instanceof st)||/[^ -~]/.test(r.text))return null;let n=or(r.dom);if(n.length!=1)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let r=Qa(this,e,t);if(!this.children.length&&r&&this.parent){let{heightOracle:n}=this.parent.view.viewState,s=r.bottom-r.top;if(Math.abs(s-n.lineHeight)<2&&n.textHeight=t){if(s instanceof i)return s;if(o>t)break}n=o+s.breakAfter}return null}},Gt=class i extends ee{constructor(e,t,r){super(),this.widget=e,this.length=t,this.deco=r,this.breakAfter=0,this.prevWidget=null}merge(e,t,r,n,s,o){return r&&(!(r instanceof i)||!this.widget.compare(r.widget)||e>0&&s<=0||t0}},hr=class extends bi{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}},tr=class i{constructor(e,t,r,n){this.doc=e,this.pos=t,this.end=r,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}posCovered(){if(this.content.length==0)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof Gt&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new we),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ln(new lr(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,!this.posCovered()&&!(e&&this.content.length&&this.content[this.content.length-1]instanceof Gt)&&this.getLine()}buildText(e,t,r){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let n=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-r)),this.getLine().append(ln(new st(this.text.slice(this.textOff,this.textOff+n)),t),r),this.atCursorPos=!0,this.textOff+=n,e-=n,r=0}}span(e,t,r,n){this.buildText(t-e,r,n),this.pos=t,this.openStart<0&&(this.openStart=n)}point(e,t,r,n,s,o){if(this.disallowBlockEffectsFor[o]&&r instanceof kt){if(r.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(r instanceof kt)if(r.block)r.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Gt(r.widget||Mt.block,l,r));else{let a=vn.create(r.widget||Mt.inline,l,l?0:r.startSide),u=this.atCursorPos&&!a.isEditable&&s<=n.length&&(e0),h=!a.isEditable&&(en.length||r.startSide<=0),c=this.getLine();this.pendingBuffer==2&&!u&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(n),u&&(c.append(ln(new lr(1),n),s),s=n.length+Math.max(0,s-n.length)),c.append(ln(a,n),s),this.atCursorPos=h,this.pendingBuffer=h?en.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(r);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,r,n,s){let o=new i(e,t,r,s);return o.openEnd=he.spans(n,t,r,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function ln(i,e){for(let t of e)i=new Tt(t,[i],i.length);return i}var Mt=class extends bi{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};Mt.inline=new Mt("span");Mt.block=new Mt("div");var me=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(me||(me={})),Xt=me.LTR,fo=me.RTL;function eu(i){let e=[];for(let t=0;t=t){if(l.level==r)return o;(s<0||(n!=0?n<0?l.fromt:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function iu(i,e){if(i.length!=e.length)return!1;for(let t=0;t=0;g-=3)if(et[g+1]==-d){let y=et[g+2],b=y&2?n:y&4?y&1?s:n:0;b&&(Z[c]=Z[et[g]]=b),l=g;break}}else{if(et.length==189)break;et[l++]=c,et[l++]=f,et[l++]=a}else if((p=Z[c])==2||p==1){let g=p==n;a=g?0:1;for(let y=l-3;y>=0;y-=3){let b=et[y+2];if(b&2)break;if(g)et[y+2]|=2;else{if(b&4)break;et[y+2]|=4}}}}}function xf(i,e,t,r){for(let n=0,s=r;n<=t.length;n++){let o=n?t[n-1].to:i,l=na;)p==y&&(p=t[--g].from,y=g?t[g-1].to:i),Z[--p]=d;a=h}else s=u,a++}}}function Ws(i,e,t,r,n,s,o){let l=r%2?2:1;if(r%2==n%2)for(let a=e,u=0;aa&&o.push(new it(a,g.from,d));let y=g.direction==Xt!=!(d%2);zs(i,y?r+1:r,n,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==t||(h?Z[p]!=l:Z[p]==l))break;p++}f?Ws(i,a,p,r+1,n,f,o):ae;){let h=!0,c=!1;if(!u||a>s[u-1].to){let g=Z[a-1];g!=l&&(h=!1,c=g==16)}let f=!h&&l==1?[]:null,d=h?r:r+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(c)break e;let g=s[--u];if(!h)for(let y=g.from,b=u;;){if(y==e)break e;if(b&&s[b-1].to==y)y=s[--b].from;else{if(Z[y-1]==l)break e;break}}if(f)f.push(g);else{g.toZ.length;)Z[Z.length]=256;let r=[],n=e==Xt?0:1;return zs(i,n,n,t,0,i.length,r),r}function ru(i){return[new it(0,i,0)]}var nu="";function kf(i,e,t,r,n){var s;let o=r.head-i.from,l=it.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),a=e[l],u=a.side(n,t);if(o==u){let f=l+=n?1:-1;if(f<0||f>=e.length)return null;a=e[l=f],o=a.side(!n,t),u=a.side(n,t)}let h=Ze(i.text,o,a.forward(n,t));(ha.to)&&(h=u),nu=i.text.slice(Math.min(o,h),Math.max(o,h));let c=l==(n?e.length-1:0)?null:e[l+(n?1:-1)];return c&&h==u&&c.level+(n?0:1)i.some(e=>e)}),Rf=$.define({combine:i=>i.some(e=>e)}),fu=$.define(),ir=class i{constructor(e,t="nearest",r="nearest",n=5,s=5,o=!1){this.range=e,this.y=t,this.x=r,this.yMargin=n,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new i(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new i(P.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},an=se.define({map:(i,e)=>i.map(e)}),du=se.define();function ze(i,e,t){let r=i.facet(au);r.length?r[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var Et=$.define({combine:i=>i.length?i[0]:!0}),Nf=0,Xi=$.define(),Jt=class i{constructor(e,t,r,n,s){this.id=e,this.create=t,this.domEventHandlers=r,this.domEventObservers=n,this.extension=s(this)}static define(e,t){let{eventHandlers:r,eventObservers:n,provide:s,decorations:o}=t||{};return new i(Nf++,e,r,n,l=>{let a=[Xi.of(l)];return o&&a.push(cr.of(u=>{let h=u.plugin(l);return h?o(h):le.none})),s&&a.push(s(l)),a})}static fromClass(e,t){return i.define(r=>new e(r),t)}},rr=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(r){if(ze(t.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(n){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){ze(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(r){ze(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},pu=$.define(),mo=$.define(),cr=$.define(),gu=$.define(),yo=$.define(),mu=$.define();function ma(i,e){let t=i.state.facet(mu);if(!t.length)return t;let r=t.map(s=>s instanceof Function?s(i):s),n=[];return he.spans(r,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,h=o-e.from,c=n;for(let f=l.length-1;f>=0;f--,a--){let d=l[f].spec.bidiIsolate,p;if(d==null&&(d=Mf(e.text,u,h)),a>0&&c.length&&(p=c[c.length-1]).to==u&&p.direction==d)p.to=h,c=p.inner;else{let g={from:u,to:h,direction:d,inner:[]};c.push(g),c=g.inner}}}}),n}var yu=$.define();function bu(i){let e=0,t=0,r=0,n=0;for(let s of i.state.facet(yu)){let o=s(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(n=Math.max(n,o.bottom)))}return{left:e,right:t,top:r,bottom:n}}var Ji=$.define(),nt=class i{constructor(e,t,r,n){this.fromA=e,this.toA=t,this.fromB=r,this.toB=n}join(e){return new i(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,r=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>r.toA)){if(n.toAh)break;s+=2}if(!a)return r;new i(a.fromA,a.toA,a.fromB,a.toB).addToSet(r),o=a.toA,l=a.toB}}},An=class i{constructor(e,t,r){this.view=e,this.state=t,this.transactions=r,this.flags=0,this.startState=e.state,this.changes=_e.empty(this.startState.doc.length);for(let s of r)this.changes=this.changes.compose(s.changes);let n=[];this.changes.iterChangedRanges((s,o,l,a)=>n.push(new nt(s,o,l,a))),this.changedRanges=n}static create(e,t,r){return new i(e,t,r)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Cn=class extends ee{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=le.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new we],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new nt(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:u,toA:h})=>hthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?n=this.domChanged.newSel.head:!Ff(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let s=n>-1?Bf(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:u,to:h}=this.hasComposition;r=new nt(u,h,e.changes.mapPos(u,-1),e.changes.mapPos(h,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(R.ie||R.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.updateDeco(),a=_f(o,l,e.changes);return r=nt.extendWithRanges(r,a),!(this.flags&7)&&r.length==0?!1:(this.updateInner(r,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,r){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,r);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=R.chrome||R.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||n.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to=0?n[o]:null;if(!l)break;let{fromA:a,toA:u,fromB:h,toB:c}=l,f,d,p,g;if(r&&r.range.fromBh){let E=tr.build(this.view.state.doc,h,r.range.fromB,this.decorations,this.dynamicDecorationMap),S=tr.build(this.view.state.doc,r.range.toB,c,this.decorations,this.dynamicDecorationMap);d=E.breakAtStart,p=E.openStart,g=S.openEnd;let N=this.compositionView(r);S.breakAtStart?N.breakAfter=1:S.content.length&&N.merge(N.length,N.length,S.content[0],!1,S.openStart,0)&&(N.breakAfter=S.content[0].breakAfter,S.content.shift()),E.content.length&&N.merge(0,0,E.content[E.content.length-1],!0,0,E.openEnd)&&E.content.pop(),f=E.content.concat(N).concat(S.content)}else({content:f,breakAtStart:d,openStart:p,openEnd:g}=tr.build(this.view.state.doc,h,c,this.decorations,this.dynamicDecorationMap));let{i:y,off:b}=s.findPos(u,1),{i:A,off:w}=s.findPos(a,-1);ja(this,A,w,y,b,f,d,p,g)}r&&this.fixCompositionDOM(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let r of t.effects)r.is(du)&&(this.editContextFormatting=r.value)}compositionView(e){let t=new st(e.text.nodeValue);t.flags|=8;for(let{deco:n}of e.marks)t=new Tt(n,[t],t.length);let r=new we;return r.append(t,0),r}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(a=>a.flags&7)?1:0),this.markedForComposition.add(o);let l=ee.get(s);l&&l!=o&&(l.dom=null),o.setDOM(s)},r=this.childPos(e.range.fromB,1),n=this.children[r.i];t(e.line,n);for(let s=e.marks.length-1;s>=-1;s--)r=n.childPos(r.off,1),n=n.children[r.i],t(s>=0?e.marks[s].node:e.text,n)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let r=this.view.root.activeElement,n=r==this.dom,s=!n&&pn(this.dom,this.view.observer.selectionRange)&&!(r&&this.dom.contains(r));if(!(n||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),u=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(R.gecko&&l.empty&&!this.hasComposition&&Of(a)){let c=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(c,a.node.childNodes[a.offset]||null)),a=u=new xe(c,0),o=!0}let h=this.view.observer.selectionRange;(o||!h.focusNode||(!er(a.node,a.offset,h.anchorNode,h.anchorOffset)||!er(u.node,u.offset,h.focusNode,h.focusOffset))&&!this.suppressWidgetCursorChange(h,l))&&(this.view.observer.ignore(()=>{R.android&&R.chrome&&this.dom.contains(h.focusNode)&&If(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let c=sr(this.view.root);if(c)if(l.empty){if(R.gecko){let f=Pf(a.node,a.offset);if(f&&f!=3){let d=(f==1?Wa:za)(a.node,a.offset);d&&(a=new xe(d.node,d.offset))}}c.collapse(a.node,a.offset),l.bidiLevel!=null&&c.caretBidiLevel!==void 0&&(c.caretBidiLevel=l.bidiLevel)}else if(c.extend){c.collapse(a.node,a.offset);try{c.extend(u.node,u.offset)}catch(f){}}else{let f=document.createRange();l.anchor>l.head&&([a,u]=[u,a]),f.setEnd(u.node,u.offset),f.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(f)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(a,u)),this.impreciseAnchor=a.precise?null:new xe(h.anchorNode,h.anchorOffset),this.impreciseHead=u.precise?null:new xe(h.focusNode,h.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&er(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,r=sr(e.root),{anchorNode:n,anchorOffset:s}=e.observer.selectionRange;if(!r||!t.empty||!t.assoc||!r.modify)return;let o=we.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),u=this.coordsAt(t.head,1);if(!a||!u||a.bottom>u.top)return;let h=this.domAtPos(t.head+t.assoc);r.collapse(h.node,h.offset),r.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&r.collapse(n,s)}moveToLine(e){let t=this.dom,r;if(e.node!=t)return e;for(let n=e.offset;!r&&n=0;n--){let s=ee.get(t.childNodes[n]);s instanceof we&&(r=s.domAtPos(s.length))}return r?new xe(r.node,r.offset,!0):e}nearest(e){for(let t=e;t;){let r=ee.get(t);if(r&&r.rootView==this)return r;t=t.parentNode}return null}posFromDOM(e,t){let r=this.nearest(e);if(!r)throw new RangeError("Trying to find position for a DOM position outside of the document");return r.localPosFromDOM(e,t)+r.posAtStart}domAtPos(e){let{i:t,off:r}=this.childCursor().findPos(e,-1);for(;t=0;o--){let l=this.children[o],a=s-l.breakAfter,u=a-l.length;if(ae||l.covers(1))&&(!r||l instanceof we&&!(r instanceof we&&t>=0)))r=l,n=u;else if(r&&u==e&&a==e&&l instanceof Gt&&Math.abs(t)<2){if(l.deco.startSide<0)break;o&&(r=null)}s=u}return r?r.coordsAt(e-n,t):null}coordsForChar(e){let{i:t,off:r}=this.childPos(e,1),n=this.children[t];if(!(n instanceof we))return null;for(;n.children.length;){let{i:l,off:a}=n.childPos(r,1);for(;;l++){if(l==n.children.length)return null;if((n=n.children[l]).length)break}r=a}if(!(n instanceof st))return null;let s=Ze(n.text,r);if(s==r)return null;let o=Yt(n.dom,r,s).getClientRects();for(let l=0;lMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==me.LTR;for(let u=0,h=0;hn)break;if(u>=r){let d=c.dom.getBoundingClientRect();if(t.push(d.height),o){let p=c.dom.lastChild,g=p?or(p):[];if(g.length){let y=g[g.length-1],b=a?y.right-d.left:d.right-y.left;b>l&&(l=b,this.minWidth=s,this.minWidthFrom=u,this.minWidthTo=f)}}}u=f+c.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?me.RTL:me.LTR}measureTextSize(){for(let s of this.children)if(s instanceof we){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,r,n;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=or(e.firstChild)[0];t=e.getBoundingClientRect().height,r=s?s.width/27:7,n=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:r,textHeight:n}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new bn(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let r=0,n=0;;n++){let s=n==t.viewports.length?null:t.viewports[n],o=s?s.from-1:this.length;if(o>r){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(r).top)/this.view.scaleY;e.push(le.replace({widget:new hr(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return le.set(e)}updateDeco(){let e=1,t=this.view.state.facet(cr).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,n=this.view.state.facet(gu).map((s,o)=>{let l=typeof s=="function";return l&&(r=!0),l?s(this.view):s});for(n.length&&(this.dynamicDecorationMap[e++]=r,t.push(he.join(n))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];et.anchor?-1:1),n;if(!r)return;!t.empty&&(n=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(r={left:Math.min(r.left,n.left),top:Math.min(r.top,n.top),right:Math.max(r.right,n.right),bottom:Math.max(r.bottom,n.bottom)});let s=bu(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;ff(this.view.scrollDOM,o,t.head{re.from&&(t=!0)}),t}function Hf(i,e,t=1){let r=i.charCategorizer(e),n=i.doc.lineAt(e),s=e-n.from;if(n.length==0)return P.cursor(e);s==0?t=1:s==n.length&&(t=-1);let o=s,l=s;t<0?o=Ze(n.text,s,!1):l=Ze(n.text,s);let a=r(n.text.slice(o,l));for(;o>0;){let u=Ze(n.text,o,!1);if(r(n.text.slice(u,o))!=a)break;o=u}for(;li?e.left-i:Math.max(0,i-e.right)}function Vf(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function Os(i,e){return i.tope.top+1}function ya(i,e){return ei.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function Gs(i,e,t){let r,n,s,o,l=!1,a,u,h,c;for(let p=i.firstChild;p;p=p.nextSibling){let g=or(p);for(let y=0;yw||o==w&&s>A){r=p,n=b,s=A,o=w;let E=w?t0?y0)}A==0?t>b.bottom&&(!h||h.bottomb.top)&&(u=p,c=b):h&&Os(h,b)?h=ba(h,b.bottom):c&&Os(c,b)&&(c=ya(c,b.top))}}if(h&&h.bottom>=t?(r=a,n=h):c&&c.top<=t&&(r=u,n=c),!r)return{node:i,offset:0};let f=Math.max(n.left,Math.min(n.right,e));if(r.nodeType==3)return va(r,f,t);if(l&&r.contentEditable!="false")return Gs(r,f,t);let d=Array.prototype.indexOf.call(i.childNodes,r)+(e>=(n.left+n.right)/2?1:0);return{node:i,offset:d}}function va(i,e,t){let r=i.nodeValue.length,n=-1,s=1e9,o=0;for(let l=0;lt?h.top-t:t-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c=(h.left+h.right)/2,d=f;if((R.chrome||R.gecko)&&Yt(i,l).getBoundingClientRect().left==h.right&&(d=!f),c<=0)return{node:i,offset:l+(d?1:0)};n=l+(d?1:0),s=c}}}return{node:i,offset:n>-1?n:o>0?i.nodeValue.length:0}}function wu(i,e,t,r=-1){var n,s;let o=i.contentDOM.getBoundingClientRect(),l=o.top+i.viewState.paddingTop,a,{docHeight:u}=i.viewState,{x:h,y:c}=e,f=c-l;if(f<0)return 0;if(f>u)return i.state.doc.length;for(let E=i.viewState.heightOracle.textHeight/2,S=!1;a=i.elementAtHeight(f),a.type!=rt.Text;)for(;f=r>0?a.bottom+E:a.top-E,!(f>=0&&f<=u);){if(S)return t?null:0;S=!0,r=-r}c=l+f;let d=a.from;if(di.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:wa(i,o,a,h,c);let p=i.dom.ownerDocument,g=i.root.elementFromPoint?i.root:p,y=g.elementFromPoint(h,c);y&&!i.contentDOM.contains(y)&&(y=null),y||(h=Math.max(o.left+1,Math.min(o.right-1,h)),y=g.elementFromPoint(h,c),y&&!i.contentDOM.contains(y)&&(y=null));let b,A=-1;if(y&&((n=i.docView.nearest(y))===null||n===void 0?void 0:n.isEditable)!=!1){if(p.caretPositionFromPoint){let E=p.caretPositionFromPoint(h,c);E&&({offsetNode:b,offset:A}=E)}else if(p.caretRangeFromPoint){let E=p.caretRangeFromPoint(h,c);E&&({startContainer:b,startOffset:A}=E,(!i.contentDOM.contains(b)||R.safari&&qf(b,A,h)||R.chrome&&Uf(b,A,h))&&(b=void 0))}}if(!b||!i.docView.dom.contains(b)){let E=we.find(i.docView,d);if(!E)return f>a.top+a.height/2?a.to:a.from;({node:b,offset:A}=Gs(E.dom,h,c))}let w=i.docView.nearest(b);if(!w)return null;if(w.isWidget&&((s=w.dom)===null||s===void 0?void 0:s.nodeType)==1){let E=w.dom.getBoundingClientRect();return e.yi.defaultLineHeight*1.5){let l=i.viewState.heightOracle.textHeight,a=Math.floor((n-t.top-(i.defaultLineHeight-l)*.5)/l);s+=a*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+sa(o,s,i.state.tabSize)}function qf(i,e,t){let r;if(i.nodeType!=3||e!=(r=i.nodeValue.length))return!1;for(let n=i.nextSibling;n;n=n.nextSibling)if(n.nodeType!=1||n.nodeName!="BR")return!1;return Yt(i,r-1,r).getBoundingClientRect().left>t}function Uf(i,e,t){if(e!=0)return!1;for(let n=i;;){let s=n.parentNode;if(!s||s.nodeType!=1||s.firstChild!=n)return!1;if(s.classList.contains("cm-line"))break;n=s}let r=i.nodeType==1?i.getBoundingClientRect():Yt(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-r.left>5}function Wf(i,e){let t=i.lineBlockAt(e);if(Array.isArray(t.type)){for(let r of t.type)if(r.to>e||r.to==e&&(r.to==t.to||r.type==rt.Text))return r}return t}function zf(i,e,t,r){let n=Wf(i,e.head),s=!r||n.type!=rt.Text||!(i.lineWrapping||n.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>n.from?e.head-1:e.head);if(s){let o=i.dom.getBoundingClientRect(),l=i.textDirectionAt(n.from),a=i.posAtCoords({x:t==(l==me.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return P.cursor(a,t?-1:1)}return P.cursor(t?n.to:n.from,t?-1:1)}function Aa(i,e,t,r){let n=i.state.doc.lineAt(e.head),s=i.bidiSpans(n),o=i.textDirectionAt(n.from);for(let l=e,a=null;;){let u=kf(n,s,o,l,t),h=nu;if(!u){if(n.number==(t?i.state.doc.lines:1))return l;h=`\n`,n=i.state.doc.line(n.number+(t?1:-1)),s=i.bidiSpans(n),u=i.visualLineSide(n,!t)}if(a){if(!a(h))return l}else{if(!r)return u;a=r(h)}l=u}}function jf(i,e,t){let r=i.state.charCategorizer(e),n=r(t);return s=>{let o=r(s);return n==Qe.Space&&(n=o),n==o}}function Gf(i,e,t,r){let n=e.head,s=t?1:-1;if(n==(t?i.state.doc.length:0))return P.cursor(n,e.assoc);let o=e.goalColumn,l,a=i.contentDOM.getBoundingClientRect(),u=i.coordsAtPos(n,e.assoc||-1),h=i.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let d=i.viewState.lineBlockAt(n);o==null&&(o=Math.min(a.right-a.left,i.defaultCharacterWidth*(n-d.from))),l=(s<0?d.top:d.bottom)+h}let c=a.left+o,f=r!=null?r:i.viewState.heightOracle.textHeight>>1;for(let d=0;;d+=10){let p=l+(f+d)*s,g=wu(i,{x:c,y:p},!1,s);if(pa.bottom||(s<0?gn)){let y=i.docView.coordsForChar(g),b=!y||p{if(e>s&&en(i)),t.from,e.head>t.from?-1:1);return r==t.from?t:P.cursor(r,rs)&&this.lineBreak(),n=o}return this.findPointBefore(r,t),this}readTextNode(e){let t=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,t.length));for(let r=0,n=this.lineSeparator?null:/\\r\\n?|\\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=n.exec(t))&&(s=l.index,o=l[0].length),this.append(t.slice(r,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=s+o}}readNode(e){if(e.cmIgnore)return;let t=ee.get(e),r=t&&t.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let n=r.iter();!n.next().done;)n.lineBreak?this.lineBreak():this.append(n.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==t&&(r.pos=this.text.length)}findPointInside(e,t){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(Kf(e,r.node,r.offset)?t:0))}};function Kf(i,e,t){for(;;){if(!e||t-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,r,0))){let l=s||o?[]:Jf(e),a=new Ks(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=Qf(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=s&&s.node==l.focusNode&&s.offset==l.focusOffset||!Ls(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Ls(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset),h=e.viewport;if((R.ios||R.chrome)&&e.state.selection.main.empty&&a!=u&&(h.from>0||h.toDate.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=n.from,u=null;(s===8||R.android&&e.text.length=n.from&&t.to<=n.to&&(t.from!=n.from||t.to!=n.to)&&n.to-n.from-(t.to-t.from)<=4?t={from:n.from,to:n.to,insert:i.state.doc.slice(n.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,n.to))}:(R.mac||R.android)&&t&&t.from==t.to&&t.from==n.head-1&&/^\\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(r&&t.insert.length==2&&(r=P.single(r.main.anchor-1,r.main.head-1)),t={from:n.from,to:n.to,insert:Y.of([" "])}):R.chrome&&t&&t.from==t.to&&t.from==n.head&&t.insert.toString()==`\n `&&i.lineWrapping&&(r&&(r=P.single(r.main.anchor-1,r.main.head-1)),t={from:n.from,to:n.to,insert:Y.of([" "])}),t)return bo(i,t,r,s);if(r&&!r.main.eq(n)){let o=!1,l="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),l=i.inputState.lastSelectionOrigin),i.dispatch({selection:r,scrollIntoView:o,userEvent:l}),!0}else return!1}function bo(i,e,t,r=-1){if(R.ios&&i.inputState.flushIOSKey(e))return!0;let n=i.state.selection.main;if(R.android&&(e.to==n.to&&(e.from==n.from||e.from==n.from-1&&i.state.sliceDoc(e.from,n.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&yi(i.contentDOM,"Enter",13)||(e.from==n.from-1&&e.to==n.to&&e.insert.length==0||r==8&&e.insert.lengthn.head)&&yi(i.contentDOM,"Backspace",8)||e.from==n.from&&e.to==n.to+1&&e.insert.length==0&&yi(i.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let o,l=()=>o||(o=Yf(i,e,t));return i.state.facet(uu).some(a=>a(i,e.from,e.to,s,l))||i.dispatch(l()),!0}function Yf(i,e,t){let r,n=i.state,s=n.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&i.inputState.composing<0){let l=s.frome.to?n.sliceDoc(e.to,s.to):"";r=n.replaceSelection(i.state.toText(l+e.insert.sliceString(0,void 0,i.state.lineBreak)+a))}else{let l=n.changes(e),a=t&&t.main.to<=l.newLength?t.main:void 0;if(n.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let u=i.state.sliceDoc(e.from,e.to),h,c=t&&vu(i,t.main.head);if(c){let p=e.insert.length-(e.to-e.from);h={from:c.from,to:c.to-p}}else h=i.state.doc.lineAt(s.head);let f=s.to-e.to,d=s.to-s.from;r=n.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:l,range:a||p.map(l)};let g=p.to-f,y=g-u.length;if(p.to-p.from!=d||i.state.sliceDoc(y,g)!=u||p.to>=h.from&&p.from<=h.to)return{range:p};let b=n.changes({from:y,to:g,insert:e.insert}),A=p.to-s.to;return{changes:b,range:a?P.range(Math.max(0,a.anchor+A),Math.max(0,a.head+A)):p.map(b)}})}else r={changes:l,selection:a&&n.selection.replaceRange(a)}}let o="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,o+=".compose",i.inputState.compositionFirstChange&&(o+=".start",i.inputState.compositionFirstChange=!1)),n.update(r,{userEvent:o,scrollIntoView:!0})}function Xf(i,e,t,r){let n=Math.min(i.length,e.length),s=0;for(;s0&&l>0&&i.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,s-Math.min(o,l));t-=o+a-s}if(o=o?s-t:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-t:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function Jf(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:r,focusNode:n,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new Sn(t,r)),(n!=t||s!=r)&&e.push(new Sn(n,s))),e}function Qf(i,e){if(i.length==0)return null;let t=i[0].pos,r=i.length==2?i[1].pos:t;return t>-1&&r>-1?P.single(t+e,r+e):null}var Xs=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,R.safari&&e.contentDOM.addEventListener("input",()=>null),R.gecko&&pd(e.contentDOM.ownerDocument)}handleEvent(e){!od(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let r=this.handlers[e];if(r){for(let n of r.observers)n(this.view,t);for(let n of r.handlers){if(t.defaultPrevented)break;if(n(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Zf(e),r=this.handlers,n=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,l=r[s];l&&o!=!l.handlers.length&&(n.removeEventListener(s,this.handleEvent),l=null),l||n.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!t[s]&&n.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&td.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),R.android&&R.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return R.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=Cu.find(r=>r.keyCode==e.keyCode))&&!e.ctrlKey||ed.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from0?!0:R.safari&&!R.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Ca(i,e){return(t,r)=>{try{return e.call(i,r,t)}catch(n){ze(t.state,n)}}}function Zf(i){let e=Object.create(null);function t(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of i){let n=r.spec;if(n&&n.domEventHandlers)for(let s in n.domEventHandlers){let o=n.domEventHandlers[s];o&&t(s).handlers.push(Ca(r.value,o))}if(n&&n.domEventObservers)for(let s in n.domEventObservers){let o=n.domEventObservers[s];o&&t(s).observers.push(Ca(r.value,o))}}for(let r in je)t(r).handlers.push(je[r]);for(let r in Ve)t(r).observers.push(Ve[r]);return e}var Cu=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ed="dthko",td=[16,17,18,20,91,92,224,225],un=6;function hn(i){return Math.max(0,i)*.7+8}function id(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}var Js=class{constructor(e,t,r,n){this.view=e,this.startEvent=t,this.style=r,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=df(e.contentDOM),this.atoms=e.state.facet(yo).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(oe.allowMultipleSelections)&&rd(e,t),this.dragging=sd(e,t)&&Eu(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&id(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,r=0,n=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:n,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=bu(this.view);e.clientX-a.left<=n+un?t=-hn(n-e.clientX):e.clientX+a.right>=o-un&&(t=hn(e.clientX-o)),e.clientY-a.top<=s+un?r=-hn(s-e.clientY):e.clientY+a.bottom>=l-un&&(r=hn(e.clientY-l)),this.setScrollSpeed(t,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let r=0;rt.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function rd(i,e){let t=i.state.facet(su);return t.length?t[0](e):R.mac?e.metaKey:e.ctrlKey}function nd(i,e){let t=i.state.facet(ou);return t.length?t[0](e):R.mac?!e.altKey:!e.ctrlKey}function sd(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let r=sr(i.root);if(!r||r.rangeCount==0)return!0;let n=r.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function od(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,r;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(r=ee.get(t))&&r.ignoreEvent(e))return!1;return!0}var je=Object.create(null),Ve=Object.create(null),Su=R.ie&&R.ie_version<15||R.ios&&R.webkit_version<604;function ld(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),Du(i,t.value)},50)}function Rn(i,e,t){for(let r of i.facet(e))t=r(t,i);return t}function Du(i,e){e=Rn(i.state,po,e);let{state:t}=i,r,n=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Qs!=null&&t.selection.ranges.every(a=>a.empty)&&Qs==s.toString()){let a=-1;r=t.changeByRange(u=>{let h=t.doc.lineAt(u.from);if(h.from==a)return{range:u};a=h.from;let c=t.toText((o?s.line(n++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:c},range:P.cursor(u.from+c.length)}})}else o?r=t.changeByRange(a=>{let u=s.line(n++);return{changes:{from:a.from,to:a.to,insert:u.text},range:P.cursor(a.from+u.length)}}):r=t.replaceSelection(s);i.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}Ve.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};je.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&i.inputState.tabFocusMode!=0&&(i.inputState.tabFocusMode=Date.now()+2e3),!1);Ve.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};Ve.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};je.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let r of i.state.facet(lu))if(t=r(i,e),t)break;if(!t&&e.button==0&&(t=hd(i,e)),t){let r=!i.hasFocus;i.inputState.startMouseSelection(new Js(i,e,t,r)),r&&i.observer.ignore(()=>{Va(i.contentDOM);let s=i.root.activeElement;s&&!s.contains(i.contentDOM)&&s.blur()});let n=i.inputState.mouseSelection;if(n)return n.start(e),n.dragging===!1}return!1};function Sa(i,e,t,r){if(r==1)return P.cursor(e,t);if(r==2)return Hf(i.state,e,t);{let n=we.find(i.docView,e),s=i.state.doc.lineAt(n?n.posAtEnd:e),o=n?n.posAtStart:s.from,l=n?n.posAtEnd:s.to;return le>=t.top&&e<=t.bottom&&i>=t.left&&i<=t.right;function ad(i,e,t,r){let n=we.find(i.docView,e);if(!n)return 1;let s=e-n.posAtStart;if(s==0)return 1;if(s==n.length)return-1;let o=n.coordsAt(s,-1);if(o&&Da(t,r,o))return-1;let l=n.coordsAt(s,1);return l&&Da(t,r,l)?1:o&&o.bottom>=r?-1:1}function Ea(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:ad(i,t,e.clientX,e.clientY)}}var ud=R.ie&&R.ie_version<=11,xa=null,Ta=0,ka=0;function Eu(i){if(!ud)return i.detail;let e=xa,t=ka;return xa=i,ka=Date.now(),Ta=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(Ta+1)%3:1}function hd(i,e){let t=Ea(i,e),r=Eu(e),n=i.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),n=n.map(s.changes))},get(s,o,l){let a=Ea(i,s),u,h=Sa(i,a.pos,a.bias,r);if(t.pos!=a.pos&&!o){let c=Sa(i,t.pos,t.bias,r),f=Math.min(c.from,h.from),d=Math.max(c.to,h.to);h=f1&&(u=cd(n,a.pos))?u:l?n.addRange(h):P.create([h])}}}function cd(i,e){for(let t=0;t=e)return P.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}je.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let n=i.docView.nearest(e.target);if(n&&n.isWidget){let s=n.posAtStart,o=s+n.length;(s>=t.to||o<=t.from)&&(t=P.range(s,o))}}let{inputState:r}=i;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",Rn(i.state,go,i.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};je.dragend=i=>(i.inputState.draggedContent=null,!1);function Ma(i,e,t,r){if(t=Rn(i.state,po,t),!t)return;let n=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=i.inputState,o=r&&s&&nd(i,e)?{from:s.from,to:s.to}:null,l={from:n,insert:t},a=i.state.changes(o?[o,l]:l);i.focus(),i.dispatch({changes:a,selection:{anchor:a.mapPos(n,-1),head:a.mapPos(n,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}je.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let r=Array(t.length),n=0,s=()=>{++n==t.length&&Ma(i,e,r.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o{/[\\x00-\\x08\\x0e-\\x1f]{2}/.test(l.result)||(r[o]=l.result),s()},l.readAsText(t[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return Ma(i,e,r,!0),!0}return!1};je.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=Su?null:e.clipboardData;return t?(Du(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(ld(i),!1)};function fd(i,e){let t=i.dom.parentNode;if(!t)return;let r=t.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),i.focus()},50)}function dd(i){let e=[],t=[],r=!1;for(let n of i.selection.ranges)n.empty||(e.push(i.sliceDoc(n.from,n.to)),t.push(n));if(!e.length){let n=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>n&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),n=o.number}r=!0}return{text:Rn(i,go,e.join(i.lineBreak)),ranges:t,linewise:r}}var Qs=null;je.copy=je.cut=(i,e)=>{let{text:t,ranges:r,linewise:n}=dd(i.state);if(!t&&!n)return!1;Qs=n?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=Su?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(fd(i,t),!1)};var xu=mt.define();function Tu(i,e){let t=[];for(let r of i.facet(hu)){let n=r(i,e);n&&t.push(n)}return t?i.update({effects:t,annotations:xu.of(!0)}):null}function ku(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=Tu(i.state,e);t?i.dispatch(t):i.update([])}},10)}Ve.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),ku(i)};Ve.blur=i=>{i.observer.clearSelectionRange(),ku(i)};Ve.compositionstart=Ve.compositionupdate=i=>{i.observer.editContext||(i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0))};Ve.compositionend=i=>{i.observer.editContext||(i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,R.chrome&&R.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50))};Ve.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};je.beforeinput=(i,e)=>{var t,r;if(e.inputType=="insertReplacementText"&&i.observer.editContext){let s=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=i.posAtDOM(l.startContainer,l.startOffset),u=i.posAtDOM(l.endContainer,l.endOffset);return bo(i,{from:a,to:u,insert:i.state.toText(s)},null),!0}}let n;if(R.chrome&&R.android&&(n=Cu.find(s=>s.inputType==e.inputType))&&(i.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return R.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),R.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>Ve.compositionend(i,e),20),!1};var Ra=new Set;function pd(i){Ra.has(i)||(Ra.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}var Na=["pre-wrap","normal","pre-line","break-spaces"],vi=!1;function Oa(){vi=!1}var Zs=class{constructor(e){this.lineWrapping=e,this.doc=Y.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let r=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((t-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Na.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let r=0;r-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=r,this.textHeight=n,this.lineLength=s,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>mn&&(vi=!0),this.height=e)}replace(e,t,r){return i.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,r,n){let s=this,o=r.doc;for(let l=n.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:h,toB:c}=n[l],f=s.lineAt(a,re.ByPosNoHeight,r.setDoc(t),0,0),d=f.to>=u?f:s.lineAt(u,re.ByPosNoHeight,r,0,0);for(c+=d.to-u,u=d.to;l>0&&f.from<=n[l-1].toA;)a=n[l-1].fromA,h=n[l-1].fromB,l--,as*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),r+=1+l.break,n-=l.size}else if(s>n*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(n=s&&o(this.blockAt(0,r,n,s))}updateHeight(e,t=0,r=!1,n){return n&&n.from<=t&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},$e=class i extends En{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,r,n){return new tt(n,this.length,r,this.height,this.breaks)}replace(e,t,r){let n=r[0];return r.length==1&&(n instanceof i||n instanceof xt&&n.flags&4)&&Math.abs(this.length-n.length)<10?(n instanceof xt?n=new i(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):Ie.of(r)}updateHeight(e,t=0,r=!1,n){return n&&n.from<=t&&n.more?this.setHeight(n.heights[n.index++]):(r||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},xt=class i extends Ie{constructor(e){super(e,0)}heightMetrics(e,t){let r=e.doc.lineAt(t).number,n=e.doc.lineAt(t+this.length).number,s=n-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:n,perLine:o,perChar:l}}blockAt(e,t,r,n){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,n);if(t.lineWrapping){let u=n+(e0){let s=r[r.length-1];s instanceof i?r[r.length-1]=new i(s.length+n):r.push(null,new i(n-1))}if(e>0){let s=r[0];s instanceof i?r[0]=new i(e+s.length):r.unshift(new i(e-1),null)}return Ie.of(r)}decomposeLeft(e,t){t.push(new i(e-1),null)}decomposeRight(e,t){t.push(null,new i(this.length-e-1))}updateHeight(e,t=0,r=!1,n){let s=t+this.length;if(n&&n.from<=t+this.length&&n.more){let o=[],l=Math.max(t,n.from),a=-1;for(n.from>t&&o.push(new i(n.from-t-1).updateHeight(e,t));l<=s&&n.more;){let h=e.doc.lineAt(l).length;o.length&&o.push(null);let c=n.heights[n.index++];a==-1?a=c:Math.abs(c-a)>=mn&&(a=-2);let f=new $e(h,c);f.outdated=!1,o.push(f),l+=h+1}l<=s&&o.push(null,new i(s-l).updateHeight(e,l));let u=Ie.of(o);return(a<0||Math.abs(u.height-this.height)>=mn||Math.abs(a-this.heightMetrics(e,t).perLine)>=mn)&&(vi=!0),Dn(this,u)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},to=class extends Ie{constructor(e,t,r){super(e.length+t+r.length,e.height+r.height,t|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,t,r,n){let s=r+this.left.height;return el))return u;let h=t==re.ByPosNoHeight?re.ByPosNoHeight:re.ByPos;return a?u.join(this.right.lineAt(l,h,r,o,l)):this.left.lineAt(l,h,r,n,s).join(u)}forEachLine(e,t,r,n,s,o){let l=n+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,r,l,a,o);else{let u=this.lineAt(a,re.ByPos,r,n,s);e=e&&u.from<=t&&o(u),t>u.to&&this.right.forEachLine(u.to+1,t,r,l,a,o)}}replace(e,t,r){let n=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of r)s.push(l);if(e>0&&Ba(s,o-1),t=r&&t.push(null)),e>r&&this.right.decomposeLeft(e-r,t)}decomposeRight(e,t){let r=this.left.length,n=r+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e2*t.size||t.size>2*e.size?Ie.of(this.break?[e,null,t]:[e,t]):(this.left=Dn(this.left,e),this.right=Dn(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,r=!1,n){let{left:s,right:o}=this,l=t+s.length+this.break,a=null;return n&&n.from<=t+s.length&&n.more?a=s=s.updateHeight(e,t,r,n):s.updateHeight(e,t,r),n&&n.from<=l+o.length&&n.more?a=o=o.updateHeight(e,l,r,n):o.updateHeight(e,l,r),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function Ba(i,e){let t,r;i[e]==null&&(t=i[e-1])instanceof xt&&(r=i[e+1])instanceof xt&&i.splice(e-1,3,new xt(t.length+1+r.length))}var gd=5,io=class i{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let r=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof $e?n.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new $e(r-this.pos,-1)),this.writtenTo=r,t>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,r){if(e=gd)&&this.addLineDeco(n,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new $e(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let r=new xt(t-e);return this.oracle.doc.lineAt(e).to==t&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof $e)return e;let t=new $e(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,r){let n=this.ensureLine();n.length+=r,n.collapsed+=r,n.widgetHeight=Math.max(n.widgetHeight,e),n.breaks+=t,this.writtenTo=this.pos=this.pos+r}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof $e)&&!this.isCovered?this.nodes.push(new $e(0,-1)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&c.overflow!="visible"){let f=h.getBoundingClientRect();s=Math.max(s,f.left),o=Math.min(o,f.right),l=Math.max(l,f.top),a=Math.min(u==i.parentNode?n.innerHeight:a,f.bottom)}u=c.position=="absolute"||c.position=="fixed"?h.offsetParent:h.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function bd(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var nr=class{constructor(e,t,r){this.from=e,this.to=t,this.size=r}static same(e,t){if(e.length!=t.length)return!1;for(let r=0;rtypeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Zs(t),this.stateDeco=e.facet(cr).filter(r=>typeof r!="function"),this.heightMap=Ie.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle.setDoc(e.doc),[new nt(0,0,0,e.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=le.set(this.lineGaps.map(r=>r.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let r=0;r<=1;r++){let n=r?t.head:t.anchor;if(!e.some(({from:s,to:o})=>n>=s&&n<=o)){let{from:s,to:o}=this.lineBlockAt(n);e.push(new mi(s,o))}}return this.viewports=e.sort((r,n)=>r.from-n.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Pa:new so(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Zi(e,this.scaler))})}update(e,t=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=this.state.facet(cr).filter(h=>typeof h!="function");let n=e.changedRanges,s=nt.extendWithRanges(n,md(r,this.stateDeco,e?e.changes:_e.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);Oa(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||vi)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Rf)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,r=window.getComputedStyle(t),n=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?me.RTL:me.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,h=0;if(l.width&&l.height){let{scaleX:E,scaleY:S}=$a(t,l);(E>.005&&Math.abs(this.scaleX-E)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=E,this.scaleY=S,u|=8,o=a=!0)}let c=(parseInt(r.paddingTop)||0)*this.scaleY,f=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=f)&&(this.paddingTop=c,this.paddingBottom=f,u|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=8);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Ua(e.scrollDOM);let p=(this.printing?bd:yd)(t,this.paddingTop),g=p.top-this.pixelViewport.top,y=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let A=l.width;if((this.contentDOMWidth!=A||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=8),a){let E=e.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(E)&&(o=!0),o||n.lineWrapping&&Math.abs(A-this.contentDOMWidth)>n.charWidth){let{lineHeight:S,charWidth:N,textHeight:M}=e.docView.measureTextSize();o=S>0&&n.refresh(s,S,N,M,A/N,E),o&&(e.docView.minWidth=0,u|=8)}g>0&&y>0?h=Math.max(g,y):g<0&&y<0&&(h=Math.min(g,y)),Oa();for(let S of this.viewports){let N=S.from==this.viewport.from?E:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?Ie.empty().applyChanges(this.stateDeco,Y.empty,this.heightOracle,[new nt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new eo(S.from,N))}vi&&(u|=2)}let w=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return w&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),u|=this.updateForViewport()),(u&2||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new mi(n.lineAt(o-r*1e3,re.ByHeight,s,0,0).from,n.lineAt(l+(1-r)*1e3,re.ByHeight,s,0,0).to);if(t){let{head:u}=t.range;if(ua.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=n.lineAt(u,re.ByPos,s,0,0),f;t.y=="center"?f=(c.top+c.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&n>o-2*1e3&&s>1,o=n<<1;if(this.defaultTextDirection!=me.LTR&&!r)return[];let l=[],a=(h,c,f,d)=>{if(c-hh&&bb.from>=f.from&&b.to<=f.to&&Math.abs(b.from-h)b.fromA));if(!y){if(cb.from<=c&&b.to>=c)){let b=t.moveToLineBoundary(P.cursor(c),!1,!0).head;b>h&&(c=b)}y=new nr(h,c,this.gapSize(f,h,c,d))}l.push(y)},u=h=>{if(h.lengthh.from&&a(h.from,d,h,c),pt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];he.spans(e,this.viewport.from,this.viewport.to,{span(n,s){t.push({from:n,to:s})},point(){}},20);let r=t.length!=this.visibleRanges.length||this.visibleRanges.some((n,s)=>n.from!=t[s].from||n.to!=t[s].to);return this.visibleRanges=t,r?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Zi(this.heightMap.lineAt(e,re.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||Zi(this.heightMap.lineAt(this.scaler.fromDOM(e),re.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Zi(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},mi=class{constructor(e,t){this.from=e,this.to=t}};function vd(i,e,t){let r=[],n=i,s=0;return he.spans(t,i,e,{span(){},point(o,l){o>n&&(r.push({from:n,to:o}),s+=o-n),n=l}},20),n=1)return e[e.length-1].to;let r=Math.floor(i*t);for(let n=0;;n++){let{from:s,to:o}=e[n],l=o-s;if(r<=l)return s+r;r-=l}}function fn(i,e){let t=0;for(let{from:r,to:n}of i.ranges){if(e<=n){t+=e-r;break}t+=n-r}return t/i.total}function wd(i,e){for(let t of i)if(e(t))return t}var Pa={toDOM(i){return i},fromDOM(i){return i},scale:1,eq(i){return i==this}},so=class i{constructor(e,t,r){let n=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=t.lineAt(l,re.ByPos,e,0,0).top,h=t.lineAt(a,re.ByPos,e,0,0).bottom;return n+=h-u,{from:l,to:a,top:u,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(t.height-n);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let t=0,r=0,n=0;;t++){let s=tt.from==e.viewports[r].from&&t.to==e.viewports[r].to):!1}};function Zi(i,e){if(e.scale==1)return i;let t=e.toDOM(i.top),r=e.toDOM(i.bottom);return new tt(i.from,i.length,t,r-t,Array.isArray(i._content)?i._content.map(n=>Zi(n,e)):i._content)}var dn=$.define({combine:i=>i.join(" ")}),oo=$.define({combine:i=>i.indexOf(!0)>-1}),lo=He.newName(),Mu=He.newName(),Ru=He.newName(),Nu={"&light":"."+Mu,"&dark":"."+Ru};function ao(i,e,t){return new He(e,{finish(r){return/&/.test(r)?r.replace(/&\\w*/,n=>{if(n=="&")return i;if(!t||!t[n])throw new RangeError(`Unsupported selector: ${n}`);return t[n]}):i+" "+r}})}var Ad=ao("."+lo,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url(\'data:image/svg+xml,\')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Nu),Cd={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Ps=R.ie&&R.ie_version<=11,uo=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new _s,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let r of t)this.queue.push(r);(R.ie&&R.ie_version<=11||R.ios&&e.composing)&&t.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&e.constructor.EDIT_CONTEXT!==!1&&!(R.chrome&&R.chrome_version<126)&&(this.editContext=new ho(e),e.state.facet(Et)&&(e.contentDOM.editContext=this.editContext.editContext)),Ps&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,r)=>t!=e[r]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,n=this.selectionRange;if(r.state.facet(Et)?r.root.activeElement!=this.dom:!pn(r.dom,n))return;let s=n.anchorNode&&r.docView.nearest(n.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(R.ie&&R.ie_version<=11||R.android&&R.chrome)&&!r.state.selection.main.empty&&n.focusNode&&er(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=sr(e.root);if(!t)return!1;let r=R.safari&&e.root.nodeType==11&&hf(this.dom.ownerDocument)==this.dom&&Sd(this.view,t)||t;if(!r||this.selectionRange.eq(r))return!1;let n=pn(this.dom,r);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&yi(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(n)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,r=-1,n=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(n=!0),t==-1?{from:t,to:r}=o:(t=Math.min(o.from,t),r=Math.max(o.to,r)))}return{from:t,to:r,typeOver:n}}readChange(){let{from:e,to:t,typeOver:r}=this.processRecords(),n=this.selectionChanged&&pn(this.dom,this.selectionRange);if(e<0&&!n)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Ys(this.view,e,t,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let r=this.view.state,n=Au(this.view,t);return this.view.state==r&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let r=La(t,e.previousSibling||e.target.previousSibling,-1),n=La(t,e.nextSibling||e.target.nextSibling,1);return{from:r?t.posAfter(r):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Et)!=e.state.facet(Et)&&(e.view.contentDOM.editContext=e.state.facet(Et)?this.editContext.editContext:null))}destroy(){var e,t,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function La(i,e,t){for(;e;){let r=ee.get(e);if(r&&r.parent==i)return r;let n=e.parentNode;e=n!=i.dom?n:t>0?e.nextSibling:e.previousSibling}return null}function _a(i,e){let t=e.startContainer,r=e.startOffset,n=e.endContainer,s=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor);return er(o.node,o.offset,n,s)&&([t,r,n,s]=[n,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:n,focusOffset:s}}function Sd(i,e){if(e.getComposedRanges){let n=e.getComposedRanges(i.root)[0];if(n)return _a(i,n)}let t=null;function r(n){n.preventDefault(),n.stopImmediatePropagation(),t=n.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",r,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",r,!0),t?_a(i,t):null}var ho=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let{anchor:n}=e.state.selection.main,s={from:this.toEditorPos(r.updateRangeStart),to:this.toEditorPos(r.updateRangeEnd),insert:Y.of(r.text.split(`\n`))};s.from==this.from&&nthis.to&&(s.to=n),!(s.from==s.to&&!s.insert.length)&&(this.pendingContextChange=s,e.state.readOnly||bo(e,s,P.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd))),this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)))},this.handlers.characterboundsupdate=r=>{let n=[],s=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let n=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(o!="None"&&l!="None"){let a=`text-decoration: underline ${o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${l=="Thin"?1:2}px`;n.push(le.mark({attributes:{style:a}}).range(this.toEditorPos(s.rangeStart),this.toEditorPos(s.rangeEnd)))}}e.dispatch({effects:du.of(le.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{e.inputState.composing=-1,e.inputState.compositionFirstChange=null};for(let r in this.handlers)t.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{this.editContext.updateControlBounds(r.contentDOM.getBoundingClientRect());let n=sr(r.root);n&&n.rangeCount&&this.editContext.updateSelectionBounds(n.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,r=!1,n=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(r)return;let h=u.length-(o-s);if(n&&o>=n.to)if(n.from==s&&n.to==o&&n.insert.eq(u)){n=this.pendingContextChange=null,t+=h,this.to+=h;return}else n=null,this.revertPending(e.state);if(s+=t,o+=t,o<=this.from)this.from+=h,this.to+=h;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=h}t+=h}),n&&!r&&this.revertPending(e.state),!r}update(e){let t=this.pendingContextChange;!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.resetRange(e.state),this.editContext.updateText(0,this.editContext.text.length,e.state.doc.sliceString(this.from,this.to)),this.setSelection(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),n=this.toContextPos(t.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=n)&&this.editContext.updateSelection(r,n)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e){return e+this.from}toContextPos(e){return e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},q=class i{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(n=>n.forEach(s=>r(s,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||pf(e.parent)||document,this.viewState=new xn(e.state||oe.create(e)),e.scrollTo&&e.scrollTo.is(an)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Xi).map(n=>new rr(n));for(let n of this.plugins)n.update(this);this.observer=new uo(this),this.inputState=new Xs(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Cn(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof Re?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,r=!1,n,s=this.state;for(let f of e){if(f.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn\'t start from the previous state.");s=f.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(f=>f.annotation(xu))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Tu(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,h=null;if(u?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(oe.phrases)!=this.state.facet(oe.phrases))return this.setState(s);n=An.create(this,s,e),n.flags|=l;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let f of e){if(c&&(c=c.map(f.changes)),f.scrollIntoView){let{main:d}=f.state.selection;c=new ir(d.empty?d:P.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of f.effects)d.is(an)&&(c=d.value.clip(this.state))}this.viewState.update(n,c),this.bidiCache=Tn.update(this.bidiCache,n.changes),n.empty||(this.updatePlugins(n),this.inputState.update(n)),t=this.docView.update(n),this.state.facet(Ji)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(n.startState.facet(dn)!=n.state.facet(dn)&&(this.viewState.mustMeasureContent=!0),(t||r||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!n.empty)for(let f of this.state.facet(js))try{f(n)}catch(d){ze(this.state,d,"update listener")}(a||h)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),h&&!Au(this,h)&&u.force&&yi(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new xn(e),this.plugins=e.facet(Xi).map(r=>new rr(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Cn(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Xi),r=e.state.facet(Xi);if(t!=r){let n=[];for(let s of r){let o=t.indexOf(s);if(o<0)n.push(new rr(s));else{let l=this.plugins[o];l.mustUpdate=e,n.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let n of this.plugins)n.mustUpdate=e;for(let n=0;n-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,r=this.scrollDOM,n=r.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(Ua(r))s=-1,o=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(n);s=d.from,o=d.top}this.updateState=1;let a=this.viewState.measure(this);if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let h=u.map(d=>{try{return d.read(this)}catch(p){return ze(this.state,p),Ia}}),c=An.create(this,this.state,[]),f=!1;c.flags|=a,t?t.flags|=a:t=c,this.updateState=2,c.empty||(this.updatePlugins(c),this.inputState.update(c),this.updateAttrs(),f=this.docView.update(c),f&&this.docViewUpdate());for(let d=0;d1||p<-1){n=n+p,r.scrollTop=n/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(js))l(t)}get themeClasses(){return lo+" "+(this.state.facet(oo)?Ru:Mu)+" "+this.state.facet(dn)}updateAttrs(){let e=Fa(this,pu,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Et)?"true":"false",class:"cm-content",style:`${R.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Fa(this,mo,t);let r=this.observer.ignore(()=>{let n=Vs(this.contentDOM,this.contentAttrs,t),s=Vs(this.dom,this.editorAttrs,e);return n||s});return this.editorAttrs=e,this.contentAttrs=t,r}showAnnouncements(e){let t=!0;for(let r of e)for(let n of r.effects)if(n.is(i.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=n.value}}mountStyles(){this.styleModules=this.state.facet(Ji);let e=this.state.facet(i.cspNonce);He.mount(this.root,this.styleModules.concat(Ad).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn\'t allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;tr.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,r){return Bs(this,e,Aa(this,e,t,r))}moveByGroup(e,t){return Bs(this,e,Aa(this,e,t,r=>jf(this,e.head,r)))}visualLineSide(e,t){let r=this.bidiSpans(e),n=this.textDirectionAt(e.from),s=r[t?r.length-1:0];return P.cursor(s.side(t,n)+e.from,s.forward(!t,n)?1:-1)}moveToLineBoundary(e,t,r=!0){return zf(this,e,t,r)}moveVertically(e,t,r){return Bs(this,e,Gf(this,e,t,r))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),wu(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let r=this.docView.coordsAt(e,t);if(!r||r.left==r.right)return r;let n=this.state.doc.lineAt(e),s=this.bidiSpans(n),o=s[it.find(s,e-n.from,-1,t)];return kn(r,o.dir==me.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(cu)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Dd)return ru(e.length);let t=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||iu(s.isolates,r=ma(this,e))))return s.order;r||(r=ma(this,e));let n=Tf(e.text,t,r);return this.bidiCache.push(new Tn(e.from,e.to,t,r,!0,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||R.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Va(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return an.of(new ir(typeof e=="number"?P.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return an.of(new ir(P.cursor(r.from),"start","start",r.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Jt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Jt.define(()=>({}),{eventObservers:e})}static theme(e,t){let r=He.newName(),n=[dn.of(r),Ji.of(ao(`.${r}`,e))];return t&&t.dark&&n.push(oo.of(!0)),n}static baseTheme(e){return nn.lowest(Ji.of(ao("."+lo,e,Nu)))}static findFromDOM(e){var t;let r=e.querySelector(".cm-content"),n=r&&ee.get(r)||ee.get(e);return((t=n==null?void 0:n.rootView)===null||t===void 0?void 0:t.view)||null}};q.styleModule=Ji;q.inputHandler=uu;q.clipboardInputFilter=po;q.clipboardOutputFilter=go;q.scrollHandler=fu;q.focusChangeEffect=hu;q.perLineTextDirection=cu;q.exceptionSink=au;q.updateListener=js;q.editable=Et;q.mouseSelectionStyle=lu;q.dragMovesSelection=ou;q.clickAddsSelectionRange=su;q.decorations=cr;q.outerDecorations=gu;q.atomicRanges=yo;q.bidiIsolatedRanges=mu;q.scrollMargins=yu;q.darkTheme=oo;q.cspNonce=$.define({combine:i=>i.length?i[0]:""});q.contentAttributes=mo;q.editorAttributes=pu;q.lineWrapping=q.contentAttributes.of({class:"cm-lineWrapping"});q.announce=se.define();var Dd=4096,Ia={},Tn=class i{constructor(e,t,r,n,s,o){this.from=e,this.to=t,this.dir=r,this.isolates=n,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let r=[],n=e.length?e[e.length-1].dir:me.LTR;for(let s=Math.max(0,e.length-10);s=0;n--){let s=r[n],o=typeof s=="function"?s(i):s;o&&$s(o,t)}return t}var Ob=R.mac?"mac":R.windows?"win":R.linux?"linux":"key";var Ed=!R.ios;var Ha={".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"}},".cm-content":{"& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}};Ed&&(Ha[".cm-line"].caretColor=Ha[".cm-content"].caretColor="transparent !important");var Bb=/x/.unicode!=null?"gu":"g";var Pb=q.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"\'\'",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}});var vt=class extends yt{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};vt.prototype.elementClass="";vt.prototype.toDOM=void 0;vt.prototype.mapMode=Me.TrackBefore;vt.prototype.startSide=vt.prototype.endSide=-1;vt.prototype.point=!0;var xd=Function.prototype.toString,vo=Object.create,Td=Object.prototype.toString,kd=function(){function i(){this._keys=[],this._values=[]}return i.prototype.has=function(e){return!!~this._keys.indexOf(e)},i.prototype.get=function(e){return this._values[this._keys.indexOf(e)]},i.prototype.set=function(e,t){this._keys.push(e),this._values.push(t)},i}();function Md(){return new kd}function Rd(){return new WeakMap}var Nd=typeof WeakMap!="undefined"?Rd:Md;function Ao(i){if(!i)return vo(null);var e=i.constructor;if(e===Object)return i===Object.prototype?{}:vo(i);if(e&&~xd.call(e).indexOf("[native code]"))try{return new e}catch(t){}return vo(i)}function Od(i){var e="";return i.global&&(e+="g"),i.ignoreCase&&(e+="i"),i.multiline&&(e+="m"),i.unicode&&(e+="u"),i.sticky&&(e+="y"),e}function Bd(i){return i.flags}var Pd=/test/g.flags==="g"?Bd:Od;function Ou(i){var e=Td.call(i);return e.substring(8,e.length-1)}function Ld(i){return i[Symbol.toStringTag]||Ou(i)}var _d=typeof Symbol!="undefined"?Ld:Ou,Id=Object.defineProperty,Fd=Object.getOwnPropertyDescriptor,Bu=Object.getOwnPropertyNames,Co=Object.getOwnPropertySymbols,Pu=Object.prototype,Lu=Pu.hasOwnProperty,Hd=Pu.propertyIsEnumerable,_u=typeof Co=="function";function $d(i){return Bu(i).concat(Co(i))}var Vd=_u?$d:Bu;function On(i,e,t){for(var r=Vd(i),n=0,s=r.length,o=void 0,l=void 0;n{throw new Error("This node type doesn\'t define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can\'t add per-node props to node types");return typeof e!="function"&&(e=Fe.match(e)),t=>{let r=e(t);return r===void 0?null:[this,r]}}};J.closedBy=new J({deserialize:i=>i.split(" ")});J.openedBy=new J({deserialize:i=>i.split(" ")});J.group=new J({deserialize:i=>i.split(" ")});J.isolate=new J({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});J.contextHash=new J({perNode:!0});J.lookAhead=new J({perNode:!0});J.mounted=new J({perNode:!0});var wi=class{constructor(e,t,r){this.tree=e,this.overlay=t,this.parser=r}static get(e){return e&&e.props&&e.props[J.mounted.id]}},lp=Object.create(null),Fe=class i{constructor(e,t,r,n=0){this.name=e,this.props=t,this.id=r,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):lp,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),n=new i(e.name||"",t,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(n)),s){if(s[0].perNode)throw new RangeError("Can\'t store a per-node prop on a node type");t[s[0].id]=s[1]}}return n}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(J.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return r=>{for(let n=r.prop(J.group),s=-1;s<(n?n.length:0);s++){let o=t[s<0?r.name:n[s]];if(o)return o}}}};Fe.none=new Fe("",Object.create(null),0,8);var Bn=new WeakMap,qu=new WeakMap,ye;(function(i){i[i.ExcludeBuffers=1]="ExcludeBuffers",i[i.IncludeAnonymous=2]="IncludeAnonymous",i[i.IgnoreMounts=4]="IgnoreMounts",i[i.IgnoreOverlays=8]="IgnoreOverlays"})(ye||(ye={}));var Ee=class i{constructor(e,t,r,n,s){if(this.type=e,this.children=t,this.positions=r,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,l]of s)this.props[typeof o=="number"?o:o.id]=l}}toString(){let e=wi.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let n=r.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new gr(this.topNode,e)}cursorAt(e,t=0,r=0){let n=Bn.get(this)||this.topNode,s=new gr(n);return s.moveTo(e,t),Bn.set(this,s._tree),s}get topNode(){return new ot(this,0,0,null)}resolve(e,t=0){let r=dr(Bn.get(this)||this.topNode,e,t,!1);return Bn.set(this,r),r}resolveInner(e,t=0){let r=dr(qu.get(this)||this.topNode,e,t,!0);return qu.set(this,r),r}resolveStack(e,t=0){return ap(this,e,t)}iterate(e){let{enter:t,leave:r,from:n=0,to:s=this.length}=e,o=e.mode||0,l=(o&ye.IncludeAnonymous)>0;for(let a=this.cursor(o|ye.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=n&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Ro(Fe.none,this.children,this.positions,0,this.children.length,0,this.length,(t,r,n)=>new i(this.type,t,r,n,this.propValues),e.makeTree||((t,r,n)=>new i(Fe.none,t,r,n)))}static build(e){return up(e)}};Ee.empty=new Ee(Fe.none,[],[],0);var Do=class i{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new i(this.buffer,this.index)}},Rt=class i{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return Fe.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,r){let n=this.buffer,s=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&r>e;case 2:return r>e;case 4:return!0}}function dr(i,e,t,r){for(var n;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?l.length:-1;e!=u;e+=t){let h=l[e],c=a[e]+o.from;if(zu(n,r,c,c+h.length)){if(h instanceof Rt){if(s&ye.ExcludeBuffers)continue;let f=h.findChild(0,h.buffer.length,t,r-c,n);if(f>-1)return new pr(new xo(o,h,e,c),null,f)}else if(s&ye.IncludeAnonymous||!h.type.isAnonymous||Mo(h)){let f;if(!(s&ye.IgnoreMounts)&&(f=wi.get(h))&&!f.overlay)return new i(f.tree,c,e,o);let d=new i(h,c,e,o);return s&ye.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?h.children.length-1:0,t,r,n)}}}if(s&ye.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let n;if(!(r&ye.IgnoreOverlays)&&(n=wi.get(this._tree))&&n.overlay){let s=e-this.from;for(let{from:o,to:l}of n.overlay)if((t>0?o<=s:o=s:l>s))return new i(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function Uu(i,e,t,r){let n=i.cursor(),s=[];if(!n.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=n.type.is(t),!n.nextSibling())return s}for(;;){if(r!=null&&n.type.is(r))return s;if(n.type.is(e)&&s.push(n.node),!n.nextSibling())return r==null?s:[]}}function Eo(i,e,t=e.length-1){for(let r=i.parent;t>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[t]&&e[t]!=r.name)return!1;t--}}return!0}var xo=class{constructor(e,t,r,n){this.parent=e,this.buffer=t,this.index=r,this.start=n}},pr=class i extends Ln{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,r){super(),this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,t,r){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,r);return s<0?null:new i(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&ye.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new i(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new i(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new i(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,n=this.index+4,s=r.buffer[this.index+3];if(s>n){let o=r.buffer[this.index+1];e.push(r.slice(n,s,o)),t.push(0)}return new Ee(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function ju(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;st.from||o.to=e){let l=new ot(o.tree,o.overlay[0].from+s.from,-1,s);(n||(n=[r])).push(dr(l,e,t,!1))}}return n?ju(n):r}var gr=class{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ot)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:r,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=r+n.buffer[e+1],this.to=r+n.buffer[e+2],!0}yield(e){return e?e instanceof ot?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?r&ye.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ye.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ye.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let n=r<0?0:this.stack[r]+4;if(this.index!=n)return this.yieldBuf(t.findChild(n,this.index,-1,0,4))}else{let n=t.buffer[this.index+3];if(n<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(n)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:n}=this;if(n){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let l=r._tree.children[s];if(this.mode&ye.IncludeAnonymous||l instanceof Rt||!l.type.isAnonymous||Mo(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==n){if(n==this.index)return o;t=o,r=s+1;break e}n=this.stack[--s]}for(let n=r;n=0;s--){if(s<0)return Eo(this.node,e,n);let o=r[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[n]&&e[n]!=o.name)return!1;n--}}return!0}};function Mo(i){return i.children.some(e=>e instanceof Rt||!e.type.isAnonymous||Mo(e))}function up(i){var e;let{buffer:t,nodeSet:r,maxBufferLength:n=1024,reused:s=[],minRepeatType:o=r.types.length}=i,l=Array.isArray(t)?new Do(t,t.length):t,a=r.types,u=0,h=0;function c(S,N,M,j,D,H){let{id:B,start:O,end:W,size:I}=l,te=h;for(;I<0;)if(l.next(),I==-1){let K=s[B];M.push(K),j.push(O-S);return}else if(I==-3){u=B;return}else if(I==-4){h=B;return}else throw new RangeError(`Unrecognized record size: ${I}`);let Ce=a[B],F,Se,k=O-S;if(W-O<=n&&(Se=y(l.pos-N,D))){let K=new Uint16Array(Se.size-Se.skip),ue=l.pos-Se.size,pe=K.length;for(;l.pos>ue;)pe=b(Se.start,K,pe);F=new Rt(K,W-Se.start,r),k=Se.start-S}else{let K=l.pos-I;l.next();let ue=[],pe=[],Je=B>=o?B:-1,pt=0,Ht=W;for(;l.pos>K;)Je>=0&&l.id==Je&&l.size>=0?(l.end<=Ht-n&&(p(ue,pe,O,pt,l.end,Ht,Je,te),pt=ue.length,Ht=l.end),l.next()):H>2500?f(O,K,ue,pe):c(O,K,ue,pe,Je,H+1);if(Je>=0&&pt>0&&pt-1&&pt>0){let Wi=d(Ce);F=Ro(Ce,ue,pe,0,ue.length,0,W-O,Wi,Wi)}else F=g(Ce,ue,pe,W-O,te-W)}M.push(F),j.push(k)}function f(S,N,M,j){let D=[],H=0,B=-1;for(;l.pos>N;){let{id:O,start:W,end:I,size:te}=l;if(te>4)l.next();else{if(B>-1&&W=0;I-=3)O[te++]=D[I],O[te++]=D[I+1]-W,O[te++]=D[I+2]-W,O[te++]=te;M.push(new Rt(O,D[2]-W,r)),j.push(W-S)}}function d(S){return(N,M,j)=>{let D=0,H=N.length-1,B,O;if(H>=0&&(B=N[H])instanceof Ee){if(!H&&B.type==S&&B.length==j)return B;(O=B.prop(J.lookAhead))&&(D=M[H]+B.length+O)}return g(S,N,M,j,D)}}function p(S,N,M,j,D,H,B,O){let W=[],I=[];for(;S.length>j;)W.push(S.pop()),I.push(N.pop()+M-D);S.push(g(r.types[B],W,I,H-D,O-H)),N.push(D-M)}function g(S,N,M,j,D=0,H){if(u){let B=[J.contextHash,u];H=H?[B].concat(H):[B]}if(D>25){let B=[J.lookAhead,D];H=H?[B].concat(H):[B]}return new Ee(S,N,M,j,H)}function y(S,N){let M=l.fork(),j=0,D=0,H=0,B=M.end-n,O={size:0,start:0,skip:0};e:for(let W=M.pos-S;M.pos>W;){let I=M.size;if(M.id==N&&I>=0){O.size=j,O.start=D,O.skip=H,H+=4,j+=4,M.next();continue}let te=M.pos-I;if(I<0||te=o?4:0,F=M.start;for(M.next();M.pos>te;){if(M.size<0)if(M.size==-3)Ce+=4;else break e;else M.id>=o&&(Ce+=4);M.next()}D=F,j+=I,H+=Ce}return(N<0||j==S)&&(O.size=j,O.start=D,O.skip=H),O.size>4?O:void 0}function b(S,N,M){let{id:j,start:D,end:H,size:B}=l;if(l.next(),B>=0&&j4){let W=l.pos-(B-4);for(;l.pos>W;)M=b(S,N,M)}N[--M]=O,N[--M]=H-S,N[--M]=D-S,N[--M]=j}else B==-3?u=j:B==-4&&(h=j);return M}let A=[],w=[];for(;l.pos>0;)c(i.start||0,i.bufferStart||0,A,w,-1,0);let E=(e=i.length)!==null&&e!==void 0?e:A.length?w[0]+A[0].length:0;return new Ee(a[i.topID],A.reverse(),w.reverse(),E)}var Wu=new WeakMap;function Pn(i,e){if(!i.isAnonymous||e instanceof Rt||e.type!=i)return 1;let t=Wu.get(e);if(t==null){t=1;for(let r of e.children){if(r.type!=i||!(r instanceof Ee)){t=1;break}t+=Pn(i,r)}Wu.set(e,t)}return t}function Ro(i,e,t,r,n,s,o,l,a){let u=0;for(let p=r;p=h)break;N+=M}if(w==E+1){if(N>h){let M=p[E];d(M.children,M.positions,0,M.children.length,g[E]+A);continue}c.push(p[E])}else{let M=g[w-1]+p[w-1].length-S;c.push(Ro(i,p,g,E,w,S,M,null,a))}f.push(S+A-s)}}return d(e,t,r,n,0),(l||a)(c,f,o)}var Qt=class i{constructor(e,t,r,n,s=!1,o=!1){this.from=e,this.to=t,this.tree=r,this.offset=n,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],r=!1){let n=[new i(0,e.length,e,0,!1,r)];for(let s of t)s.to>e.length&&n.push(s);return n}static applyChanges(e,t,r=128){if(!t.length)return e;let n=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let h=l=r)for(;o&&o.from=f.from||c<=f.to||u){let d=Math.max(f.from,a)-u,p=Math.min(f.to,c)-u;f=d>=p?null:new i(d,p,f.tree,f.offset+u,l>0,!!h)}if(f&&n.push(f),o.to>c)break;o=snew fr(n.from,n.to)):[new fr(0,0)]:[new fr(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let s=n.advance();if(s)return s}}},ko=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var Fb=new J({perNode:!0});var hp=0,Ge=class i{constructor(e,t,r,n){this.name=e,this.set=t,this.base=r,this.modified=n,this.id=hp++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let r=typeof e=="string"?e:"?";if(e instanceof i&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let n=new i(r,[],null,[]);if(n.set.push(n),t)for(let s of t.set)n.set.push(s);return n}static defineModifier(e){let t=new $n(e);return r=>r.modified.indexOf(t)>-1?r:$n.get(r.base||r,r.modified.concat(t).sort((n,s)=>n.id-s.id))}},cp=0,$n=class i{constructor(e){this.name=e,this.instances=[],this.id=cp++}static get(e,t){if(!t.length)return e;let r=t[0].instances.find(l=>l.base==e&&fp(t,l.modified));if(r)return r;let n=[],s=new Ge(e.name,n,e,t);for(let l of t)l.instances.push(s);let o=dp(t);for(let l of e.set)if(!l.modified.length)for(let a of o)n.push(i.get(l,a));return s}};function fp(i,e){return i.length==e.length&&i.every((t,r)=>t==e[r])}function dp(i){let e=[[]];for(let t=0;tr.length-t.length)}function Yu(i){let e=Object.create(null);for(let t in i){let r=i[t];Array.isArray(r)||(r=[r]);for(let n of t.split(" "))if(n){let s=[],o=2,l=n;for(let c=0;;){if(l=="..."&&c>0&&c+3==n.length){o=1;break}let f=/^"(?:[^"\\\\]|\\\\.)*?"|[^\\/!]+/.exec(l);if(!f)throw new RangeError("Invalid path: "+n);if(s.push(f[0]=="*"?"":f[0][0]==\'"\'?JSON.parse(f[0]):f[0]),c+=f[0].length,c==n.length)break;let d=n[c++];if(c==n.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+n);l=n.slice(c)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+n);let h=new Ai(r,o,a>0?s.slice(0,a):null);e[u]=h.sort(e[u])}}return Xu.add(e)}var Xu=new J,Ai=class{constructor(e,t,r,n){this.tags=e,this.mode=t,this.context=r,this.next=n}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=n;for(let l of s)for(let a of l.set){let u=t[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function pp(i,e){let t=null;for(let r of i){let n=r.style(e);n&&(t=t?t+" "+n:n)}return t}function Ju(i,e,t,r=0,n=i.length){let s=new Oo(r,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),r,n,"",s.highlighters),s.flush(n)}var Oo=class{constructor(e,t,r){this.at=e,this.highlighters=t,this.span=r,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,r,n,s){let{type:o,from:l,to:a}=e;if(l>=r||a<=t)return;o.isTop&&(s=this.highlighters.filter(d=>!d.scope||d.scope(o)));let u=n,h=gp(e)||Ai.empty,c=pp(s,h.tags);if(c&&(u&&(u+=" "),u+=c,h.mode==1&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(t,l),u),h.opaque)return;let f=e.tree&&e.tree.prop(J.mounted);if(f&&f.overlay){let d=e.node.enter(f.overlay[0].from+l,1),p=this.highlighters.filter(y=>!y.scope||y.scope(f.tree.type)),g=e.firstChild();for(let y=0,b=l;;y++){let A=y=w||!e.nextSibling())););if(!A||w>r)break;b=A.to+l,b>t&&(this.highlightRange(d.cursor(),Math.max(t,A.from+l),Math.min(r,b),"",p),this.startSpan(Math.min(r,b),u))}g&&e.parent()}else if(e.firstChild()){f&&(n="");do if(!(e.to<=t)){if(e.from>=r)break;this.highlightRange(e,t,r,n,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}};function gp(i){let e=i.type.prop(Xu);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}var C=Ge.define,In=C(),Nt=C(),Gu=C(Nt),Ku=C(Nt),Ot=C(),Fn=C(Ot),No=C(Ot),ut=C(),Zt=C(ut),lt=C(),at=C(),Bo=C(),mr=C(Bo),Hn=C(),m={comment:In,lineComment:C(In),blockComment:C(In),docComment:C(In),name:Nt,variableName:C(Nt),typeName:Gu,tagName:C(Gu),propertyName:Ku,attributeName:C(Ku),className:C(Nt),labelName:C(Nt),namespace:C(Nt),macroName:C(Nt),literal:Ot,string:Fn,docString:C(Fn),character:C(Fn),attributeValue:C(Fn),number:No,integer:C(No),float:C(No),bool:C(Ot),regexp:C(Ot),escape:C(Ot),color:C(Ot),url:C(Ot),keyword:lt,self:C(lt),null:C(lt),atom:C(lt),unit:C(lt),modifier:C(lt),operatorKeyword:C(lt),controlKeyword:C(lt),definitionKeyword:C(lt),moduleKeyword:C(lt),operator:at,derefOperator:C(at),arithmeticOperator:C(at),logicOperator:C(at),bitwiseOperator:C(at),compareOperator:C(at),updateOperator:C(at),definitionOperator:C(at),typeOperator:C(at),controlOperator:C(at),punctuation:Bo,separator:C(Bo),bracket:mr,angleBracket:C(mr),squareBracket:C(mr),paren:C(mr),brace:C(mr),content:ut,heading:Zt,heading1:C(Zt),heading2:C(Zt),heading3:C(Zt),heading4:C(Zt),heading5:C(Zt),heading6:C(Zt),contentSeparator:C(ut),list:C(ut),quote:C(ut),emphasis:C(ut),strong:C(ut),link:C(ut),monospace:C(ut),strikethrough:C(ut),inserted:C(),deleted:C(),changed:C(),invalid:C(),meta:Hn,documentMeta:C(Hn),annotation:C(Hn),processingInstruction:C(Hn),definition:Ge.defineModifier("definition"),constant:Ge.defineModifier("constant"),function:Ge.defineModifier("function"),standard:Ge.defineModifier("standard"),local:Ge.defineModifier("local"),special:Ge.defineModifier("special")};for(let i in m){let e=m[i];e instanceof Ge&&(e.name=i)}var Vb=Po([{tag:m.link,class:"tok-link"},{tag:m.heading,class:"tok-heading"},{tag:m.emphasis,class:"tok-emphasis"},{tag:m.strong,class:"tok-strong"},{tag:m.keyword,class:"tok-keyword"},{tag:m.atom,class:"tok-atom"},{tag:m.bool,class:"tok-bool"},{tag:m.url,class:"tok-url"},{tag:m.labelName,class:"tok-labelName"},{tag:m.inserted,class:"tok-inserted"},{tag:m.deleted,class:"tok-deleted"},{tag:m.literal,class:"tok-literal"},{tag:m.string,class:"tok-string"},{tag:m.number,class:"tok-number"},{tag:[m.regexp,m.escape,m.special(m.string)],class:"tok-string2"},{tag:m.variableName,class:"tok-variableName"},{tag:m.local(m.variableName),class:"tok-variableName tok-local"},{tag:m.definition(m.variableName),class:"tok-variableName tok-definition"},{tag:m.special(m.variableName),class:"tok-variableName2"},{tag:m.definition(m.propertyName),class:"tok-propertyName tok-definition"},{tag:m.typeName,class:"tok-typeName"},{tag:m.namespace,class:"tok-namespace"},{tag:m.className,class:"tok-className"},{tag:m.macroName,class:"tok-macroName"},{tag:m.propertyName,class:"tok-propertyName"},{tag:m.operator,class:"tok-operator"},{tag:m.comment,class:"tok-comment"},{tag:m.meta,class:"tok-meta"},{tag:m.invalid,class:"tok-invalid"},{tag:m.punctuation,class:"tok-punctuation"}]);var Lo,br=new J;var mp=new J,qe=class{constructor(e,t,r=[],n=""){this.data=e,this.name=n,oe.prototype.hasOwnProperty("tree")||Object.defineProperty(oe.prototype,"tree",{get(){return vr(this)}}),this.parser=t,this.extension=[Ci.of(this),oe.languageData.of((s,o,l)=>{let a=Qu(s,o,l),u=a.type.prop(br);if(!u)return[];let h=s.facet(u),c=a.type.prop(mp);if(c){let f=a.resolve(o-a.from,l);for(let d of c)if(d.test(f,s)){let p=s.facet(d.facet);return d.type=="replace"?p:p.concat(h)}}return h})].concat(r)}isActiveAt(e,t,r=-1){return Qu(e,t,r).type.prop(br)==this.data}findRegions(e){let t=e.facet(Ci);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],n=(s,o)=>{if(s.prop(br)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(J.mounted);if(l){if(l.tree.prop(br)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(n(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;a=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}},yr=null,$o=class i{constructor(e,t,r=[],n,s,o,l,a){this.parser=e,this.state=t,this.fragments=r,this.tree=n,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,r){return new i(e,t,[],Ee.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Ho(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Ee.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let n=Date.now()+e;e=()=>Date.now()>n}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Qt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=yr;yr=this;try{return e()}finally{yr=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Zu(e,t.from,t.to);return e}changes(e,t){let{fragments:r,tree:n,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,h,c,f)=>a.push({fromA:u,toA:h,fromB:c,toB:f})),r=Qt.applyChanges(r,a),n=Ee.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let h=e.mapPos(u.from,1),c=e.mapPos(u.to,-1);he.from&&(this.fragments=Zu(this.fragments,n,s),this.skipped.splice(r--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends _n{createParse(t,r,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let a=yr;if(a){for(let u of n)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Ee(Fe.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return yr}};function Zu(i,e,t){return Qt.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}var wr=class i{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,r)||t.takeTree(),new i(t)}static init(e){let t=Math.min(3e3,e.doc.length),r=$o.create(e.facet(Ci).parser,e,{from:0,to:t});return r.work(20,t)||r.takeTree(),new i(r)}};qe.state=gt.define({create:wr.init,update(i,e){for(let t of e.effects)if(t.is(qe.setState))return t.value;return e.startState.facet(Ci)!=e.state.facet(Ci)?wr.init(e.state):i.apply(e)}});var rh=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(rh=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var _o=typeof navigator!="undefined"&&(!((Lo=navigator.scheduling)===null||Lo===void 0)&&Lo.isInputPending)?()=>navigator.scheduling.isInputPending():null,yp=Jt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(qe.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(qe.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=rh(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,a=s.context.work(()=>_o&&_o()||Date.now()>o,n+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:qe.setState.of(new wr(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ze(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ci=$.define({combine(i){return i.length?i[0]:null},enables:i=>[qe.state,yp,q.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});var Bt=class i{constructor(e,t){this.specs=e;let r;function n(l){let a=He.newName();return(r||(r=Object.create(null)))["."+a]=l,a}let s=typeof t.all=="string"?t.all:t.all?n(t.all):void 0,o=t.scope;this.scope=o instanceof qe?l=>l.prop(br)==o.data:o?l=>l==o:void 0,this.style=Po(e.map(l=>({tag:l.tag,class:l.class||n(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new He(r):null,this.themeType=t.themeType}static define(e,t){return new i(e,t||{})}},Vo=$.define(),nh=$.define({combine(i){return i.length?[i[0]]:null}});function Io(i){let e=i.facet(Vo);return e.length?e:i.facet(nh)}function Vn(i,e){let t=[bp],r;return i instanceof Bt&&(i.module&&t.push(q.styleModule.of(i.module)),r=i.themeType),e!=null&&e.fallback?t.push(nh.of(i)):r?t.push(Vo.computeN([q.darkTheme],n=>n.facet(q.darkTheme)==(r=="dark")?[i]:[])):t.push(Vo.of(i)),t}var qo=class{constructor(e){this.markCache=Object.create(null),this.tree=vr(e.state),this.decorations=this.buildDeco(e,Io(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=vr(e.state),r=Io(e.state),n=r!=Io(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||n)&&(this.tree=t,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return le.none;let r=new zt;for(let{from:n,to:s}of e.visibleRanges)Ju(this.tree,t,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=le.mark({class:a})))},n,s);return r.finish()}},bp=nn.high(Jt.fromClass(qo,{decorations:i=>i.decorations})),Jb=Bt.define([{tag:m.meta,color:"#404740"},{tag:m.link,textDecoration:"underline"},{tag:m.heading,textDecoration:"underline",fontWeight:"bold"},{tag:m.emphasis,fontStyle:"italic"},{tag:m.strong,fontWeight:"bold"},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.keyword,color:"#708"},{tag:[m.atom,m.bool,m.url,m.contentSeparator,m.labelName],color:"#219"},{tag:[m.literal,m.inserted],color:"#164"},{tag:[m.string,m.deleted],color:"#a11"},{tag:[m.regexp,m.escape,m.special(m.string)],color:"#e40"},{tag:m.definition(m.variableName),color:"#00f"},{tag:m.local(m.variableName),color:"#30a"},{tag:[m.typeName,m.namespace],color:"#085"},{tag:m.className,color:"#167"},{tag:[m.special(m.variableName),m.macroName],color:"#256"},{tag:m.definition(m.propertyName),color:"#00c"},{tag:m.comment,color:"#940"},{tag:m.invalid,color:"#f00"}]);var vp=Object.create(null),eh=[Fe.none];var th=[],ih=Object.create(null),wp=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])wp[i]=Ap(vp,e);function Fo(i,e){th.indexOf(i)>-1||(th.push(i),console.warn(e))}function Ap(i,e){let t=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let h=i[u]||m[u];h?typeof h=="function"?a.length?a=a.map(h):Fo(u,`Modifier ${u} used at start of tag`):a.length?Fo(u,`Tag ${u} used as modifier`):a=Array.isArray(h)?h:[h]:Fo(u,`Unknown highlighting tag ${u}`)}for(let u of a)t.push(u)}if(!t.length)return 0;let r=e.replace(/ /g,"_"),n=r+" "+t.map(l=>l.id),s=ih[n];if(s)return s.id;let o=ih[n]=Fe.define({id:eh.length,name:r,props:[Yu({[r]:t})]});return eh.push(o),o.id}var Qb={rtl:le.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:me.RTL}),ltr:le.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:me.LTR}),auto:le.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var Cp="#abb2bf",Sp="#7d8799",Dp="#ffffff",Ep="#21252b",Uo="rgba(0, 0, 0, 0.5)",xp="#292d3e",Wo="#353a42",Tp="rgba(128, 203, 196, 0.2)",sh="#ffcc00",kp=q.theme({"&":{color:"#ffffff",backgroundColor:xp},".cm-content":{caretColor:sh},"&.cm-focused .cm-cursor":{borderLeftColor:sh},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Tp},".cm-panels":{backgroundColor:Ep,color:"#ffffff"},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:Uo},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847",outline:"1px solid #515a6b"},".cm-gutters":{background:"#292d3e",color:"#676e95",border:"none"},".cm-activeLineGutter":{backgroundColor:Uo},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Wo},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Wo,borderBottomColor:Wo},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Uo,color:Cp}}},{dark:!0}),Mp=Bt.define([{tag:m.keyword,color:"#c792ea"},{tag:m.operator,color:"#89ddff"},{tag:m.special(m.variableName),color:"#eeffff"},{tag:m.typeName,color:"#f07178"},{tag:m.atom,color:"#f78c6c"},{tag:m.number,color:"#ff5370"},{tag:m.definition(m.variableName),color:"#82aaff"},{tag:m.string,color:"#c3e88d"},{tag:m.special(m.string),color:"#f07178"},{tag:m.comment,color:Sp},{tag:m.variableName,color:"#f07178"},{tag:m.tagName,color:"#ff5370"},{tag:m.bracket,color:"#a2a1a4"},{tag:m.meta,color:"#ffcb6b"},{tag:m.attributeName,color:"#c792ea"},{tag:m.propertyName,color:"#c792ea"},{tag:m.className,color:"#decb6b"},{tag:m.invalid,color:Dp}]),Rp=[kp,Vn(Mp)];var oh="#2e3440",Xo="#3b4252",lh="#434c5e",qn="#4c566a";var ah="#e5e9f0",Yo="#eceff4",zo="#8fbcbb",uh="#88c0d0",Np="#81a1c1",Ke="#5e81ac",Op="#bf616a",Si="#d08770",jo="#ebcb8b",hh="#a3be8c",Bp="#b48ead",ch="#d30102",Jo=Yo,Go=Jo,Pp="#ffffff",Ko=Xo,Lp=Jo,fh=Xo,dh=q.theme({"&":{color:oh,backgroundColor:Pp},".cm-content":{caretColor:fh},".cm-cursor, .cm-dropCursor":{borderLeftColor:fh},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Lp},".cm-panels":{backgroundColor:Jo,color:qn},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${qn}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:ah},".cm-activeLine":{backgroundColor:Go},".cm-selectionMatch":{backgroundColor:ah},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${qn}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:Yo},".cm-gutters":{backgroundColor:Yo,color:oh,border:"none"},".cm-activeLineGutter":{backgroundColor:Go},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Ko},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Ko,borderBottomColor:Ko},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Go,color:qn}}},{dark:!1}),_p=Bt.define([{tag:m.keyword,color:Ke},{tag:[m.name,m.deleted,m.character,m.propertyName,m.macroName],color:Si},{tag:[m.variableName],color:Si},{tag:[m.function(m.variableName)],color:Ke},{tag:[m.labelName],color:Np},{tag:[m.color,m.constant(m.name),m.standard(m.name)],color:Ke},{tag:[m.definition(m.name),m.separator],color:hh},{tag:[m.brace],color:zo},{tag:[m.annotation],color:ch},{tag:[m.number,m.changed,m.annotation,m.modifier,m.self,m.namespace],color:uh},{tag:[m.typeName,m.className],color:jo},{tag:[m.operator,m.operatorKeyword],color:hh},{tag:[m.tagName],color:Bp},{tag:[m.squareBracket],color:Op},{tag:[m.angleBracket],color:Si},{tag:[m.attributeName],color:jo},{tag:[m.regexp],color:Ke},{tag:[m.quote],color:Xo},{tag:[m.string],color:Si},{tag:m.link,color:zo,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[m.url,m.escape,m.special(m.string)],color:Si},{tag:[m.meta],color:uh},{tag:[m.comment],color:lh,fontStyle:"italic"},{tag:m.strong,fontWeight:"bold",color:Ke},{tag:m.emphasis,fontStyle:"italic",color:Ke},{tag:m.strikethrough,textDecoration:"line-through"},{tag:m.heading,fontWeight:"bold",color:Ke},{tag:m.special(m.heading1),fontWeight:"bold",color:Ke},{tag:m.heading1,fontWeight:"bold",color:Ke},{tag:[m.heading2,m.heading3,m.heading4],fontWeight:"bold",color:Ke},{tag:[m.heading5,m.heading6],color:Ke},{tag:[m.atom,m.bool,m.special(m.variableName)],color:Si},{tag:[m.processingInstruction,m.inserted],color:zo},{tag:[m.contentSeparator],color:jo},{tag:m.invalid,color:lh,borderBottom:`1px dotted ${ch}`}]),u1=[dh,Vn(_p)];function Ar(i,e=0,t=" ",r=!0){let n=[];if(e==5||i==null)return"";if(typeof i=="string")return i;if(typeof i=="number")return`${i}`;if(Array.isArray(i))n.push(`${r?"(":""}${i.map(s=>Ar(s,e+1)).join(t)}${r?")":""}`);else if(typeof i=="object")for(let s of Object.values(i))n.push(Ar(s,e+1));return n.join(" ")}var Ip={str:"strength",dex:"dexterity",con:"constitution",wis:"wisdom",int:"intelligence",cha:"charisma"};function ht(i){return i?i.replace(/{@condition (.+?)(?:\\|.+)?}/g,"$1").replace(/{@item (.+?)(?:\\|.+)?}/g,"$1").replace(/{@spell ([\\s\\S]+?)(?:\\|.+)?}/g,"$1").replace(/{@recharge (.+?)(?:\\|.+)?}/g,"(Recharge $1-6)").replace(/{@recharge}/g,"(Recharge 6)").replace(/{@h}/g,"").replace(/{@damage (.+?)}/g,"$1").replace(/{@atk ms}/g,"Melee Spell Attack").replace(/{@atk rs}/g,"Ranged Spell Attack").replace(/{@atk mw}/g,"Melee Weapon Attack").replace(/{@atk rw}/g,"Ranged Weapon Attack").replace(/{@atk mw,rw}/g,"Melee / Ranged Weapon Attack").replace(/{@creature (.+?)(?:\\|.+)?}/g,"$1").replace(/{@skill (.+?)(?:\\|.+)?}/g,"$1").replace(/{@dice (.+?)(?:\\|.+)?}/g,"$1").replace(/{@hit (\\d+?)(?:\\|.+)?}/g,"+$1").replace(/{@dc (\\d+?)(?:\\|.+)?}/g,"$1").replace(/{@quickref (.+?)\\|\\|.+?}/,"$1"):""}async function ph(i){return new Promise((e,t)=>{let r=new FileReader;r.onload=async n=>{var s,o,l,a,u,h,c,f,d,p,g,y,b,A,w,E,S;try{let N=JSON.parse(n.target.result),M;"monster"in N?M=N.monster:Array.isArray(N)?M=N:typeof N=="object"?M=[N]:t("Invalid monster JSON provided.");let j=[];for(let D of M)try{let H={image:null,bestiary:!0,name:D.name,source:Xp(D),type:Fp(D.type),subtype:Hp(D.type),size:lg[(s=D.size)==null?void 0:s[0]],alignment:Gp(D),hp:D.hp&&"average"in D.hp?(o=D.hp)==null?void 0:o.average:null,hit_dice:D.hp&&"formula"in D.hp?(l=D.hp)==null?void 0:l.formula:"",ac:qp(D.ac),speed:Kp(D),stats:[D.str,D.dex,D.con,D.int,D.wis,D.cha],damage_immunities:ht(Di(D.immune)),damage_resistances:ht(Di(D.resist)),damage_vulnerabilities:ht(Di(D.vulnerable)),condition_immunities:ht(Di(D.conditionImmune)),saves:Object.entries((a=D.save)!=null?a:{}).map(B=>{var W,I;if(!B||!B[1])return;let[,O]=(I=(W=B[1])==null?void 0:W.match(/.*?(\\d+)/))!=null?I:[];if(O)return{[Ip[B[0]]]:O}}).filter(B=>B),skillsaves:X0(D),senses:Yp(D),languages:Ar(D.languages,0,", ",!1),cr:$p(D.cr),traits:(h=(u=D.trait)==null?void 0:u.flatMap(ei))!=null?h:[],actions:(f=(c=D.action)==null?void 0:c.flatMap(ei))!=null?f:[],bonus_actions:(p=(d=D.bonus)==null?void 0:d.flatMap(ei))!=null?p:[],reactions:(y=(g=D.reaction)==null?void 0:g.flatMap(ei))!=null?y:[],legendary_actions:(A=(b=D.legendary)==null?void 0:b.flatMap(ei))!=null?A:[],mythic_actions:[...(w=(D.mythicHeader?[{name:"",entries:D.mythicHeader}]:[]).flatMap(ei))!=null?w:[],...(S=(E=D.mythic)==null?void 0:E.flatMap(ei))!=null?S:[]],spells:jp(D),spellsNotes:Vp(D).join(" ")};j.push(H)}catch(H){console.error(H);continue}e(j)}catch(N){console.error("reject!!!",N),t(N)}},r.readAsText(i)})}function Fp(i){if(i)return typeof i=="string"?i:i.type}function Hp(i){if(!i||typeof i=="string"||!i.tags)return;let e=[];for(var t of i.tags)typeof t=="string"?e.push(t):e.push(t.tag);return e.join(", ")}function $p(i){if(i)return typeof i=="string"?i:i.cr}function Vp(i){let e=[];for(let t in i.spellcasting)e.push(Ar(i.spellcasting[t].footerEntries,0,", ",!1));return e}function Di(i){if(!i)return"";let e=[];for(let t of i){if(typeof t=="string"){e.push(t);continue}if("special"in t){e.push(t.special);continue}if("immune"in t){e.push(`${Di(t.immune)}${t.note?" ":""}${t.note?t.note:""}`);continue}if("resist"in t){e.push(`${Di(t.resist)}${t.note?" ":""}${t.note?t.note:""}`);continue}}return e.join(", ")}function qp(i=[]){var t;let[e]=i;if(e){if(typeof e=="number")return e;if(typeof e=="string"){let[r,n]=(t=e.match(/(\\d+)/))!=null?t:[];return n?Number(n):null}if(typeof e=="object")return"special"in e?e.special:"ac"in e?"from"in e?`${e.ac} (${ht(e.from.join(", "))})`:`${e.ac}`:null}}var Up={0:"Cantrips (at will)",1:"1st level",2:"2nd level",3:"3rd level",4:"4th level",5:"5th level",6:"6th level",7:"7th level",8:"8th level",9:"9th level"};function Qo(i){let e=[];for(let t of i){if(typeof t=="string"){e.push(t);continue}!t.hidden&&t.entry&&t.entry.length&&e.push(t.entry)}return ht(e.join(", "))}function Wp(i){let e=[];for(let t of Object.keys(i)){let r=i[t],n=Number(t.replace(/[^0-9]/,""));e.push([n,Qo(r)])}return e}function zp(i){var n,s;let e=[ht(((n=i.headerEntries)!=null?n:[]).join(`\n`))];if("spells"in i)try{for(let o in(s=i.spells)!=null?s:{}){let l=i.spells[o],{spells:a}=l,u=`${Up[o]}`;u+="slots"in l?` (${l.slots} slots)`:"";let h=ht(a.join(", "));e.push({[u]:h})}}catch(o){throw new Error("There was an error parsing the spells.")}if("will"in i&&i.will.length>0)try{e.push({"At will":Qo(i.will)})}catch(o){throw new Error("There was an error parsing the at-will spells.")}if("ritual"in i&&i.ritual.length>0)try{e.push({Rituals:Qo(i.ritual)})}catch(o){throw new Error("There was an error parsing the ritual spells.")}let t=["rest","daily","weekly","yearly","charges"],r={rest:"/rest each",daily:"/day each",weekly:"/week each",yearly:"/year each",charges:" charges"};for(let o of t)if(o in i){let l=Wp(i[o]);for(let a of l.sort((u,h)=>h[0]-u[0]))e.push({[`${a[0]}${r[o]}`]:a[1]})}return e}function jp(i){return!i.spellcasting||!i.spellcasting.length?[]:i.spellcasting.flatMap(zp)}function Gp(i){return i.alignment?Un(i.alignment):null}function Un(i){var t;if(!i)return null;let e=[];if(Array.isArray(i)){let r=[];for(let n of i)typeof n=="string"?r.push(Un(n)):e.push(Un(n));r.length>0&&e.push(r.join(" "))}else if(typeof i=="object"){if("special"in i&&i.special!=null)return i.special;if("alignment"in i)return`${((t=i.alignment)!=null?t:[]).map(r=>Un(r)).join(" ")}${i.chance?` (${i.chance}%)`:""}${i.note?` (${i.note})`:""}`}else{switch(i.toUpperCase()){case"L":return"lawful";case"N":return"neutral";case"NX":return"neutral (law/chaos axis)";case"NY":return"neutral (good/evil axis)";case"C":return"chaotic";case"G":return"good";case"E":return"evil";case"U":return"unaligned";case"A":return"any alignment"}return i}return e.join(" or ")}function Kp(i){var l,a;let e=i.speed;if(!e)return"\\u2014";if(typeof e=="number")return`${e}`;function t(u){return typeof u=="number"?u:u.number!=null?u.number:u}function r(u){var h;return typeof u=="number"?"":(h=u==null?void 0:u.condition)!=null?h:""}let n=[],s=["walk","burrow","climb","fly","swim"];for(let u of s){if(u!="walk"&&!(u in e)&&!(u in((l=e.alternate)!=null?l:{})))continue;let h=[];n.push(`${u==="walk"?"":`${u} `}${t((a=e[u])!=null?a:0)} ft. ${r(e[u])}`.trim()),e.alternate&&e.alternate[u]&&e.alternate[u].forEach(c=>{n.push(`${u==="walk"?"":`${u} `}${t(c!=null?c:0)} ft. ${r(c)}`.trim())})}let o=", ";if(e.choose){o="; ";let u=e.choose.from.sort();u.length>1?(`${u.slice(0,u.length-1).join(", ")}${u[u.length-1]}${e.choose.amount}`,e.choose.note&&`${e.choose.note}`):n.push(`${u} ${e.choose.amount} ft.${e.choose.note?` ${e.choose.note}`:""}`)}return n.join(o)}function Yp(i){if(typeof i.senses=="string")return i.senses;let e=[];return Array.isArray(i.senses)&&i.senses.length>0&&(e=[i.senses.join(", ").trim()]),i.passive&&e.push(`passive Perception ${i.passive}`),e.join(", ")}function Xp(i){var t,r,n;let e=[];return(t=i.source)!=null&&t.length&&e.push((r=v[i.source])!=null?r:i.source),(n=i.otherSources)!=null&&n.length&&e.push(...i.otherSources.map(s=>{var o;return(o=v[s.source])!=null?o:s.source})),e}function ei(i){return i.entries.reduce((t,r)=>{var s;if(typeof r!="string"){let o=(s=r.items)==null?void 0:s.map(l=>typeof l=="string"?{name:l,entries:[]}:"entry"in l?{name:l.name,entries:[l.entry]}:{name:l.name,entries:l.entries});return t.concat(o!=null?o:[])}return t.length>1||t[0].entries.push(r),t},[{name:i.name,entries:[]}]).map(({name:t,entries:r})=>({name:ht(t),desc:ht(r.join(`\n`))}))}var Jp="F",Qp="D",Zp="T",eg="S",tg="M",ig="L",rg="H",ng="G",sg="C",og="V",lg={[Jp]:"Fine",[Qp]:"Diminutive",[Zp]:"Tiny",[eg]:"Small",[tg]:"Medium",[ig]:"Large",[rg]:"Huge",[ng]:"Gargantuan",[sg]:"Colossal",[og]:"Varies"},ag="CoS",ug="DMG",hg="EEPC",cg="EET",fg="HotDQ",dg="LMoP",pg="Mag",gg="MM",mg="OotA",yg="PHB",bg="PotA",vg="RoT",wg="RoTOS",Ag="SCAG",Cg="SKT",Sg="ToA",Dg="ToD",Eg="TTP",xg="TftYP",Tg="TftYP-AtG",kg="TftYP-DiT",Mg="TftYP-TFoF",Rg="TftYP-THSoT",Ng="TftYP-TSC",Og="TftYP-ToH",Bg="TftYP-WPM",Pg="VGM",Lg="XGE",_g="OGA",Ig="MTF",Fg="WDH",Hg="WDMM",$g="GGR",Vg="KKW",qg="LLK",Ug="GoS",Wg="AI",zg="OoW",jg="ESK",Gg="DIP",Kg="HftT",Yg="DC",Xg="SLW",Jg="SDW",Qg="BGDIA",Zg="LR",em="AL",tm="SAC",im="ERLW",rm="EFR",nm="RMBRE",sm="RMR",om="MFF",lm="AWM",am="IMR",um="SADS",hm="EGW",cm="ToR",fm="DD",dm="FS",pm="US",gm="MOT",mm="IDRotF",ym="TCE",bm="VRGR",vm="HoL",wm="Screen",Am="ScreenWildernessKit",Cm="HF",Sm="CM",Dm="WBtW",Em="CRCotN",Zo="AL",xm=`${Zo}CurseOfStrahd`,Tm=`${Zo}ElementalEvil`,km=`${Zo}RageOfDemons`,Ei="PS",Mm=`${Ei}A`,Rm=`${Ei}I`,Nm=`${Ei}K`,Om=`${Ei}Z`,Bm=`${Ei}X`,Pm=`${Ei}D`,x="UA",Lm=`${x}Artificer`,_m=`${x}EladrinAndGith`,Im=`${x}Eberron`,Fm=`${x}FeatsForRaces`,Hm=`${x}FeatsForSkills`,$m=`${x}FiendishOptions`,Vm=`${x}Feats`,qm=`${x}GothicHeroes`,Um=`${x}ModernMagic`,Wm=`${x}StarterSpells`,zm=`${x}TheMysticClass`,jm=`${x}ThatOldBlackMagic`,Gm=`${x}TheRangerRevised`,Km=`${x}WaterborneAdventures`,Ym=`${x}VariantRules`,Xm=`${x}LightDarkUnderdark`,Jm=`${x}RangerAndRogue`,Qm=`${x}ATrioOfSubclasses`,Zm=`${x}BarbarianPrimalPaths`,e0=`${x}RevisedSubclasses`,t0=`${x}KitsOfOld`,i0=`${x}BardBardColleges`,r0=`${x}ClericDivineDomains`,n0=`${x}Druid`,s0=`${x}RevisedClassOptions`,o0=`${x}Fighter`,l0=`${x}Monk`,a0=`${x}Paladin`,u0=`${x}ModifyingClasses`,h0=`${x}Sorcerer`,c0=`${x}WarlockAndWizard`,f0=`${x}TheFaithful`,d0=`${x}WizardRevisited`,p0=`${x}ElfSubraces`,g0=`${x}MassCombat`,m0=`${x}ThreePillarExperience`,y0=`${x}GreyhawkInitiative`,b0=`${x}ThreeSubclasses`,v0=`${x}OrderDomain`,w0=`${x}CentaursMinotaurs`,A0=`${x}GiantSoulSorcerer`,C0=`${x}RacesOfEberron`,S0=`${x}RacesOfRavnica`,D0=`${x}WGE`,E0=`${x}OfShipsAndSea`,x0=`${x}Sidekicks`,T0=`${x}ArtificerRevisited`,k0=`${x}BarbarianAndMonk`,M0=`${x}SorcererAndWarlock`,R0=`${x}BardAndPaladin`,N0=`${x}ClericDruidWizard`,O0=`${x}FighterRangerRogue`,B0=`${x}ClassFeatureVariants`,P0=`${x}FighterRogueWizard`,L0=`${x}PrestigeClassesRunMagic`,_0=`${x}Ranger`,I0=`${x}2020SubclassesPt1`,F0=`${x}2020SubclassesPt2`,H0=`${x}2020SubclassesPt3`,$0=`${x}2020SubclassesPt4`,V0=`${x}2020SubclassesPt5`,q0=`${x}2020SpellsAndMagicTattoos`,U0=`${x}2020PsionicOptionsRevisited`,W0=`${x}2020SubclassesRevisited`,z0=`${x}2020Feats`,j0=`${x}2021GothicLineages`,G0=`${x}2021FolkOfTheFeywild`,K0=`${x}2021DraconicOptions`,Y0=`${x}2021MagesOfStrixhaven`,el="Adventurers League: ",xi="Plane Shift: ",T="Unearthed Arcana: ",Pt="Tales from the Yawning Portal",v={};v[ag]="Curse of Strahd";v[ug]="Dungeon Master\'s Guide";v[hg]="Elemental Evil Player\'s Companion";v[cg]="Elemental Evil: Trinkets";v[fg]="Hoard of the Dragon Queen";v[dg]="Lost Mine of Phandelver";v[pg]="Dragon Magazine";v[gg]="Monster Manual";v[mg]="Out of the Abyss";v[yg]="Player\'s Handbook";v[bg]="Princes of the Apocalypse";v[vg]="The Rise of Tiamat";v[wg]="The Rise of Tiamat Online Supplement";v[Ag]="Sword Coast Adventurer\'s Guide";v[Cg]="Storm King\'s Thunder";v[Sg]="Tomb of Annihilation";v[Dg]="Tyranny of Dragons";v[Eg]="The Tortle Package";v[xg]=Pt;v[Tg]=`${Pt}: Against the Giants`;v[kg]=`${Pt}: Dead in Thay`;v[Mg]=`${Pt}: The Forge of Fury`;v[Rg]=`${Pt}: The Hidden Shrine of Tamoachan`;v[Ng]=`${Pt}: The Sunless Citadel`;v[Og]=`${Pt}: Tomb of Horrors`;v[Bg]=`${Pt}: White Plume Mountain`;v[Pg]="Volo\'s Guide to Monsters";v[Lg]="Xanathar\'s Guide to Everything";v[_g]="One Grung Above";v[Ig]="Mordenkainen\'s Tome of Foes";v[Fg]="Waterdeep: Dragon Heist";v[Hg]="Waterdeep: Dungeon of the Mad Mage";v[$g]="Guildmasters\' Guide to Ravnica";v[Vg]="Krenko\'s Way";v[qg]="Lost Laboratory of Kwalish";v[Ug]="Ghosts of Saltmarsh";v[Wg]="Acquisitions Incorporated";v[zg]="The Orrery of the Wanderer";v[jg]="Essentials Kit";v[Gg]="Dragon of Icespire Peak";v[Kg]="Hunt for the Thessalhydra";v[Yg]="Divine Contention";v[Xg]="Storm Lord\'s Wrath";v[Jg]="Sleeping Dragon\'s Wake";v[Qg]="Baldur\'s Gate: Descent Into Avernus";v[Zg]="Locathah Rising";v[em]="Adventurers\' League";v[tm]="Sage Advice Compendium";v[im]="Eberron: Rising from the Last War";v[rm]="Eberron: Forgotten Relics";v[nm]="The Lost Dungeon of Rickedness: Big Rick Energy";v[sm]="Dungeons & Dragons vs. Rick and Morty: Basic Rules";v[om]="Mordenkainen\'s Fiendish Folio";v[lm]="Adventure with Muk";v[am]="Infernal Machine Rebuild";v[um]="Sapphire Anniversary Dice Set";v[hm]="Explorer\'s Guide to Wildemount";v[cm]="Tide of Retribution";v[fm]="Dangerous Designs";v[dm]="Frozen Sick";v[pm]="Unwelcome Spirits";v[gm]="Mythic Odysseys of Theros";v[mm]="Icewind Dale: Rime of the Frostmaiden";v[ym]="Tasha\'s Cauldron of Everything";v[bm]="Van Richten\'s Guide to Ravenloft";v[vm]="The House of Lament";v[wm]="Dungeon Master\'s Screen";v[Am]="Dungeon Master\'s Screen: Wilderness Kit";v[Cm]="Heroes\' Feast";v[Sm]="Candlekeep Mysteries";v[xm]=`${el}Curse of Strahd`;v[Tm]=`${el}Elemental Evil`;v[km]=`${el}Rage of Demons`;v[Mm]=`${xi}Amonkhet`;v[Rm]=`${xi}Innistrad`;v[Nm]=`${xi}Kaladesh`;v[Om]=`${xi}Zendikar`;v[Bm]=`${xi}Ixalan`;v[Pm]=`${xi}Dominaria`;v[Lm]=`${T}Artificer`;v[_m]=`${T}Eladrin and Gith`;v[Im]=`${T}Eberron`;v[Fm]=`${T}Feats for Races`;v[Hm]=`${T}Feats for Skills`;v[$m]=`${T}Fiendish Options`;v[Vm]=`${T}Feats`;v[qm]=`${T}Gothic Heroes`;v[Um]=`${T}Modern Magic`;v[Wm]=`${T}Starter Spells`;v[zm]=`${T}The Mystic Class`;v[jm]=`${T}That Old Black Magic`;v[Gm]=`${T}The Ranger, Revised`;v[Km]=`${T}Waterborne Adventures`;v[Ym]=`${T}Variant Rules`;v[Xm]=`${T}Light, Dark, Underdark!`;v[Jm]=`${T}Ranger and Rogue`;v[Qm]=`${T}A Trio of Subclasses`;v[Zm]=`${T}Barbarian Primal Paths`;v[e0]=`${T}Revised Subclasses`;v[t0]=`${T}Kits of Old`;v[i0]=`${T}Bard: Bard Colleges`;v[r0]=`${T}Cleric: Divine Domains`;v[n0]=`${T}Druid`;v[s0]=`${T}Revised Class Options`;v[o0]=`${T}Fighter`;v[l0]=`${T}Monk`;v[a0]=`${T}Paladin`;v[u0]=`${T}Modifying Classes`;v[h0]=`${T}Sorcerer`;v[c0]=`${T}Warlock and Wizard`;v[f0]=`${T}The Faithful`;v[d0]=`${T}Wizard Revisited`;v[p0]=`${T}Elf Subraces`;v[g0]=`${T}Mass Combat`;v[m0]=`${T}Three-Pillar Experience`;v[y0]=`${T}Greyhawk Initiative`;v[b0]=`${T}Three Subclasses`;v[v0]=`${T}Order Domain`;v[w0]=`${T}Centaurs and Minotaurs`;v[A0]=`${T}Giant Soul Sorcerer`;v[C0]=`${T}Races of Eberron`;v[S0]=`${T}Races of Ravnica`;v[D0]="Wayfinder\'s Guide to Eberron";v[E0]=`${T}Of Ships and the Sea`;v[x0]=`${T}Sidekicks`;v[T0]=`${T}Artificer Revisited`;v[k0]=`${T}Barbarian and Monk`;v[M0]=`${T}Sorcerer and Warlock`;v[R0]=`${T}Bard and Paladin`;v[N0]=`${T}Cleric, Druid, and Wizard`;v[O0]=`${T}Fighter, Ranger, and Rogue`;v[B0]=`${T}Class Feature Variants`;v[P0]=`${T}Fighter, Rogue, and Wizard`;v[L0]=`${T}Prestige Classes and Rune Magic`;v[_0]=`${T}Ranger`;v[I0]=`${T}2020 Subclasses, Part 1`;v[F0]=`${T}2020 Subclasses, Part 2`;v[H0]=`${T}2020 Subclasses, Part 3`;v[$0]=`${T}2020 Subclasses, Part 4`;v[V0]=`${T}2020 Subclasses, Part 5`;v[q0]=`${T}2020 Spells and Magic Tattoos`;v[U0]=`${T}2020 Psionic Options Revisited`;v[W0]=`${T}2020 Subclasses Revisited`;v[z0]=`${T}2020 Feats`;v[j0]=`${T}2021 Gothic Lineages`;v[G0]=`${T}2021 Folk of the Feywild`;v[K0]=`${T}2021 Draconic Options`;v[Y0]=`${T}2021 Mages of Strixhaven`;v[Dm]="The Wild Beyond the Witchlight";v[Em]="Critical Role: Call of the Netherdeep";function X0(i){var n,s,o;let e=i.skill;if(!e)return[];let t=[],r=[];for(let l of Object.keys(e)){if(l=="other"){let h=e[l];for(let c of h){let f=c.oneOf;if(!f)continue;let d=Object.keys(f).sort(),p=d.shift(),g=f[p],[,y]=(n=g==null?void 0:g.match(/.*?(\\d+)/))!=null?n:[];r.push({[`plus one of the following: ${p.charAt(0).toUpperCase()+p.slice(1)}`]:y});for(let b of d.slice(1)){let A=f[b],[,w]=(s=A==null?void 0:A.match(/.*?(\\d+)/))!=null?s:[];w&&r.push({[b]:w})}}continue}let a=e[l],[,u]=(o=a==null?void 0:a.match(/.*?(\\d+)/))!=null?o:[];u&&t.push({[l]:u})}return[...t.filter(l=>l),...r.filter(l=>l)]}async function gh(i){return new Promise((e,t)=>{let r=new FileReader;r.onload=async n=>{var o,l,a,u,h,c,f,d,p,g,y,b,A,w,E,S,N,M,j,D,H,B,O,W,I;let s=[];try{let te=JSON.parse(n.target.result),Ce=[];te.creatures?Ce=te.creatures:Ce=[te];for(let F of Ce)try{let Se={image:null,name:F.name,source:"CritterDB",type:F.stats.race,subtype:"",size:F.stats.size,alignment:F.stats.alignment,hp:F.stats.hitPoints,hit_dice:`${Math.floor(F.stats.extraHealthFromConstitution/F.stats.abilityScoreModifiers.constitution)}d${F.stats.hitDieSize} + ${F.stats.extraHealthFromConstitution}`,ac:F.stats.armorClass,speed:F.stats.speed,stats:[F.stats.abilityScores.strength,F.stats.abilityScores.dexterity,F.stats.abilityScores.constitution,F.stats.abilityScores.intelligence,F.stats.abilityScores.wisdom,F.stats.abilityScores.charisma],damage_immunities:(l=(o=F.stats.damageImmunities)==null?void 0:o.join("; ").toLowerCase().trim())!=null?l:"",damage_resistances:(u=(a=F.stats.damageResistances)==null?void 0:a.join(", ").toLowerCase().trim())!=null?u:"",damage_vulnerabilities:(c=(h=F.stats.damageVulnerabilities)==null?void 0:h.join(", ").toLowerCase().trim())!=null?c:"",condition_immunities:(d=(f=F.stats.conditionImmunities)==null?void 0:f.join(", ").toLowerCase().trim())!=null?d:"",saves:(g=(p=F.stats.savingThrows)==null?void 0:p.map(k=>{var K;if(!(!("value"in k)&&!("modifier"in k)))return{[k.ability]:(K=k.value)!=null?K:k.modifier}}).filter(k=>k))!=null?g:[],skillsaves:(b=(y=F.stats.skills)==null?void 0:y.map(k=>{var K;if(!(!("value"in k)&&!("modifier"in k)))return{[k.name]:(K=k.value)!=null?K:k.modifier}}).filter(k=>k))!=null?b:[],senses:(w=(A=F.stats.senses)==null?void 0:A.join(", ").trim())!=null?w:"",languages:(S=(E=F.stats.languages)==null?void 0:E.join(", ").trim())!=null?S:"",cr:(N=F.stats.challengeRating)!=null?N:"",traits:(j=(M=F.stats.additionalAbilities)==null?void 0:M.map(k=>({name:k.name,desc:k.description.replace(/<[^>]*>/g,"")})))!=null?j:[],actions:(H=(D=F.stats.actions)==null?void 0:D.map(k=>({name:k.name,desc:k.description.replace(/<[^>]*>/g,"")})))!=null?H:[],reactions:(O=(B=F.stats.reactions)==null?void 0:B.map(k=>({name:k.name,desc:k.description.replace(/<[^>]*>/g,"")})))!=null?O:[],legendary_actions:(I=(W=F.stats.legendaryActions)==null?void 0:W.map(k=>({name:k.name,desc:k.description.replace(/<[^>]*>/g,"")})))!=null?I:[]};s.push(Se)}catch(Se){continue}e(s)}catch(te){t()}},r.readAsText(i)})}var kc=Gc(xc());async function Mc(i){return new Promise((e,t)=>{let r=new FileReader;r.onload=async n=>{let s=n.target.result,l=new kc.DOMParser().parseFromString(s,"application/xml").getElementsByTagName("monster"),a=[];if(l.length){for(let u of Array.from(l))try{let h={image:null,name:ve(u,"name"),size:Uy(u),type:ve(u,"type"),subtype:ve(u,"subtype"),alignment:ve(u,"alignment"),ac:Wy(u),hp:Number(Tc(u,"hp")),hit_dice:Tc(u,"hit_dice"),speed:ve(u,"speed"),stats:[Number(ve(u,"str")),Number(ve(u,"dex")),Number(ve(u,"con")),Number(ve(u,"int")),Number(ve(u,"wis")),Number(ve(u,"cha"))],saves:Vy(u),skillsaves:Hy(u),damage_vulnerabilities:ve(u,"vulnerable"),damage_resistances:ve(u,"resist"),damage_immunities:ve(u,"immune"),condition_immunities:ve(u,"conditionImmune"),senses:ve(u,"senses"),languages:ve(u,"languages"),cr:ve(u,"cr"),traits:os(u,"trait"),spells:Fy(u),actions:os(u,"action"),legendary_actions:os(u,"legendary"),reactions:os(u,"reaction"),source:zy(u)};a.push(h)}catch(h){console.error(h);continue}e(a)}},r.readAsText(i)})}function ve(i,e){let t=i.getElementsByTagName(e);if(t&&t.length)return t[0].textContent}function os(i,e){var n;if(!((n=i.getElementsByTagName(e))!=null&&n.length))return[];let t=i.getElementsByTagName(e),r=[];for(let s of Array.from(t)){let o=s.getElementsByTagName("name");if(!o||!o.length||!o[0].textContent||o[0].textContent.includes("Spellcasting"))continue;let l=[],a=s.getElementsByTagName("text");for(let u of Array.from(a))l.push(u.textContent);r.push({name:o[0].textContent,desc:l.join(" ")})}return r}function Fy(i){var r;if(!((r=i.getElementsByTagName("trait"))!=null&&r.length))return[];let t=Array.from(i.getElementsByTagName("trait")).find(n=>{var s;return(s=n.getElementsByTagName("name")[0])==null?void 0:s.textContent.includes("Spellcasting")});return t?Array.from(t.getElementsByTagName("text")).map(n=>n.textContent.replace(/(•|\u2022)/u,"").trim()).filter(n=>n.length):[]}function Hy(i){var r;if(!((r=i.getElementsByTagName("skill"))!=null&&r.length))return[];let e=i.getElementsByTagName("skill")[0].textContent.split(", "),t=[];return e.forEach(n=>{let s=n.split(/\\s[\\+\\-]/);t.push({[s[0]]:Number(s[1])})}),t}var $y={Str:"strength",Dex:"dexterity",Con:"constitution",Int:"intelligence",Wis:"wisdom",Cha:"charisma"};function Vy(i){var r;if(!((r=i.getElementsByTagName("save"))!=null&&r.length))return[];let e=i.getElementsByTagName("save")[0].textContent.split(", "),t=[];return e.forEach(n=>{let s=n.split(/\\s[\\+\\-]/);t.push({[$y[s[0]]]:Number(s[1])})}),t}function Tc(i,e){var s,o;if(!((s=i.getElementsByTagName("hp"))!=null&&s.length))return"";let t=i.getElementsByTagName("hp")[0].textContent,[,r,n]=(o=t.match(/(\\d+) \\(([\\s\\S]+)\\)/))!=null?o:[,"",""];return{hp:r,hit_dice:n}[e]}var qy={T:"tiny",S:"small",M:"medium",L:"large",H:"huge",G:"gargantuan"};function Uy(i){var e;return i.getElementsByTagName("size")&&(e=qy[i.getElementsByTagName("size")[0].textContent])!=null?e:""}function Wy(i){var e;if(i.getElementsByTagName("ac")){let[,t]=(e=i.getElementsByTagName("ac")[0])==null?void 0:e.textContent.match(/(\\d+)/);return Number(t)}return 0}function zy(i){var t,r,n,s,o,l;let e="Unknown";if((t=i.getElementsByTagName("source"))!=null&&t.length)e=i.getElementsByTagName("source")[0].textContent;else if((r=i.getElementsByTagName("trait"))!=null&&r.length&&Array.from(i.getElementsByTagName("trait")).find(a=>{var u;return((u=a.getElementsByTagName("name"))==null?void 0:u[0].textContent)=="Source"})){let a=Array.from(i.getElementsByTagName("trait")).find(u=>{var h,c;return((c=(h=u.getElementsByTagName("name"))==null?void 0:h[0])==null?void 0:c.textContent)=="Source"});e=(o=(s=(n=a==null?void 0:a.getElementsByTagName("text"))==null?void 0:n[0])==null?void 0:s.textContent)==null?void 0:o.replace(/p. \\d+/,"").trim()}else if((l=i.getElementsByTagName("description"))!=null&&l.length){let a=i.getElementsByTagName("description"),u="Source: ";if(a[0].textContent.includes(u)){let h=a[0].textContent.lastIndexOf(u);e=a[0].textContent.slice(h+u.length).split(/, ?/)[0]}}return e}var jy={STR:"strength",DEX:"dexterity",CON:"constitution",INT:"intelligence",WIS:"wisdom",CHA:"charisma"};async function Rc(i){return new Promise((e,t)=>{let r=new FileReader,n=[];r.onload=async s=>{var o,l,a,u,h,c,f,d,p,g,y,b,A,w,E,S,N,M,j,D,H,B,O,W,I,te,Ce,F,Se,k,K,ue,pe,Je,pt,Ht,Wi,Al,Cl,Sl,Dl,El,xl,Tl,kl,Ml,Rl,Nl,Ol,Bl,Pl,Ll,_l;try{let as=JSON.parse(s.target.result),Hc=Object.keys(as).filter(us=>/^Creatures\\./.test(us));for(let us of Hc)try{let ie=as[us],$c={name:ie.Name,source:(o=ie.Source)!=null&&o.trim().length?(l=ie.Source)==null?void 0:l.trim():"Unknown",type:(h=(u=(a=ie.Type)==null?void 0:a.split(/,\\s?/))==null?void 0:u[0])==null?void 0:h.trim(),subtype:"",size:"",alignment:(d=(f=(c=ie.Type)==null?void 0:c.split(/,\\s?/))==null?void 0:f[1])==null?void 0:d.trim(),hp:(p=ie.HP)==null?void 0:p.Value,hit_dice:(b=(y=(g=ie.HP)==null?void 0:g.Notes)==null?void 0:y.replace(/([()])/g,""))==null?void 0:b.trim(),ac:ie.AC.Value,speed:(w=(A=ie.Speed)==null?void 0:A.join(", "))==null?void 0:w.trim(),stats:Object.values((E=ie.Abilities)!=null?E:{}),damage_immunities:(j=(M=(N=(S=ie.DamageImmunities)==null?void 0:S.join("; "))==null?void 0:N.toLowerCase())==null?void 0:M.trim())!=null?j:"",damage_resistances:(O=(B=(H=(D=ie.DamageResistances)==null?void 0:D.join(", "))==null?void 0:H.toLowerCase())==null?void 0:B.trim())!=null?O:"",damage_vulnerabilities:(Ce=(te=(I=(W=ie.DamageVulnerabilities)==null?void 0:W.join(", "))==null?void 0:I.toLowerCase())==null?void 0:te.trim())!=null?Ce:"",condition_immunities:(K=(k=(Se=(F=ie.ConditionImmunities)==null?void 0:F.join(", "))==null?void 0:Se.toLowerCase())==null?void 0:k.trim())!=null?K:"",saves:(pe=(ue=ie.Saves)==null?void 0:ue.map(({Name:ge,Modifier:hs})=>({[jy[ge]]:hs})))!=null?pe:[],skillsaves:(pt=(Je=ie.Skills)==null?void 0:Je.map(({Name:ge,Modifier:hs})=>({[ge]:hs})))!=null?pt:[],senses:(Al=(Wi=(Ht=ie.Senses)==null?void 0:Ht.join(", "))==null?void 0:Wi.trim())!=null?Al:"",languages:(Dl=(Sl=(Cl=ie.Languages)==null?void 0:Cl.join(", "))==null?void 0:Sl.trim())!=null?Dl:"",cr:(xl=(El=ie.Challenge)==null?void 0:El.trim())!=null?xl:"",traits:(kl=(Tl=ie.Traits)==null?void 0:Tl.map(ge=>({name:ge.Name,desc:ge.Content})))!=null?kl:[],actions:(Rl=(Ml=ie.Actions)==null?void 0:Ml.map(ge=>({name:ge.Name,desc:ge.Content})))!=null?Rl:[],bonus_actions:(Ol=(Nl=ie.BonusActions)==null?void 0:Nl.map(ge=>({name:ge.Name,desc:ge.Content})))!=null?Ol:[],reactions:(Pl=(Bl=ie.Reactions)==null?void 0:Bl.map(ge=>({name:ge.Name,desc:ge.Content})))!=null?Pl:[],legendary_actions:(_l=(Ll=ie.LegendaryActions)==null?void 0:Ll.map(ge=>({name:ge.Name,desc:ge.Content})))!=null?_l:[],image:null};n.push($c)}catch(ie){continue}e(n)}catch(as){t()}},r.readAsText(i)})}async function Oc(i){return new Promise((e,t)=>{let r=new FileReader;r.onload=async n=>{try{let s=JSON.parse(n.target.result),o=[fe(s.strength),fe(s.dexterity),fe(s.constitution),fe(s.intelligence),fe(s.wisdom),fe(s.charisma)],l=fe(s.ac),a=tb(s.specials),u=ob(s.spelltype,s.focuspoints,s.cantriplevel,s.spelldc,s.spellattack,s.spells,s.constant),h=s.creature||"Creature",c={layout:"Basic Pathfinder 2e Layout",name:s.name,level:h+" "+s.level.toString(),size:s.size,trait_03:s.type,modifier:fe(s.perception),perception:ib(s.perception),abilities_top:a.filter(d=>d.type===Qy).map(d=>({name:d.name,desc:d.desc})),abilities_mid:a.filter(d=>d.type===Zy).map(d=>({name:d.name,desc:d.desc})),abilities_bot:a.filter(d=>d.type===eb).map(d=>({name:d.name,desc:d.desc})),type:s.type,subtype:"",alignment:s.alignment,ac:l,armorclass:bl(l,fe(s.fortitude),fe(s.reflex),fe(s.will)),hp:fe(s.hp)||1,health:nb(s.hp,s.immunity,s.resistance,s.weakness),attacks:sb(s.strikes),spellcasting:u,speed:s.speed||"5 feet",stats:o,abilityMods:o,damage_vulnerabilities:s.weakness,damage_resistances:s.resistance,damage_immunities:"",condition_immunities:s.immunity,senses:s.perception.note,languages:s.languages,cr:s.level,bestiary:!1,skills:lb(s)},f=ab(s.traits);for(let d=0;d{let t=rb(e.actions),r=Bc(ub(e.description));return{name:e.name,desc:t+r,type:e.type}})}function ib(i){let e=ke(fe(i)),t=i.note?` ${i.note};`:"";return[{name:"Perception",desc:`Perception ${e};${t}`}]}function qi(i){return i<0?`${i} (1d20${i})`:`+${i} (1d20+${i})`}function ke(i){return i>=0?`+${i}`:i.toString()}function bl(i,e,t,r){let n=qi(e),s=qi(t),o=qi(r);return[{name:"AC",desc:`${i}; __Fort__: ${n}; __Ref__: ${s}; __Will__: ${o};`}]}function rb(i){let t={reaction:Gy,one:ls,two:Ky,three:Yy,free:Xy,none:Jy}[i];return t||i}function nb(i,e,t,r){let n=fe(i)||1,s=fe(e),o=fe(t),l=fe(r),a=i.note?` (${i.note});`:"",u=s?` __Immunities__ ${s};`:"",h=o?` __Resistances__ ${o};`:"",c=l?` __Weaknesses__ ${l};`:"";return[{name:"HP",desc:`${n};${a}${u}${h}${c}`}]}function sb(i){return i.map(e=>{let t=e.traits?` (${e.traits});`:"",r=e.damage?` __Damage__ ${Bc(e.damage)}`:"",n=ke(parseInt(e.attack));return{name:e.type,desc:ls+` ${e.name} ${n}${t}${r}`}})}function ob(i,e,t,r,n,s,o){if(s.join(",").split(",").map(c=>c.trim()).filter(c=>c!=="").length===0)return[];let a=e?`${e} Focus Points, `:"",u=10;var h="";for(let c=0;c({skill:n,value:fe(i[n]),note:i[n].note})).filter(n=>n.value!==0).map(n=>`__${zr(n.skill)}__: ${qi(n.value)}`+(n.note?` (${n.note})`:""),"").join(" ");return r.length===0?[]:[{name:"Skills",desc:r}]}function ab(i){let e=i.split(",");return e.forEach(t=>t.trim()),e}function Bc(i){return i.replace(/ ?(\\d+d\\d+( ?[+-] ?\\d+)?)/g," $1 ($1)")}function ub(i){return i.replace(/((Trigger)|(Requirements)|(Effect))/g,"__$1__")}function Nc(i){let e=["th","st","nd","rd"],t=i%100;return i+(e[(t-20)%10]||e[t]||e[0])}function zr(i){return i.replace(/\\w\\S*/g,e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase())}var hb={acrobatics:"dex",arcana:"int",athletics:"str",crafting:"int",deception:"cha",diplomacy:"cha",intimidation:"cha",medicine:"wis",nature:"wis",occultism:"int",performance:"cha",religion:"wis",society:"int",stealth:"dex",survival:"wis",thievery:"dex",lore:"int"},cb=["Tiny","Small","Medium","Large","Huge"];async function Lc(i){return new Promise((e,t)=>{let r=new FileReader;r.onload=()=>{try{let s=JSON.parse(r.result).build,o=s.attributes,l=s.abilities,a=s.proficiencies,u=s.acTotal.acTotal,h=ai(l.str),c=ai(l.dex),f=ai(l.con),d=ai(l.int),p=ai(l.wis),g=ai(l.cha),y=p+a.perception+s.level,b=o.ancestryhp+(o.classhp+o.bonushp+f+o.bonushpPerLevel)*s.level,A=Ui(l.con,a.fortitude,s.level),w=Ui(l.dex,a.reflex,s.level),E=Ui(l.wis,a.will,s.level),S={layout:"Basic Pathfinder 2e Layout",source:"Pathbuilder",sourcebook:i.name,columns:2,name:s.name,player:!0,level:s.level,rare_01:"unique",trait_01:s.ancestry,trait_02:s.heritage,trait_03:s.background,alignment:s.alignment,size:cb[s.size],modifier:y,perception:mb(y),type:s.class,subtype:"",ac:u,armorclass:bl(u,A,w,E),hp:b,health:pb(b,s.resistances),attacks:gb(s.weapons),abilities_top:[{name:"Class DC",desc:String(10+Ui(l[s.keyability],a.classDC,s.level))},bb(s.equipment),vb(s.armor)],abilities_bot:[Pc("Feats",s.feats.map(N=>N[0])),Pc("Specials",s.specials)],abilityMods:[ke(h),ke(c),ke(f),ke(d),ke(p),ke(g)],skills:[yb(l,a,s.level),{name:"Lore",desc:s.lores.map(N=>`[[${N[0]}]] ${qi(Ui(l.int,Number(N[1]),s.level))}`).join(", ")}],speed:`${o.speed+o.speedBonus} feet`,spellcasting:fb(s),damage_vulnerabilities:"",damage_resistances:s.resistances.join(", "),damage_immunities:"",condition_immunities:"",senses:"",languages:s.languages.join(", "),cr:s.level,bestiary:!1,stats:null};e([S])}catch(n){console.error("Error importing Pathbuilder file",n),t(n)}},r.readAsText(i)})}function fb(i){let e=i.spellCasters.map(r=>r.spells.map(n=>n.list.length===0?{}:{name:`${r.name} ${n.spellLevel===0?"Cantrips":`Rank ${n.spellLevel} (${r.perDay[n.spellLevel]})`}`,desc:`[[${n.list.join("]], [[")}]]`})).flat();console.log("getSpells - spells",e);let t=db(i.focus,i.level);return console.log("getSpells - focusSpells",t),[e,t].flat()}function db(i,e){let t=[];return Object.keys(i).forEach(r=>{let n=i[r];Object.keys(n).forEach(s=>{let o=n[s],l=o.focusCantrips;(l==null?void 0:l.length)>0&&t.push({name:`${zr(r)} Focus Cantrips ${ke(o.abilityBonus+o.proficiency+e)}`,desc:`[[${l.join("]], [[")}]]`});let a=o.focusSpells;(a==null?void 0:a.length)>0&&t.push({name:`${zr(r)} Focus Spells ${ke(o.abilityBonus+o.proficiency+e)}`,desc:`[[${a.join("]], [[")}]]`})})}),t}function pb(i,e){let t=e.join(", ");return[{name:"HP",desc:`${i} ${t?`__Resistances__ (${t})`:""}`}]}function gb(i){return i.map(e=>{let t=e.damageBonus?ke(e.damageBonus):"",r="1";return e.str=="striking"?r="2":e.str=="greater striking"&&(r="3"),{name:"Melee",desc:ls+`[[${e.name}|${e.display}]] ${ke(e.attack)} __Damage__ ${r}${e.die}${t} _(${e.damageType})_`}})}function mb(i){let e=ke(i);return[{name:"Perception",desc:`${e} (1d20${e});`}]}function yb(i,e,t){return{name:"Skills",desc:["acrobatics","arcana","athletics","crafting","deception","diplomacy","intimidation","medicine","nature","occultism","performance","religion","society","stealth","survival","thievery"].filter(o=>e[o]>0).map(o=>{let l=o,u=i[hb[o]],h=e[l],c=Ui(u,h,t);return`${zr(l)} ${ke(c)}`}).join(", ")}}function bb(i){let e=[{prefix:"Scroll of ",length:10},{prefix:"Potion of ",length:9},{prefix:"Wand of ",length:7}];function t(o){for(let{prefix:a,length:u}of e)if(o.startsWith(a))return`${a}[[${o.slice(u)}]]`;let l=o.match(/ \\+(\\d)$/);return l&&(o=o.slice(0,-3)+` (+${l[1]})`),`[[${o}]]`}function r(o){return o.map(([l,a])=>[t(l),a])}function n(o){return o.map(([l,a])=>`${a>1?`${a}x `:""}${l}`).join(", ")}let s=r(i);return{name:"Items",desc:n(s)}}function vb(i){return{name:"Armor",desc:i.map(e=>`${e.qty>1?String(e.qty)+"x ":""}[[${e.name}${e.display?"|"+e.display:""}]]`).join(", ")}}function Pc(i,e){return{name:i,desc:"[["+e.join("]], [[")+"]]"}}function ai(i){return Math.floor((i-10)/2)}function Ui(i,e,t){return ai(i)+e+t}var _c={0:{cr:"0",value:0,xp:0},"1/8":{cr:"1/8",value:.125,xp:25},"1/4":{cr:"1/4",value:.25,xp:50},"1/2":{cr:"1/2",value:.5,xp:100},"0.125":{cr:"1/8",value:.125,xp:25},"0.25":{cr:"1/4",value:.25,xp:50},"0.5":{cr:"1/2",value:.5,xp:100},1:{cr:"1",value:1,xp:200},2:{cr:"2",value:2,xp:450},3:{cr:"3",value:3,xp:700},4:{cr:"4",value:4,xp:1100},5:{cr:"5",value:5,xp:1800},6:{cr:"6",value:6,xp:2300},7:{cr:"7",value:7,xp:2900},8:{cr:"8",value:8,xp:3900},9:{cr:"9",value:9,xp:5e3},10:{cr:"10",value:10,xp:5900},11:{cr:"11",value:11,xp:7200},12:{cr:"12",value:12,xp:8400},13:{cr:"13",value:13,xp:1e4},14:{cr:"14",value:14,xp:11500},15:{cr:"15",value:15,xp:13e3},16:{cr:"16",value:16,xp:15e3},17:{cr:"17",value:17,xp:18e3},18:{cr:"18",value:18,xp:2e4},19:{cr:"19",value:19,xp:22e3},20:{cr:"20",value:20,xp:25e3},21:{cr:"21",value:21,xp:33e3},22:{cr:"22",value:22,xp:41e3},23:{cr:"23",value:23,xp:5e4},24:{cr:"24",value:24,xp:62e3},25:{cr:"25",value:25,xp:75e3},26:{cr:"26",value:26,xp:9e4},27:{cr:"27",value:27,xp:105e3},28:{cr:"28",value:28,xp:12e4},29:{cr:"29",value:29,xp:135e3},30:{cr:"30",value:30,xp:155e3}};function Ct(i){return Math.floor(((i!=null?i:10)-10)/2)}var Ic={tiny:4,small:6,medium:8,large:10,huge:12,gargantuan:20},wb={str:"strength",dex:"dexterity",con:"constitution",int:"intelligence",wis:"wisdom",cha:"charisma"},vl=class i{constructor(e){this.monster=e;this.proficiency=this.getProf(this.monster);this.stats={str:this.monster.strPoints,dex:this.monster.dexPoints,con:this.monster.conPoints,int:this.monster.intPoints,wis:this.monster.wisPoints,cha:this.monster.chaPoints};this.modifiers={str:Ct(this.stats.str),dex:Ct(this.stats.dex),con:Ct(this.stats.con),int:Ct(this.stats.int),wis:Ct(this.stats.wis),cha:Ct(this.stats.cha)}}static parse(e){var n,s,o,l,a,u,h,c,f,d,p,g,y,b,A,w;let t=new i(e);return{image:null,name:e.name,source:"TetraCube",type:e.type,subtype:e.tag,size:e.size,alignment:e.alignment,hp:(n=t.getHP(e))==null?void 0:n.hp,hit_dice:(s=t.getHP(e))==null?void 0:s.dice,ac:(a=(l=((o=e.ac)!=null?o:[])[0])==null?void 0:l.ac)!=null?a:"",speed:t.getSpeedString(e),stats:[e.strPoints,e.dexPoints,e.conPoints,e.intPoints,e.wisPoints,e.chaPoints],damage_immunities:t.parseImmune(e,"i"),damage_resistances:t.parseImmune(e,"r"),damage_vulnerabilities:t.parseImmune(e,"v"),condition_immunities:t.parseConditions(e),saves:t.getSaves(e),skillsaves:t.getSkills(e),senses:t.getSenses(e),languages:t.getLanguages(e),cr:(u=e.cr)!=null?u:"",traits:t.getTraits(e.abilities),actions:t.getTraits(e.actions),bonus_actions:t.getTraits(e.bonusActions),reactions:t.getTraits(e.reactions),legendary_description:(h=e.isLegendary)!=null&&h?e.legendariesDescription:null,legendary_actions:(c=e.isLegendary)!=null&&c?t.getTraits(e.legendaries):null,mythic_description:(f=e.isMythic)!=null&&f?e.mythicDescription:null,mythic_actions:(d=e.isMythic)!=null&&d?t.getTraits(e.mythics):null,lair_description:(p=e.isLair)!=null&&p?e.lairDescription:null,lair_actions:(g=e.isLair)!=null&&g?t.getTraits(e.lairs):null,lair_description_end:(y=e.isLair)!=null&&y?e.lairDescriptionEnd:null,regional_description:(b=e.isRegional)!=null&&b?e.regionalDescription:null,regional_actions:(A=e.isRegional)!=null&&A?t.getTraits(e.regionals):null,regional_description_end:(w=e.isRegional)!=null&&w?e.regionalDescriptionEnd:null,spells:t.getSpells(e.abilities)}}getHP(e){var t,r;if(e.customHP||e.hitDice&&/(\\d+) \\((.+)\\)/.test(e.hpText)){let[n,s,o]=(t=e.hpText.match(/(\\d+) \\((.+)\\)/))!=null?t:[];return{hp:s,dice:o}}if(e.hitDice){let n=Number(e.hitDice),s=(r=Ic[e.size])!=null?r:Ic.medium,o=this.modifiers.con,l=n*s/(2+.5)+o*n,a=o>0?"+":"-",u=o==0?"":` ${a} ${o*n}`;return{hp:l,dice:`${n}d${s}${u}`}}}getSpeedString(e){if(e.customSpeed)return e.speedDesc;let t=[e.speed+" ft."];return e.burrowSpeed>0&&t.push("burrow "+e.burrowSpeed+" ft."),e.climbSpeed>0&&t.push("climb "+e.climbSpeed+" ft."),e.flySpeed>0&&t.push("fly "+e.flySpeed+" ft."+(e.hover?" (hover)":"")),e.swimSpeed>0&&t.push("swim "+e.swimSpeed+" ft."),t.join(", ")}parseImmune(e,t){let r=[];"damagetypes"in e&&Array.isArray(e.damagetypes)&&r.push(...e.damagetypes.filter(s=>s.type==t).map(s=>s.name));let n=[];return"specialdamage"in e&&Array.isArray(e.specialdamage)&&n.push(...e.specialdamage.filter(s=>s.type==t).map(s=>s.name)),[r.join(", "),n.join(", ")].filter(s=>s&&s.length).join("; ")}getLanguages(e){let t=[],r=[],n=[];for(let s=0;s0&&t.push([r.slice(0,r.length-2).map(s=>s.name).join(", "),r.slice(-1).map(s=>s.name)].filter(s=>s).join(" and ")),n.length>0&&t.push([n.slice(0,n.length-2).map(s=>s.name).join(", "),n.slice(-1).map(s=>s.name)].filter(s=>s).join(" and ")),e.telepathy>0&&t.push("telepathy "+e.telepathy+" ft."),t.length==0&&t.push("—"),t.join("; ")}getSenses(e){let t=[];e.blindsight>0&&t.push("blindsight "+e.blindsight+" ft."+(e.blind?" (blind beyond this radius)":"")),e.darkvision>0&&t.push("darkvision "+e.darkvision+" ft."),e.tremorsense>0&&t.push("tremorsense "+e.tremorsense+" ft."),e.truesight>0&&t.push("truesight "+e.truesight+" ft.");let r=e.skills.find(s=>s.name=="perception"),n=10+Ct(e.wisPoints);return r!=null&&(n+=this.proficiency*("note"in r?2:1)),t.push("passive Perception "+n),t.join(", ")}transformString(e){return e.replace(/(_|\\*|\\s*>\\s*)/g,"").replace(/\\[MON(S)?\\]/g,`${this.monster.shortName&&this.monster.shortName.length?this.monster.shortName:this.monster.name}$1`).replace(/\\[(\\w+)\\]/g,(t,r)=>{if(r=r.toLowerCase(),!(r in this.modifiers))return t;let n=this.modifiers[r];return`${n>=0?"+":""}${n}`}).replace(/\\[(\\w+) (ATK|SAVE)\\s?(?:([+-])\\s?(\\d+))?\\]/g,(t,r,n="ATK",s="+",o=0)=>{if(r=r.toLowerCase(),!(r in this.modifiers))return t;o=s=="+"?Number(o):-Number(o);let l=(n=="ATK"?0:8)+this.modifiers[r]+this.proficiency+o;return`${l>=0?"+":""}${l}`}).replace(/\\[(\\w+)?\\s?(\\d*[dD]\\d+)\\s?(?:([+-])\\s?(\\d+))?\\]/g,(t,r,n,s="+",o=0)=>{var c;r=r.toLowerCase();let[,l=1,a]=(c=n.match(/(\\d*)[dD](\\d+)/))!=null?c:[];if(l||(l=1),!a)return t;o=s=="+"?Number(o):-Number(o),r in this.modifiers&&(o+=this.modifiers[r]);let u=Math.floor((a/2+.5)*l)+o,h=[`${l}d${a}`];return o&&o!=0&&(h.push(o>=0?"+":"-"),h.push(o)),`${u} (${h.join(" ")})`})}getTraits(e){return!e||!e.length?void 0:e.filter(r=>r.name!="Spellcasting").map(r=>({name:r.name,desc:this.transformString(r.desc)}))}getSpells(e){var n;if(!e.abilities||!e.abilities.length)return;let{desc:t}=(n=e.abilities.find(s=>s.name=="Spellcasting"))!=null?n:{};return t?this.transformString(t).trim().split(`\n`).filter(s=>s.length):void 0}getSaves(e){if(!("sthrows"in e)||!Array.isArray(e.sthrows)||!e.sthrows.length)return[];let t=this.proficiency,r=[];for(let n of e.sthrows){let s=n.name,o=Ct(Number(e[`${s}Points`]));isNaN(o)||r.push({[wb[s]]:o+t})}return r}getSkills(e){if(!("skills"in e)||!Array.isArray(e.skills)||!e.skills.length)return[];let t=[],r=this.proficiency;for(let n of e.skills){let s=n.stat,o=Ct(Number(e[`${s}Points`]));if(isNaN(o))continue;let l="note"in n;t.push({[n.name]:r+o+o*Number(l)})}return t}getProf(e){var r,n;let t=0;return e.cr=="*"&&(t=e.customProf),"cr"in e&&e.cr in _c&&(t=Math.max(Math.floor(2+(((n=(r=_c[e.cr])==null?void 0:r.value)!=null?n:0)-1)/4),2)),isNaN(Number(t))?0:Number(t)}parseConditions(e){if("conditions"in e&&Array.isArray(e.conditions))return e.conditions.map(t=>t.name).join(", ")}};async function Fc(i){return new Promise((e,t)=>{let r=new FileReader,n=[];r.onload=async s=>{try{let o=JSON.parse(s.target.result),l;"monster"in o?l=o.monster:Array.isArray(o)?l=o:typeof o=="object"?l=[o]:t("Invalid monster JSON provided.");let a=[];for(let u of l)try{let h=vl.parse(u);a.push(h)}catch(h){console.error(h);continue}e(a)}catch(o){console.error("reject!!!",o),t(o)}},r.readAsText(i)})}var wl=self;wl.onmessage=async i=>{if(!i.data)return;let{files:e,source:t}=i.data,r=[];for(let n of e)switch(t){case"5e":{let s=await ph(n);r.push(...s!=null?s:[]);break}case"critter":{let s=await gh(n);r.push(...s!=null?s:[]);break}case"improved":{let s=await Rc(n);r.push(...s!=null?s:[]);break}case"appfile":{let s=await Mc(n);r.push(...s!=null?s:[]);break}case"tetra":{let s=await Fc(n);r.push(...s!=null?s:[]);break}case"PF2eMonsterTool":{let s=await Oc(n);r.push(...s!=null?s:[]);break}case"pathbuilder":{let s=await Lc(n);r.push(...s!=null?s:[]);break}case"generic":{let s=await new Promise((o,l)=>{let a=new FileReader;a.onload=async u=>{try{let h=JSON.parse(u.target.result),c=[];if(Array.isArray(h))c=h;else if(typeof h=="object")if("name"in h)c=[h];else for(let d in h)Array.isArray(h[d])&&c.push(...h[d]);else l("Invalid monster JSON provided. Must be array or object.");let f=[];for(let d of c)"name"in d&&f.push(d);o(f)}catch(h){console.error("reject!!!",h),l(h)}},a.readAsText(n)});r.push(...s!=null?s:[])}default:console.error(`Unknown source: ${t}`)}wl.postMessage({monsters:r})};wl.addEventListener("unhandledrejection",function(i){throw i.reason});\n')}var Wi=require("obsidian");var wl=class extends wt{constructor(){super(...arguments);this.saved=!1}display(){this.titleEl.createSpan({text:"Set Sources"}),new Wi.Setting(this.contentEl).setName("A source could not be found for some imported monsters. Do you wish to manually add one?").addText(t=>{t.setPlaceholder("Unknown").onChange(i=>{this.source=i})}),this.buildButtons(this.contentEl)}buildButtons(t){new Wi.Setting(t).addButton(i=>i.setCta().setIcon("checkmark").setTooltip("Save").onClick(()=>{this.saved=!0,this.close()})).addExtraButton(i=>i.setIcon("cross").setTooltip("Cancel").onClick(()=>{this.close()}))}onOpen(){this.display()}},G0=async n=>new Promise(e=>{let t=new wl(n);t.onClose=()=>{t.saved||e(null),e(t.source)},t.open()}),Sa=class{constructor(e){this.plugin=e;this.workers=new Map}async import(e,t){return new Promise(i=>{let a=new kl,s=U();this.workers.set(s,a),a.onmessage=async r=>{let{monsters:o}=r.data??{monsters:[]};if(o){new Wi.Notice(`Successfully imported ${o.length} Monsters`);let l=o.filter(d=>d.source=="Unknown"||!d.source),c;l.length&&(c=await G0(this.plugin))&&l.forEach(d=>d.source=c)}a.terminate(),this.workers.delete(s),i(o)},a.onerror=r=>{new Wi.Notice(`There was an error importing the file. ${r.message}`),a.terminate(),this.workers.delete(s),i([])},a.postMessage({files:e,source:t})})}};var K0=[{type:"inline",id:U(),properties:[],hasRule:!0,nested:[{type:"group",id:U(),properties:["name","description","aspects","temporaryAspects"],nested:[{type:"heading",id:U(),properties:["name"],conditioned:!0,size:1},{type:"text",id:U(),properties:["description"],conditioned:!0,markdown:!0,text:null,dice:!1},{type:"text",id:U(),properties:["aspects"],markdown:!0,text:null,dice:!1,conditioned:!0,heading:"Aspects"},{type:"text",id:U(),properties:["temporaryAspects"],markdown:!0,text:null,dice:!1,conditioned:!0,heading:"Temporary Aspects"}],conditioned:!0},{type:"image",id:U(),properties:["image"],conditioned:!0}]},{type:"table",id:U(),properties:["stress"],headers:["Physical","Mental"],calculate:!1,hasRule:!0,conditioned:!0},{type:"traits",id:U(),properties:["consequences"],conditioned:!0,heading:"Consequences"},{type:"traits",id:U(),properties:["skills"],conditioned:!0,hasRule:!1,heading:"Skills"},{type:"traits",id:U(),properties:["stunts"],markdown:!0,dice:!1,conditioned:!0,heading:"Stunts"},{type:"traits",id:U(),properties:["items"],heading:"Items",conditioned:!0,markdown:!0,dice:!1},{type:"traits",id:U(),properties:["extras"],heading:"Extras",conditioned:!0,markdown:!0,dice:!1}],Th={blocks:K0,id:"basic-fate-core-layout",name:"Basic Fate Core Layout",edited:!1};var UA=[{type:"inline",id:U(),properties:[],hasRule:!0,nested:[{type:"group",id:U(),properties:["name","description","aspects","temporaryAspects"],nested:[{type:"heading",id:U(),properties:["name"],conditioned:!0,size:1},{type:"text",id:U(),properties:["description"],conditioned:!0,markdown:!0,text:null,dice:!1},{type:"text",id:U(),properties:["aspects"],markdown:!0,text:null,dice:!1,conditioned:!0,heading:"Aspects"},{type:"text",id:U(),properties:["temporaryAspects"],markdown:!0,text:null,dice:!1,conditioned:!0,heading:"Temporary Aspects"}],conditioned:!0},{type:"image",id:U(),properties:["image"],conditioned:!0}]},{type:"table",id:U(),properties:["stress"],headers:["Physical","Mental"],calculate:!1,hasRule:!0,conditioned:!0},{type:"traits",id:U(),properties:["consequences"],conditioned:!0,heading:"Consequences"},{type:"traits",id:U(),properties:["skills"],conditioned:!0,hasRule:!1,heading:"Skills"},{type:"traits",id:U(),properties:["stunts"],markdown:!0,dice:!1,conditioned:!0,heading:"Stunts"},{type:"traits",id:U(),properties:["items"],heading:"Items",conditioned:!0,markdown:!0,dice:!1},{type:"traits",id:U(),properties:["extras"],heading:"Extras",conditioned:!0,markdown:!0,dice:!1}],Dh={blocks:[{type:"inline",id:"e9b8483aeafa",properties:[],nested:[{type:"property",id:"2b596a6919fb",properties:["name"],fallback:"-",markdown:!0,dice:!1,conditioned:!0,display:" "},{type:"property",id:"98389a48f808",properties:["level"],fallback:"-",display:" ",conditioned:!0,markdown:!0,dice:!1}],hasRule:!0},{type:"group",id:"4b3a6809a938",properties:[],nested:[{type:"inline",id:"289a4b787968",properties:[],nested:[{type:"property",id:"694a3888b859",properties:["rare_01"],fallback:"-",conditioned:!0,markdown:!0},{type:"property",id:"590a88988ae8",properties:["rare_02"],fallback:"-",conditioned:!0,markdown:!0},{type:"property",id:"9a9be808699a",properties:["rare_03"],fallback:"-",conditioned:!0,markdown:!0},{type:"property",id:"2988db1a685a",properties:["rare_04"],fallback:"-",conditioned:!0,markdown:!0},{type:"property",id:"ba891ba8cbeb",properties:["alignment"],fallback:" ",display:" ",conditioned:!0,markdown:!0},{type:"property",id:"ebf9883938a8",properties:["size"],fallback:" ",display:" ",conditioned:!0,markdown:!0},{type:"property",id:"dabaf9e9fb68",properties:["trait_01"],fallback:" ",display:" ",conditioned:!0,markdown:!0},{type:"property",id:"e81a6aeadbf9",properties:["trait_02"],fallback:" ",display:" ",conditioned:!0,markdown:!0},{type:"property",id:"fa7919caabbb",properties:["trait_03"],fallback:"-",conditioned:!0,display:" ",markdown:!0},{type:"property",id:"58c9c8580b68",properties:["trait_04"],fallback:"-",conditioned:!0,display:" ",markdown:!0},{type:"property",id:"da894a7b8849",properties:["trait_05"],fallback:"-",display:" ",conditioned:!0,markdown:!0},{type:"property",id:"fb6b4b6bab49",properties:["trait_06"],fallback:"-",display:" ",conditioned:!0,markdown:!0},{type:"property",id:"480a5bfafb88",properties:["trait_07"],fallback:"-",display:" ",conditioned:!0,markdown:!0}],hasRule:!0,conditioned:!0}]},{type:"group",id:"5999ea79ca3b",properties:[],nested:[{type:"traits",id:"9a9af9fbe959",properties:["perception"],fallback:"-",heading:" ",conditioned:!0,dice:!0,markdown:!0,headingProp:!0},{type:"property",id:"ba28f9384918",properties:["languages"],fallback:"-",display:"Language",conditioned:!0,markdown:!0},{type:"traits",id:"a8f8187b89fb",properties:["skills"],fallback:"-",markdown:!0,dice:!0,conditioned:!0,heading:" "},{type:"table",id:"b82b0a1a9969",properties:["abilityMods"],headers:["Str","Dex","Con","Int","Wis","Cha"],calculate:!1,fallback:"-",conditioned:!0,dice:!0},{type:"traits",id:"e96ba9d8a80a",properties:["abilities_top"],fallback:"-",conditioned:!0,dice:!0,markdown:!0,heading:" ",hasRule:!1}],hasRule:!0},{type:"group",id:"faaa08993a98",properties:[],nested:[{type:"traits",id:"68ca69891bea",properties:["armorclass"],fallback:"-",heading:"",conditioned:!0,dice:!0,markdown:!0},{type:"traits",id:"9b1998e9a8da",properties:["health"],fallback:"-",heading:"",conditioned:!0,dice:!0,markdown:!0},{type:"traits",id:"ca2bf968987b",properties:["abilities_mid"],fallback:"-",heading:"",conditioned:!0,dice:!0,markdown:!0,hasRule:!1}],hasRule:!0},{type:"group",id:"cbeabaf93b58",properties:[],nested:[{type:"property",id:"0b4809ba0b29",properties:["speed"],fallback:"-",display:"Speed",conditioned:!0,markdown:!0,dice:!1},{type:"traits",id:"882bc9aa0898",properties:["attacks"],fallback:"-",conditioned:!0,dice:!0,markdown:!0,headingProp:!1,heading:""},{type:"traits",id:"6919b8996939",properties:["spellcasting"],fallback:"-",heading:" ",markdown:!0,dice:!0,conditioned:!0},{type:"traits",id:"aacb399a3b58",properties:["abilities_bot"],fallback:"-",conditioned:!0,dice:!0,markdown:!0,hasRule:!1}],hasRule:!0},{type:"text",id:"1b195a894b58",properties:["token"],text:null,fallback:"",heading:"Show to Players",conditioned:!0,markdown:!0},{type:"image",id:"1bba89582b29",properties:["token"],fallback:"",conditioned:!0,hasRule:!0},{type:"property",id:"88e97a485b79",properties:["sourcebook"],fallback:"-",conditioned:!0,markdown:!0,dice:!1,display:" Source:"}],name:"Basic Pathfinder 2e Layout",id:"path-2e-block",version:2,diceParsing:[{regex:/\((\d+d\d+(?:\s*[+-]\s*\d+)?)\)/.source,parser:`const [, text] = matches; return ["(", { text }, ")"];`,id:U(),desc:"(1d8+3)"},{regex:/(\w+?) ([+-])(\d+)/.source,parser:`let [, initial, sign, number] = matches; let mult = 1; if (sign === "-") { mult = -1; } let text; if (!isNaN(Number(number))) { text = \`1d20+\${mult * Number(number)}\`; } return [original, " (", { text }, ")"];`,id:U(),desc:"longsword +15"}]};var Eh={blocks:[{type:"inline",id:"2a9b58ba0ab8",properties:[],nested:[{type:"heading",id:"c89a2ae859f8",properties:["name"],size:1,fallback:"Creature"},{type:"image",id:"e83a48f858b8",properties:["image"],fallback:"TILE ART",conditioned:!0,hasRule:!1}],hasRule:!0},{type:"group",id:"fabb0b884838",properties:[],nested:[{type:"text",id:"5b7bc86b6919",properties:["flavor_text"],text:null,fallback:"-",conditioned:!0,markdown:!0,hasRule:!1}],cls:"flavor-text",hasRule:!0},{type:"group",id:"1a6999887a69",properties:[],nested:[{type:"javascript",id:"d958f898e9fa",conditioned:!1,code:`var base_string = \`\${monster.level} level \${monster.role}\`; if (monster.size) { base_string = \`\${monster.size} \${base_string}\`; } const monster_strength = document.createElement("p"); monster_strength.innerHTML = base_string; monster_strength.classList.add("monster-strength"); if (monster.type) { const type = \`[\${monster.type}]\`; const type_block = document.createElement("span"); type_block.classList.add("type"); type_block.innerText = type; monster_strength.append(type_block) } return monster_strength;`},{type:"property",id:"780809c90898",properties:["initiative"],fallback:"+0",display:"Initiative: ",markdown:!0},{type:"property",id:"88eb4a6aea0b",properties:["vulnerability"],fallback:"-",display:"Vulnerability: ",conditioned:!0,markdown:!0}],hasRule:!0},{type:"group",id:"999bb81b7aab",properties:[],nested:[{type:"traits",id:"996ab9d9a86a",properties:["actions"],fallback:"-",markdown:!0,hasRule:!0},{type:"traits",id:"69ca5b7a3898",properties:["traits"],fallback:"-",conditioned:!0,markdown:!0,hasRule:!0},{type:"traits",id:"c8794b580948",properties:["triggered_actions"],fallback:"-",headingProp:!1,heading:"Triggered Abilities",conditioned:!0,markdown:!0,hasRule:!0},{type:"traits",id:"aa1a3a2abb19",properties:["nastier_traits"],fallback:"-",headingProp:!1,heading:"Nastier Specials",conditioned:!0,subheadingText:"",markdown:!0,hasRule:!0}],hasRule:!1,cls:"abilities"},{type:"group",id:"8a7969a96a48",properties:[],nested:[{type:"javascript",id:"f99b8b1bf908",conditioned:!1,code:`const getStatLine = (statName, statValue) => { const statLine = document.createElement("div"); const statClass = \`\${statName.toLowerCase()}-block\`; statLine.classList.add("defense-line"); statLine.classList.add(statClass); const statNameBlock = document.createElement("span"); statNameBlock.classList.add("defense-name"); statNameBlock.innerText = statName.toUpperCase(); const statValueBlock = document.createElement("span"); statValueBlock.classList.add("defense-value"); if (statName === "HP" && monster.mook !== undefined) { statValue = \`\${statValue} (mook)\`; } statValueBlock.innerText = statValue; statLine.append(statNameBlock); statLine.append(statValueBlock); return statLine; } const statFullBlock = document.createElement("div"); statFullBlock.classList.add("defense-block"); statFullBlock.append(getStatLine("AC", monster.ac)); statFullBlock.append(getStatLine("PD", monster.pd)); statFullBlock.append(getStatLine("MD", monster.md)); statFullBlock.append(getStatLine("HP", monster.hp)); return statFullBlock; `},{type:"property",id:"6aa9684a08db",properties:["mook"],fallback:"-",display:"Mook",conditioned:!0,callback:"return `Kill one _${monster.name}_ for every ${monster.hp} damage dealt to the mob`",markdown:!0}],cls:"monster-stats"},{type:"group",id:"a96bcabad818",properties:[],nested:[{type:"text",id:"4a0b6a59385a",properties:["description"],text:null,conditioned:!0,fallback:"-",markdown:!0}],cls:"monster-description"}],name:"Basic 13th Age Monster Layout",id:"basic-13th-age-monster-block"};var Mh={blocks:[{type:"group",id:"0a58d8280a7b",properties:[],nested:[{type:"image",id:"48db7bfb6809",properties:["Token"],fallback:"-",conditioned:!0}]},{type:"group",id:"b8e9ea5a5b68",properties:[],nested:[{type:"inline",id:"7a3a6b3ad9d9",properties:[],nested:[{type:"heading",id:"0a982a598818",properties:["Name"],size:1,fallback:"-"},{type:"property",id:"cb1a28885afb",properties:["Type"],fallback:"Unknown.",conditioned:!1,display:" "}]},{type:"subheading",id:"4b3848590a48",properties:["TitleOfMob","FlavorText","TypeOfBoss"],separator:" , ",fallback:"-",conditioned:!0}],hasRule:!0},{type:"group",id:"fb98fb48f93a",properties:[],nested:[{type:"inline",id:"3898c8ea0bf9",properties:[],nested:[{type:"property",id:"a8980a09e92a",properties:["BadassRank"],fallback:" ",conditioned:!1,display:" "},{type:"property",id:"c83a18fb2ac9",properties:["MovementType"],fallback:" ",display:" ",callback:`const Move = monster.MovementType; const Types = ['move', 'flight', 'swim', 'burrow', 'teleport', 'leap', 'hover', 'climb',]; const Symbols = ['\u2B47', '\u{E1502}', '\u{E1504}', '\u{E1506}', '\u{E1503}', '\u{E1501}', '\u{E1500}', '\u{E1505}',]; let Output = ''; for (let i = 0; i < Types.length; i++) { for (let j = 0; j <= 10; j++) { if (Move.includes(\`\${Types[i]} \${j}\`)) { Output += \`\${Symbols[i]} \${j} Square\${j > 1 ? 's' : ''}\\n\`; } } } return Output.trim();`},{type:"inline",id:"59e8dad80b6b",properties:[],nested:[{type:"property",id:"d8d98b8b6bfa",properties:["Health"],fallback:"Dead",conditioned:!0,display:"Health:"},{type:"property",id:"c969ebe85aca",properties:["Shield"],fallback:"N/A",display:"Shield:",conditioned:!0},{type:"property",id:"b95a6a68e89b",properties:["Armor"],fallback:"N/A",conditioned:!0,display:"Armor:"},{type:"property",id:"cb4a68db0ad8",properties:["Traits"],fallback:"N/A",display:"Traits:",conditioned:!0,markdown:!0}],cls:"shat"}],cls:"bomshat"}]},{type:"group",id:"2a99795abbb8",properties:[],nested:[{type:"property",id:"1a4aaa3b78e9",properties:["Weapon"],fallback:"N/A",conditioned:!1,dice:!0,display:"Weapon:"},{type:"property",id:"4a8b3ae86bb8",properties:["Special"],fallback:"-",display:"Special:",dice:!0,markdown:!0},{type:"property",id:"d85b69696908",properties:["SuperSpecial"],fallback:"-",display:"Additional Effects:",conditioned:!0,markdown:!0,dice:!0,hasRule:!0}],hasRule:!1},{type:"group",id:"8ae89989a83b",properties:[],nested:[{type:"traits",id:"cb28b8484afa",properties:["Actions"],fallback:"-",heading:"Actions",conditioned:!0,hasRule:!1,markdown:!0,dice:!0},{type:"traits",id:"5beae9c80838",properties:["Mayhem"],fallback:"-",conditioned:!0,heading:"\u{E1531} Mayhem",dice:!0,markdown:!0},{type:"traits",id:"ea6b78db3b59",properties:["Loot"],fallback:"-",heading:"Loot",conditioned:!0,dice:!0,markdown:!0}],hasRule:!1,cls:""},{type:"group",id:"283a2b39ca3a",properties:[],nested:[{type:"text",id:"8a78b8393819",properties:["Image"],text:null,fallback:"-",heading:"",conditioned:!0},{type:"image",id:"2b09ea3958fa",properties:["Image"],fallback:"-",conditioned:!0}],cls:"biggies"}],id:"basic-bnb-bestiary-layout",name:"Basic BnB Bestiary Layout",edited:!1};var Ih={blocks:[{type:"inline",id:"aabbab5bb92a",properties:[],nested:[{type:"image",id:"a80b9a1a791b",properties:["Token"],fallback:"-",conditioned:!0}]},{type:"inline",id:"19788a293819",properties:[],nested:[{type:"heading",id:"bb98085bdbab",properties:["Name"],fallback:"Unknown",conditioned:!1,size:1},{type:"property",id:"f97b886ba819",properties:["Type"],fallback:"Unknown",display:"",conditioned:!0,markdown:!0,dice:!1}],hasRule:!0},{type:"group",id:"c81968abe80b",properties:[],nested:[{type:"inline",id:"4809ea49d92a",properties:[],nested:[{type:"inline",id:"48f93a487988",properties:[],nested:[{type:"property",id:"4dc7e12b6c6c",properties:["MovementType"],fallback:"-",display:" ",conditioned:!0,callback:`const Move = monster.MovementType; const Types = ['move', 'flight', 'swim', 'burrow', 'teleport', 'leap', 'hover', 'climb',]; const Symbols = ['\u2B47', '\u{E1502}', '\u{E1504}', '\u{E1506}', '\u{E1503}', '\u{E1501}', '\u{E1500}', '\u{E1505}',]; let Output = ''; for (let i = 0; i < Types.length; i++) { for (let j = 0; j <= 10; j++) { if (Move.includes(\`\${Types[i]} \${j}\`)) { Output += \`\${Symbols[i]} \${j} Square\${j > 1 ? 's' : ''}\\n\`; } } } return Output.trim();`,markdown:!1,hasRule:!1},{type:"inline",id:"294ad96ad9ba",properties:[],nested:[{type:"property",id:"4a3beb0948e9",properties:["Health"],fallback:"-",display:"Health:",conditioned:!0},{type:"property",id:"7ac8d84999bb",properties:["Regen"],fallback:"-",display:"HP Regen:",conditioned:!0,dice:!0},{type:"property",id:"ea8b1b5bfb4a",properties:["Shield"],fallback:"",display:"Shield:",conditioned:!0},{type:"property",id:"596b79ab7b6a",properties:["Charge"],fallback:"-",display:"SH Charge:",conditioned:!0,dice:!0},{type:"property",id:"f8aa6b4a396a",properties:["Armor"],fallback:"-",display:"Armor:",conditioned:!0},{type:"property",id:"8a2a6a691918",properties:["Repair"],fallback:"-",display:"AR Repair:",conditioned:!0,dice:!0},{type:"property",id:"2b5b9b0b689b",properties:["Traits"],fallback:"-",conditioned:!0,display:"Traits:"}],cls:"familiar-tams"}],cls:""}],hasRule:!1,cls:"move-shat"},{type:"table",id:"cb4bdb99abdb",properties:["Abilityscore"],headers:["ACC","DMG","SPD","MST"],calculate:!1,fallback:"-",conditioned:!0,dice:!0},{type:"property",id:"494b58086a5a",properties:["Damage"],fallback:"-",display:"Damage:",conditioned:!0,dice:!0,hasRule:!0}],hasRule:!1,conditioned:!0},{type:"group",id:"eaa94ab86ba9",properties:[],nested:[{type:"property",id:"3a4a88da394a",properties:["Weapon"],fallback:"N/A",markdown:!0,display:"Weapon:",dice:!0,conditioned:!0},{type:"property",id:"5a8b7b08b8ca",properties:["Special"],fallback:"N/A",display:"Special:",markdown:!0,hasRule:!1,dice:!0,conditioned:!0},{type:"traits",id:"b9da9b7a6958",properties:["SuperSpecial"],fallback:"-",conditioned:!0,dice:!0,markdown:!0}],hasRule:!0,conditioned:!0},{type:"group",id:"799ada4bc8c9",properties:[],nested:[{type:"table",id:"5a2bdb7819b8",properties:["Hit-Crit"],headers:["2-7","8-15","16+"],calculate:!1,fallback:"-",conditioned:!0,dice:!0},{type:"traits",id:"ea68aaba0819",properties:["Actions"],fallback:"-",heading:"Actions",conditioned:!0,markdown:!0,dice:!0},{type:"traits",id:"d979ba0a69da",properties:["Skills"],fallback:"-",headingProp:!1,heading:"Skills",conditioned:!0,markdown:!0,dice:!0}],conditioned:!1,hasRule:!0},{type:"image",id:"999b68298919",properties:["Image"],fallback:"-",conditioned:!0}],id:"basic-bnb-familiar-layout",name:"Basic BnB Familiar Layout",edited:!1};var ci=[rn,Th,Dh,Eh,Mh,Ih];var ui=require("obsidian");function $0(n){re(n,"svelte-xx603q",".pagination.svelte-xx603q.svelte-xx603q{display:flex;justify-content:space-between;align-items:center;gap:1rem}.paginated-container.svelte-xx603q.svelte-xx603q{display:flex;align-items:center;gap:1rem}.paginated.svelte-xx603q.svelte-xx603q{display:flex;align-items:center;gap:1rem}.clickable-icon.active.svelte-xx603q.svelte-xx603q{background-color:var(--background-modifier-hover)}.slicer.svelte-xx603q.svelte-xx603q{display:flex;align-items:center;gap:0.5rem}.slicer.svelte-xx603q .per.svelte-xx603q{color:var(--text-muted);font-size:var(--font-smallest)}")}function Oh(n,e,t){let i=n.slice();return i[16]=e[t],i}function Y0(n){let e,t=n[16]+"",i,a,s,r;function o(){return n[14](n[16])}return{c(){e=v("span"),i=pe(t),a=R(),g(e,"class","clickable-icon svelte-xx603q"),oe(e,"active",n[16]==n[3])},m(l,c){D(l,e,c),y(e,i),y(e,a),s||(r=z(e,"click",o),s=!0)},p(l,c){n=l,c&16&&t!==(t=n[16]+"")&&we(i,t),c&24&&oe(e,"active",n[16]==n[3])},d(l){l&&x(e),s=!1,r()}}}function J0(n){let e,t,i;return{c(){e=v("span"),e.textContent="..."},m(a,s){D(a,e,s),t||(i=z(e,"click",n[13]),t=!0)},p:N,d(a){a&&x(e),t=!1,i()}}}function Ph(n){let e;function t(s,r){return s[16]==null?J0:Y0}let i=t(n,-1),a=i(n);return{c(){a.c(),e=_e()},m(s,r){a.m(s,r),D(s,e,r)},p(s,r){i===(i=t(s,r))&&a?a.p(s,r):(a.d(1),a=i(s),a&&(a.c(),a.m(e.parentNode,e)))},d(s){s&&x(e),a.d(s)}}}function X0(n){let e,t,i,a,s,r,o,l,c,d,u,h,m,f,p,b,_,S=ye(n[4]),C=[];for(let M=0;M(r(),r=Tt(p,L=>t(3,s=L)),p),l,c=N,d=()=>(c(),c=Tt(b,L=>t(12,l=L)),b),u,h=N,m=()=>(h(),h=Tt(f,L=>t(15,u=L)),f);n.$$.on_destroy.push(()=>r()),n.$$.on_destroy.push(()=>c()),n.$$.on_destroy.push(()=>h());let{slice:f}=e;m();let{page:p}=e;o();let{pages:b}=e;d();let _=L=>{new ui.DropdownComponent(L).addOptions({10:"10",25:"25",50:"50",100:"100",200:"200"}).setValue(`${u}`).onChange(B=>Ae(f,u=Number(B),u))},S,C=L=>{t(9,S=new ui.ExtraButtonComponent(L).setIcon("chevron-left").setDisabled(s==1).onClick(()=>{Ae(p,s=s-1,s)}))},M,w=L=>{t(10,M=new ui.ExtraButtonComponent(L).setIcon("chevron-right").setDisabled(s==l).onClick(()=>{Ae(p,s=Math.min(s+1,l),s)}))},k=L=>{let B=new ui.Menu;for(let O of i)B.addItem(q=>{q.setTitle(`${O}`).onClick(()=>{Ae(p,s=O,s)})});B.showAtMouseEvent(L)},A=L=>k(L),P=L=>Ae(p,s=L,s);return n.$$set=L=>{"slice"in L&&m(t(0,f=L.slice)),"page"in L&&o(t(1,p=L.page)),"pages"in L&&d(t(2,b=L.pages))},n.$$.update=()=>{n.$$.dirty&4096&&t(11,i=[...Array(l).keys()].map(L=>L+1)),n.$$.dirty&5640&&M&&S&&(M.setDisabled(s==l),S.setDisabled(s==1)),n.$$.dirty&6152&&t(4,a=i.reduce((L,B)=>(B==1||s==1&&(B==2||B==3)||B==l||s==l&&(B==l-1||B==l-2)||B==s-1||B==s||B==s+1?L.push(B):L.length>=1&&L[L.length-1]!=null&&L.push(null),L),[]))},[f,p,b,s,a,_,C,w,k,S,M,i,l,A,P]}var _l=class extends G{constructor(e){super(),K(this,e,Q0,X0,j,{slice:0,page:1,pages:2},$0)}},Rh=_l;var zi=require("obsidian");var Bs=require("obsidian");var Ot=require("obsidian");function Z0(n){re(n,"svelte-1m3i208",".top-level.svelte-1m3i208.svelte-1m3i208{display:flex;flex-flow:column nowrap}textarea.svelte-1m3i208.svelte-1m3i208{flex-grow:1;height:500px;max-height:50vh}.json.svelte-1m3i208.svelte-1m3i208{margin-bottom:1rem;display:flex;justify-content:flex-start;align-items:center}.json.svelte-1m3i208>div.svelte-1m3i208{border-radius:4px;margin:5px 0px}.active.svelte-1m3i208.svelte-1m3i208{background-color:var(--background-secondary-alt)}.buttons.svelte-1m3i208.svelte-1m3i208{margin-top:1rem;display:flex;justify-content:flex-end;align-items:center}")}function Nh(n){let e,t,i,a;return{c(){e=v("textarea"),e.value=t=n[6](),g(e,"class","svelte-1m3i208")},m(s,r){D(s,e,r),n[11](e),i||(a=z(e,"blur",n[12]),i=!0)},p:N,d(s){s&&x(e),n[11](null),i=!1,a()}}}function ey(n){let e,t,i,a,s,r,o,l,c,d,u,h=n[0],m,f,p,b,_,S,C,M,w,k=Nh(n);return{c(){e=v("div"),t=v("h2"),t.textContent="Edit Monster",i=R(),a=v("div"),s=v("div"),r=v("div"),l=R(),c=v("div"),u=R(),k.c(),m=R(),f=v("div"),p=v("div"),_=R(),S=v("div"),g(r,"class","svelte-1m3i208"),oe(r,"active",!n[0]),g(c,"class","svelte-1m3i208"),oe(c,"active",n[0]),g(s,"class","json svelte-1m3i208"),g(a,"class","top-level svelte-1m3i208"),g(f,"class","buttons svelte-1m3i208"),g(e,"class","edit-monster-modal")},m(A,P){D(A,e,P),y(e,t),y(e,i),y(e,a),y(a,s),y(s,r),y(s,l),y(s,c),y(a,u),k.m(a,null),y(e,m),y(e,f),y(f,p),y(f,_),y(f,S),M||(w=[X(o=n[3].call(null,r)),z(r,"click",n[9]),X(d=n[2].call(null,c)),z(c,"click",n[10]),X(b=n[4].call(null,p)),X(C=n[5].call(null,S))],M=!0)},p(A,[P]){P&1&&oe(r,"active",!A[0]),P&1&&oe(c,"active",A[0]),P&1&&j(h,h=A[0])?(k.d(1),k=Nh(A),k.c(),k.m(a,null)):k.p(A,P)},i:N,o:N,d(A){A&&x(e),k.d(A),M=!1,le(w)}}}function ty(n,e,t){let i=Me(),{monster:a={}}=e,s=!1,r,o=_=>{new Ot.ExtraButtonComponent(_).setIcon("code-glyph").setTooltip("JSON")},l=_=>{new Ot.ExtraButtonComponent(_).setIcon("lines-of-text").setTooltip("YAML")},c=_=>{new Ot.ButtonComponent(_).setIcon("checkmark").setTooltip("Save Changes").onClick(()=>{if(s)try{s?t(8,a=JSON.parse(r.value)):t(8,a=(0,Ot.parseYaml)(r.value))}catch(S){console.error(S),new Ot.Notice(`There was an error saving the creaturen ${S.message}`);return}i("save",a)})},d=_=>{new Ot.ExtraButtonComponent(_).setIcon("cross").setTooltip("Cancel").onClick(()=>{i("cancel")})};function u(){return s?JSON.stringify(a,null,2):!a||!Object.keys(a??{})?.length?"":(0,Ot.stringifyYaml)(a).trim()}function h(){try{s?t(8,a=JSON.parse(r.value)):t(8,a=(0,Ot.parseYaml)(r.value))}catch(_){console.error(_)}}let m=()=>t(0,s=!1),f=()=>t(0,s=!0);function p(_){Re[_?"unshift":"push"](()=>{r=_,t(1,r)})}let b=()=>h();return n.$$set=_=>{"monster"in _&&t(8,a=_.monster)},[s,r,o,l,c,d,u,h,a,m,f,p,b]}var Sl=class extends G{constructor(e){super(),K(this,e,ty,ey,j,{monster:8},Z0)}},Lh=Sl;var Hi=class extends wt{constructor(t,i={}){super(t);this.monster=i}onOpen(){this._instance=new Lh({target:this.contentEl,props:{monster:this.monster}}),this._instance.$on("cancel",()=>{this.close()}),this._instance.$on("save",async({detail:t})=>{if(!t.name){new Bs.Notice("Creatures must be given a name.");return}await this.plugin.updateMonster(this.monster,t),this.close()})}onClose(){}close(){this._instance&&this._instance.$destroy(),super.close()}},Ls=class extends wt{constructor(t,i){super(t);this.monster=i}async display(){Bs.Platform.isMobile||(this.contentEl.style.maxWidth="85vw"),new $t({container:this.contentEl,monster:this.monster,plugin:this.plugin})}onOpen(){this.display()}};var wn=Be(""),di=Be([]),Fs="None",Bh=yt([wn,di],([n,e])=>(n?.length?1:0)+(e?.length?1:0));function ny(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","creature")},m(s,r){D(s,e,r),i||(a=X(t=n[0].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function iy(n,e,t){let i;Se(n,wn,c=>t(3,i=c));let{item:a}=e,s=Me(),r=xt("plugin"),o,l=c=>{t(2,o=new zi.Setting(c));let d,u=!1;if(Array.isArray(a.source)){let h=a.source.slice(0,4);a.source.length>4&&(h.push(`and ${a.source.length-4} more`),u=!0),d=be(h,0,", ",!1)}else d=a.source;if(o.setDesc(d??""),u&&o.descEl.setAttr("aria-label",be(a.source,0,", ",!1)),ve.isLocal(a.name))o.addExtraButton(h=>{h.setIcon("pencil").setTooltip("Edit").onClick(()=>{new Hi(r,a).open()})}).addExtraButton(h=>{h.setIcon("trash").setTooltip("Delete").onClick(async()=>{await r.deleteMonsters(a.name)})});else if(a.path){let h=r.app.vault.getFileByPath(a.path);if(!h)return;o.addExtraButton(m=>{m.setIcon("file-symlink").onClick(async()=>{await r.app.workspace.getLeaf().openFile(h),r.app.setting.close()})})}o.addExtraButton(h=>{h.setIcon("info").setTooltip("View").onClick(()=>{new Ls(r,a).open()})})};return n.$$set=c=>{"item"in c&&t(1,a=c.item)},n.$$.update=()=>{if(n.$$.dirty&14&&o)if(i.length){let c=(0,zi.prepareSimpleSearch)(i)(a.name);c&&(o.nameEl.empty(),(0,zi.renderMatches)(o.nameEl,a.name,c.matches))}else o.setName(a.name)},[l,a,o,i]}var Cl=class extends G{constructor(e){super(),K(this,e,iy,ny,j,{item:1})}},Fh=Cl;var qs=require("obsidian");var Ws=require("obsidian");function ay(n){re(n,"svelte-1xutc2s",".search.svelte-1xutc2s,.search.svelte-1xutc2s input{width:100%}")}function sy(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","search svelte-1xutc2s")},m(s,r){D(s,e,r),i||(a=X(t=n[1].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function ry(n,e,t){let i,a=N,s=()=>(a(),a=Tt(r,c=>t(3,i=c)),r);n.$$.on_destroy.push(()=>a());let{filter:r}=e;s();let{placeholder:o}=e,l=c=>{let d=new Ws.SearchComponent(c).setPlaceholder(o).onChange((0,Ws.debounce)(u=>{Ae(r,i=u,i)},10));r.subscribe(u=>{(!u||!u.length)&&d.setValue("")})};return n.$$set=c=>{"filter"in c&&s(t(0,r=c.filter)),"placeholder"in c&&t(2,o=c.placeholder)},[r,l,o]}var xl=class extends G{constructor(e){super(),K(this,e,ry,sy,j,{filter:0,placeholder:2},ay)}},Wh=xl;function oy(n){re(n,"svelte-66wdl1","div.svelte-66wdl1{display:inline-block;vertical-align:middle;margin:0 3pt;border-width:calc(1em / 5);border-style:solid;border-radius:50%;animation:var(--duration) infinite svelte-66wdl1-rotate}@keyframes svelte-66wdl1-rotate{100%{transform:rotate(360deg)}}")}function ly(n){let e,t=`${n[0]} transparent ${n[0]} ${n[0]}`;return{c(){e=v("div"),He(e,"--duration",n[1]),g(e,"class","svelte-66wdl1"),He(e,"border-color",t),He(e,"width",n[2]),He(e,"height",n[2])},m(i,a){D(i,e,a)},p(i,[a]){a&2&&He(e,"--duration",i[1]);let s=a&2;(a&3&&t!==(t=`${i[0]} transparent ${i[0]} ${i[0]}`)||s)&&He(e,"border-color",t),(a&6||s)&&He(e,"width",i[2]),(a&6||s)&&He(e,"height",i[2])},i:N,o:N,d(i){i&&x(e)}}}function cy(n,e,t){let{color:i="cornflowerblue"}=e,{duration:a="1.5s"}=e,{size:s="1em"}=e;return n.$$set=r=>{"color"in r&&t(0,i=r.color),"duration"in r&&t(1,a=r.duration),"size"in r&&t(2,s=r.size)},[i,a,s]}var Al=class extends G{constructor(e){super(),K(this,e,cy,ly,j,{color:0,duration:1,size:2},oy)}},Tl=Al;function Hs(n){return Object.prototype.toString.call(n)==="[object Date]"}function Dl(n,e,t,i){if(typeof t=="number"||Hs(t)){let a=i-t,s=(t-e)/(n.dt||1/60),r=n.opts.stiffness*a,o=n.opts.damping*s,l=(r-o)*n.inv_mass,c=(s+l)*n.dt;return Math.abs(c)Dl(n,e[s],t[s],i[s]));if(typeof t=="object"){let a={};for(let s in t)a[s]=Dl(n,e[s],t[s],i[s]);return a}else throw new Error(`Cannot spring ${typeof t} values`)}}function Hh(n,e={}){let t=Be(n),{stiffness:i=.15,damping:a=.8,precision:s=.01}=e,r,o,l,c=n,d=n,u=1,h=0,m=!1;function f(b,_={}){d=b;let S=l={};return n==null||_.hard||p.stiffness>=1&&p.damping>=1?(m=!0,r=An(),c=b,t.set(n=d),Promise.resolve()):(_.soft&&(h=1/((_.soft===!0?.5:+_.soft)*60),u=0),o||(r=An(),m=!1,o=Gn(C=>{if(m)return m=!1,o=null,!1;u=Math.min(u+h,1);let M={inv_mass:u,opts:p,settled:!0,dt:(C-r)*60/1e3},w=Dl(M,c,n,d);return r=C,c=n,t.set(n=w),M.settled&&(o=null),!M.settled})),new Promise(C=>{o.promise.then(()=>{S===l&&C()})}))}let p={set:f,update:(b,_)=>f(b(d,n),_),subscribe:t.subscribe,stiffness:i,damping:a,precision:s};return p}function uy(n){let e,t=`rotate(${n[0].angle}deg) scale(${n[0].scale}) translate(${n[0].dx}px, ${n[0].dy}px)`,i,a=n[11].default,s=st(a,n,n[10],null);return{c(){e=v("span"),s&&s.c(),He(e,"transform",t)},m(r,o){D(r,e,o),s&&s.m(e,null),i=!0},p(r,[o]){s&&s.p&&(!i||o&1024)&&ot(s,a,r,r[10],i?rt(a,r[10],o,null):lt(r[10]),null),o&1&&t!==(t=`rotate(${r[0].angle}deg) scale(${r[0].scale}) translate(${r[0].dx}px, ${r[0].dy}px)`)&&He(e,"transform",t)},i(r){i||(E(s,r),i=!0)},o(r){I(s,r),i=!1},d(r){r&&x(e),s&&s.d(r)}}}function dy(n,e,t){let i,{$$slots:a={},$$scope:s}=e,{wiggle:r=!1}=e,{angle:o=0}=e,{scale:l=1}=e,{dx:c=0}=e,{dy:d=0}=e,{duration:u=200}=e,{stiffness:h=.05}=e,{damping:m=.1}=e,f={angle:0,scale:1,dx:0,dy:0},p=Hh(f,{stiffness:h,damping:m});return Se(n,p,b=>t(0,i=b)),n.$$set=b=>{"wiggle"in b&&t(2,r=b.wiggle),"angle"in b&&t(3,o=b.angle),"scale"in b&&t(4,l=b.scale),"dx"in b&&t(5,c=b.dx),"dy"in b&&t(6,d=b.dy),"duration"in b&&t(7,u=b.duration),"stiffness"in b&&t(8,h=b.stiffness),"damping"in b&&t(9,m=b.damping),"$$scope"in b&&t(10,s=b.$$scope)},n.$$.update=()=>{n.$$.dirty&132&&r&&setTimeout(()=>t(2,r=!1),u),n.$$.dirty&124&&p.set(r?{scale:l,angle:o,dx:c,dy:d}:f)},[i,p,r,o,l,c,d,u,h,m,s,a]}var El=class extends G{constructor(e){super(),K(this,e,dy,uy,j,{wiggle:2,angle:3,scale:4,dx:5,dy:6,duration:7,stiffness:8,damping:9})}},Ml=El;function hy(n){let e,t,i=[n[0],{fill:"currentColor"},{viewBox:"0 0 16 16"}],a={};for(let s=0;s{t(0,e=at(at({},e),Vt(i)))},e=Vt(e),[e]}var Il=class extends G{constructor(e){super(),K(this,e,fy,hy,j,{})}},Ol=Il;function my(n){let e,t,i=[n[0],{viewBox:"0 0 24 24"},{fill:"currentColor"}],a={};for(let s=0;s{t(0,e=at(at({},e),Vt(i)))},e=Vt(e),[e]}var Pl=class extends G{constructor(e){super(),K(this,e,gy,my,j,{})}},zs=Pl;function py(n){let e,t,i=[n[0],{viewBox:"0 0 24 24"},{fill:"currentColor"}],a={};for(let s=0;s{t(0,e=at(at({},e),Vt(i)))},e=Vt(e),[e]}var Rl=class extends G{constructor(e){super(),K(this,e,by,py,j,{})}},Nl=Rl;var it=n=>n instanceof Object?(n.label===void 0&&console.error(`MultiSelect option ${JSON.stringify(n)} is an object but has no label key`),n.label):`${n}`;function Ca(n,e=null){if(!n?.style)return null;if(!["selected","option",null].includes(e)){console.error(`MultiSelect: Invalid key=${e} for get_style`);return}if(typeof n=="object"&&n.style){if(typeof n.style=="string")return n.style;if(typeof n.style=="object"){if(e&&e in n.style)return n.style[e];console.error(`Invalid style object for option=${JSON.stringify(n)}`)}}}var{Boolean:yy}=$i;function vy(n){re(n,"svelte-1r2hsto",".svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect){position:relative;align-items:center;display:flex;cursor:text;box-sizing:border-box;border:var(--sms-border, 1pt solid lightgray);border-radius:var(--sms-border-radius, 3pt);background:var(--sms-bg);width:var(--sms-width);max-width:var(--sms-max-width);padding:var(--sms-padding, 0 3pt);color:var(--sms-text-color);font-size:var(--sms-font-size, inherit);min-height:var(--sms-min-height, 22pt);margin:var(--sms-margin)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect.open){z-index:var(--sms-open-z-index, 4)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect:focus-within){border:var(--sms-focus-border, 1pt solid var(--sms-active-color, cornflowerblue))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect.disabled){background:var(--sms-disabled-bg, lightgray);cursor:not-allowed}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected){display:flex;flex:1;padding:0;margin:0;flex-wrap:wrap}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected > li){align-items:center;border-radius:3pt;display:flex;margin:2pt;line-height:normal;transition:0.3s;white-space:nowrap;background:var(--sms-selected-bg, rgba(0, 0, 0, 0.15));padding:var(--sms-selected-li-padding, 1pt 5pt);color:var(--sms-selected-text-color, var(--sms-text-color))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected > li[draggable='true']){cursor:grab}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected > li.active){background:var(--sms-li-active-bg, var(--sms-active-color, rgba(0, 0, 0, 0.15)))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect button){border-radius:50%;display:flex;transition:0.2s;color:inherit;background:transparent;border:none;cursor:pointer;outline:none;padding:0;margin:0 0 0 3pt}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect button.remove-all){margin:0 3pt}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(ul.selected > li button:hover, button.remove-all:hover, button:focus){color:var(--sms-remove-btn-hover-color, lightskyblue);background:var(--sms-remove-btn-hover-bg, rgba(0, 0, 0, 0.2))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect input){margin:auto 0;padding:0}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.selected > input){border:none;outline:none;background:none;flex:1;min-width:2em;color:var(--sms-text-color);font-size:inherit;cursor:inherit;border-radius:0}div.multiselect.svelte-1r2hsto>ul.selected.svelte-1r2hsto>input.svelte-1r2hsto::placeholder{padding-left:5pt;color:var(--sms-placeholder-color);opacity:var(--sms-placeholder-opacity)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > input.form-control){width:2em;position:absolute;background:transparent;border:none;outline:none;z-index:-1;opacity:0;pointer-events:none}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options){list-style:none;top:100%;left:0;width:100%;position:absolute;overflow:auto;transition:all 0.2s;box-sizing:border-box;background:var(--sms-options-bg, white);max-height:var(--sms-options-max-height, 50vh);overscroll-behavior:var(--sms-options-overscroll, none);box-shadow:var(--sms-options-shadow, 0 0 14pt -8pt black);border:var(--sms-options-border);border-width:var(--sms-options-border-width);border-radius:var(--sms-options-border-radius, 1ex);padding:var(--sms-options-padding);margin:var(--sms-options-margin, inherit)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options.hidden){visibility:hidden;opacity:0;transform:translateY(50px)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options > li){padding:3pt 2ex;cursor:pointer;scroll-margin:var(--sms-options-scroll-margin, 100px)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options .user-msg){display:block;padding:3pt 2ex}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options > li.selected){background:var(--sms-li-selected-bg);color:var(--sms-li-selected-color)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options > li.active){background:var(--sms-li-active-bg, var(--sms-active-color, rgba(0, 0, 0, 0.15)))}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(div.multiselect > ul.options > li.disabled){cursor:not-allowed;background:var(--sms-li-disabled-bg, #f5f5f6);color:var(--sms-li-disabled-text, #b8b8b8)}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto:where(span.max-select-msg){padding:0 3pt}.svelte-1r2hsto.svelte-1r2hsto.svelte-1r2hsto::highlight(sms-search-matches){color:mediumaquamarine}")}var ky=n=>({searchText:n[0]&8,msgType:n[0]&1073810458,msg:n[0]&1073843226}),zh=n=>({searchText:n[3],msgType:n[116],msg:n[117]});function Ll(n){let e=n.slice(),t={dupe:e[15],create:e[10],"no-match":e[30]}[e[116]];return e[117]=t,e}function Bl(n){let e=n.slice(),t=e[4].map(it).includes(e[3]);e[112]=t;let i=!e[16]&&e[112]&&"dupe";e[113]=i;let a=!!(e[11]&&e[10])&&"create";e[114]=a;let s=!!(e[1]?.length==0&&e[30])&&"no-match";e[115]=s;let r=e[113]||e[114]||e[115];return e[116]=r,e}function qh(n,e,t){let i=n.slice();i[118]=e[t],i[125]=t;let a=i[118]instanceof Object?i[118]:{label:i[118]};i[119]=a.label,i[42]=a.disabled!==void 0?a.disabled:null,i[120]=a.title!==void 0?a.title:null,i[121]=a.selectedTitle!==void 0?a.selectedTitle:null,i[122]=a.disabledTitle!==void 0?a.disabledTitle:i[13];let s=i[0]===i[125];return i[123]=s,i}var wy=n=>({option:n[0]&33554434}),jh=n=>({option:n[118],idx:n[125]}),_y=n=>({option:n[0]&33554434}),Vh=n=>({option:n[118],idx:n[125]}),Sy=n=>({}),Uh=n=>({}),Cy=n=>({}),Gh=n=>({}),xy=n=>({}),Kh=n=>({}),Ay=n=>({selected:n[0]&16,disabled:n[1]&2048,invalid:n[0]&128,id:n[0]&262144,placeholder:n[1]&8,open:n[0]&256,required:n[1]&128}),$h=n=>({selected:n[4],disabled:n[42],invalid:n[7],id:n[18],placeholder:n[34],open:n[8],required:n[38]});function Yh(n,e,t){let i=n.slice();return i[118]=e[t],i[125]=t,i}var Ty=n=>({}),Jh=n=>({}),Dy=n=>({option:n[0]&16,idx:n[0]&16}),Xh=n=>({option:n[118],idx:n[125]}),Ey=n=>({option:n[0]&16,idx:n[0]&16}),Qh=n=>({option:n[118],idx:n[125]}),My=n=>({open:n[0]&256}),Zh=n=>({open:n[8]});function Iy(n){let e,t;return e=new Ol({props:{width:"15px",style:"min-width: 1em; padding: 0 1pt; cursor: pointer;"}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p:N,i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function Oy(n){let e=it(n[118])+"",t;return{c(){t=pe(e)},m(i,a){D(i,t,a)},p(i,a){a[0]&16&&e!==(e=it(i[118])+"")&&we(t,e)},d(i){i&&x(t)}}}function Py(n){let e,t=it(n[118])+"",i;return{c(){e=new gn(!1),i=_e(),e.a=i},m(a,s){e.m(t,a,s),D(a,i,s)},p(a,s){s[0]&16&&t!==(t=it(a[118])+"")&&e.p(t)},d(a){a&&(x(i),e.d())}}}function Ry(n){let e;function t(s,r){return s[32]?Py:Oy}let i=t(n,[-1,-1,-1,-1,-1]),a=i(n);return{c(){a.c(),e=_e()},m(s,r){a.m(s,r),D(s,e,r)},p(s,r){i===(i=t(s,r))&&a?a.p(s,r):(a.d(1),a=i(s),a&&(a.c(),a.m(e.parentNode,e)))},d(s){s&&x(e),a.d(s)}}}function Ny(n){let e,t=n[69].default,i=st(t,n,n[107],Xh),a=i||Ry(n);return{c(){a&&a.c()},m(s,r){a&&a.m(s,r),e=!0},p(s,r){i?i.p&&(!e||r[0]&16|r[3]&16384)&&ot(i,t,s,s[107],e?rt(t,s[107],r,Dy):lt(s[107]),Xh):a&&a.p&&(!e||r[0]&16|r[1]&2)&&a.p(s,e?r:[-1,-1,-1,-1,-1])},i(s){e||(E(a,s),e=!0)},o(s){I(a,s),e=!1},d(s){a&&a.d(s)}}}function ef(n){let e,t,i,a,s,r=n[69]["remove-icon"],o=st(r,n,n[107],Jh),l=o||Ly(n);function c(){return n[89](n[118])}function d(){return n[90](n[118])}return{c(){e=v("button"),l&&l.c(),g(e,"type","button"),g(e,"title",t=n[36]+" "+it(n[118])),g(e,"class","remove svelte-1r2hsto")},m(u,h){D(u,e,h),l&&l.m(e,null),i=!0,a||(s=[z(e,"mouseup",ln(c)),z(e,"keydown",function(){Pe(n[54](d))&&n[54](d).apply(this,arguments)})],a=!0)},p(u,h){n=u,o&&o.p&&(!i||h[3]&16384)&&ot(o,r,n,n[107],i?rt(r,n[107],h,Ty):lt(n[107]),Jh),(!i||h[0]&16|h[1]&32&&t!==(t=n[36]+" "+it(n[118])))&&g(e,"title",t)},i(u){i||(E(l,u),i=!0)},o(u){I(l,u),i=!1},d(u){u&&x(e),l&&l.d(u),a=!1,le(s)}}}function Ly(n){let e,t;return e=new zs({props:{width:"15px"}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p:N,i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function tf(n,e){let t,i,a,s,r,o,l=N,c,d,u,h=e[69].selected,m=st(h,e,e[107],Qh),f=m||Ny(e),p=!e[42]&&(e[37]===null||e[4].length>e[37])&&ef(e);function b(){return e[91](e[125])}return{key:n,first:null,c(){t=v("li"),f&&f.c(),i=R(),p&&p.c(),g(t,"class",a=xn(e[23])+" svelte-1r2hsto"),g(t,"role","option"),g(t,"aria-selected","true"),g(t,"draggable",s=e[39]&&!e[42]&&e[4].length>1),g(t,"style",r=Ca(e[118],"selected")),oe(t,"active",e[46]===e[125]),this.first=t},m(_,S){D(_,t,S),f&&f.m(t,null),y(t,i),p&&p.m(t,null),c=!0,d||(u=[z(t,"dragstart",function(){Pe(e[57](e[125]))&&e[57](e[125]).apply(this,arguments)}),z(t,"drop",Sr(function(){Pe(e[56](e[125]))&&e[56](e[125]).apply(this,arguments)})),z(t,"dragenter",b),z(t,"dragover",Sr(e[85]))],d=!0)},p(_,S){e=_,m?m.p&&(!c||S[0]&16|S[3]&16384)&&ot(m,h,e,e[107],c?rt(h,e[107],S,Ey):lt(e[107]),Qh):f&&f.p&&(!c||S[0]&16|S[1]&2|S[3]&16384)&&f.p(e,c?S:[-1,-1,-1,-1,-1]),!e[42]&&(e[37]===null||e[4].length>e[37])?p?(p.p(e,S),S[0]&16|S[1]&2112&&E(p,1)):(p=ef(e),p.c(),E(p,1),p.m(t,null)):p&&(ce(),I(p,1,1,()=>{p=null}),ue()),(!c||S[0]&8388608&&a!==(a=xn(e[23])+" svelte-1r2hsto"))&&g(t,"class",a),(!c||S[0]&16|S[1]&2304&&s!==(s=e[39]&&!e[42]&&e[4].length>1))&&g(t,"draggable",s),(!c||S[0]&16&&r!==(r=Ca(e[118],"selected")))&&g(t,"style",r),(!c||S[0]&8388624|S[1]&32768)&&oe(t,"active",e[46]===e[125])},r(){o=t.getBoundingClientRect()},f(){Dn(t),l()},a(){l(),l=Tn(t,o,Pn,{duration:100})},i(_){c||(E(f,_),E(p),c=!0)},o(_){I(f,_),I(p),c=!1},d(_){_&&x(t),f&&f.d(_),p&&p.d(),d=!1,le(u)}}}function nf(n){let e,t=n[69].spinner,i=st(t,n,n[107],Kh),a=i||By(n);return{c(){a&&a.c()},m(s,r){a&&a.m(s,r),e=!0},p(s,r){i&&i.p&&(!e||r[3]&16384)&&ot(i,t,s,s[107],e?rt(t,s[107],r,xy):lt(s[107]),Kh)},i(s){e||(E(a,s),e=!0)},o(s){I(a,s),e=!1},d(s){a&&a.d(s)}}}function By(n){let e,t;return e=new Tl({}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function Fy(n){let e,t,i,a=n[26]&&(n[26]>1||n[27])&&af(n),s=n[26]!==1&&n[4].length>1&&sf(n);return{c(){a&&a.c(),e=R(),s&&s.c(),t=_e()},m(r,o){a&&a.m(r,o),D(r,e,o),s&&s.m(r,o),D(r,t,o),i=!0},p(r,o){r[26]&&(r[26]>1||r[27])?a?(a.p(r,o),o[0]&201326592&&E(a,1)):(a=af(r),a.c(),E(a,1),a.m(e.parentNode,e)):a&&(ce(),I(a,1,1,()=>{a=null}),ue()),r[26]!==1&&r[4].length>1?s?(s.p(r,o),o[0]&67108880&&E(s,1)):(s=sf(r),s.c(),E(s,1),s.m(t.parentNode,t)):s&&(ce(),I(s,1,1,()=>{s=null}),ue())},i(r){i||(E(a),E(s),i=!0)},o(r){I(a),I(s),i=!1},d(r){r&&(x(e),x(t)),a&&a.d(r),s&&s.d(r)}}}function Wy(n){let e,t=n[69]["disabled-icon"],i=st(t,n,n[107],Gh),a=i||qy(n);return{c(){a&&a.c()},m(s,r){a&&a.m(s,r),e=!0},p(s,r){i&&i.p&&(!e||r[3]&16384)&&ot(i,t,s,s[107],e?rt(t,s[107],r,Cy):lt(s[107]),Gh)},i(s){e||(E(a,s),e=!0)},o(s){I(a,s),e=!1},d(s){a&&a.d(s)}}}function af(n){let e,t,i;function a(r){n[94](r)}let s={angle:20,$$slots:{default:[Hy]},$$scope:{ctx:n}};return n[43]!==void 0&&(s.wiggle=n[43]),e=new Ml({props:s}),Re.push(()=>Bt(e,"wiggle",a)),{c(){ae(e.$$.fragment)},m(r,o){te(e,r,o),i=!0},p(r,o){let l={};o[0]&469762064|o[3]&16384&&(l.$$scope={dirty:o,ctx:r}),!t&&o[1]&4096&&(t=!0,l.wiggle=r[43],Lt(()=>t=!1)),e.$set(l)},i(r){i||(E(e.$$.fragment,r),i=!0)},o(r){I(e.$$.fragment,r),i=!1},d(r){ne(e,r)}}}function Hy(n){let e,t=n[27]?.(n[4].length,n[26])+"",i,a;return{c(){e=v("span"),i=pe(t),g(e,"class",a="max-select-msg "+n[28]+" svelte-1r2hsto")},m(s,r){D(s,e,r),y(e,i)},p(s,r){r[0]&201326608&&t!==(t=s[27]?.(s[4].length,s[26])+"")&&we(i,t),r[0]&268435456&&a!==(a="max-select-msg "+s[28]+" svelte-1r2hsto")&&g(e,"class",a)},d(s){s&&x(e)}}}function sf(n){let e,t,i,a,s=n[69]["remove-icon"],r=st(s,n,n[107],Uh),o=r||zy(n);return{c(){e=v("button"),o&&o.c(),g(e,"type","button"),g(e,"class","remove remove-all svelte-1r2hsto"),g(e,"title",n[35])},m(l,c){D(l,e,c),o&&o.m(e,null),t=!0,i||(a=[z(e,"mouseup",ln(n[53])),z(e,"keydown",n[54](n[53]))],i=!0)},p(l,c){r&&r.p&&(!t||c[3]&16384)&&ot(r,s,l,l[107],t?rt(s,l[107],c,Sy):lt(l[107]),Uh),(!t||c[1]&16)&&g(e,"title",l[35])},i(l){t||(E(o,l),t=!0)},o(l){I(o,l),t=!1},d(l){l&&x(e),o&&o.d(l),i=!1,le(a)}}}function zy(n){let e,t;return e=new zs({props:{width:"15px"}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p:N,i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function qy(n){let e,t;return e=new Nl({props:{width:"14pt",style:"margin: 0 2pt;","data-name":"disabled-icon"}}),{c(){ae(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p:N,i(i){t||(E(e.$$.fragment,i),t=!0)},o(i){I(e.$$.fragment,i),t=!1},d(i){ne(e,i)}}}function rf(n){let e,t,i,a,s,r,o=ye(n[1].slice(0,Math.max(0,n[25]??0)||1/0)),l=[];for(let u=0;uI(l[u],1,1,()=>{l[u]=null}),d=n[3]&&lf(Bl(n));return{c(){e=v("ul");for(let u=0;u1),g(e,"aria-expanded",n[8]),g(e,"aria-disabled",s=n[42]?"true":null),oe(e,"hidden",!n[8])},m(u,h){D(u,e,h);for(let m=0;m{d=null}),ue()),(!r||h[1]&512&&i!==(i="options "+u[40]+" svelte-1r2hsto"))&&g(e,"class",i),(!r||h[0]&67108864&&a!==(a=u[26]===null||u[26]>1))&&g(e,"aria-multiselectable",a),(!r||h[0]&256)&&g(e,"aria-expanded",u[8]),(!r||h[1]&2048&&s!==(s=u[42]?"true":null))&&g(e,"aria-disabled",s),(!r||h[0]&256|h[1]&512)&&oe(e,"hidden",!u[8])},i(u){if(!r){for(let h=0;h{i=null}),ue())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function cf(n){let e,t,i,a,s=n[69]["user-msg"],r=st(s,n,n[107],zh),o=r||Ky(n);return{c(){e=v("li"),o&&o.c(),g(e,"title",n[10]),g(e,"role","option"),g(e,"aria-selected","false"),g(e,"class","user-msg svelte-1r2hsto"),oe(e,"active",n[44]),He(e,"cursor",{dupe:"not-allowed",create:"pointer","no-match":"default"}[n[116]])},m(l,c){D(l,e,c),o&&o.m(e,null),t=!0,i||(a=[z(e,"mousedown",ln(n[70])),z(e,"mouseup",ln(n[100])),z(e,"mouseover",n[101]),z(e,"focus",n[102]),z(e,"mouseout",n[103]),z(e,"blur",n[104])],i=!0)},p(l,c){r?r.p&&(!t||c[0]&1073843226|c[3]&16384)&&ot(r,s,l,l[107],t?rt(s,l[107],c,ky):lt(l[107]),zh):o&&o.p&&(!t||c[0]&1073843226)&&o.p(l,t?c:[-1,-1,-1,-1,-1]),(!t||c[0]&1024)&&g(e,"title",l[10]),(!t||c[1]&8192)&&oe(e,"active",l[44]),c[0]&1073810458&&He(e,"cursor",{dupe:"not-allowed",create:"pointer","no-match":"default"}[l[116]])},i(l){t||(E(o,l),t=!0)},o(l){I(o,l),t=!1},d(l){l&&x(e),o&&o.d(l),i=!1,le(a)}}}function Ky(n){let e=n[117]+"",t;return{c(){t=pe(e)},m(i,a){D(i,t,a)},p(i,a){a[0]&1073843226&&e!==(e=i[117]+"")&&we(t,e)},d(i){i&&x(t)}}}function $y(n){let e,t,i,a,s,r,o,l=[],c=new Map,d,u,h,m,f,p,b,_,S,C,M,w,k,A,P,L,B;Mt(n[86]);let O=n[69]["expand-icon"],q=st(O,n,n[107],Zh),Z=q||Iy(n),ee=ye(n[4]),se=V=>V[16]?[V[17](V[118]),V[125]]:V[17](V[118]);for(let V=0;V0?1:-1}~(C=Y(n,[-1,-1,-1,-1,-1]))&&(M=ie[C]=F[C](n));let de=(n[3]&&n[30]||n[2]?.length>0)&&rf(n);return{c(){e=v("div"),t=v("input"),s=R(),Z&&Z.c(),r=R(),o=v("ul");for(let V=0;V=Number(n[38])?JSON.stringify(n[4]):null,g(t,"tabindex","-1"),g(t,"aria-hidden","true"),g(t,"aria-label","ignore this, used only to prevent form submission if select is required but empty"),g(t,"class","form-control svelte-1r2hsto"),g(u,"class",h=xn(n[19])+" svelte-1r2hsto"),g(u,"id",n[18]),u.disabled=n[42],g(u,"autocomplete",n[12]),g(u,"inputmode",n[20]),g(u,"pattern",n[33]),g(u,"placeholder",m=n[4].length==0?n[34]:null),g(u,"aria-invalid",f=n[7]?"true":null),g(u,"ondrop","return false"),g(o,"class",b="selected "+n[41]+" svelte-1r2hsto"),g(o,"aria-label","selected options"),g(e,"class",k="multiselect "+n[31]+" svelte-1r2hsto"),g(e,"title",A=n[42]?n[14]:null),g(e,"data-id",n[18]),g(e,"role","searchbox"),g(e,"tabindex","-1"),oe(e,"disabled",n[42]),oe(e,"single",n[26]===1),oe(e,"open",n[8]),oe(e,"invalid",n[7])},m(V,H){D(V,e,H),y(e,t),n[87](t),y(e,s),Z&&Z.m(e,null),y(e,r),y(e,o);for(let fe=0;fe=Number(V[38])?JSON.stringify(V[4]):null)&&t.value!==a)&&(t.value=a),q&&q.p&&(!P||H[0]&256|H[3]&16384)&&ot(q,O,V,V[107],P?rt(O,V[107],H,My):lt(V[107]),Zh),H[0]&8585232|H[1]&109611362|H[3]&16384){ee=ye(V[4]),ce();for(let Ce=0;Ce{J=null}),ue());let fe=C;C=Y(V,H),C===fe?~C&&ie[C].p(V,H):(M&&(ce(),I(ie[fe],1,1,()=>{ie[fe]=null}),ue()),~C?(M=ie[C],M?M.p(V,H):(M=ie[C]=F[C](V),M.c()),E(M,1),M.m(e,w)):M=null),V[3]&&V[30]||V[2]?.length>0?de?(de.p(V,H),H[0]&1073741836&&E(de,1)):(de=rf(V),de.c(),E(de,1),de.m(e,null)):de&&(ce(),I(de,1,1,()=>{de=null}),ue()),(!P||H[1]&1&&k!==(k="multiselect "+V[31]+" svelte-1r2hsto"))&&g(e,"class",k),(!P||H[0]&16384|H[1]&2048&&A!==(A=V[42]?V[14]:null))&&g(e,"title",A),(!P||H[0]&262144)&&g(e,"data-id",V[18]),(!P||H[1]&2049)&&oe(e,"disabled",V[42]),(!P||H[0]&67108864|H[1]&1)&&oe(e,"single",V[26]===1),(!P||H[0]&256|H[1]&1)&&oe(e,"open",V[8]),(!P||H[0]&128|H[1]&1)&&oe(e,"invalid",V[7])},i(V){if(!P){E(Z,V);for(let H=0;H`${it(T)}`.toLowerCase()}=e,{filterFunc:M=(T,Ee)=>Ee?`${it(T)}`.toLowerCase().includes(Ee.toLowerCase()):!0}=e,{closeDropdownOnSelect:w="desktop"}=e,{form_input:k=null}=e,{highlightMatches:A=!0}=e,{id:P=null}=e,{input:L=null}=e,{inputClass:B=""}=e,{inputmode:O=null}=e,{invalid:q=!1}=e,{liActiveOptionClass:Z=""}=e,{liOptionClass:ee=""}=e,{liSelectedClass:se=""}=e,{loading:$=!1}=e,{matchingOptions:W=[]}=e,{maxOptions:J=void 0}=e,{maxSelect:F=null}=e,{maxSelectMsg:ie=(T,Ee)=>Ee>1?`${T}/${Ee}`:""}=e,{maxSelectMsgClass:Y=""}=e,{name:de=null}=e,{noMatchingOptionsMsg:V="No matching options"}=e,{open:H=!1}=e,{options:fe}=e,{outerDiv:Ce=null}=e,{outerDivClass:Ie=""}=e,{parseLabelsAsHtml:et=!1}=e,{pattern:At=null}=e,{placeholder:mi=null}=e,{removeAllTitle:gi="Remove all"}=e,{removeBtnTitle:Pt="Remove"}=e,{minSelect:Rt=null}=e,{required:gt=!1}=e,{resetFilterOnAdd:Js=!0}=e,{searchText:Qe=""}=e,{selected:De=fe?.filter(T=>T instanceof Object&&T?.preselected).slice(0,F??void 0)??[]}=e,{sortSelected:jn=!1}=e,{selectedOptionsDraggable:Xs=!jn}=e,{ulOptionsClass:Gl=""}=e,{ulSelectedClass:Kl=""}=e,{value:Oa=null}=e,vf=T=>{t(59,Oa=F===1?T[0]??null:T)},kf=T=>{F===1?t(4,De=T?[T]:[]):t(4,De=T??[])},Pa=!1;fe?.length>0||(c||$||p||d?fe=[]:console.error("MultiSelect received no options")),F!==null&&F<1&&console.error(`MultiSelect's maxSelect must be null or positive integer, got ${F}`),Array.isArray(De)||console.error(`MultiSelect's selected prop should always be an array, got ${De}`),F&&typeof gt=="number"&>>F&&console.error(`MultiSelect maxSelect=${F} < required=${gt}, makes it impossible for users to submit a valid form`),et&&c&&console.warn("Don't combine parseLabelsAsHtml and allowUserOptions. It's susceptible to XSS attacks!"),jn&&Xs&&console.warn("MultiSelect's sortSelected and selectedOptionsDraggable should not be combined as any user re-orderings of selected options will be undone by sortSelected on component re-renders."),c&&!l&&l!==null&&console.error(`MultiSelect has allowUserOptions=${c} but createOptionMsg=${l} is falsy. This prevents the "Add option" from showing up, resulting in a confusing user experience.`),J&&(typeof J!="number"||J<0||J%1!=0)&&console.error(`MultiSelect's maxOptions must be undefined or a positive integer, got ${J}`);let mn=Me(),Vn=!1,Qs;if(r!==null&&!W[r])throw`Run time error, activeIndex=${r} is out of bounds, matchingOptions.length=${W.length}`;function qi(T,Ee){F&&F>1&&De.length>=F&&t(43,Pa=!0),!isNaN(Number(T))&&typeof De.map(it)[0]=="number"&&(T=Number(T));let Ge=De.map(C).includes(C(T));if((F===null||F===1||De.length0&&(typeof fe[0]=="object"?T={label:Qe}:(["number","undefined"].includes(typeof fe[0])&&!isNaN(Number(Qe))?T=Number(Qe):T=Qe,mn("create",{option:T})),c==="append"&&t(2,fe=[...fe,T])),Js&&t(3,Qe=""),["",void 0,null].includes(T)){console.error(`MultiSelect: encountered falsy option ${T}`);return}F===1?t(4,De=[T]):(t(4,De=[...De,T]),jn===!0?t(4,De=De.sort((tr,Un)=>{let[Vi,Na]=[it(tr),it(Un)];return`${Vi}`.localeCompare(`${Na}`)})):typeof jn=="function"&&t(4,De=De.sort(jn)));let pt=De.length===F,pi=w===!0||w==="desktop"&&QsC(pt)===C(T)),[Ge]=De.splice(Ee,1);if(Ge===void 0&&c&&(Ge=typeof fe[0]?{label:T}:T),Ge===void 0)return console.error(`Multiselect can't remove selected option ${JSON.stringify(T)}, not found in selected list`);t(4,De=[...De]),t(7,q=!1),k?.setCustomValidity(""),mn("remove",{option:Ge}),mn("change",{option:Ge,type:"remove"})}function $l(T){p||(t(8,H=!0),T instanceof FocusEvent||L?.focus(),mn("open",{event:T}))}function Zs(T){t(8,H=!1),L?.blur(),t(0,r=null),mn("close",{event:T})}async function wf(T){if(T.key==="Escape"||T.key==="Tab")Zs(T),t(3,Qe="");else if(T.key==="Enter")T.preventDefault(),o?(De.includes(o)?ji(o):qi(o,T),t(3,Qe="")):c&&Qe.length>0?qi(Qe,T):$l(T);else if(["ArrowDown","ArrowUp"].includes(T.key)){if(r===null&&W.length>0){t(0,r=0);return}else if(c&&!W.length&&Qe.length>0){t(44,Vn=!Vn);return}else if(r===null)return;T.preventDefault();let Ee=T.key==="ArrowUp"?-1:1;if(t(0,r=(r+Ee)%W.length),r<0&&t(0,r=W.length-1),h){await Ja();let Ge=document.querySelector("ul.options > li.active");Ge&&Ge.scrollIntoViewIfNeeded?.()}}else T.key==="Backspace"&&De.length>0&&!Qe?ji(De.at(-1)):W.length>0&&t(0,r=0)}function _f(){mn("removeAll",{options:De}),mn("change",{options:De,type:"removeAll"}),t(4,De=[]),t(3,Qe="")}let Sf=T=>Ee=>{["Enter","Space"].includes(Ee.code)&&(Ee.preventDefault(),T())};function Cf(T){Ce&&!Ce.contains(T.target)&&Zs(T)}let er=null,xf=T=>Ee=>{if(!Ee.dataTransfer)return;Ee.dataTransfer.dropEffect="move";let Ge=parseInt(Ee.dataTransfer.getData("text/plain")),pt=[...De];GeEe=>{Ee.dataTransfer&&(Ee.dataTransfer.effectAllowed="move",Ee.dataTransfer.dropEffect="move",Ee.dataTransfer.setData("text/plain",`${T}`))},Ra;function Tf(T){if(!A||typeof CSS>"u"||!CSS.highlights)return;CSS.highlights.clear();let Ee=T?.target?.value.trim().toLowerCase();if(!Ee)return;let Ge=document.createTreeWalker(Ra,NodeFilter.SHOW_TEXT,{acceptNode:Un=>Un?.textContent===V?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),pt=[],pi=Ge.nextNode();for(;pi;)pt.push(pi),pi=Ge.nextNode();let tr=pt.map(Un=>{let Vi=Un.textContent?.toLowerCase(),Na=[],nr=0;for(;Vi&&nr{let ir=new Range;return ir.setStart(Un,bi),ir.setEnd(Un,bi+Ee.length),ir})});CSS.highlights.set("sms-search-matches",new Highlight(...tr.flat()))}function Df(T){Ue.call(this,n,T)}function Ef(T){Ue.call(this,n,T)}function Mf(T){Ue.call(this,n,T)}function If(T){Ue.call(this,n,T)}function Of(T){Ue.call(this,n,T)}function Pf(T){Ue.call(this,n,T)}function Rf(T){Ue.call(this,n,T)}function Nf(T){Ue.call(this,n,T)}function Lf(T){Ue.call(this,n,T)}function Bf(T){Ue.call(this,n,T)}function Ff(T){Ue.call(this,n,T)}function Wf(T){Ue.call(this,n,T)}function Hf(T){Ue.call(this,n,T)}function zf(T){Ue.call(this,n,T)}function qf(T){Ue.call(this,n,T)}function jf(T){Ue.call(this,n,T)}function Vf(){t(45,Qs=window.innerWidth)}function Uf(T){Re[T?"unshift":"push"](()=>{k=T,t(5,k)})}let Gf=()=>{t(7,q=!0);let T;F&&F>1&&Number(gt)>1?T=`Please select between ${gt} and ${F} options`:Number(gt)>1?T=`Please select at least ${gt} options`:T="Please select an option",k?.setCustomValidity(T)},Kf=T=>ji(T),$f=T=>ji(T),Yf=T=>t(46,er=T);function Jf(T){Re[T?"unshift":"push"](()=>{L=T,t(6,L)})}function Xf(){Qe=this.value,t(3,Qe)}function Qf(T){Pa=T,t(43,Pa)}let Zf=(T,Ee,Ge)=>{T||qi(Ee,Ge)},em=(T,Ee)=>{T||t(0,r=Ee)},tm=(T,Ee)=>{T||t(0,r=Ee)},nm=()=>t(0,r=null),im=()=>t(0,r=null),am=T=>{c&&qi(Qe,T)},sm=()=>t(44,Vn=!0),rm=()=>t(44,Vn=!0),om=()=>t(44,Vn=!1),lm=()=>t(44,Vn=!1);function cm(T){Re[T?"unshift":"push"](()=>{Ra=T,t(47,Ra)})}function um(T){Re[T?"unshift":"push"](()=>{Ce=T,t(9,Ce)})}return n.$$set=T=>{"activeIndex"in T&&t(0,r=T.activeIndex),"activeOption"in T&&t(60,o=T.activeOption),"createOptionMsg"in T&&t(10,l=T.createOptionMsg),"allowUserOptions"in T&&t(11,c=T.allowUserOptions),"allowEmpty"in T&&t(61,d=T.allowEmpty),"autocomplete"in T&&t(12,u=T.autocomplete),"autoScroll"in T&&t(62,h=T.autoScroll),"breakpoint"in T&&t(63,m=T.breakpoint),"defaultDisabledTitle"in T&&t(13,f=T.defaultDisabledTitle),"disabled"in T&&t(42,p=T.disabled),"disabledInputTitle"in T&&t(14,b=T.disabledInputTitle),"duplicateOptionMsg"in T&&t(15,_=T.duplicateOptionMsg),"duplicates"in T&&t(16,S=T.duplicates),"key"in T&&t(17,C=T.key),"filterFunc"in T&&t(64,M=T.filterFunc),"closeDropdownOnSelect"in T&&t(65,w=T.closeDropdownOnSelect),"form_input"in T&&t(5,k=T.form_input),"highlightMatches"in T&&t(66,A=T.highlightMatches),"id"in T&&t(18,P=T.id),"input"in T&&t(6,L=T.input),"inputClass"in T&&t(19,B=T.inputClass),"inputmode"in T&&t(20,O=T.inputmode),"invalid"in T&&t(7,q=T.invalid),"liActiveOptionClass"in T&&t(21,Z=T.liActiveOptionClass),"liOptionClass"in T&&t(22,ee=T.liOptionClass),"liSelectedClass"in T&&t(23,se=T.liSelectedClass),"loading"in T&&t(24,$=T.loading),"matchingOptions"in T&&t(1,W=T.matchingOptions),"maxOptions"in T&&t(25,J=T.maxOptions),"maxSelect"in T&&t(26,F=T.maxSelect),"maxSelectMsg"in T&&t(27,ie=T.maxSelectMsg),"maxSelectMsgClass"in T&&t(28,Y=T.maxSelectMsgClass),"name"in T&&t(29,de=T.name),"noMatchingOptionsMsg"in T&&t(30,V=T.noMatchingOptionsMsg),"open"in T&&t(8,H=T.open),"options"in T&&t(2,fe=T.options),"outerDiv"in T&&t(9,Ce=T.outerDiv),"outerDivClass"in T&&t(31,Ie=T.outerDivClass),"parseLabelsAsHtml"in T&&t(32,et=T.parseLabelsAsHtml),"pattern"in T&&t(33,At=T.pattern),"placeholder"in T&&t(34,mi=T.placeholder),"removeAllTitle"in T&&t(35,gi=T.removeAllTitle),"removeBtnTitle"in T&&t(36,Pt=T.removeBtnTitle),"minSelect"in T&&t(37,Rt=T.minSelect),"required"in T&&t(38,gt=T.required),"resetFilterOnAdd"in T&&t(67,Js=T.resetFilterOnAdd),"searchText"in T&&t(3,Qe=T.searchText),"selected"in T&&t(4,De=T.selected),"sortSelected"in T&&t(68,jn=T.sortSelected),"selectedOptionsDraggable"in T&&t(39,Xs=T.selectedOptionsDraggable),"ulOptionsClass"in T&&t(40,Gl=T.ulOptionsClass),"ulSelectedClass"in T&&t(41,Kl=T.ulSelectedClass),"value"in T&&t(59,Oa=T.value),"$$scope"in T&&t(107,s=T.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&16&&vf(De),n.$$.dirty[1]&268435456&&kf(Oa),n.$$.dirty[0]&196636|n.$$.dirty[2]&4&&t(1,W=fe.filter(T=>M(T,Qe)&&(!De.map(C).includes(C(T))||S))),n.$$.dirty[0]&3&&t(60,o=W[r??-1]??null),n.$$.dirty[0]&16&&t(48,i=T=>De.map(it).includes(T))},[r,W,fe,Qe,De,k,L,q,H,Ce,l,c,u,f,b,_,S,C,P,B,O,Z,ee,se,$,J,F,ie,Y,de,V,Ie,et,At,mi,gi,Pt,Rt,gt,Xs,Gl,Kl,p,Pa,Vn,Qs,er,Ra,i,qi,ji,$l,wf,_f,Sf,Cf,xf,Af,Tf,Oa,o,d,h,m,M,w,A,Js,jn,a,Df,Ef,Mf,If,Of,Pf,Rf,Nf,Lf,Bf,Ff,Wf,Hf,zf,qf,jf,Vf,Uf,Gf,Kf,$f,Yf,Jf,Xf,Qf,Zf,em,tm,nm,im,am,sm,rm,om,lm,cm,um,s]}var Fl=class extends G{constructor(e){super(),K(this,e,Yy,$y,j,{activeIndex:0,activeOption:60,createOptionMsg:10,allowUserOptions:11,allowEmpty:61,autocomplete:12,autoScroll:62,breakpoint:63,defaultDisabledTitle:13,disabled:42,disabledInputTitle:14,duplicateOptionMsg:15,duplicates:16,key:17,filterFunc:64,closeDropdownOnSelect:65,form_input:5,highlightMatches:66,id:18,input:6,inputClass:19,inputmode:20,invalid:7,liActiveOptionClass:21,liOptionClass:22,liSelectedClass:23,loading:24,matchingOptions:1,maxOptions:25,maxSelect:26,maxSelectMsg:27,maxSelectMsgClass:28,name:29,noMatchingOptionsMsg:30,open:8,options:2,outerDiv:9,outerDivClass:31,parseLabelsAsHtml:32,pattern:33,placeholder:34,removeAllTitle:35,removeBtnTitle:36,minSelect:37,required:38,resetFilterOnAdd:67,searchText:3,selected:4,sortSelected:68,selectedOptionsDraggable:39,ulOptionsClass:40,ulSelectedClass:41,value:59},vy,[-1,-1,-1,-1,-1])}},xa=Fl;function Jy(n=!0){let e=this,t=new IntersectionObserver(function([i]){let a=i.intersectionRatio;if(a<1){let s=a<=0&&n?"center":"nearest";e.scrollIntoView({block:s,inline:s})}this.disconnect()});return t.observe(e),t}typeof Element<"u"&&!Element.prototype?.scrollIntoViewIfNeeded&&typeof IntersectionObserver<"u"&&(Element.prototype.scrollIntoViewIfNeeded=Jy);function Xy(n){re(n,"svelte-1dl3a9e",".multiselect-container.svelte-1dl3a9e{width:100%}.multiselect-container.svelte-1dl3a9e .multiselect-dropdown{height:auto;min-height:var(--input-height, 30px)}.multiselect-container.svelte-1dl3a9e div.multiselect{--sms-border:none;--sms-bg:var(--interactive-normal);--sms-options-bg:var(--interactive-normal);--sms-border-radius:var(--radius)}.multiselect-container.svelte-1dl3a9e div.multiselect ul{padding-left:0;border-radius:var(--radius)}.multiselect-container.svelte-1dl3a9e div.multiselect button{height:0}.multiselect-container.svelte-1dl3a9e div.multiselect input{width:0;font-size:var(--font-ui-small)}.multiselect-container.svelte-1dl3a9e div.multiselect li{border-left:none}.multiselect-container.svelte-1dl3a9e div.multiselect li::before{content:none}")}function Qy(n){let e,t,i,a;function s(o){n[5](o)}let r={options:n[3],outerDivClass:"multiselect-dropdown",placeholder:n[1]};return n[2]!==void 0&&(r.selected=n[2]),t=new xa({props:r}),Re.push(()=>Bt(t,"selected",s)),{c(){e=v("div"),ae(t.$$.fragment),g(e,"class","multiselect-container svelte-1dl3a9e")},m(o,l){D(o,e,l),te(t,e,null),a=!0},p(o,[l]){let c={};l&2&&(c.placeholder=o[1]),!i&&l&4&&(i=!0,c.selected=o[2],Lt(()=>i=!1)),t.$set(c)},i(o){a||(E(t.$$.fragment,o),a=!0)},o(o){I(t.$$.fragment,o),a=!1},d(o){o&&x(e),ne(t)}}}function Zy(n,e,t){let i,a=N,s=()=>(a(),a=Tt(r,u=>t(2,i=u)),r);n.$$.on_destroy.push(()=>a());let{filter:r}=e;s();let{options:o}=e,l=[...o,Fs],{placeholder:c}=e;function d(u){i=u,r.set(i)}return n.$$set=u=>{"filter"in u&&s(t(0,r=u.filter)),"options"in u&&t(4,o=u.options),"placeholder"in u&&t(1,c=u.placeholder)},[r,c,i,l,o,d]}var Wl=class extends G{constructor(e){super(),K(this,e,Zy,Qy,j,{filter:0,options:4,placeholder:1},Xy)}},uf=Wl;function ev(n){re(n,"svelte-1y4cmh8",".controls.svelte-1y4cmh8{display:flex;justify-content:space-between;align-items:center;gap:0.5rem}.filter-button.svelte-1y4cmh8{position:relative}.filter-number.svelte-1y4cmh8{position:absolute;bottom:0;right:0;background-color:var(--interactive-normal);border-radius:50%;width:14px;height:14px;display:flex;align-items:center;justify-content:center;font-size:var(--font-smallest);pointer-events:none}.container.svelte-1y4cmh8{display:flex;flex-flow:column nowrap;gap:1rem}")}function df(n){let e,t,i,a;return t=new uf({props:{options:n[1],placeholder:"Sources",filter:di}}),{c(){e=v("div"),ae(t.$$.fragment),g(e,"class","filters")},m(s,r){D(s,e,r),te(t,e,null),a=!0},p(s,r){let o={};r&2&&(o.options=s[1]),t.$set(o)},i(s){a||(E(t.$$.fragment,s),s&&Mt(()=>{a&&(i||(i=Yn(e,Pi,{easing:on},!0)),i.run(1))}),a=!0)},o(s){I(t.$$.fragment,s),s&&(i||(i=Yn(e,Pi,{easing:on},!1)),i.run(0)),a=!1},d(s){s&&x(e),ne(t),s&&i&&i.end()}}}function tv(n){let e,t,i,a,s,r,o,l,c,d,u,h,m,f,p,b,_,S,C,M;i=new Wh({props:{filter:wn,placeholder:"Search Creatures"}});let w=n[0]&&df(n);return{c(){e=v("div"),t=v("div"),ae(i.$$.fragment),a=R(),s=v("div"),r=v("div"),l=R(),c=v("div"),d=pe(n[2]),u=R(),h=v("div"),f=R(),p=v("div"),_=R(),w&&w.c(),g(c,"class","filter-number svelte-1y4cmh8"),g(s,"class","filter-button svelte-1y4cmh8"),g(p,"aria-label","Delete filtered creatures"),g(t,"class","controls svelte-1y4cmh8"),g(e,"class","container svelte-1y4cmh8")},m(k,A){D(k,e,A),y(e,t),te(i,t,null),y(t,a),y(t,s),y(s,r),y(s,l),y(s,c),y(c,d),y(t,u),y(t,h),y(t,f),y(t,p),y(e,_),w&&w.m(e,null),S=!0,C||(M=[X(o=n[7].call(null,r)),z(s,"click",n[9]),X(m=n[5].call(null,h)),z(h,"click",n[10]),X(b=n[6].call(null,p)),z(p,"click",n[11])],C=!0)},p(k,[A]){(!S||A&4)&&we(d,k[2]),k[0]?w?(w.p(k,A),A&1&&E(w,1)):(w=df(k),w.c(),E(w,1),w.m(e,null)):w&&(ce(),I(w,1,1,()=>{w=null}),ue())},i(k){S||(E(i.$$.fragment,k),E(w),S=!0)},o(k){I(i.$$.fragment,k),I(w),S=!1},d(k){k&&x(e),ne(i),w&&w.d(),C=!1,le(M)}}}function nv(n,e,t){let i,a,s,r;Se(n,di,_=>t(12,i=_)),Se(n,wn,_=>t(13,a=_)),Se(n,Bh,_=>t(2,r=_));let o=Be([...ve.getIndex("source").keys()]);Se(n,o,_=>t(1,s=_));let l=Me();ve.onIndexUpdated("source",()=>Ae(o,s=[...ve.getIndex("source").keys()],s));let c=!0,d=_=>{new qs.ExtraButtonComponent(_).setIcon("reset")},u=_=>{new qs.ExtraButtonComponent(_).setIcon("trash")},h=_=>{new qs.ExtraButtonComponent(_).setIcon("filter")},m=()=>{Ae(wn,a="",a),Ae(di,i=[],i)};return[c,s,r,o,l,d,u,h,m,()=>t(0,c=!c),()=>m(),()=>l("remove")]}var Hl=class extends G{constructor(e){super(),K(this,e,nv,tv,j,{},ev)}},hf=Hl;var gf=require("obsidian");function iv(n){re(n,"svelte-1e6o0go",".bestiary-container.svelte-1e6o0go{display:flex;flex-flow:column;gap:1rem}.filters-container.svelte-1e6o0go{display:flex;flex-flow:column nowrap;gap:0.25rem}")}function ff(n,e,t){let i=n.slice();return i[16]=e[t],i}function mf(n,e){let t,i,a;return i=new Fh({props:{item:e[16]}}),i.$on("close",e[13]),{key:n,first:null,c(){t=_e(),ae(i.$$.fragment),this.first=t},m(s,r){D(s,t,r),te(i,s,r),a=!0},p(s,r){e=s;let o={};r&8&&(o.item=e[16]),i.$set(o)},i(s){a||(E(i.$$.fragment,s),a=!0)},o(s){I(i.$$.fragment,s),a=!1},d(s){s&&x(t),ne(i,s)}}}function av(n){let e,t,i,a,s,r=(n[2].length?n[2].length:"No")+"",o,l,c=n[2].length===1?"":"s",d,u,h,m=[],f=new Map,p,b,_,S;i=new hf({}),i.$on("remove",n[12]);let C=ye(n[3]),M=w=>w[16].name;for(let w=0;wt(14,a=C));let d=ve.onSortedBy("name",C=>{Ae(c,a=C,a)});bn(()=>{d()});let u=Be(50),h=Be(1),m=yt([c,wn,di],([C,M,w])=>{let k=[];for(let A of C){let P=!0;M.length&&((0,gf.prepareSimpleSearch)(M)(A.name)||(P=!1)),w.length&&![A.source].flat().some(L=>L&&w.includes(L))&&(P=!1),!A.source&&w.includes(Fs)&&(P=!0),P&&k.push(A)}return k});Se(n,m,C=>t(2,i=C));let f=async()=>{i.length&&await ho(r.app,`Are you sure you want to delete ${i.length} creature${i.length===1?"":"s"}?`)&&await r.deleteMonsters(...i.map(C=>C.name))},p=yt([u,m],([C,M])=>Math.ceil(M.length/C)),b=yt([m,u,h],([C,M,w])=>C.slice((w-1)*M,w*M));Se(n,b,C=>t(3,s=C));let _=()=>f();function S(C){Ue.call(this,n,C)}return n.$$set=C=>{"plugin"in C&&t(11,r=C.plugin),"backgroundColor"in C&&t(0,o=C.backgroundColor),"paddingTop"in C&&t(1,l=C.paddingTop)},[o,l,i,s,c,u,h,m,f,p,b,r,_,S]}var zl=class extends G{constructor(e){super(),K(this,e,sv,av,j,{plugin:11,backgroundColor:0,paddingTop:1},iv)}},pf=zl;var Ta=class extends ke.PluginSettingTab{constructor(t,i){super(t,i);this.plugin=i;this.results=[];this.importer=new Sa(this.plugin)}async display(){try{let{containerEl:t}=this;t.empty(),t.addClass("statblock-settings"),t.createEl("h2",{text:"Fantasy Statblocks Settings"}),this.generateTopSettings(t.createDiv()),this.generateParseSettings(t.createDiv()),this.generateAdvancedSettings(t.createDiv()),this.generateLayouts(t.createDiv()),this.generateImports(t.createDiv()),this.generateMonsters(t.createDiv()),t.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=\u2615&slug=valentine195&button_colour=e3e7ef&font_colour=262626&font_family=Inter&outline_colour=262626&coffee_colour=ff0000"}})}catch(t){console.error(t),new ke.Notice("There was an error displaying the settings tab for 5e Statblocks.")}}generateAdvancedSettings(t){t.empty(),new ke.Setting(t).setHeading().setName("Advanced Settings"),new ke.Setting(t).setName("Try to Save Data Atomically").setDesc(createFragment(i=>{i.createSpan({text:"This will cause to plugin to save data to a temporary file before saving the actual data file in an attempt to prevent data loss."}),i.createEl("br"),i.createSpan({text:"This can cause issues sometimes when using sync services."}),i.createEl("br");let a=i.createDiv();(0,ke.setIcon)(a.createDiv(),"warning"),a.createSpan({attr:{style:"color: var(--text-error)"},text:"This setting is currently disabled."})})).addToggle(i=>i.setValue(this.plugin.settings.atomicWrite).onChange(async a=>{this.plugin.settings.atomicWrite=a,await this.plugin.saveSettings()}))}generateTopSettings(t){t.empty(),new ke.Setting(t).setHeading().setName("General Settings"),new ke.Setting(t).setName("Integrate Dice Roller").setDesc(createFragment(i=>{this.plugin.diceRollerInstalled?(i.createSpan({text:"Add Dice Roller dice to statblocks by default. Use "}),i.createEl("code",{text:"dice: false"}),i.createSpan({text:" to disable per-statblock."})):i.createSpan({text:"This setting is only usable with the Dice Roller plugin enabled."})})).setDisabled(!this.plugin.diceRollerInstalled).addToggle(i=>i.setValue(this.plugin.settings.useDice).onChange(async a=>{this.plugin.settings.useDice=a,await this.plugin.saveSettings()})),new ke.Setting(t).setName("Render Dice Rolls").setDesc(createFragment(i=>{this.plugin.diceRollerInstalled?(i.createSpan({text:"Roll graphical dice inside statblocks by default. Use "}),i.createEl("code",{text:"render: false"}),i.createSpan({text:" to disable per-statblock."})):i.createSpan({text:"This setting is only usable with the Dice Roller plugin enabled."})})).setDisabled(!this.plugin.diceRollerInstalled).addToggle(i=>i.setValue(this.plugin.settings.renderDice).onChange(async a=>{this.plugin.settings.renderDice=a,this.plugin.diceRollerInstalled&&window.DiceRoller.registerSource(hi,{showDice:!0,shouldRender:this.plugin.settings.renderDice,showFormula:!1,showParens:!1,expectedValue:Fi.Average}),await this.plugin.saveSettings()})),new ke.Setting(t).setName("Try to Render Wikilinks").setDesc(createFragment(i=>{i.createSpan({text:"The plugin will attempt to detect wikilinks inside Statblocks."}),i.createEl("br"),i.createEl("strong",{text:"Please note: these links will not be added to the graph."})})).addToggle(i=>i.setValue(this.plugin.settings.tryToRenderLinks).onChange(async a=>{this.plugin.settings.tryToRenderLinks=a,await this.plugin.saveSettings()})),new ke.Setting(t).setName("Enable 5e SRD").setDesc(createFragment(i=>{i.createSpan({text:"Use the Dungeons & Dragons 5th Edition System Reference Document monsters."})})).addToggle(i=>i.setValue(!this.plugin.settings.disableSRD).onChange(async a=>{this.plugin.settings.disableSRD=!a,await this.plugin.saveSettings(),this.plugin.app.workspace.trigger("fantasy-statblocks:srd-change",a)}))}generateParseSettings(t){t.empty();let i=t.createDiv("statblock-additional-container");new ke.Setting(i).setHeading().setName("Note Parsing"),new ke.Setting(i).setName("Automatically Parse Frontmatter for Creatures").setDesc(createFragment(r=>{r.createSpan({text:"The plugin will watch the vault for creatures defined in note frontmatter."}),r.createEl("br"),r.createEl("br"),r.createSpan({text:'The "Parse Frontmatter for Creatures" command can also be used.'})})).addToggle(r=>{r.setValue(this.plugin.settings.autoParse).onChange(async o=>{this.plugin.settings.autoParse=o,o&&kn.start(),await this.plugin.saveSettings()})}),new ke.Setting(i).setName("Enable Debug Messages").setDesc(createFragment(r=>{r.createSpan({text:"Debug messages will be displayed by the file parser."})})).addToggle(r=>r.setValue(this.plugin.settings.debug).onChange(async o=>{this.plugin.settings.debug=o,kn.setDebug(),await this.plugin.saveSettings()}));let a;new ke.Setting(i).setName("Bestiary Folder").setDesc("The plugin will only parse notes inside these folders and their children.").addText(async r=>{let o=this.app.vault.getAllLoadedFiles().filter(c=>c instanceof ke.TFolder&&!this.plugin.settings.paths.includes(c.path));r.setPlaceholder("/"),new bf.FolderInputSuggest(this.app,r,[...o]).onSelect(async({item:c})=>{a=(0,ke.normalizePath)(c.path),r.setValue(c.path)}),r.inputEl.onblur=async()=>{let c=r.inputEl.value?.trim()?r.inputEl.value.trim():"/";a=(0,ke.normalizePath)(c)}}).addExtraButton(r=>{r.setIcon("plus-with-circle").onClick(async()=>{!a||!a.length||(this.plugin.settings.paths.push((0,ke.normalizePath)(a)),await this.plugin.saveSettings(),await kn.reparseVault(),await this.generateParseSettings(t))})});let s=i.createDiv("additional");for(let r of this.plugin.settings.paths)new ke.Setting(s).setName(r).addExtraButton(o=>o.setIcon("trash").onClick(async()=>{this.plugin.settings.paths=this.plugin.settings.paths.filter(l=>l!=r),await this.plugin.saveSettings(),await kn.reparseVault(),await this.generateParseSettings(t)}))}generateLayouts(t){t.empty(),new ke.Setting(t).setHeading().setName("Layouts");let i=t.createDiv("statblock-additional-container");i.createDiv("setting-item").createDiv().appendChild(createFragment(l=>{l.createSpan({text:"New statblock layouts can be created and managed here. A specific layout can be used for a creature using the "}),l.createEl("code",{text:"layout"}),l.createSpan({text:" parameter."})}));let a=new ke.Setting(i).setName("Import From JSON").setDesc("Import a custom layout from a JSON file."),s=createEl("input",{attr:{type:"file",name:"layout",accept:".json",multiple:!0}});s.onchange=async()=>{let{files:l}=s;if(l?.length)try{let{files:c}=s;if(!c?.length)return;for(let d of Array.from(c))await new Promise((u,h)=>{let m=new FileReader;m.onload=async f=>{try{let p=JSON.parse(f.target?.result);if(!p){h(new Error("Invalid layout imported"));return}if(!p?.name){h(new Error("Invalid layout imported: layout does not have a name"));return}if(!p?.blocks){h(new Error("Invalid layout imported: no blocks defined in layout."));return}p.diceParsing||(p.diceParsing=[]),p.id=U(),!this.plugin.settings.alwaysImport&&p.blocks.find(b=>b.type=="javascript")&&!await rv(this.plugin)&&u(),this.plugin.settings.layouts.push(this.getDuplicate(p)),u()}catch(p){h(p)}},m.readAsText(d)}).catch(u=>{new ke.Notice(`There was an error importing the layout: ${u}`),console.error(u)});await this.plugin.saveSettings(),s.value="",this.buildCustomLayouts(o,t)}catch{}},a.addButton(l=>{l.setIcon("upload"),l.buttonEl.addClass("statblock-file-upload"),l.buttonEl.appendChild(s),l.onClick(()=>s.click())}),new ke.Setting(i).setName("Add New Layout").addButton(l=>l.setIcon("plus-with-circle").setTooltip("Add New Layout").onClick(()=>{let c=new Aa(this.plugin);c.onClose=async()=>{if(!c.saved)return;let d=this.getDuplicate(c.layout);this.plugin.settings.layouts.push(d),this.plugin.manager.addLayout(d),await this.plugin.saveSettings(),this.buildCustomLayouts(o,t)},c.open()}));let r=i.createDiv("additional");new ke.Setting(r).setName("Default Layout").setDesc("Change the default statblock layout used, if not specified.").addDropdown(async l=>{for(let c of this.plugin.manager.getAllLayouts())l.addOption(c.id,c.name);(!this.plugin.settings.default||!this.plugin.manager.getAllLayouts().find(({id:c})=>c==this.plugin.settings.default))&&(this.plugin.settings.default=rn.id,await this.plugin.saveSettings()),l.setValue(this.plugin.settings.default??rn.id),l.onChange(async c=>{this.plugin.settings.default=c,this.plugin.manager.setDefaultLayout(c),await this.plugin.saveSettings()})}),new ke.Setting(r).setName("Show Advanced Options").setDesc("Show advanced options when editing layout blocks.").addToggle(l=>l.setValue(this.plugin.settings.showAdvanced).onChange(async c=>{this.plugin.settings.showAdvanced=c,await this.plugin.saveSettings()}));let o=i.createDiv("additional");this.buildCustomLayouts(o,t)}getDuplicate(t){if(!this.plugin.manager.getAllLayouts().find(o=>o.name==t.name))return t;let i=this.plugin.manager.getSortedLayoutNames().filter(o=>o.contains(`${t.name} Copy`)),a=`${t.name} Copy`,s=a,r=1;for(;i.includes(s);)s=`${a} (${r})`,r++;return{blocks:Ze(t.blocks),name:s,id:U()}}buildCustomLayouts(t,i){t.empty(),this.plugin.manager.getAllDefaultLayouts().some(a=>a.removed)&&new ke.Setting(t).setName("Restore Default Layouts").addButton(a=>{a.setIcon("rotate-ccw").onClick(async()=>{for(let s of Object.values(this.plugin.settings.defaultLayouts))s.removed=!1,s.edited||delete this.plugin.settings.defaultLayouts[s.id];await this.plugin.saveSettings(),this.generateLayouts(i)})});for(let a of this.plugin.manager.getAllDefaultLayouts()){if(a.removed)continue;let s=new ke.Setting(t).setName(a.name).addExtraButton(r=>{r.setIcon("pencil").setTooltip("Edit").onClick(()=>{let o=new Aa(this.plugin,a);o.onClose=async()=>{o.saved&&(o.layout.edited=!0,this.plugin.settings.defaultLayouts[a.id]=o.layout,await this.plugin.saveSettings(),this.plugin.manager.updateDefaultLayout(a.id,o.layout),this.generateLayouts(i))},o.open()})});a.edited&&s.addExtraButton(r=>r.setIcon("undo").onClick(async()=>{let o=ci.find(({id:l})=>l==a.id);delete this.plugin.settings.defaultLayouts[a.id],await this.plugin.saveSettings(),this.plugin.manager.updateDefaultLayout(a.id,o),this.generateLayouts(i)})),s.addExtraButton(r=>{r.setIcon("duplicate-glyph").setTooltip("Create Copy").onClick(async()=>{let o=this.getDuplicate(a);this.plugin.settings.layouts.push(o),await this.plugin.saveSettings(),this.plugin.manager.addLayout(o),this.buildCustomLayouts(t,i)})}).addExtraButton(r=>{r.setIcon("import-glyph").setTooltip("Export as JSON").onClick(()=>{let o=createEl("a"),l=new Blob([JSON.stringify(a)],{type:"json"}),c=URL.createObjectURL(l);o.href=c,o.download=`${a.name}.json`,o.click(),URL.revokeObjectURL(c)})}).addExtraButton(r=>{r.setIcon("trash").setTooltip("Delete").onClick(async()=>{a.removed=!0,this.plugin.settings.defaultLayouts[a.id]=a,await this.plugin.saveSettings(),this.generateLayouts(i)})})}for(let a of this.plugin.settings.layouts)new ke.Setting(t).setName(a.name).addExtraButton(s=>{s.setIcon("pencil").setTooltip("Edit").onClick(()=>{let r=new Aa(this.plugin,a);r.onClose=async()=>{r.saved&&(ci.find(({id:o})=>o==a.id)&&(r.layout.edited=!0),this.plugin.settings.layouts.splice(this.plugin.settings.layouts.indexOf(a),1,r.layout),await this.plugin.saveSettings(),this.plugin.manager.updateLayout(a.id,r.layout),this.generateLayouts(i))},r.open()})}).addExtraButton(s=>{s.setIcon("duplicate-glyph").setTooltip("Create Copy").onClick(async()=>{let r=this.getDuplicate(a);this.plugin.settings.layouts.push(r),await this.plugin.saveSettings(),this.plugin.manager.addLayout(r),this.buildCustomLayouts(t,i)})}).addExtraButton(s=>{s.setIcon("import-glyph").setTooltip("Export as JSON").onClick(()=>{let r=createEl("a"),o=new Blob([JSON.stringify(a)],{type:"json"}),l=URL.createObjectURL(o);r.href=l,r.download=`${a.name}.json`,r.click(),URL.revokeObjectURL(l)})}).addExtraButton(s=>{s.setIcon("trash").setTooltip("Delete").onClick(async()=>{this.plugin.settings.layouts=this.plugin.settings.layouts.filter(r=>r.id!==a.id),await this.plugin.saveSettings(),this.plugin.manager.removeLayout(a.id),this.generateLayouts(i)})})}generateImports(t){t.empty(),new ke.Setting(t).setHeading().setName("Import Homebrew Creatures");let i=t.createDiv("statblock-additional-container");new ke.Setting(i).setDesc("Import creatures from creature files. Monsters are stored by name, so only the last creature by that name will be saved. This is destructive - any saved creature will be overwritten.");let a=i.createDiv("additional"),s=new ke.Setting(a).setName("Import DnDAppFile").setDesc("Only import content that you own."),r=createEl("input",{attr:{type:"file",name:"dndappfile",accept:".xml",multiple:!0}});r.onchange=async()=>{let{files:w}=r;if(w?.length)try{let{files:k}=r;if(!k?.length)return;let A=await this.importer.import(k,"appfile");A&&A.length&&await this.plugin.saveMonsters(A),this.display()}catch{}},s.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import DnDAppFile Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(r),w.onClick(()=>r.click())});let o=new ke.Setting(a).setName("Import Improved Initiative Data").setDesc("Only import content that you own."),l=createEl("input",{attr:{type:"file",name:"improvedinitiative",accept:".json",multiple:!0}});l.onchange=async()=>{let{files:w}=l;if(w?.length)try{let{files:k}=l;if(!k?.length)return;let A=await this.importer.import(k,"improved");A&&A.length&&await this.plugin.saveMonsters(A),this.display()}catch{}},o.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import Improved Initiative Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(l),w.onClick(()=>l.click())});let c=new ke.Setting(a).setName("Import CritterDB Data").setDesc("Only import content that you own."),d=createEl("input",{attr:{type:"file",name:"critterdb",accept:".json",multiple:!0}});d.onchange=async()=>{let{files:w}=d;if(w?.length)try{let{files:k}=d;if(!k?.length)return;let A=await this.importer.import(k,"critter");A&&A.length&&await this.plugin.saveMonsters(A),this.display()}catch{}},c.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import CritterDB Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(d),w.onClick(()=>d.click())});let u=new ke.Setting(a).setName("Import 5e.tools Data").setDesc("Only import content that you own."),h=createEl("input",{attr:{type:"file",name:"fivetools",accept:".json",multiple:!0}});h.onchange=async()=>{let{files:w}=h;if(!w?.length)return;let k=await this.importer.import(w,"5e");k&&k.length&&await this.plugin.saveMonsters(k),this.display()},u.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import 5e.tools Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(h),w.onClick(()=>h.click())});let m=new ke.Setting(a).setName("Import TetraCube Data").setDesc("Only import content that you own."),f=createEl("input",{attr:{type:"file",name:"tetra",accept:".json, .monster",multiple:!0}});f.onchange=async()=>{let{files:w}=f;if(!w?.length)return;let k=await this.importer.import(w,"tetra");k&&k.length&&await this.plugin.saveMonsters(k),this.display()},m.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import TetraCube Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(f),w.onClick(()=>f.click())});let p=new ke.Setting(a).setName("Import PF2eMonsterTools Data").setDesc("Only import content that you own."),b=createEl("input",{attr:{type:"file",name:"PF2eMonsterTool",accept:".json, .monster",multiple:!0}});b.onchange=async()=>{let{files:w}=b;if(!w?.length)return;let k=await this.importer.import(w,"PF2eMonsterTool");k&&k.length&&await this.plugin.saveMonsters(k),this.display()},p.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import PF2EMonsterTools Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(b),w.onClick(()=>b.click())});let _=new ke.Setting(a).setName("Import Pathbuilder Data").setDesc("Import a PC or NPC exported from Pathbuilder2e."),S=createEl("input",{attr:{type:"file",name:"pathbuilder",accept:".json",multiple:!0}});S.onchange=async()=>{let{files:w}=S;if(!w.length)return;let k=await this.importer.import(w,"pathbuilder");k&&k.length&&await this.plugin.saveMonsters(k),this.display()},_.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import Pathbuilder Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(S),w.onClick(()=>S.click())});let C=new ke.Setting(a).setName("Import Generic Data").setDesc(createFragment(w=>{w.createSpan({text:"Import generic JSON files. JSON objects will be imported "}),w.createEl("strong",{text:"as-is"}),w.createSpan({text:" and all objects must have the "}),w.createEl("code",{text:"name"}),w.createSpan({text:" property."})})),M=createEl("input",{attr:{type:"file",name:"generic",accept:".json, .monster",multiple:!0}});M.onchange=async()=>{let{files:w}=M;if(!w?.length)return;let k=await this.importer.import(w,"generic");k&&k.length&&await this.plugin.saveMonsters(k),this.display()},C.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import Generic Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(M),w.onClick(()=>M.click())})}generateMonsters(t){t.empty(),new ke.Setting(t).setHeading().setName("Bestiary");let i=t.createDiv("statblock-additional-container statblock-monsters");new ke.Setting(i).setName("Add Creature").addButton(o=>{o.setIcon("plus-with-circle").onClick(()=>{let l=new Hi(this.plugin);l.onClose=()=>{this.generateMonsters(t)},l.open()})});let a=this.containerEl.closest(".statblock-settings"),{backgroundColor:s,paddingTop:r}=getComputedStyle(a);this.$UI=new pf({target:i,props:{plugin:this.plugin,backgroundColor:s,paddingTop:r}})}hide(){this.$UI.$destroy()}},Aa=class extends wt{constructor(t,i={name:"Layout",blocks:[],id:U()}){super(t);this.plugin=t;this.saved=!1;this.layout=Ze(i),this.modalEl.addClasses(["mod-sidebar-layout","mod-settings"]),this.contentEl.addClass("vertical-tabs-container")}onOpen(){this.display()}display(){this.titleEl.createSpan({text:"Create Layout"}),this.creator=new Ah({target:this.contentEl,props:{layout:this.layout,plugin:this.plugin}}),this.creator.$on("saved",()=>{this.saved=!0,this.close()}),this.creator.$on("cancel",()=>{this.close()})}};async function rv(n){return new Promise((e,t)=>{try{let i=new ql(n);i.onClose=()=>{e(i.confirmed)},i.open()}catch{t()}})}var ql=class extends wt{constructor(t){super(t);this.plugin=t;this.confirmed=!1}async display(){this.contentEl.empty(),this.contentEl.addClass("confirm-modal"),this.contentEl.createEl("p",{text:"This Layout includes JavaScript blocks. JavaScript blocks can execute code in your vault, which could cause loss or corruption of data."}),this.contentEl.createEl("p",{text:"Are you sure you want to import this layout?"});let t=this.contentEl.createDiv("confirm-buttons-container");t.createEl("a").createEl("small",{cls:"dont-ask",text:"Import and don't ask again"}).onclick=async()=>{this.confirmed=!0,this.plugin.settings.alwaysImport=!0,this.close()};let i=t.createDiv("confirm-buttons");new ke.ButtonComponent(i).setButtonText("Import").setCta().onClick(()=>{this.confirmed=!0,this.close()}),i.createEl("a").createEl("small",{cls:"dont-ask",text:"Cancel"}).onclick=()=>{this.close()}}onOpen(){this.display()}};var Vs=require("obsidian");var ov=["creature","name","layout","source","dice","render","columns","forceColumns","columnWidth","columnHeight","extends"],js=class extends Vs.EditorSuggest{constructor(t){super(t.app);this.plugin=t;this._context=4}getSuggestions(t){let i=[];switch(this._context){case 3:{i=["true","false"];break}case 1:{i=this.plugin.api.getBestiaryNames();break}case 0:{i=this.plugin.manager.getSortedLayoutNames();break}case 2:{let a=this.plugin.manager.getLayoutOrDefault(this._layout).id;this._props=this.plugin.manager.getProperties(a),i=[...new Set([...ov,...this._props.keys()??[]])].filter(s=>!this._keys.includes(s));break}case 4:default:return[]}return t.query?.length?i.filter(a=>a.toLowerCase().contains(t.query.toLowerCase())):i}renderSuggestion(t,i){i.createSpan({text:t})}selectSuggestion(t,i){if(!this.context)return;let a=this.context.editor.getLine(this.context.end.line).slice(this.context.end.ch),[s,r]=a.match(/^(\] ?)/)??[],o;if(this._context===2)if(this._props.has(t))switch(this._props.get(t).type){case"heading":case"subheading":case"property":case"image":case"text":{t=`${t}: `;break}case"traits":{t=`${t}: - name: desc:`,o=t.length-10;break}case"table":{t=`${t}: []`,o=t.length-1;break}case"saves":case"spells":{t=`${t}: - `,o=t.length;break}case"inline":case"group":case"ifelse":case"collapse":case"javascript":case"layout":default:break}else t=`${t}: `,o=t.length;this.context.editor.replaceRange(`${t}`,this.context.start,{...this.context.end,ch:this.context.start.ch+this.context.query.length+(r?.length??0)},"statblocks"),this.context.editor.setCursor(this.context.start.line,this.context.start.ch+o),this.close()}onTrigger(t,i,a){let s=i.getRange({line:0,ch:0},t);if(s.indexOf("```statblock\n")===-1)return null;let r=s.split(` `),o=!1,l;for(let d=r.length-1;d>=0;d--){let u=r[d];if(/^\`\`\`$/.test(u))return null;if(/^\`\`\`statblock/.test(u)){o=!0,l=d;break}}if(!o)return;let c=i.getLine(t.line);if(this._context=4,/^name/.test(c))return null;if(/^(dice|render)/.test(c)){this._context=3;let d=c.match(/^(dice|render):\s?(.*)\n?/);if(!d)return null;let[u,h,m]=d;return m==="true"||m==="false"?null:{end:t,start:{ch:h.length+2,line:t.line},query:m}}if(/^(monster|creature|extends):/.test(c)){this._context=1;let d=c.match(/^(monster|creature|extends):\s?(.*)\n?/);if(!d)return null;let[u,h,m]=d;return ve.getBestiaryNames().find(f=>f.toLowerCase()==m.toLowerCase())?null:{end:t,start:{ch:h.length+2,line:t.line},query:m}}if(/^(layout):/m.test(c)){this._context=0;let d=c.match(/^(layout):\s?(.*)\n?/);if(!d)return null;let[u,h,m]=d;return this.plugin.manager.getAllLayouts().find(p=>p.name.toLowerCase()==m.toLowerCase())?null:{end:t,start:{ch:h.length+2,line:t.line},query:m}}try{let d=i.getValue().split(` `);d.splice(t.line,1),d=d.slice(l+1);let u=d.findIndex(m=>/^```$/.test(m));u<0&&(u=d.length);let h=(0,Vs.parseYaml)(d.slice(0,u).join(` `));this._keys=Object.keys(h),this._layout=h.layout??this.plugin.manager.getDefaultLayout().name}catch{this._keys=[]}return this._keys||(this._keys=[]),this._context=2,{end:t,start:{ch:0,line:t.line},query:c}}};var fi,_t,jl,Us,Ea,fn,_n,Ma,Vl,Ul,Da=class{constructor(){Le(this,_t);Le(this,fi,new Map);Le(this,Ea);Le(this,fn,new Map);Le(this,_n,new Map);Le(this,Ma,new WeakMap)}initialize(e){this.setDefaultLayout(e.default),this.setDefaultLayouts(e.defaultLayouts),this.setLayouts(e.layouts);for(let t of this.getAllLayouts())this.addStyleSheet(t)}unload(){for(let e of Q(this,fi).values())e.detach()}addStyleSheet(e){this.removeStyleSheet(e.id);let t=this.generateStyleSheet(e);t&&Q(this,fi).set(e.id,t)}removeStyleSheet(e){Q(this,fi).has(e)&&Q(this,fi).get(e).detach()}getSheetRules(e){if(!e.cssProperties)return[];let t=`.${e.name.toLowerCase().replace(/\s+/g,"-")}`,i=[Oe(this,_t,Us).call(this,t,{...cl,...e.cssProperties})];return Te.Light in e.cssProperties&&i.push(Oe(this,_t,Us).call(this,`.theme-light ${t}`,e.cssProperties[Te.Light])),Te.Dark in e.cssProperties&&i.push(Oe(this,_t,Us).call(this,`.theme-dark ${t}`,e.cssProperties[Te.Dark])),i}generateStyleSheet(e,t=`FS_CSS_PROPERTIES_${e.id}`){if(!e.cssProperties)return null;let i=document.head.createEl("style",{attr:{id:t}}),a=this.getSheetRules(e);for(let s of a)i.sheet.insertRule(s,i.sheet.cssRules.length);return i}updateDefaultLayout(e,t){Q(this,fn).delete(e),this.setDefaultLayouts({[t.id]:t}),this.addStyleSheet(t)}removeDefaultLayout(e){Q(this,fn).delete(e),this.removeStyleSheet(e)}setDefaultLayouts(e){for(let t of ci)Q(this,fn).set(t.id,t.id in e?e[t.id]:t);setTimeout(()=>{for(let t of Q(this,fn).values())Oe(this,_t,Vl).call(this,t)},0)}setDefaultLayout(e){nn(this,Ea,e)}getDefaultLayout(){return this.getAllLayouts()?.find(e=>e.id==Q(this,Ea))??rn}setLayouts(e){for(let t of e)Q(this,_n).set(t.id,t);setTimeout(()=>{for(let t of e)Oe(this,_t,Vl).call(this,t)},0)}getCustomLayouts(){return Q(this,_n).values()}getAllLayouts(){return[...Q(this,fn).values(),...Q(this,_n).values()].filter(e=>!("removed"in e)||!e.removed)}getAllDefaultLayouts(){return[...Q(this,fn).values()]}getLayout(e){return Q(this,_n).get(e)??Q(this,fn).get(e)??null}getLayoutOrDefault(e){return this.getAllLayouts().find(t=>t.name==e)??this.getDefaultLayout()}updateLayout(e,t){Q(this,_n).delete(e),this.setLayouts([t]),this.addStyleSheet(t)}removeLayout(e){Q(this,_n).delete(e),this.removeStyleSheet(e)}addLayout(e){this.setLayouts([e]),this.addStyleSheet(e)}getSortedLayoutNames(){let e=new Set([this.getDefaultLayout().name]);for(let t of this.getAllLayouts())e.has(t.name)||e.add(t.name);return[...e]}getProperties(e){let t=typeof e=="string"?this.getLayout(e):e;return Q(this,Ma).get(t)}};fi=new WeakMap,_t=new WeakSet,jl=function(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)},Us=function(e,t){let i=[];for(let[a,s]of Object.entries(t)){if(a==Te.Dark||a==Te.Light)continue;let r=wa.includes(s)?`var(--statblock-${Oe(this,_t,jl).call(this,s)})`:s;i.push(` --statblock-${Oe(this,_t,jl).call(this,a)}: ${r};`)}return`${e} {${i.join("")} }`},Ea=new WeakMap,fn=new WeakMap,_n=new WeakMap,Ma=new WeakMap,Vl=function(e){let t=new Map;Q(this,Ma).set(e,Oe(this,_t,Ul).call(this,e.blocks,t))},Ul=function(e,t){for(let i of e){if("nested"in i){Oe(this,_t,Ul).call(this,i.nested,t);continue}if("properties"in i)for(let a of i.properties)t.set(a,i)}return t};var Hn=require("obsidian");var Sn="fantasy-statblocks-creature-pane",Ia=class extends Hn.ItemView{constructor(t,i){super(t);this.plugin=i;this.topEl=this.contentEl.createDiv("creature-view-top-pane");this.statblockEl=this.contentEl.createDiv("creature-statblock-container");this.load(),this.containerEl.addClasses(["fantasy-statblocks","creature-view-container"]),this.containerEl.on("mouseover","a.internal-link",(0,Hn.debounce)(a=>{this.plugin.app.workspace.trigger("hover-link",{event:a,source:this.plugin.manifest.id,hoverParent:this.leaf,targetEl:a.target,linktext:a.target.dataset.href})},10)),this.containerEl.on("click","a.internal-link",a=>this.app.workspace.openLinkText(a.target.dataset.href,"fantasy-statblocks"))}onload(){let t=new Hn.SearchComponent(this.topEl).setPlaceholder("Find a creature"),i=new Bi(this.plugin.app,t,ve.getBestiaryCreatures());ve.onResolved(()=>{i.items=ve.getBestiaryCreatures()}),i.onSelect(async a=>{a&&(await this.render(a.item),t.setValue(""))}),new Hn.ExtraButtonComponent(this.topEl).setIcon("cross").setTooltip("Close Statblock").onClick(async()=>{await this.render(),t.setValue("")})}async render(t){if(this.statblockEl.empty(),!t){this.statblockEl.createEl("em",{text:"Select a creature to view it here."});return}let i=this.plugin.api.render(t,this.statblockEl);this.addChild(i)}getDisplayText(){return"Combatant"}getIcon(){return"skull"}getViewType(){return Sn}};var Ks=require("obsidian");var zn,Gs=class{constructor(e){Le(this,zn);nn(this,zn,e)}getVersion(){return Q(this,zn).settings.version}getBestiary(){return ve.getBestiary()}getBestiaryCreatures(){return ve.getBestiaryCreatures()}getBestiaryNames(){return ve.getBestiaryNames()}hasCreature(e){return ve.hasCreature(e)}getCreatureFromBestiary(e){return ve.getCreatureFromBestiarySync(e)}async getCreature(e){return await ve.getCreatureFromBestiary(e)}getSortedBy(e){return ve.getSortedBy(e)}onSortedBy(e,t){return ve.onSortedBy(e,t)}registerSorter(e,t){return ve.registerSorter(e,t)}getIndices(){return ve.getIndices()}getIndex(e){return ve.getIndex(e)}registerIndex(e){return ve.registerIndex(e)}onIndexUpdated(e,t){return ve.onIndexUpdated(e,t)}isResolved(){return ve.isResolved()}onResolved(e){return ve.onResolved(e)}onUpdated(e){return ve.onUpdated(e)}render(e,t,i){let a=Object.assign({},Ze(this.getCreatureFromBestiary(e.name??"")??{}),Ze(e));return a?(i&&(a.name=i),new $t({container:t,monster:a,plugin:Q(this,zn),context:"STATBLOCK_RENDERER"})):new Ks.Component}isStatblockLink(e){return Ft.isStatblockLink(e)}parseStatblockLink(e){return Ft.stringifyLinks(e)}stringifyLinks(e){return Ft.stringifyLinks(e)}transformLinks(e){return Ft.transformSource(e)}renderMarkdown(e,t,i="",a=Q(this,zn)){Ks.MarkdownRenderer.render(Q(this,zn).app,e,t,i,a)}};zn=new WeakMap;var hi="FANTASY_STATBLOCKS_PLUGIN",lv={monsters:[],defaultLayouts:{},layouts:[],default:rn.name,useDice:!0,renderDice:!1,export:!0,showAdvanced:!1,version:{major:null,minor:null,patch:null},paths:["/"],autoParse:!1,disableSRD:!1,tryToRenderLinks:!0,debug:!1,notifiedOfFantasy:!1,hideConditionHelp:!1,alwaysImport:!1,defaultLayoutsIntegrated:!1,atomicWrite:!1},Ys,$s=class extends qn.Plugin{constructor(){super(...arguments);this.manager=new Da;this.api=new Gs(this);Le(this,Ys,t=>{let i=t?.creature??t?.name??"";if(ve.hasCreature(i)){let a=ve.get(i);this.creature_view?this.creature_view.render(a):this.openCreatureView().then(s=>s.render(a))}})}getRoller(t){return this.canUseDiceRoller?window.DiceRoller.getRollerSync(t,hi):void 0}getRollerString(t){return this.canUseDiceRoller?window.DiceRoller.getRollerString(t,hi):t}get diceRollerInstalled(){return window.DiceRoller!=null}get canUseDiceRoller(){return this.diceRollerInstalled?this.settings.useDice:!1}get creature_view(){let t=this.app.workspace.getLeavesOfType(Sn),i=t?.length?t[0]:null;if(i&&i.view&&i.view instanceof Ia)return i.view}async openCreatureView(t=!1){let i,a=this.app.workspace.getLeavesOfType(Sn);return!t&&a?.length?i=a.shift():(t&&a?.length?i=this.app.workspace.createLeafInParent(a[0].parent,a[0].parent.children.length):i=this.app.workspace.getRightLeaf(!0),await i.setViewState({type:Sn})),this.app.workspace.revealLeaf(i),i.view}async onload(){console.log("Fantasy StatBlocks loaded"),this.app.workspace.trigger("fantasy-statblocks:loaded",null),await this.loadSettings(),await this.saveSettings(),this.manager.initialize(this.settings),this.register(()=>this.manager.unload()),ve.initialize(this),ut.initialize(this.app.metadataCache,this.app),this.register(()=>ut.unload()),this.registerHoverLinkSource(this.manifest.id,{display:this.manifest.name,defaultMod:!1}),this.addCommand({id:"open-creature-view",name:"Open Creature pane",checkCallback:t=>this.app.workspace.getLeavesOfType(Sn).length?!1:(t||this.openCreatureView(),!0)}),this.addCommand({id:"reveal-creature-view",name:"Reveal Creature pane",checkCallback:t=>this.app.workspace.getLeavesOfType(Sn).length?(t||this.openCreatureView(),!0):!1}),this.addCommand({id:"open-new-creature-view",name:"Open new Creature pane",callback:()=>{this.openCreatureView(!0)}}),this.addRibbonIcon("skull","Open Creature pane",async t=>{this.openCreatureView(t.getModifierState("Meta"))}),this.registerObsidianProtocolHandler("creature-pane",Q(this,Ys).bind(this)),(0,qn.addIcon)("markdown-icon",''),this.addSettingTab(new Ta(this.app,this)),(window.FantasyStatblocks=this.api)&&this.register(()=>delete window.FantasyStatblocks),this.registerMarkdownCodeBlockProcessor("statblock",this.postprocessor.bind(this)),this.registerEditorSuggest(new js(this)),this.registerView(Sn,t=>new Ia(t,this)),this.canUseDiceRoller&&window.DiceRoller.registerSource(hi,{showDice:!0,shouldRender:this.settings.renderDice,showFormula:!1,showParens:!1,expectedValue:Fi.Average,text:null}),this.registerEvent(this.app.workspace.on("dice-roller:loaded",()=>{window.DiceRoller.registerSource(hi,{showDice:!0,shouldRender:this.settings.renderDice,showFormula:!1,showParens:!1,expectedValue:Fi.Average,text:null})}))}async loadSettings(){let t=await this.loadData();if(this.settings={...lv,...t},!this.settings.defaultLayoutsIntegrated){for(let s of this.settings.layouts)s.id=U();this.settings.default=(this.layouts.find(({name:s})=>s==this.settings.default)??rn).id,this.settings.defaultLayoutsIntegrated=!0}if(Array.isArray(this.settings.defaultLayouts)){let s={};for(let r of this.settings.defaultLayouts)(r.removed||r.edited)&&(s[r.id]=r);this.settings.defaultLayouts=s}for(let s of ci){if(!(s.id in this.settings.defaultLayouts)||s.version==null)continue;let r=this.settings.defaultLayouts[s.id];if(!(r.version>=s.version)){if(r.edited){r.updatable=!0;continue}r.blocks=Ze(s.blocks)}}function i(...s){for(let r of s)r.type=="spells"&&(r.properties.length||r.properties.push("spells")),"nested"in r&&i(...r.nested)}for(let s of this.settings.layouts)i(...s.blocks);let a=this.manifest.version.split(".");this.settings.version={major:Number(a[0]),minor:Number(a[1]),patch:Number(a[2])}}async saveSettings(){this.app.workspace.trigger("fantasy-statblocks:settings-change",this.settings),await this.saveData(this.settings)}async loadData(){return await super.loadData()}async saveData(t){super.saveData(t)}async saveMonster(t,i=!0){if(t.name){if(ve.isLocal(t.name)){let a=this.settings.monsters.findIndex(([s])=>s===t.name);a>=0?this.settings.monsters.splice(a,1,[t.name,t]):this.settings.monsters.push([t.name,t])}else this.settings.monsters.push([t.name,t]);ve.addLocalCreature(t),i&&await this.saveSettings()}}async saveMonsters(t){for(let i of t)await this.saveMonster(i,!1);await this.saveSettings()}async updateMonster(t,i){await this.deleteMonsters(t.name),await this.saveMonster(i)}async deleteMonsters(...t){for(let i of t)ve.removeLocalCreature(i);this.settings.monsters=this.settings.monsters.filter(([i])=>!t.includes(i)),await this.saveSettings()}onunload(){console.log("Fantasy StatBlocks unloaded"),this.app.workspace.getLeavesOfType(Sn).forEach(t=>t.detach())}exportAsPng(t,i){function a(r){return!r.hasClass||!r.hasClass("clickable-icon")}let s=i.querySelector(".statblock-content");s&&delete s.style.boxShadow,yf.default.toPng(i,{filter:a,style:{height:"100%"}}).then(r=>{let o=document.createElement("a");o.download=t+".png",o.href=r,o.click(),o.detach()}).catch(r=>{new qn.Notice(`There was an error creating the image: ${r.message}`),console.error(r)})}get layouts(){return this.manager.getAllLayouts()}get defaultLayout(){return this.manager.getDefaultLayout()}getLayoutOrDefault(t){return this.manager.getLayoutOrDefault(t.layout)}async postprocessor(t,i,a){try{t=ut.transformSource(t);let s=(0,qn.parseYaml)(t);i.addClass("statblock-plugin-container"),i.parentElement?.addClass("statblock-plugin-parent");let r=new $t({container:i,plugin:this,params:s,context:a.sourcePath});a.addChild(r)}catch(s){console.error(`Obsidian Statblock Error: ${s}`),createEl("pre").setText(`\`\`\`statblock There was an error rendering the statblock: ${s.stack.split(` `).filter(o=>!/^at/.test(o?.trim())).join(` `)} \`\`\``)}}render(t,i,a){this.api.render(t,i,a)}};Ys=new WeakMap; /* nosourcemap */