diff --git a/CAWS/.obsidian/app.json b/CAWS/.obsidian/app.json index 9a617ff..ff07663 100644 --- a/CAWS/.obsidian/app.json +++ b/CAWS/.obsidian/app.json @@ -3,5 +3,6 @@ "strictLineBreaks": false, "showLineNumber": false, "showIndentGuide": true, - "readableLineLength": true + "readableLineLength": true, + "promptDelete": false } \ No newline at end of file diff --git a/CAWS/.obsidian/community-plugins.json b/CAWS/.obsidian/community-plugins.json index 593a1b1..22ac526 100644 --- a/CAWS/.obsidian/community-plugins.json +++ b/CAWS/.obsidian/community-plugins.json @@ -1,4 +1,5 @@ [ "better-export-pdf", - "obsidian-style-settings" + "obsidian-style-settings", + "obsidian-git" ] \ No newline at end of file diff --git a/CAWS/.obsidian/plugins/obsidian-5e-statblocks/main.js b/CAWS/.obsidian/plugins/obsidian-5e-statblocks/main.js index 1190858..8756ee8 100644 --- a/CAWS/.obsidian/plugins/obsidian-5e-statblocks/main.js +++ b/CAWS/.obsidian/plugins/obsidian-5e-statblocks/main.js @@ -3,8 +3,8 @@ 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 vm=Object.create;var Gi=Object.defineProperty;var km=Object.getOwnPropertyDescriptor;var wm=Object.getOwnPropertyNames;var _m=Object.getPrototypeOf,Sm=Object.prototype.hasOwnProperty;var Jl=n=>{throw TypeError(n)};var Cm=(n,e,t)=>e in n?Gi(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Xl=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),xm=(n,e)=>{for(var t in e)Gi(n,t,{get:e[t],enumerable:!0})},Ql=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of wm(e))!Sm.call(n,a)&&a!==t&&Gi(n,a,{get:()=>e[a],enumerable:!(i=km(e,a))||i.enumerable});return n};var La=(n,e,t)=>(t=n!=null?vm(_m(n)):{},Ql(e||!n||!n.__esModule?Gi(t,"default",{value:n,enumerable:!0}):t,n)),Am=n=>Ql(Gi({},"__esModule",{value:!0}),n);var We=(n,e,t)=>Cm(n,typeof e!="symbol"?e+"":e,t),sr=(n,e,t)=>e.has(n)||Jl("Cannot "+t);var X=(n,e,t)=>(sr(n,e,"read from private field"),t?t.call(n):e.get(n)),Be=(n,e,t)=>e.has(n)?Jl("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),an=(n,e,t,i)=>(sr(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),Oe=(n,e,t)=>(sr(n,e,"access private method"),t);var ec=Xl((Zl,rr)=>{(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 rr<"u"?rr.exports=r:n.domtoimage=r;function o(k,A){return A=A||{},h(A),Promise.resolve(k).then(function(B){return m(B,A.filter,!0)}).then(p).then(b).then(P).then(function(B){return _(B,A.width||e.width(k),A.height||e.height(k))});function P(B){return A.bgcolor&&(B.style.backgroundColor=A.bgcolor),A.width&&(B.style.width=A.width+"px"),A.height&&(B.style.height=A.height+"px"),A.style&&Object.keys(A.style).forEach(function(L){B.style[L]=A.style[L]}),B}}function l(k,A){return f(k,A||{}).then(function(P){return P.getContext("2d").getImageData(0,0,e.width(k),e.height(k)).data})}function c(k,A){return f(k,A||{}).then(function(P){return P.toDataURL()})}function d(k,A){return A=A||{},f(k,A).then(function(P){return P.toDataURL("image/jpeg",A.quality||1)})}function u(k,A){return f(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 f(k,A){return o(k,A).then(e.makeImage).then(e.delay(100)).then(function(B){var L=P(k);return L.getContext("2d").drawImage(B,0,0),L});function P(B){var L=document.createElement("canvas");if(L.width=A.width||e.width(B),L.height=A.height||e.height(B),A.bgcolor){var O=L.getContext("2d");O.fillStyle=A.bgcolor,O.fillRect(0,0,L.width,L.height)}return L}}function m(k,A,P){if(!P&&A&&!A(k))return Promise.resolve();return Promise.resolve(k).then(B).then(function(j){return L(k,j,A)}).then(function(j){return O(k,j)});function B(j){return j instanceof HTMLCanvasElement?e.makeImage(j.toDataURL()):j.cloneNode(!1)}function L(j,Z,ee){var ae=j.childNodes;if(ae.length===0)return Promise.resolve(Z);return $(Z,e.asArray(ae),ee).then(function(){return Z});function $(W,Y,F){var H=Promise.resolve();return Y.forEach(function(he){H=H.then(function(){return m(he,F)}).then(function(ue){ue&&W.appendChild(ue)})}),H}}function O(j,Z){if(!(Z instanceof Element))return Z;return Promise.resolve().then(ee).then(ae).then($).then(W).then(function(){return Z});function ee(){Y(window.getComputedStyle(j),Z.style);function Y(F,H){F.cssText?H.cssText=F.cssText:he(F,H);function he(ue,U){e.asArray(ue).forEach(function(z){U.setProperty(z,ue.getPropertyValue(z),ue.getPropertyPriority(z))})}}}function ae(){[":before",":after"].forEach(function(F){Y(F)});function Y(F){var H=window.getComputedStyle(j,F),he=H.getPropertyValue("content");if(he===""||he==="none")return;var ue=e.uid();Z.className=Z.className+" "+ue;var U=document.createElement("style");U.appendChild(z(ue,F,H)),Z.appendChild(U);function z(me,Ce,Ie){var et="."+me+":"+Ce,Tt=Ie.cssText?mi(Ie):gi(Ie);return document.createTextNode(et+"{"+Tt+"}");function mi(Rt){var Nt=Rt.getPropertyValue("content");return Rt.cssText+" content: "+Nt+";"}function gi(Rt){return e.asArray(Rt).map(Nt).join("; ")+";";function Nt(bt){return bt+": "+Rt.getPropertyValue(bt)+(Rt.getPropertyPriority(bt)?" !important":"")}}}}}function $(){j instanceof HTMLTextAreaElement&&(Z.innerHTML=j.value),j instanceof HTMLInputElement&&Z.setAttribute("value",j.value)}function W(){Z instanceof SVGElement&&(Z.setAttribute("xmlns","http://www.w3.org/2000/svg"),Z instanceof SVGRectElement&&["width","height"].forEach(function(Y){var F=Z.getAttribute(Y);F&&Z.style.setProperty(Y,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(B){return B.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),new XMLSerializer().serializeToString(B)}).then(e.escapeXhtml).then(function(B){return''+B+""}).then(function(B){return''+B+""}).then(function(B){return"data:image/svg+xml;charset=utf-8,"+B})}function S(){return{escape:W,parseExtension:A,mimeType:P,dataAsUrl:$,isDataUrl:B,canvasToBlob:O,resolveUrl:j,getAndEncode:ae,uid:Z(),delay:Y,asArray:F,escapeXhtml:H,makeImage:ee,width:he,height:ue};function k(){var z="application/font-woff",me="image/jpeg";return{woff:z,woff2:z,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:me,jpeg:me,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}}function A(z){var me=/\.([^\.\/]*?)$/g.exec(z);return me?me[1]:""}function P(z){var me=A(z).toLowerCase();return k()[me]||""}function B(z){return z.search(/^(data:)/)!==-1}function L(z){return new Promise(function(me){for(var Ce=window.atob(z.toDataURL().split(",")[1]),Ie=Ce.length,et=new Uint8Array(Ie),Tt=0;Tt{"use strict";var Fo=Object.defineProperty,U1=Object.getOwnPropertyDescriptor,G1=Object.getOwnPropertyNames,K1=Object.prototype.hasOwnProperty,$1=(n,e)=>{for(var t in e)Fo(n,t,{get:e[t],enumerable:!0})},Y1=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of G1(e))!K1.call(n,a)&&a!==t&&Fo(n,a,{get:()=>e[a],enumerable:!(i=U1(e,a))||i.enumerable});return n},J1=n=>Y1(Fo({},"__esModule",{value:!0}),n),jd={};$1(jd,{FileInputSuggest:()=>Q1,FolderInputSuggest:()=>X1,FuzzyInputSuggest:()=>Wo,createCollapsibleSection:()=>t0,setNodeIcon:()=>e0});Vd.exports=J1(jd);var Lo=require("obsidian"),Wo=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)}},Hd=require("obsidian"),X1=class extends Wo{getItemText(n){return n.path}renderNote(n,e){let{item:t,match:i}=e;(0,Hd.renderMatches)(n,t.path,i.matches)}renderTitle(n,e){let{item:t,match:i}=e;(0,Hd.renderMatches)(n,t.name,i.matches,t.path.length-t.name.length)}},zd=require("obsidian"),Q1=class extends Wo{getItemText(n){return n.path}renderNote(n,e){let{item:t,match:i}=e;(0,zd.renderMatches)(n,t.path,i.matches)}renderTitle(n,e){let{item:t,match:i}=e;(0,zd.renderMatches)(n,t.name,i.matches,t.path.length-t.name.length)}},Z1=require("obsidian");function e0(n,e){n.addClass("has-node-icon"),(0,Z1.setIcon)(n,e)}var qd=require("obsidian");function t0(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 qd.Setting(s).setHeading().setName(e),(0,qd.setIcon)(s.createDiv("handle"),"chevron-right"),a}});var yv={};xm(yv,{DICE_ROLLER_SOURCE:()=>hi,default:()=>Ys});module.exports=Am(yv);var jn=require("obsidian"),Af=La(ec());var Ct=require("obsidian");var Cc=require("@codemirror/state"),xc=require("@codemirror/view");var Tm=Function.prototype.toString,or=Object.create,Dm=Object.prototype.toString,Em=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 Mm(){return new Em}function Im(){return new WeakMap}var Om=typeof WeakMap<"u"?Im:Mm;function cr(n){if(!n)return or(null);var e=n.constructor;if(e===Object)return n===Object.prototype?{}:or(n);if(e&&~Tm.call(e).indexOf("[native code]"))try{return new e}catch{}return or(n)}function Pm(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 Rm(n){return n.flags}var Nm=/test/g.flags==="g"?Rm:Pm;function tc(n){var e=Dm.call(n);return e.substring(8,e.length-1)}function Bm(n){return n[Symbol.toStringTag]||tc(n)}var Lm=typeof Symbol<"u"?Bm:tc,Fm=Object.defineProperty,Wm=Object.getOwnPropertyDescriptor,nc=Object.getOwnPropertyNames,ur=Object.getOwnPropertySymbols,ic=Object.prototype,ac=ic.hasOwnProperty,Hm=ic.propertyIsEnumerable,sc=typeof ur=="function";function zm(n){return nc(n).concat(ur(n))}var qm=sc?zm:nc;function Wa(n,e,t){for(var i=qm(n),a=0,s=i.length,r=void 0,o=void 0;a[(0,Bt.foldGutter)(),(0,sn.drawSelection)(),(0,sn.dropCursor)(),(0,Bt.indentOnInput)(),(0,Bt.syntaxHighlighting)(Bt.defaultHighlightStyle,{fallback:!0}),sn.EditorView.lineWrapping,(0,Bt.bracketMatching)(),(0,Cn.closeBrackets)(),(0,Cn.autocompletion)(),(0,sn.rectangularSelection)(),(0,Ha.highlightSelectionMatches)(),sn.keymap.of([...Cn.closeBracketsKeymap,...yi.defaultKeymap,...Ha.searchKeymap,...yi.historyKeymap,yi.indentWithTab,...Bt.foldKeymap,...Cn.completionKeymap,...dc.lintKeymap])];var mc=require("@codemirror/view"),Cv=require("@codemirror/state"),za=require("@codemirror/language"),Ve=require("@lezer/highlight"),rg="#abb2bf",og="#7d8799",lg="#ffffff",cg="#21252b",hr="rgba(0, 0, 0, 0.5)",ug="#292d3e",fr="#353a42",dg="rgba(128, 203, 196, 0.2)",fc="#ffcc00",hg=mc.EditorView.theme({"&":{color:"#ffffff",backgroundColor:ug},".cm-content":{caretColor:fc},"&.cm-focused .cm-cursor":{borderLeftColor:fc},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:dg},".cm-panels":{backgroundColor:cg,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:hr},".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:hr},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:fr},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:fr,borderBottomColor:fr},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:hr,color:rg}}},{dark:!0}),fg=za.HighlightStyle.define([{tag:Ve.tags.keyword,color:"#c792ea"},{tag:Ve.tags.operator,color:"#89ddff"},{tag:Ve.tags.special(Ve.tags.variableName),color:"#eeffff"},{tag:Ve.tags.typeName,color:"#f07178"},{tag:Ve.tags.atom,color:"#f78c6c"},{tag:Ve.tags.number,color:"#ff5370"},{tag:Ve.tags.definition(Ve.tags.variableName),color:"#82aaff"},{tag:Ve.tags.string,color:"#c3e88d"},{tag:Ve.tags.special(Ve.tags.string),color:"#f07178"},{tag:Ve.tags.comment,color:og},{tag:Ve.tags.variableName,color:"#f07178"},{tag:Ve.tags.tagName,color:"#ff5370"},{tag:Ve.tags.bracket,color:"#a2a1a4"},{tag:Ve.tags.meta,color:"#ffcb6b"},{tag:Ve.tags.attributeName,color:"#c792ea"},{tag:Ve.tags.propertyName,color:"#c792ea"},{tag:Ve.tags.className,color:"#decb6b"},{tag:Ve.tags.invalid,color:lg}]),gc=[hg,(0,za.syntaxHighlighting)(fg)];var Sc=require("@codemirror/view"),Tv=require("@codemirror/state"),ja=require("@codemirror/language"),de=require("@lezer/highlight"),pc="#2e3440",vr="#3b4252",bc="#434c5e",qa="#4c566a";var yc="#e5e9f0",yr="#eceff4",mr="#8fbcbb",vc="#88c0d0",mg="#81a1c1",Vt="#5e81ac",gg="#bf616a",vi="#d08770",gr="#ebcb8b",kc="#a3be8c",pg="#b48ead",wc="#d30102",kr=yr,pr=kr,bg="#ffffff",br=vr,yg=kr,_c=vr,wr=Sc.EditorView.theme({"&":{color:pc,backgroundColor:bg},".cm-content":{caretColor:_c},".cm-cursor, .cm-dropCursor":{borderLeftColor:_c},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:yg},".cm-panels":{backgroundColor:kr,color:qa},".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 ${qa}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:yc},".cm-activeLine":{backgroundColor:pr},".cm-selectionMatch":{backgroundColor:yc},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${qa}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:yr},".cm-gutters":{backgroundColor:yr,color:pc,border:"none"},".cm-activeLineGutter":{backgroundColor:pr},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:br},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:br,borderBottomColor:br},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:pr,color:qa}}},{dark:!1}),vg=ja.HighlightStyle.define([{tag:de.tags.keyword,color:Vt},{tag:[de.tags.name,de.tags.deleted,de.tags.character,de.tags.propertyName,de.tags.macroName],color:vi},{tag:[de.tags.variableName],color:vi},{tag:[de.tags.function(de.tags.variableName)],color:Vt},{tag:[de.tags.labelName],color:mg},{tag:[de.tags.color,de.tags.constant(de.tags.name),de.tags.standard(de.tags.name)],color:Vt},{tag:[de.tags.definition(de.tags.name),de.tags.separator],color:kc},{tag:[de.tags.brace],color:mr},{tag:[de.tags.annotation],color:wc},{tag:[de.tags.number,de.tags.changed,de.tags.annotation,de.tags.modifier,de.tags.self,de.tags.namespace],color:vc},{tag:[de.tags.typeName,de.tags.className],color:gr},{tag:[de.tags.operator,de.tags.operatorKeyword],color:kc},{tag:[de.tags.tagName],color:pg},{tag:[de.tags.squareBracket],color:gg},{tag:[de.tags.angleBracket],color:vi},{tag:[de.tags.attributeName],color:gr},{tag:[de.tags.regexp],color:Vt},{tag:[de.tags.quote],color:vr},{tag:[de.tags.string],color:vi},{tag:de.tags.link,color:mr,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[de.tags.url,de.tags.escape,de.tags.special(de.tags.string)],color:vi},{tag:[de.tags.meta],color:vc},{tag:[de.tags.comment],color:bc,fontStyle:"italic"},{tag:de.tags.strong,fontWeight:"bold",color:Vt},{tag:de.tags.emphasis,fontStyle:"italic",color:Vt},{tag:de.tags.strikethrough,textDecoration:"line-through"},{tag:de.tags.heading,fontWeight:"bold",color:Vt},{tag:de.tags.special(de.tags.heading1),fontWeight:"bold",color:Vt},{tag:de.tags.heading1,fontWeight:"bold",color:Vt},{tag:[de.tags.heading2,de.tags.heading3,de.tags.heading4],fontWeight:"bold",color:Vt},{tag:[de.tags.heading5,de.tags.heading6],color:Vt},{tag:[de.tags.atom,de.tags.bool,de.tags.special(de.tags.variableName)],color:vi},{tag:[de.tags.processingInstruction,de.tags.inserted],color:mr},{tag:[de.tags.contentSeparator],color:gr},{tag:de.tags.invalid,color:bc,borderBottom:`1px dotted ${wc}`}]),Ev=[wr,(0,ja.syntaxHighlighting)(vg)];function Lt(n,e,t="js"){let i=hc();document.body.hasClass("theme-dark")?i.push(gc):i.push(wr);let a=[...i];e&&a.push(e);let s=new xc.EditorView({state:Cc.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 mt(n){return n?n.toLowerCase().replace(/[^A-Za-z0-9\s_-]/g,"").replace(/\s+/g,"-"):""}var ki=(n,e)=>n?.toLowerCase().replace(/\s+/g,"-").replaceAll(".","-")??e;function Ki(n){return n[0].toUpperCase()+n.slice(1).toLowerCase()}function Q(){return"xyxyxyxyxyxy".replace(/[xy]/g,function(n){let e=Math.random()*16|0;return(n=="x"?e:e&3|8).toString(16)})}function ye(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=>ye(s,e+1)).join(t)}${i?")":""}`);else if(typeof n=="object")for(let s of Object.values(n))a.push(ye(s,e+1));return a.join(" ")}function _r(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} ${ye(e)}`;return e}var kg=[{type:"inline",id:Q(),properties:[],hasRule:!0,nested:[{type:"group",id:Q(),properties:["name","size","type","subtype","alignment"],nested:[{type:"inline",id:Q(),properties:[],hasRule:!1,nested:[{type:"heading",id:Q(),properties:["name"],conditioned:!0,size:1},{type:"inline",id:Q(),properties:[],hasRule:!1,nested:[{type:"action",id:Q(),icon:"sword",callback:"try { InitiativeTracker.newEncounter({roll: true, creatures: [monster]}); } catch(e) {}"},{type:"action",id:Q(),icon:"plus-with-circle",callback:"try { InitiativeTracker.addCreatures([monster]); } catch(e) {}"}]}]},{type:"subheading",id:Q(),properties:["size","type","subtype","alignment"],conditioned:!0,separator:", "}],conditioned:!0},{type:"image",id:Q(),properties:["image"]}]},{type:"group",id:Q(),properties:["ac","hp","speed"],nested:[{type:"property",id:Q(),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:Q(),properties:["hp"],display:"Hit Points",dice:!0,diceProperty:"hit_dice",diceCallback:`if ("hit_dice" in monster) { +"use strict";var vm=Object.create;var Gi=Object.defineProperty;var km=Object.getOwnPropertyDescriptor;var wm=Object.getOwnPropertyNames;var _m=Object.getPrototypeOf,Sm=Object.prototype.hasOwnProperty;var Jl=n=>{throw TypeError(n)};var Cm=(n,e,t)=>e in n?Gi(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Xl=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),xm=(n,e)=>{for(var t in e)Gi(n,t,{get:e[t],enumerable:!0})},Ql=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of wm(e))!Sm.call(n,a)&&a!==t&&Gi(n,a,{get:()=>e[a],enumerable:!(i=km(e,a))||i.enumerable});return n};var La=(n,e,t)=>(t=n!=null?vm(_m(n)):{},Ql(e||!n||!n.__esModule?Gi(t,"default",{value:n,enumerable:!0}):t,n)),Am=n=>Ql(Gi({},"__esModule",{value:!0}),n);var We=(n,e,t)=>Cm(n,typeof e!="symbol"?e+"":e,t),rr=(n,e,t)=>e.has(n)||Jl("Cannot "+t);var X=(n,e,t)=>(rr(n,e,"read from private field"),t?t.call(n):e.get(n)),Be=(n,e,t)=>e.has(n)?Jl("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),an=(n,e,t,i)=>(rr(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),Oe=(n,e,t)=>(rr(n,e,"access private method"),t);var ec=Xl((Zl,or)=>{(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 or<"u"?or.exports=r:n.domtoimage=r;function o(k,A){return A=A||{},h(A),Promise.resolve(k).then(function(B){return m(B,A.filter,!0)}).then(p).then(b).then(P).then(function(B){return _(B,A.width||e.width(k),A.height||e.height(k))});function P(B){return A.bgcolor&&(B.style.backgroundColor=A.bgcolor),A.width&&(B.style.width=A.width+"px"),A.height&&(B.style.height=A.height+"px"),A.style&&Object.keys(A.style).forEach(function(L){B.style[L]=A.style[L]}),B}}function l(k,A){return f(k,A||{}).then(function(P){return P.getContext("2d").getImageData(0,0,e.width(k),e.height(k)).data})}function c(k,A){return f(k,A||{}).then(function(P){return P.toDataURL()})}function d(k,A){return A=A||{},f(k,A).then(function(P){return P.toDataURL("image/jpeg",A.quality||1)})}function u(k,A){return f(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 f(k,A){return o(k,A).then(e.makeImage).then(e.delay(100)).then(function(B){var L=P(k);return L.getContext("2d").drawImage(B,0,0),L});function P(B){var L=document.createElement("canvas");if(L.width=A.width||e.width(B),L.height=A.height||e.height(B),A.bgcolor){var O=L.getContext("2d");O.fillStyle=A.bgcolor,O.fillRect(0,0,L.width,L.height)}return L}}function m(k,A,P){if(!P&&A&&!A(k))return Promise.resolve();return Promise.resolve(k).then(B).then(function(j){return L(k,j,A)}).then(function(j){return O(k,j)});function B(j){return j instanceof HTMLCanvasElement?e.makeImage(j.toDataURL()):j.cloneNode(!1)}function L(j,Z,ee){var ae=j.childNodes;if(ae.length===0)return Promise.resolve(Z);return $(Z,e.asArray(ae),ee).then(function(){return Z});function $(W,Y,F){var H=Promise.resolve();return Y.forEach(function(he){H=H.then(function(){return m(he,F)}).then(function(ue){ue&&W.appendChild(ue)})}),H}}function O(j,Z){if(!(Z instanceof Element))return Z;return Promise.resolve().then(ee).then(ae).then($).then(W).then(function(){return Z});function ee(){Y(window.getComputedStyle(j),Z.style);function Y(F,H){F.cssText?H.cssText=F.cssText:he(F,H);function he(ue,U){e.asArray(ue).forEach(function(z){U.setProperty(z,ue.getPropertyValue(z),ue.getPropertyPriority(z))})}}}function ae(){[":before",":after"].forEach(function(F){Y(F)});function Y(F){var H=window.getComputedStyle(j,F),he=H.getPropertyValue("content");if(he===""||he==="none")return;var ue=e.uid();Z.className=Z.className+" "+ue;var U=document.createElement("style");U.appendChild(z(ue,F,H)),Z.appendChild(U);function z(me,Ce,Ie){var et="."+me+":"+Ce,Tt=Ie.cssText?mi(Ie):gi(Ie);return document.createTextNode(et+"{"+Tt+"}");function mi(Rt){var Nt=Rt.getPropertyValue("content");return Rt.cssText+" content: "+Nt+";"}function gi(Rt){return e.asArray(Rt).map(Nt).join("; ")+";";function Nt(bt){return bt+": "+Rt.getPropertyValue(bt)+(Rt.getPropertyPriority(bt)?" !important":"")}}}}}function $(){j instanceof HTMLTextAreaElement&&(Z.innerHTML=j.value),j instanceof HTMLInputElement&&Z.setAttribute("value",j.value)}function W(){Z instanceof SVGElement&&(Z.setAttribute("xmlns","http://www.w3.org/2000/svg"),Z instanceof SVGRectElement&&["width","height"].forEach(function(Y){var F=Z.getAttribute(Y);F&&Z.style.setProperty(Y,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(B){return B.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),new XMLSerializer().serializeToString(B)}).then(e.escapeXhtml).then(function(B){return''+B+""}).then(function(B){return''+B+""}).then(function(B){return"data:image/svg+xml;charset=utf-8,"+B})}function S(){return{escape:W,parseExtension:A,mimeType:P,dataAsUrl:$,isDataUrl:B,canvasToBlob:O,resolveUrl:j,getAndEncode:ae,uid:Z(),delay:Y,asArray:F,escapeXhtml:H,makeImage:ee,width:he,height:ue};function k(){var z="application/font-woff",me="image/jpeg";return{woff:z,woff2:z,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:me,jpeg:me,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}}function A(z){var me=/\.([^\.\/]*?)$/g.exec(z);return me?me[1]:""}function P(z){var me=A(z).toLowerCase();return k()[me]||""}function B(z){return z.search(/^(data:)/)!==-1}function L(z){return new Promise(function(me){for(var Ce=window.atob(z.toDataURL().split(",")[1]),Ie=Ce.length,et=new Uint8Array(Ie),Tt=0;Tt{"use strict";var Fo=Object.defineProperty,U1=Object.getOwnPropertyDescriptor,G1=Object.getOwnPropertyNames,K1=Object.prototype.hasOwnProperty,$1=(n,e)=>{for(var t in e)Fo(n,t,{get:e[t],enumerable:!0})},Y1=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of G1(e))!K1.call(n,a)&&a!==t&&Fo(n,a,{get:()=>e[a],enumerable:!(i=U1(e,a))||i.enumerable});return n},J1=n=>Y1(Fo({},"__esModule",{value:!0}),n),jd={};$1(jd,{FileInputSuggest:()=>Q1,FolderInputSuggest:()=>X1,FuzzyInputSuggest:()=>Wo,createCollapsibleSection:()=>t0,setNodeIcon:()=>e0});Vd.exports=J1(jd);var Lo=require("obsidian"),Wo=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)}},Hd=require("obsidian"),X1=class extends Wo{getItemText(n){return n.path}renderNote(n,e){let{item:t,match:i}=e;(0,Hd.renderMatches)(n,t.path,i.matches)}renderTitle(n,e){let{item:t,match:i}=e;(0,Hd.renderMatches)(n,t.name,i.matches,t.path.length-t.name.length)}},zd=require("obsidian"),Q1=class extends Wo{getItemText(n){return n.path}renderNote(n,e){let{item:t,match:i}=e;(0,zd.renderMatches)(n,t.path,i.matches)}renderTitle(n,e){let{item:t,match:i}=e;(0,zd.renderMatches)(n,t.name,i.matches,t.path.length-t.name.length)}},Z1=require("obsidian");function e0(n,e){n.addClass("has-node-icon"),(0,Z1.setIcon)(n,e)}var qd=require("obsidian");function t0(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 qd.Setting(s).setHeading().setName(e),(0,qd.setIcon)(s.createDiv("handle"),"chevron-right"),a}});var yv={};xm(yv,{DICE_ROLLER_SOURCE:()=>hi,default:()=>Js});module.exports=Am(yv);var jn=require("obsidian"),Af=La(ec());var Ct=require("obsidian");var Cc=require("@codemirror/state"),xc=require("@codemirror/view");var Tm=Function.prototype.toString,lr=Object.create,Dm=Object.prototype.toString,Em=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 Mm(){return new Em}function Im(){return new WeakMap}var Om=typeof WeakMap<"u"?Im:Mm;function ur(n){if(!n)return lr(null);var e=n.constructor;if(e===Object)return n===Object.prototype?{}:lr(n);if(e&&~Tm.call(e).indexOf("[native code]"))try{return new e}catch{}return lr(n)}function Pm(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 Rm(n){return n.flags}var Nm=/test/g.flags==="g"?Rm:Pm;function tc(n){var e=Dm.call(n);return e.substring(8,e.length-1)}function Bm(n){return n[Symbol.toStringTag]||tc(n)}var Lm=typeof Symbol<"u"?Bm:tc,Fm=Object.defineProperty,Wm=Object.getOwnPropertyDescriptor,nc=Object.getOwnPropertyNames,dr=Object.getOwnPropertySymbols,ic=Object.prototype,ac=ic.hasOwnProperty,Hm=ic.propertyIsEnumerable,sc=typeof dr=="function";function zm(n){return nc(n).concat(dr(n))}var qm=sc?zm:nc;function Wa(n,e,t){for(var i=qm(n),a=0,s=i.length,r=void 0,o=void 0;a[(0,Bt.foldGutter)(),(0,sn.drawSelection)(),(0,sn.dropCursor)(),(0,Bt.indentOnInput)(),(0,Bt.syntaxHighlighting)(Bt.defaultHighlightStyle,{fallback:!0}),sn.EditorView.lineWrapping,(0,Bt.bracketMatching)(),(0,Cn.closeBrackets)(),(0,Cn.autocompletion)(),(0,sn.rectangularSelection)(),(0,Ha.highlightSelectionMatches)(),sn.keymap.of([...Cn.closeBracketsKeymap,...yi.defaultKeymap,...Ha.searchKeymap,...yi.historyKeymap,yi.indentWithTab,...Bt.foldKeymap,...Cn.completionKeymap,...dc.lintKeymap])];var mc=require("@codemirror/view"),Cv=require("@codemirror/state"),za=require("@codemirror/language"),Ve=require("@lezer/highlight"),rg="#abb2bf",og="#7d8799",lg="#ffffff",cg="#21252b",fr="rgba(0, 0, 0, 0.5)",ug="#292d3e",mr="#353a42",dg="rgba(128, 203, 196, 0.2)",fc="#ffcc00",hg=mc.EditorView.theme({"&":{color:"#ffffff",backgroundColor:ug},".cm-content":{caretColor:fc},"&.cm-focused .cm-cursor":{borderLeftColor:fc},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:dg},".cm-panels":{backgroundColor:cg,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:fr},".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:fr},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:mr},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:mr,borderBottomColor:mr},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:fr,color:rg}}},{dark:!0}),fg=za.HighlightStyle.define([{tag:Ve.tags.keyword,color:"#c792ea"},{tag:Ve.tags.operator,color:"#89ddff"},{tag:Ve.tags.special(Ve.tags.variableName),color:"#eeffff"},{tag:Ve.tags.typeName,color:"#f07178"},{tag:Ve.tags.atom,color:"#f78c6c"},{tag:Ve.tags.number,color:"#ff5370"},{tag:Ve.tags.definition(Ve.tags.variableName),color:"#82aaff"},{tag:Ve.tags.string,color:"#c3e88d"},{tag:Ve.tags.special(Ve.tags.string),color:"#f07178"},{tag:Ve.tags.comment,color:og},{tag:Ve.tags.variableName,color:"#f07178"},{tag:Ve.tags.tagName,color:"#ff5370"},{tag:Ve.tags.bracket,color:"#a2a1a4"},{tag:Ve.tags.meta,color:"#ffcb6b"},{tag:Ve.tags.attributeName,color:"#c792ea"},{tag:Ve.tags.propertyName,color:"#c792ea"},{tag:Ve.tags.className,color:"#decb6b"},{tag:Ve.tags.invalid,color:lg}]),gc=[hg,(0,za.syntaxHighlighting)(fg)];var Sc=require("@codemirror/view"),Tv=require("@codemirror/state"),ja=require("@codemirror/language"),de=require("@lezer/highlight"),pc="#2e3440",kr="#3b4252",bc="#434c5e",qa="#4c566a";var yc="#e5e9f0",vr="#eceff4",gr="#8fbcbb",vc="#88c0d0",mg="#81a1c1",Vt="#5e81ac",gg="#bf616a",vi="#d08770",pr="#ebcb8b",kc="#a3be8c",pg="#b48ead",wc="#d30102",wr=vr,br=wr,bg="#ffffff",yr=kr,yg=wr,_c=kr,_r=Sc.EditorView.theme({"&":{color:pc,backgroundColor:bg},".cm-content":{caretColor:_c},".cm-cursor, .cm-dropCursor":{borderLeftColor:_c},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:yg},".cm-panels":{backgroundColor:wr,color:qa},".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 ${qa}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:yc},".cm-activeLine":{backgroundColor:br},".cm-selectionMatch":{backgroundColor:yc},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${qa}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:vr},".cm-gutters":{backgroundColor:vr,color:pc,border:"none"},".cm-activeLineGutter":{backgroundColor:br},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:yr},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:yr,borderBottomColor:yr},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:br,color:qa}}},{dark:!1}),vg=ja.HighlightStyle.define([{tag:de.tags.keyword,color:Vt},{tag:[de.tags.name,de.tags.deleted,de.tags.character,de.tags.propertyName,de.tags.macroName],color:vi},{tag:[de.tags.variableName],color:vi},{tag:[de.tags.function(de.tags.variableName)],color:Vt},{tag:[de.tags.labelName],color:mg},{tag:[de.tags.color,de.tags.constant(de.tags.name),de.tags.standard(de.tags.name)],color:Vt},{tag:[de.tags.definition(de.tags.name),de.tags.separator],color:kc},{tag:[de.tags.brace],color:gr},{tag:[de.tags.annotation],color:wc},{tag:[de.tags.number,de.tags.changed,de.tags.annotation,de.tags.modifier,de.tags.self,de.tags.namespace],color:vc},{tag:[de.tags.typeName,de.tags.className],color:pr},{tag:[de.tags.operator,de.tags.operatorKeyword],color:kc},{tag:[de.tags.tagName],color:pg},{tag:[de.tags.squareBracket],color:gg},{tag:[de.tags.angleBracket],color:vi},{tag:[de.tags.attributeName],color:pr},{tag:[de.tags.regexp],color:Vt},{tag:[de.tags.quote],color:kr},{tag:[de.tags.string],color:vi},{tag:de.tags.link,color:gr,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[de.tags.url,de.tags.escape,de.tags.special(de.tags.string)],color:vi},{tag:[de.tags.meta],color:vc},{tag:[de.tags.comment],color:bc,fontStyle:"italic"},{tag:de.tags.strong,fontWeight:"bold",color:Vt},{tag:de.tags.emphasis,fontStyle:"italic",color:Vt},{tag:de.tags.strikethrough,textDecoration:"line-through"},{tag:de.tags.heading,fontWeight:"bold",color:Vt},{tag:de.tags.special(de.tags.heading1),fontWeight:"bold",color:Vt},{tag:de.tags.heading1,fontWeight:"bold",color:Vt},{tag:[de.tags.heading2,de.tags.heading3,de.tags.heading4],fontWeight:"bold",color:Vt},{tag:[de.tags.heading5,de.tags.heading6],color:Vt},{tag:[de.tags.atom,de.tags.bool,de.tags.special(de.tags.variableName)],color:vi},{tag:[de.tags.processingInstruction,de.tags.inserted],color:gr},{tag:[de.tags.contentSeparator],color:pr},{tag:de.tags.invalid,color:bc,borderBottom:`1px dotted ${wc}`}]),Ev=[_r,(0,ja.syntaxHighlighting)(vg)];function Lt(n,e,t="js"){let i=hc();document.body.hasClass("theme-dark")?i.push(gc):i.push(_r);let a=[...i];e&&a.push(e);let s=new xc.EditorView({state:Cc.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 mt(n){return n?n.toLowerCase().replace(/[^A-Za-z0-9\s_-]/g,"").replace(/\s+/g,"-"):""}var ki=(n,e)=>n?.toLowerCase().replace(/\s+/g,"-").replaceAll(".","-")??e;function Ki(n){return n[0].toUpperCase()+n.slice(1).toLowerCase()}function Q(){return"xyxyxyxyxyxy".replace(/[xy]/g,function(n){let e=Math.random()*16|0;return(n=="x"?e:e&3|8).toString(16)})}function ye(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=>ye(s,e+1)).join(t)}${i?")":""}`);else if(typeof n=="object")for(let s of Object.values(n))a.push(ye(s,e+1));return a.join(" ")}function Sr(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} ${ye(e)}`;return e}var kg=[{type:"inline",id:Q(),properties:[],hasRule:!0,nested:[{type:"group",id:Q(),properties:["name","size","type","subtype","alignment"],nested:[{type:"inline",id:Q(),properties:[],hasRule:!1,nested:[{type:"heading",id:Q(),properties:["name"],conditioned:!0,size:1},{type:"inline",id:Q(),properties:[],hasRule:!1,nested:[{type:"action",id:Q(),icon:"sword",callback:"try { InitiativeTracker.newEncounter({roll: true, creatures: [monster]}); } catch(e) {}"},{type:"action",id:Q(),icon:"plus-with-circle",callback:"try { InitiativeTracker.addCreatures([monster]); } catch(e) {}"}]}]},{type:"subheading",id:Q(),properties:["size","type","subtype","alignment"],conditioned:!0,separator:", "}],conditioned:!0},{type:"image",id:Q(),properties:["image"]}]},{type:"group",id:Q(),properties:["ac","hp","speed"],nested:[{type:"property",id:Q(),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:Q(),properties:["hp"],display:"Hit Points",dice:!0,diceProperty:"hit_dice",diceCallback:`if ("hit_dice" in monster) { return [{ text: monster["hit_dice"] }]; } else { return property; @@ -403,11 +403,11 @@ if ("cr" in monster && monster.cr in CR) { 2 )}\`; } -return "";`}]}],conditioned:!0,hasRule:!0},{type:"traits",id:Q(),properties:["traits"],conditioned:!0,dice:!0},{type:"spells",id:Q(),properties:["spells"],conditioned:!0,dice:!0},{type:"text",id:Q(),properties:["spellsNotes"],conditioned:!0,text:null},{type:"traits",id:Q(),properties:["actions"],heading:"Actions",conditioned:!0,dice:!0},{type:"traits",id:Q(),properties:["bonus_actions"],heading:"Bonus Actions",conditioned:!0,dice:!0},{type:"group",id:Q(),properties:["legendary_description","legendary_actions"],heading:"Legendary Actions",nested:[{type:"text",id:Q(),properties:["legendary_description"],conditioned:!0,text:null},{type:"traits",id:Q(),properties:["legendary_actions"],conditioned:!0,dice:!0}],conditioned:!0},{type:"group",id:Q(),properties:["mythic_description","mythic_actions"],heading:"Mythic Actions",nested:[{type:"text",id:Q(),properties:["mythic_description"],conditioned:!0,text:null},{type:"traits",id:Q(),properties:["mythic_actions"],conditioned:!0,dice:!0}],conditioned:!0},{type:"traits",id:Q(),properties:["reactions"],heading:"Reactions",conditioned:!0,dice:!0},{type:"traits",id:Q(),properties:["lair_actions"],heading:"Lair Actions",conditioned:!0,dice:!0},{type:"traits",id:Q(),properties:["regional_effects"],heading:"Regional Effects",conditioned:!0,dice:!0}],rn={blocks:kg,id:"basic-5e-layout",name:"Basic 5e Layout",edited:!1,version:9};var Bu=require("obsidian");function N(){}var on=n=>n;function at(n,e){for(let t in e)n[t]=e[t];return n}function Ac(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function Sr(n){return n()}function Ua(){return Object.create(null)}function oe(n){n.forEach(Sr)}function Pe(n){return typeof n=="function"}function V(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}var Va;function Tc(n,e){return n===e?!0:(Va||(Va=document.createElement("a")),Va.href=e,n===Va.href)}function Dc(n){return Object.keys(n).length===0}function Dt(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(Dt(e,t))}function st(n,e,t,i){if(n){let a=Ec(n,e,t,i);return n[0](a)}}function Ec(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(),$i=Mc?n=>requestAnimationFrame(n):N;var wi=new Set;function Ic(n){wi.forEach(e=>{e.c(n)||(wi.delete(e),e.f())}),wi.size!==0&&$i(Ic)}function Kn(n){let e;return wi.size===0&&$i(Ic),{promise:new Promise(t=>{wi.add(e={c:n,f:t})}),abort(){wi.delete(e)}}}var Yi=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var Ga=class n{constructor(e){We(this,"_listeners","WeakMap"in Yi?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)}))}};Ga.entries="WeakMap"in Yi?new WeakMap:void 0;var Oc=!1;function Pc(){Oc=!0}function Rc(){Oc=!1}function y(n,e){n.appendChild(e)}function se(n,e,t){let i=Ka(n);if(!i.getElementById(e)){let a=v("style");a.id=e,a.textContent=t,Bc(i,a)}}function Ka(n){if(!n)return document;let e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Nc(n){let e=v("style");return e.textContent="/* empty */",Bc(Ka(n),e),e.sheet}function Bc(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 He(n,e){for(let t=0;tn.removeEventListener(e,t,i)}function Cr(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 $n(n){return n===""?null:+n}function Fc(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 ze(n,e,t,i){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,i?"important":"")}function re(n,e,t){n.classList.toggle(e,!!t)}function Ji(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=Gt(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 xr(n,e){return new n(e)}var $a=new Map,Ya=0;function _g(n){let e=5381,t=n.length;for(;t--;)e=(e<<5)-e^n.charCodeAt(t);return e>>>0}function Sg(n,e){let t={stylesheet:Nc(e),rules:{}};return $a.set(n,t),t}function Xi(n,e,t,i,a,s,r,o=0){let l=16.666/i,c=`{ +return "";`}]}],conditioned:!0,hasRule:!0},{type:"traits",id:Q(),properties:["traits"],conditioned:!0,dice:!0},{type:"spells",id:Q(),properties:["spells"],conditioned:!0,dice:!0},{type:"text",id:Q(),properties:["spellsNotes"],conditioned:!0,text:null},{type:"traits",id:Q(),properties:["actions"],heading:"Actions",conditioned:!0,dice:!0},{type:"traits",id:Q(),properties:["bonus_actions"],heading:"Bonus Actions",conditioned:!0,dice:!0},{type:"group",id:Q(),properties:["legendary_description","legendary_actions"],heading:"Legendary Actions",nested:[{type:"text",id:Q(),properties:["legendary_description"],conditioned:!0,text:null},{type:"traits",id:Q(),properties:["legendary_actions"],conditioned:!0,dice:!0}],conditioned:!0},{type:"group",id:Q(),properties:["mythic_description","mythic_actions"],heading:"Mythic Actions",nested:[{type:"text",id:Q(),properties:["mythic_description"],conditioned:!0,text:null},{type:"traits",id:Q(),properties:["mythic_actions"],conditioned:!0,dice:!0}],conditioned:!0},{type:"traits",id:Q(),properties:["reactions"],heading:"Reactions",conditioned:!0,dice:!0},{type:"traits",id:Q(),properties:["lair_actions"],heading:"Lair Actions",conditioned:!0,dice:!0},{type:"traits",id:Q(),properties:["regional_effects"],heading:"Regional Effects",conditioned:!0,dice:!0}],rn={blocks:kg,id:"basic-5e-layout",name:"Basic 5e Layout",edited:!1,version:9};var Bu=require("obsidian");function N(){}var on=n=>n;function at(n,e){for(let t in e)n[t]=e[t];return n}function Ac(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function Cr(n){return n()}function Ua(){return Object.create(null)}function oe(n){n.forEach(Cr)}function Pe(n){return typeof n=="function"}function V(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}var Va;function Tc(n,e){return n===e?!0:(Va||(Va=document.createElement("a")),Va.href=e,n===Va.href)}function Dc(n){return Object.keys(n).length===0}function Dt(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(Dt(e,t))}function st(n,e,t,i){if(n){let a=Ec(n,e,t,i);return n[0](a)}}function Ec(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(),$i=Mc?n=>requestAnimationFrame(n):N;var wi=new Set;function Ic(n){wi.forEach(e=>{e.c(n)||(wi.delete(e),e.f())}),wi.size!==0&&$i(Ic)}function Kn(n){let e;return wi.size===0&&$i(Ic),{promise:new Promise(t=>{wi.add(e={c:n,f:t})}),abort(){wi.delete(e)}}}var Yi=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var Ga=class n{constructor(e){We(this,"_listeners","WeakMap"in Yi?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)}))}};Ga.entries="WeakMap"in Yi?new WeakMap:void 0;var Oc=!1;function Pc(){Oc=!0}function Rc(){Oc=!1}function y(n,e){n.appendChild(e)}function se(n,e,t){let i=Ka(n);if(!i.getElementById(e)){let a=v("style");a.id=e,a.textContent=t,Bc(i,a)}}function Ka(n){if(!n)return document;let e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function Nc(n){let e=v("style");return e.textContent="/* empty */",Bc(Ka(n),e),e.sheet}function Bc(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 He(n,e){for(let t=0;tn.removeEventListener(e,t,i)}function xr(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 $n(n){return n===""?null:+n}function Fc(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 ze(n,e,t,i){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,i?"important":"")}function re(n,e,t){n.classList.toggle(e,!!t)}function Ji(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=Gt(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 Ar(n,e){return new n(e)}var $a=new Map,Ya=0;function _g(n){let e=5381,t=n.length;for(;t--;)e=(e<<5)-e^n.charCodeAt(t);return e>>>0}function Sg(n,e){let t={stylesheet:Nc(e),rules:{}};return $a.set(n,t),t}function Xi(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_${_g(d)}_${o}`,h=Ka(n),{stylesheet:f,rules:m}=$a.get(h)||Sg(h,n);m[u]||(m[u]=!0,f.insertRule(`@keyframes ${u} ${d}`,f.cssRules.length));let p=n.style.animation||"";return n.style.animation=`${p?`${p}, `:""}${u} ${i}ms linear ${a}ms 1 both`,Ya+=1,u}function Ja(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(", "),Ya-=a,Ya||Cg())}function Cg(){$i(()=>{Ya||($a.forEach(n=>{let{ownerNode:e}=n.stylesheet;e&&x(e)}),$a.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,f=!1,m;function p(){u&&(m=Xi(n,0,1,r,s,o,u)),s||(f=!0)}function b(){u&&Ja(n,m),h=!1}return Kn(_=>{if(!f&&_>=l&&(f=!0),f&&_>=c&&(d(1,0),b()),!h)return!1;if(f){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,xg(n,a)}}function xg(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 Et(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=Ji(e,t,{cancelable:i});return a.slice().forEach(r=>{r.call(n,s)}),!s.defaultPrevented}return!0}}function Mt(n,e){return Mn().$$.context.set(n,e),e}function Ue(n){return Mn().$$.context.get(n)}function Ar(){return Mn().$$.context}function Ge(n,e){let t=n.$$.callbacks[e.type];t&&t.slice().forEach(i=>i.call(this,e))}var Yn=[];var Re=[],Si=[],Dr=[],Hc=Promise.resolve(),Er=!1;function Mr(){Er||(Er=!0,Hc.then(Qi))}function Xa(){return Mr(),Hc}function It(n){Si.push(n)}function Ft(n){Dr.push(n)}var Tr=new Set,_i=0;function Qi(){if(_i!==0)return;let n=En;do{try{for(;_in.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),Si=e}var Zi;function Tg(){return Zi||(Zi=Promise.resolve(),Zi.then(()=>{Zi=null})),Zi}function Ir(n,e,t){n.dispatchEvent(Ji(`${e?"intro":"outro"}${t}`))}var Qa=new Set,yn;function le(){yn={r:0,c:[],p:yn}}function ce(){yn.r||oe(yn.c),yn=yn.p}function E(n,e){n&&n.i&&(Qa.delete(n),n.i(e))}function I(n,e,t,i){if(n&&n.o){if(Qa.has(n))return;Qa.add(n),yn.c.push(()=>{Qa.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}var Dg={duration:0};function Jn(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&&Ja(n,c)}function h(m,p){let b=m.b-r;return p*=Math.abs(b),{a:r,b:m.b,d:b,duration:p,start:m.start,end:m.start+p,group:m.group}}function f(m){let{delay:p=0,duration:b=300,easing:_=on,tick:S=N,css:C}=s||Dg,M={start:An()+p,b:m};m||(M.group=yn,yn.r+=1),"inert"in n&&(m?d!==void 0&&(n.inert=d):(d=n.inert,n.inert=!0)),o||l?l=M:(C&&(u(),c=Xi(n,r,m,b,p,_,C)),m&&S(0,1),o=h(M,b),It(()=>Ir(n,m,"start")),Kn(w=>{if(l&&w>l.start&&(o=h(l,b),l=null,Ir(n,o.b,"start"),C&&(u(),c=Xi(n,r,o.b,o.duration,0,_,s.css))),o){if(w>=o.end)S(r=o.b,1-r),Ir(n,o.b,"end"),l||(o.b?u():--o.group.r||oe(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(m){Pe(s)?Tg().then(()=>{s=s({direction:m?"in":"out"}),f(m)}):f(m)},end(){u(),o=l=null}}}function qc(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&&(le(),I(u,1,1,()=>{e.blocks[h]===u&&(e.blocks[h]=null)}),ce())}):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&&Qi()}if(Ac(n)){let a=Mn();if(n.then(s=>{Et(a),i(e.then,1,e.value,s),Et(null)},s=>{if(Et(a),i(e.catch,2,e.error,s),Et(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 jc(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 be(n){return n?.length!==void 0?n:Array.from(n)}function Or(n,e){n.d(1),e.delete(n.key)}function Xn(n,e){I(n,1,1,()=>{e.delete(n.key)})}function Vc(n,e){n.f(),Or(n,e)}function Ci(n,e){n.f(),Xn(n,e)}function vt(n,e,t,i,a,s,r,o,l,c,d,u){let h=n.length,f=s.length,m=h,p={};for(;m--;)p[n[m].key]=m;let b=[],_=new Map,S=new Map,C=[];for(m=f;m--;){let A=u(a,s,m),P=t(A),B=r.get(P);B?i&&C.push(()=>B.p(A,e)):(B=c(P,A),B.c()),_.set(P,b[m]=B),P in p&&S.set(P,Math.abs(m-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,f--}for(;h&&f;){let A=b[f-1],P=n[h-1],B=A.key,L=P.key;A===P?(d=A.first,h--,f--):_.has(L)?!r.has(B)||M.has(B)?k(A):w.has(L)?h--:S.get(B)>S.get(L)?(w.add(B),k(A)):(M.add(L),h--):(l(P,r),h--)}for(;h--;){let A=n[h];_.has(A.key)||l(A,r)}for(;f;)k(b[f-1]);return oe(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 Eg=["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"],Mg=new Set([...Eg]);function Wt(n,e,t){let i=n.$$.props[e];i!==void 0&&(n.$$.bound[i]=t,t(n.$$.ctx[i]))}function ie(n){n&&n.c()}function te(n,e,t){let{fragment:i,after_update:a}=n.$$;i&&i.m(e,t),It(()=>{let s=n.$$.on_mount.map(Sr).filter(Pe);n.$$.on_destroy?n.$$.on_destroy.push(...s):oe(s),n.$$.on_mount=[]}),a.forEach(It)}function ne(n,e){let t=n.$$;t.fragment!==null&&(zc(t.after_update),oe(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Og(n,e){n.$$.dirty[0]===-1&&(Yn.push(n),Mr(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{let m=f.length?f[0]:h;return c.ctx&&a(c.ctx[u],c.ctx[u]=m)&&(!c.skip_bound&&c.bound[u]&&c.bound[u](m),d&&Og(n,u)),h}):[],c.update(),d=!0,oe(c.before_update),c.fragment=i?i(c.ctx):!1,e.target){if(e.hydrate){Pc();let u=Fc(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),Rc(),Qi()}Et(l)}var Pg;typeof HTMLElement=="function"&&(Pg=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=Wc(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]=Pr(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=Pr(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]=Pr(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 Pr(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&&!Dc(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var Uc="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Uc);var $t=require("obsidian");var xi=[];function Rg(n,e){return{subscribe:Le(n,e).subscribe}}function Le(n,e=N){let t,i=new Set;function a(o){if(V(n,o)&&(n=o,t)){let l=!xi.length;for(let c of i)c[1](),xi.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 kt(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 Rg(t,(r,o)=>{let l=!1,c=[],d=0,u=N,h=()=>{if(d)return;u();let m=e(i?c[0]:c,r,o);s?r(m):u=Pe(m)?m:N},f=a.map((m,p)=>Dt(m,b=>{c[p]=b,d&=~(1<{d|=1<([\\s\\S]+?)<${Za}>`),es="STATBLOCK-MARKDOWN-LINK",ns=new RegExp(`<${es}>([\\s\\S]+?)(?:\\|([\\s\\S]+?))?<${es}>`),Br=/([\s\S]+?)/,Ht=class n{static isStatblockLink(e){return Br.test(e)}static replaceWikiLink(e){return`<${Za}>${e}<${Za}>`}static replaceMarkdownLink(e,t){return`<${es}>${e}${t?"|"+t:""}<${es}>`}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(ts,"g"),(t,i)=>`[[${i}]]`).replace(new RegExp(ns,"g"),(t,i,a)=>`[${a||""}](${i})`)}};var vn,ea,Fr,Lr=class extends Ai.Component{constructor(){super(...arguments);Be(this,ea);Be(this,vn,new Map)}buildCache(){setTimeout(()=>{let t=this.metadataCache.getLinkSuggestions();for(let{alias:i,file:a}of t)i&&Oe(this,ea,Fr).call(this,[i],a)},0)}getResolvedFile(t,i){t=t.trim();let a=X(this,vn).get(t)??X(this,vn).get(t.toLowerCase())??t;return{alias:X(this,vn).has(t)||X(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,Ai.parseFrontMatterAliases)(s)??[];Oe(this,ea,Fr).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,Ht.replaceWikiLink(`${s.basename}${r?"|"+r:""}`)):t}linkifySpells(t,i=""){return t.replace(/(.+?)(\*?,|\*?$)/g,(a,s,r)=>`${this.linkify(s,i)}${r}`)}transformSource(t){return Ht.transformSource(t)}transformYamlSource(t){return Ht.transformYamlSource(t)}stringifyLinks(t){return Ht.stringifyLinks(t)}splitByLinks(t,i,a){return ye(t).split(Br).filter(s=>s&&s.length).map(s=>{if(ts.test(s)){let r=s.match(ts)[1];return{isLink:a,text:`[[${(0,Ai.normalizePath)(r)}]]`}}if(ns.test(s)){let[r,o,l]=s.match(ns);return{isLink:a,text:`[${l||""}](${o})`}}return{isLink:!1,text:s}})}};vn=new WeakMap,ea=new WeakSet,Fr=function(t,i){for(let a of t)X(this,vn).set(a,i.name),X(this,vn).set(a.toLowerCase(),i.name)};var ut=new Lr;function Gc(n,e,t){let i=new Map,a=new Map,s=n.diceParsing??is();for(let o of s){i.set(o.id,new RegExp(o.regex));let l=` +}`,u=`__svelte_${_g(d)}_${o}`,h=Ka(n),{stylesheet:f,rules:m}=$a.get(h)||Sg(h,n);m[u]||(m[u]=!0,f.insertRule(`@keyframes ${u} ${d}`,f.cssRules.length));let p=n.style.animation||"";return n.style.animation=`${p?`${p}, `:""}${u} ${i}ms linear ${a}ms 1 both`,Ya+=1,u}function Ja(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(", "),Ya-=a,Ya||Cg())}function Cg(){$i(()=>{Ya||($a.forEach(n=>{let{ownerNode:e}=n.stylesheet;e&&x(e)}),$a.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,f=!1,m;function p(){u&&(m=Xi(n,0,1,r,s,o,u)),s||(f=!0)}function b(){u&&Ja(n,m),h=!1}return Kn(_=>{if(!f&&_>=l&&(f=!0),f&&_>=c&&(d(1,0),b()),!h)return!1;if(f){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,xg(n,a)}}function xg(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 Et(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=Ji(e,t,{cancelable:i});return a.slice().forEach(r=>{r.call(n,s)}),!s.defaultPrevented}return!0}}function Mt(n,e){return Mn().$$.context.set(n,e),e}function Ue(n){return Mn().$$.context.get(n)}function Tr(){return Mn().$$.context}function Ge(n,e){let t=n.$$.callbacks[e.type];t&&t.slice().forEach(i=>i.call(this,e))}var Yn=[];var Re=[],Si=[],Er=[],Hc=Promise.resolve(),Mr=!1;function Ir(){Mr||(Mr=!0,Hc.then(Qi))}function Xa(){return Ir(),Hc}function It(n){Si.push(n)}function Ft(n){Er.push(n)}var Dr=new Set,_i=0;function Qi(){if(_i!==0)return;let n=En;do{try{for(;_in.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),Si=e}var Zi;function Tg(){return Zi||(Zi=Promise.resolve(),Zi.then(()=>{Zi=null})),Zi}function Or(n,e,t){n.dispatchEvent(Ji(`${e?"intro":"outro"}${t}`))}var Qa=new Set,yn;function le(){yn={r:0,c:[],p:yn}}function ce(){yn.r||oe(yn.c),yn=yn.p}function E(n,e){n&&n.i&&(Qa.delete(n),n.i(e))}function I(n,e,t,i){if(n&&n.o){if(Qa.has(n))return;Qa.add(n),yn.c.push(()=>{Qa.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}var Dg={duration:0};function Jn(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&&Ja(n,c)}function h(m,p){let b=m.b-r;return p*=Math.abs(b),{a:r,b:m.b,d:b,duration:p,start:m.start,end:m.start+p,group:m.group}}function f(m){let{delay:p=0,duration:b=300,easing:_=on,tick:S=N,css:C}=s||Dg,M={start:An()+p,b:m};m||(M.group=yn,yn.r+=1),"inert"in n&&(m?d!==void 0&&(n.inert=d):(d=n.inert,n.inert=!0)),o||l?l=M:(C&&(u(),c=Xi(n,r,m,b,p,_,C)),m&&S(0,1),o=h(M,b),It(()=>Or(n,m,"start")),Kn(w=>{if(l&&w>l.start&&(o=h(l,b),l=null,Or(n,o.b,"start"),C&&(u(),c=Xi(n,r,o.b,o.duration,0,_,s.css))),o){if(w>=o.end)S(r=o.b,1-r),Or(n,o.b,"end"),l||(o.b?u():--o.group.r||oe(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(m){Pe(s)?Tg().then(()=>{s=s({direction:m?"in":"out"}),f(m)}):f(m)},end(){u(),o=l=null}}}function qc(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&&(le(),I(u,1,1,()=>{e.blocks[h]===u&&(e.blocks[h]=null)}),ce())}):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&&Qi()}if(Ac(n)){let a=Mn();if(n.then(s=>{Et(a),i(e.then,1,e.value,s),Et(null)},s=>{if(Et(a),i(e.catch,2,e.error,s),Et(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 jc(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 be(n){return n?.length!==void 0?n:Array.from(n)}function Pr(n,e){n.d(1),e.delete(n.key)}function Xn(n,e){I(n,1,1,()=>{e.delete(n.key)})}function Vc(n,e){n.f(),Pr(n,e)}function Ci(n,e){n.f(),Xn(n,e)}function vt(n,e,t,i,a,s,r,o,l,c,d,u){let h=n.length,f=s.length,m=h,p={};for(;m--;)p[n[m].key]=m;let b=[],_=new Map,S=new Map,C=[];for(m=f;m--;){let A=u(a,s,m),P=t(A),B=r.get(P);B?i&&C.push(()=>B.p(A,e)):(B=c(P,A),B.c()),_.set(P,b[m]=B),P in p&&S.set(P,Math.abs(m-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,f--}for(;h&&f;){let A=b[f-1],P=n[h-1],B=A.key,L=P.key;A===P?(d=A.first,h--,f--):_.has(L)?!r.has(B)||M.has(B)?k(A):w.has(L)?h--:S.get(B)>S.get(L)?(w.add(B),k(A)):(M.add(L),h--):(l(P,r),h--)}for(;h--;){let A=n[h];_.has(A.key)||l(A,r)}for(;f;)k(b[f-1]);return oe(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 Eg=["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"],Mg=new Set([...Eg]);function Wt(n,e,t){let i=n.$$.props[e];i!==void 0&&(n.$$.bound[i]=t,t(n.$$.ctx[i]))}function ie(n){n&&n.c()}function te(n,e,t){let{fragment:i,after_update:a}=n.$$;i&&i.m(e,t),It(()=>{let s=n.$$.on_mount.map(Cr).filter(Pe);n.$$.on_destroy?n.$$.on_destroy.push(...s):oe(s),n.$$.on_mount=[]}),a.forEach(It)}function ne(n,e){let t=n.$$;t.fragment!==null&&(zc(t.after_update),oe(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function Og(n,e){n.$$.dirty[0]===-1&&(Yn.push(n),Ir(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{let m=f.length?f[0]:h;return c.ctx&&a(c.ctx[u],c.ctx[u]=m)&&(!c.skip_bound&&c.bound[u]&&c.bound[u](m),d&&Og(n,u)),h}):[],c.update(),d=!0,oe(c.before_update),c.fragment=i?i(c.ctx):!1,e.target){if(e.hydrate){Pc();let u=Fc(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),Rc(),Qi()}Et(l)}var Pg;typeof HTMLElement=="function"&&(Pg=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=Wc(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]=Rr(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=Rr(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]=Rr(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 Rr(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&&!Dc(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var Uc="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(Uc);var $t=require("obsidian");var xi=[];function Rg(n,e){return{subscribe:Le(n,e).subscribe}}function Le(n,e=N){let t,i=new Set;function a(o){if(V(n,o)&&(n=o,t)){let l=!xi.length;for(let c of i)c[1](),xi.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 kt(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 Rg(t,(r,o)=>{let l=!1,c=[],d=0,u=N,h=()=>{if(d)return;u();let m=e(i?c[0]:c,r,o);s?r(m):u=Pe(m)?m:N},f=a.map((m,p)=>Dt(m,b=>{c[p]=b,d&=~(1<{d|=1<([\\s\\S]+?)<${Za}>`),es="STATBLOCK-MARKDOWN-LINK",ns=new RegExp(`<${es}>([\\s\\S]+?)(?:\\|([\\s\\S]+?))?<${es}>`),Lr=/([\s\S]+?)/,Ht=class n{static isStatblockLink(e){return Lr.test(e)}static replaceWikiLink(e){return`<${Za}>${e}<${Za}>`}static replaceMarkdownLink(e,t){return`<${es}>${e}${t?"|"+t:""}<${es}>`}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(ts,"g"),(t,i)=>`[[${i}]]`).replace(new RegExp(ns,"g"),(t,i,a)=>`[${a||""}](${i})`)}};var vn,ea,Wr,Fr=class extends Ai.Component{constructor(){super(...arguments);Be(this,ea);Be(this,vn,new Map)}buildCache(){setTimeout(()=>{let t=this.metadataCache.getLinkSuggestions();for(let{alias:i,file:a}of t)i&&Oe(this,ea,Wr).call(this,[i],a)},0)}getResolvedFile(t,i){t=t.trim();let a=X(this,vn).get(t)??X(this,vn).get(t.toLowerCase())??t;return{alias:X(this,vn).has(t)||X(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,Ai.parseFrontMatterAliases)(s)??[];Oe(this,ea,Wr).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,Ht.replaceWikiLink(`${s.basename}${r?"|"+r:""}`)):t}linkifySpells(t,i=""){return t.replace(/(.+?)(\*?,|\*?$)/g,(a,s,r)=>`${this.linkify(s,i)}${r}`)}transformSource(t){return Ht.transformSource(t)}transformYamlSource(t){return Ht.transformYamlSource(t)}stringifyLinks(t){return Ht.stringifyLinks(t)}splitByLinks(t,i,a){return ye(t).split(Lr).filter(s=>s&&s.length).map(s=>{if(ts.test(s)){let r=s.match(ts)[1];return{isLink:a,text:`[[${(0,Ai.normalizePath)(r)}]]`}}if(ns.test(s)){let[r,o,l]=s.match(ns);return{isLink:a,text:`[${l||""}](${o})`}}return{isLink:!1,text:s}})}};vn=new WeakMap,ea=new WeakSet,Wr=function(t,i){for(let a of t)X(this,vn).set(a,i.name),X(this,vn).set(a.toLowerCase(),i.name)};var ut=new Fr;function Gc(n,e,t){let i=new Map,a=new Map,s=n.diceParsing??is();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}; @@ -449,27 +449,27 @@ if (!isNaN(Number(number))) { } return { text, original };`,id:Q(),desc:"+5"}]}function Lg(n){se(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 Fg(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=J(t=n[1].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function Wg(n,e,t){let i,{property:a}=e;a=typeof a=="string"?ut.stringifyLinks(a):a;let s=Ue("context"),r=Ue("renderer"),o=Ue("item"),l=Ue("dice"),c=o.dice,d=Ue("monster");Se(n,d,b=>t(5,i=b));let u=i;d.subscribe(b=>u=b);let h=Ue("plugin"),f=Ue("layout"),m=[a];if(l&&c)if(o.diceProperty&&o.diceProperty in u&&typeof u[o.diceProperty]=="string")m=[{text:u[o.diceProperty]}];else{let b=Gc(f,ye(a),u);Array.isArray(b)?m=b:m=[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)?m=C:m=[C]}catch(b){new as.Notice(`There was an error executing the provided dice callback for [${o.properties.join(", ")}] -${b.message}`),console.error(b)}a="";for(let b of m)if(l&&typeof b=="object"){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="\\-"),as.MarkdownRenderer.render(h.app,a,b,s,r)};return n.$$set=b=>{"property"in b&&t(2,a=b.property)},[d,p,a]}var Wr=class extends G{constructor(e){super(),K(this,e,Wg,Fg,V,{property:2},Lg)}},Kc=Wr;function Hg(n){let e,t;return e=new Kc({props:{property:n[0]}}),{c(){ie(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 zg(n,e,t){let{property:i=""}=e;return n.$$set=a=>{"property"in a&&t(0,i=a.property)},[i]}var Hr=class extends G{constructor(e){super(),K(this,e,zg,Hg,V,{property:0})}},gt=Hr;var Qc=require("obsidian");function qg(n){se(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 $c(n,e,t){let i=n.slice();return i[7]=e[t],i}function Yc(n){let e,t,i;return t=new gt({props:{property:n[2]}}),{c(){e=v("div"),ie(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 Jc(n){let e,t,i=be(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}),ce());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=Jc(c),l.c(),E(l,1),l.m(e,null)):l&&(le(),I(l,1,1,()=>{l=null}),ce()),(!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 Vg(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 Qc.Notice(`There was an error executing the provided callback for [${l.properties.join(", ")}] +${b.message}`),console.error(b)}a="";for(let b of m)if(l&&typeof b=="object"){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="\\-"),as.MarkdownRenderer.render(h.app,a,b,s,r)};return n.$$set=b=>{"property"in b&&t(2,a=b.property)},[d,p,a]}var Hr=class extends G{constructor(e){super(),K(this,e,Wg,Fg,V,{property:2},Lg)}},Kc=Hr;function Hg(n){let e,t;return e=new Kc({props:{property:n[0]}}),{c(){ie(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 zg(n,e,t){let{property:i=""}=e;return n.$$set=a=>{"property"in a&&t(0,i=a.property)},[i]}var zr=class extends G{constructor(e){super(),K(this,e,zg,Hg,V,{property:0})}},gt=zr;var Qc=require("obsidian");function qg(n){se(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 $c(n,e,t){let i=n.slice();return i[7]=e[t],i}function Yc(n){let e,t,i;return t=new gt({props:{property:n[2]}}),{c(){e=v("div"),ie(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 Jc(n){let e,t,i=be(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}),ce());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=Jc(c),l.c(),E(l,1),l.m(e,null)):l&&(le(),I(l,1,1,()=>{l=null}),ce()),(!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 Vg(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 Qc.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?[]:[mt(s),mt(o)].join(" "))},[r,a,s,o,l,i,c]}var ss=class extends G{constructor(e){super(),K(this,e,Vg,jg,V,{trait:1,name:2,desc:0,property:3,item:4,monster:6},qg)}},ta=ss;var rs=require("obsidian");function Ug(n){se(n,"svelte-1lnliuc",".inline.svelte-1lnliuc{display:inline}")}function Zc(n,e,t){let i=n.slice();return i[6]=e[t],i}function Gg(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 Kg(n){let e,t,i={ctx:n,current:null,token:null,hasCatch:!1,pending:Jg,then:Yg,catch:$g,value:9};return qc(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,jc(i,n,s)},d(a){a&&x(e),i.block.d(a),i.token=null,i=null}}}function $g(n){return{c:N,m:N,p:N,d:N}}function Yg(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 Jg(n){return{c:N,m:N,p:N,d:N}}function eu(n){let e;function t(s,r){return s[6].isLink?Kg:Gg}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 Xg(n){let e,t=be(n[0]),i=[];for(let a=0;a{let d=createDiv();return await rs.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 zr=class extends G{constructor(e){super(),K(this,e,Qg,Xg,V,{textToRender:2},Ug)}},Kt=zr;function Zg(n){se(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 tu(n,e,t){let i=n.slice();return i[2]=e[t],i}function nu(n){let e,t,i,a,s=[sp,ap,ip,np,tp,ep],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):(le(),I(r[d],1,1,()=>{r[d]=null}),ce(),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 ep(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h6"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 tp(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h5"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 np(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h4"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 ip(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h3"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 ap(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h2"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 sp(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h1"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 iu(n){let e,t,i=n[2]in n[0]&&nu(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=nu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function rp(n){let e,t,i=be(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 qr=class extends G{constructor(e){super(),K(this,e,op,rp,V,{monster:0,item:1},Zg)}},au=qr;var ru=require("obsidian");function lp(n){se(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 su(n){let e,t,i,a,s,r;return a=new gt({props:{property:n[1]}}),{c(){e=v("div"),t=v("span"),t.textContent=`${n[3]}`,i=R(),ie(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 cp(n){let e,t,i=(!n[0].conditioned||n[0].conditioned&&`${n[1]}`.length)&&su(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=su(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function up(n,e,t){let i,{monster:a}=e,{item:s}=e,r=ye(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 ru.Notice(`There was an error executing the provided callback for [${s.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?[]:[mt(s),mt(o)].join(" "))},[r,a,s,o,l,i,c]}var ss=class extends G{constructor(e){super(),K(this,e,Vg,jg,V,{trait:1,name:2,desc:0,property:3,item:4,monster:6},qg)}},ta=ss;var rs=require("obsidian");function Ug(n){se(n,"svelte-1lnliuc",".inline.svelte-1lnliuc{display:inline}")}function Zc(n,e,t){let i=n.slice();return i[6]=e[t],i}function Gg(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 Kg(n){let e,t,i={ctx:n,current:null,token:null,hasCatch:!1,pending:Jg,then:Yg,catch:$g,value:9};return qc(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,jc(i,n,s)},d(a){a&&x(e),i.block.d(a),i.token=null,i=null}}}function $g(n){return{c:N,m:N,p:N,d:N}}function Yg(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 Jg(n){return{c:N,m:N,p:N,d:N}}function eu(n){let e;function t(s,r){return s[6].isLink?Kg:Gg}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 Xg(n){let e,t=be(n[0]),i=[];for(let a=0;a{let d=createDiv();return await rs.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 qr=class extends G{constructor(e){super(),K(this,e,Qg,Xg,V,{textToRender:2},Ug)}},Kt=qr;function Zg(n){se(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 tu(n,e,t){let i=n.slice();return i[2]=e[t],i}function nu(n){let e,t,i,a,s=[sp,ap,ip,np,tp,ep],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):(le(),I(r[d],1,1,()=>{r[d]=null}),ce(),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 ep(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h6"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 tp(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h5"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 np(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h4"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 ip(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h3"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 ap(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h2"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 sp(n){let e,t,i,a,s;return t=new Kt({props:{textToRender:ye(n[0][n[2]])}}),{c(){e=v("h1"),ie(t.$$.fragment),i=R(),g(e,"class",a="heading statblock-heading "+ye(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=ye(r[0][r[2]])),t.$set(l),(!s||o&2&&a!==(a="heading statblock-heading "+ye(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 iu(n){let e,t,i=n[2]in n[0]&&nu(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=nu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function rp(n){let e,t,i=be(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 jr=class extends G{constructor(e){super(),K(this,e,op,rp,V,{monster:0,item:1},Zg)}},au=jr;var ru=require("obsidian");function lp(n){se(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 su(n){let e,t,i,a,s,r;return a=new gt({props:{property:n[1]}}),{c(){e=v("div"),t=v("span"),t.textContent=`${n[3]}`,i=R(),ie(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 cp(n){let e,t,i=(!n[0].conditioned||n[0].conditioned&&`${n[1]}`.length)&&su(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=su(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function up(n,e,t){let i,{monster:a}=e,{item:s}=e,r=ye(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 ru.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?"":mt(s.properties[0]))},[s,r,i,o,a]}var jr=class extends G{constructor(e){super(),K(this,e,up,cp,V,{monster:4,item:0},lp)}},ou=jr;function dp(n){se(n,"svelte-k72li0",`.tapered-rule.svelte-k72li0{width:auto;margin:0.5em 0;height:5px;background:-webkit-linear-gradient( +${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?"":mt(s.properties[0]))},[s,r,i,o,a]}var Vr=class extends G{constructor(e){super(),K(this,e,up,cp,V,{monster:4,item:0},lp)}},ou=Vr;function dp(n){se(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 hp(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 Vr=class extends G{constructor(e){super(),K(this,e,null,hp,V,{},dp)}},os=Vr;var uu=require("obsidian");function fp(n){se(n,"svelte-1vwmbsx",'.line.svelte-1vwmbsx.svelte-1vwmbsx{line-height:var(--active-saves-line-height);display:block;color:var(--active-font-color)}.property-name.svelte-1vwmbsx.svelte-1vwmbsx{color:var(--active-property-name-font-color);margin:0;margin-right:0.25em;display:inline;font-weight:bold}.property-text.svelte-1vwmbsx.svelte-1vwmbsx{display:inline;margin:0}.save-entry.svelte-1vwmbsx.svelte-1vwmbsx,.save-name.svelte-1vwmbsx.svelte-1vwmbsx,.save-value.svelte-1vwmbsx.svelte-1vwmbsx{display:inline}.save-entry.svelte-1vwmbsx:not(:last-child) .save-value.svelte-1vwmbsx::after{content:", "}')}function lu(n,e,t){let i=n.slice();return i[5]=e[t][0],i[6]=e[t][1],i}function mp(n){let e,t,i;return t=new gt({props:{property:n[5]}}),{c(){e=v("div"),ie(t.$$.fragment),g(e,"class","save-name svelte-1vwmbsx")},m(a,s){D(a,e,s),te(t,e,null),i=!0},p:N,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 cu(n){let e,t=!n[5].startsWith("_"),i,a,s,r,o,l,c=t&&mp(n);return s=new gt({props:{property:n[6]}}),{c(){e=v("div"),c&&c.c(),i=R(),a=v("div"),ie(s.$$.fragment),r=R(),g(a,"class","save-value svelte-1vwmbsx"),g(e,"class",o="save-entry save-"+mt(n[5])+"-entry svelte-1vwmbsx")},m(d,u){D(d,e,u),c&&c.m(e,null),y(e,i),y(e,a),te(s,a,null),y(e,r),l=!0},p(d,u){t&&c.p(d,u)},i(d){l||(E(c),E(s.$$.fragment,d),l=!0)},o(d){I(c),I(s.$$.fragment,d),l=!1},d(d){d&&x(e),c&&c.d(),ne(s)}}}function gp(n){let e,t,i,a=(n[0].display??Ki(n[0].properties[0]))+"",s,r,o,l,c,d=be(n[2]),u=[];for(let f=0;fI(u[f],1,1,()=>{u[f]=null});return{c(){e=v("div"),t=v("div"),i=v("span"),s=pe(a),r=R(),o=v("div");for(let f=0;f=0?"+":""}${n}`}function bp(n,e,t){let i,{monster:a}=e,{item:s}=e,r=a[s.properties[0]];if(Array.isArray(r)||(r=[]),s.callback)try{let l=document.body.createEl("iframe"),c=l.contentWindow.Function,d=new c("monster","property",s.callback);r=r.map(u=>d.call(void 0,a,u)??u),document.body.removeChild(l)}catch(l){new uu.Notice(`There was an error executing the provided callback for [${s.properties.join(", ")}] + );clip-path:polygon(0 0, 0 100%, 95% 50%);-webkit-clip-path:polygon(0 0, 0 100%, 95% 50%)}`)}function hp(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 Ur=class extends G{constructor(e){super(),K(this,e,null,hp,V,{},dp)}},os=Ur;var uu=require("obsidian");function fp(n){se(n,"svelte-1vwmbsx",'.line.svelte-1vwmbsx.svelte-1vwmbsx{line-height:var(--active-saves-line-height);display:block;color:var(--active-font-color)}.property-name.svelte-1vwmbsx.svelte-1vwmbsx{color:var(--active-property-name-font-color);margin:0;margin-right:0.25em;display:inline;font-weight:bold}.property-text.svelte-1vwmbsx.svelte-1vwmbsx{display:inline;margin:0}.save-entry.svelte-1vwmbsx.svelte-1vwmbsx,.save-name.svelte-1vwmbsx.svelte-1vwmbsx,.save-value.svelte-1vwmbsx.svelte-1vwmbsx{display:inline}.save-entry.svelte-1vwmbsx:not(:last-child) .save-value.svelte-1vwmbsx::after{content:", "}')}function lu(n,e,t){let i=n.slice();return i[5]=e[t][0],i[6]=e[t][1],i}function mp(n){let e,t,i;return t=new gt({props:{property:n[5]}}),{c(){e=v("div"),ie(t.$$.fragment),g(e,"class","save-name svelte-1vwmbsx")},m(a,s){D(a,e,s),te(t,e,null),i=!0},p:N,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 cu(n){let e,t=!n[5].startsWith("_"),i,a,s,r,o,l,c=t&&mp(n);return s=new gt({props:{property:n[6]}}),{c(){e=v("div"),c&&c.c(),i=R(),a=v("div"),ie(s.$$.fragment),r=R(),g(a,"class","save-value svelte-1vwmbsx"),g(e,"class",o="save-entry save-"+mt(n[5])+"-entry svelte-1vwmbsx")},m(d,u){D(d,e,u),c&&c.m(e,null),y(e,i),y(e,a),te(s,a,null),y(e,r),l=!0},p(d,u){t&&c.p(d,u)},i(d){l||(E(c),E(s.$$.fragment,d),l=!0)},o(d){I(c),I(s.$$.fragment,d),l=!1},d(d){d&&x(e),c&&c.d(),ne(s)}}}function gp(n){let e,t,i,a=(n[0].display??Ki(n[0].properties[0]))+"",s,r,o,l,c,d=be(n[2]),u=[];for(let f=0;fI(u[f],1,1,()=>{u[f]=null});return{c(){e=v("div"),t=v("div"),i=v("span"),s=pe(a),r=R(),o=v("div");for(let f=0;f=0?"+":""}${n}`}function bp(n,e,t){let i,{monster:a}=e,{item:s}=e,r=a[s.properties[0]];if(Array.isArray(r)||(r=[]),s.callback)try{let l=document.body.createEl("iframe"),c=l.contentWindow.Function,d=new c("monster","property",s.callback);r=r.map(u=>d.call(void 0,a,u)??u),document.body.removeChild(l)}catch(l){new uu.Notice(`There was an error executing the provided callback for [${s.properties.join(", ")}] -${l.message}`),console.error(l)}let o=r.map(l=>{if(!l||typeof l!="object")return null;if(l.desc)return[l.name||"_",l.desc];let c=Object.keys(l)[0];if(!c)return null;let d=Object.values(l)[0];return typeof d=="string"&&isNaN(Number(d))?[Ki(c),d]:d!=0&&(!d||isNaN(Number(d)))?null:[Ki(c),pp(d)]}).filter(l=>l);return n.$$set=l=>{"monster"in l&&t(3,a=l.monster),"item"in l&&t(0,s=l.item)},n.$$.update=()=>{n.$$.dirty&1&&t(1,i=s.doNotAddClass?[]:[mt(s.display),mt(s.properties[0])].join(" "))},[s,i,o,a]}var Ur=class extends G{constructor(e){super(),K(this,e,bp,gp,V,{monster:3,item:0},fp)}},du=Ur;function yp(n){se(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 hu(n){let e,t,i,a;return t=new Kt({props:{textToRender:n[0]}}),{c(){e=v("h3"),ie(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 vp(n){let e,t,i=n[0]&&n[0].length&&hu(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=hu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},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;if(a.headingProp){if(a.heading in i){let o=ye(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 Gr=class extends G{constructor(e){super(),K(this,e,kp,vp,V,{monster:2,item:3},yp)}},Ti=Gr;function wp(n){se(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 _p(n){let e,t,i;return t=new Kt({props:{textToRender:n[1].join(n[0].separator)}}),{c(){e=v("div"),ie(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 Sp(n){let e,t,i=n[1].length&&_p(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 Cp(n,e,t){let{monster:i}=e,{item:a}=e,s=[];for(let r of a.properties)r in i&&s.push(`${ye(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 Kr=class extends G{constructor(e){super(),K(this,e,Cp,Sp,V,{monster:2,item:0},wp)}},fu=Kr;function xp(n){se(n,"svelte-1jjvt5k",'.statblock-table-header.svelte-1jjvt5k{font-weight:var(--active-table-header-font-weight)}.statblock-table.svelte-1jjvt5k{display:flex;justify-content:space-evenly;align-items:center;flex-wrap:wrap}.table-item.svelte-1jjvt5k{display:flex;justify-content:center;align-items:center;flex-flow:column nowrap}.calculated-modifier.svelte-1jjvt5k::before{content:"("}.calculated-modifier.svelte-1jjvt5k::after{content:")"}')}function mu(n,e,t){let i=n.slice();return i[7]=e[t][0],i[2]=e[t][1],i}function gu(n,e,t){let i=n.slice();return i[10]=e[t],i}function pu(n){let e;return{c(){e=v("span"),e.textContent=`${n[3](n[10])}`,g(e,"class","calculated-modifier svelte-1jjvt5k")},m(t,i){D(t,e,i)},p:N,d(t){t&&x(e)}}}function bu(n){let e,t,i,a;t=new gt({props:{property:ye(n[10])}});let s=n[0].calculate&&pu(n);return{c(){e=v("span"),ie(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=pu(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 yu(n){let e,t,i,a,s,r=be(n[2]),o=[];for(let c=0;cI(o[c],1,1,()=>{o[c]=null});return{c(){e=v("div"),t=v("span"),t.textContent=`${n[5][n[7]]}`,i=R();for(let c=0;cI(s[o],1,1,()=>{s[o]=null});return{c(){e=v("div");for(let o=0;o=0?"+":"-"}${Math.abs(u)}`}let o=a[s.properties[0]];Array.isArray(o)||(o=[]);let l=new Map;for(let d=0;d0?o.length:1).keys()];return n.$$set=d=>{"monster"in d&&t(6,a=d.monster),"item"in d&&t(0,s=d.item)},n.$$.update=()=>{n.$$.dirty&1&&t(1,i=s.doNotAddClass?"":mt(s.properties[0]))},[s,i,o,r,l,c,a]}var $r=class extends G{constructor(e){super(),K(this,e,Tp,Ap,V,{monster:6,item:0},xp)}},vu=$r;function ku(n){let e,t,i,a,s=n[1].heading&&wu(n);return i=new gt({props:{render:n[1].markdown,property:n[2]}}),{c(){s&&s.c(),e=R(),t=v("div"),ie(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=wu(r),s.c(),E(s,1),s.m(e.parentNode,e)):s&&(le(),I(s,1,1,()=>{s=null}),ce());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 wu(n){let e,t;return e=new Ti({props:{item:n[1],monster:n[0]}}),{c(){ie(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 Dp(n){let e,t,i=(!n[1].conditioned||n[1].conditioned&&`${n[2]}`.length)&&ku(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=ku(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function Ep(n,e,t){let{monster:i}=e,{item:a}=e,s=a.text&&a.text.length?a.text:ye(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 Yr=class extends G{constructor(e){super(),K(this,e,Ep,Dp,V,{monster:0,item:1})}},_u=Yr;var Su=require("obsidian");function Mp(n){se(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 Ip(n){let e,t,i,a,s,r;return{c(){e=v("div"),t=v("img"),Tc(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"),re(e,"pointer",n[1]!=null)},m(o,l){D(o,e,l),y(e,t),s||(r=[q(e,"click",n[6]),q(e,"mouseenter",n[7])],s=!0)},p(o,l){l&1&&a!==(a=o[0].name)&&g(t,"alt",a),l&2&&re(e,"pointer",o[1]!=null)},d(o){o&&x(e),s=!1,oe(r)}}}function Op(n){let e,t=n[2]&&Ip(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 Pp(n,e,t){let{monster:i}=e,{item:a}=e,s=Ue("plugin"),r=Ue("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=Su.Platform.isMacOS?"Meta":"Control";function h(b){if(!o)return;s.app.workspace.getLeaf(b.getModifierState(u)?"window":"split").openFile(o)}function f(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 m=b=>h(b),p=b=>f(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,f,a,m,p]}var Jr=class extends G{constructor(e){super(),K(this,e,Pp,Op,V,{monster:0,item:5},Mp)}},Cu=Jr;function Rp(n){se(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 Np(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=q(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 Bp(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 Xr=class extends G{constructor(e){super(),K(this,e,Bp,Np,V,{block:0,elements:2},Rp)}},xu=Xr;var u2=require("obsidian");function Lp(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=J(t=n[1].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function Fp(n,e,t){let i,{block:a}=e,s=Ue("monster");Se(n,s,c=>t(4,i=c));let r=i;s.subscribe(c=>r=c);let o=Ue("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 Qr=class extends G{constructor(e){super(),K(this,e,Fp,Lp,V,{block:2})}},Au=Qr;function Wp(n){se(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) +${l.message}`),console.error(l)}let o=r.map(l=>{if(!l||typeof l!="object")return null;if(l.desc)return[l.name||"_",l.desc];let c=Object.keys(l)[0];if(!c)return null;let d=Object.values(l)[0];return typeof d=="string"&&isNaN(Number(d))?[Ki(c),d]:d!=0&&(!d||isNaN(Number(d)))?null:[Ki(c),pp(d)]}).filter(l=>l);return n.$$set=l=>{"monster"in l&&t(3,a=l.monster),"item"in l&&t(0,s=l.item)},n.$$.update=()=>{n.$$.dirty&1&&t(1,i=s.doNotAddClass?[]:[mt(s.display),mt(s.properties[0])].join(" "))},[s,i,o,a]}var Gr=class extends G{constructor(e){super(),K(this,e,bp,gp,V,{monster:3,item:0},fp)}},du=Gr;function yp(n){se(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 hu(n){let e,t,i,a;return t=new Kt({props:{textToRender:n[0]}}),{c(){e=v("h3"),ie(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 vp(n){let e,t,i=n[0]&&n[0].length&&hu(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=hu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},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;if(a.headingProp){if(a.heading in i){let o=ye(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 Kr=class extends G{constructor(e){super(),K(this,e,kp,vp,V,{monster:2,item:3},yp)}},Ti=Kr;function wp(n){se(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 _p(n){let e,t,i;return t=new Kt({props:{textToRender:n[1].join(n[0].separator)}}),{c(){e=v("div"),ie(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 Sp(n){let e,t,i=n[1].length&&_p(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 Cp(n,e,t){let{monster:i}=e,{item:a}=e,s=[];for(let r of a.properties)r in i&&s.push(`${ye(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 $r=class extends G{constructor(e){super(),K(this,e,Cp,Sp,V,{monster:2,item:0},wp)}},fu=$r;function xp(n){se(n,"svelte-1jjvt5k",'.statblock-table-header.svelte-1jjvt5k{font-weight:var(--active-table-header-font-weight)}.statblock-table.svelte-1jjvt5k{display:flex;justify-content:space-evenly;align-items:center;flex-wrap:wrap}.table-item.svelte-1jjvt5k{display:flex;justify-content:center;align-items:center;flex-flow:column nowrap}.calculated-modifier.svelte-1jjvt5k::before{content:"("}.calculated-modifier.svelte-1jjvt5k::after{content:")"}')}function mu(n,e,t){let i=n.slice();return i[7]=e[t][0],i[2]=e[t][1],i}function gu(n,e,t){let i=n.slice();return i[10]=e[t],i}function pu(n){let e;return{c(){e=v("span"),e.textContent=`${n[3](n[10])}`,g(e,"class","calculated-modifier svelte-1jjvt5k")},m(t,i){D(t,e,i)},p:N,d(t){t&&x(e)}}}function bu(n){let e,t,i,a;t=new gt({props:{property:ye(n[10])}});let s=n[0].calculate&&pu(n);return{c(){e=v("span"),ie(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=pu(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 yu(n){let e,t,i,a,s,r=be(n[2]),o=[];for(let c=0;cI(o[c],1,1,()=>{o[c]=null});return{c(){e=v("div"),t=v("span"),t.textContent=`${n[5][n[7]]}`,i=R();for(let c=0;cI(s[o],1,1,()=>{s[o]=null});return{c(){e=v("div");for(let o=0;o=0?"+":"-"}${Math.abs(u)}`}let o=a[s.properties[0]];Array.isArray(o)||(o=[]);let l=new Map;for(let d=0;d0?o.length:1).keys()];return n.$$set=d=>{"monster"in d&&t(6,a=d.monster),"item"in d&&t(0,s=d.item)},n.$$.update=()=>{n.$$.dirty&1&&t(1,i=s.doNotAddClass?"":mt(s.properties[0]))},[s,i,o,r,l,c,a]}var Yr=class extends G{constructor(e){super(),K(this,e,Tp,Ap,V,{monster:6,item:0},xp)}},vu=Yr;function ku(n){let e,t,i,a,s=n[1].heading&&wu(n);return i=new gt({props:{render:n[1].markdown,property:n[2]}}),{c(){s&&s.c(),e=R(),t=v("div"),ie(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=wu(r),s.c(),E(s,1),s.m(e.parentNode,e)):s&&(le(),I(s,1,1,()=>{s=null}),ce());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 wu(n){let e,t;return e=new Ti({props:{item:n[1],monster:n[0]}}),{c(){ie(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 Dp(n){let e,t,i=(!n[1].conditioned||n[1].conditioned&&`${n[2]}`.length)&&ku(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=ku(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function Ep(n,e,t){let{monster:i}=e,{item:a}=e,s=a.text&&a.text.length?a.text:ye(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 Jr=class extends G{constructor(e){super(),K(this,e,Ep,Dp,V,{monster:0,item:1})}},_u=Jr;var Su=require("obsidian");function Mp(n){se(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 Ip(n){let e,t,i,a,s,r;return{c(){e=v("div"),t=v("img"),Tc(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"),re(e,"pointer",n[1]!=null)},m(o,l){D(o,e,l),y(e,t),s||(r=[q(e,"click",n[6]),q(e,"mouseenter",n[7])],s=!0)},p(o,l){l&1&&a!==(a=o[0].name)&&g(t,"alt",a),l&2&&re(e,"pointer",o[1]!=null)},d(o){o&&x(e),s=!1,oe(r)}}}function Op(n){let e,t=n[2]&&Ip(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 Pp(n,e,t){let{monster:i}=e,{item:a}=e,s=Ue("plugin"),r=Ue("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=Su.Platform.isMacOS?"Meta":"Control";function h(b){if(!o)return;s.app.workspace.getLeaf(b.getModifierState(u)?"window":"split").openFile(o)}function f(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 m=b=>h(b),p=b=>f(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,f,a,m,p]}var Xr=class extends G{constructor(e){super(),K(this,e,Pp,Op,V,{monster:0,item:5},Mp)}},Cu=Xr;function Rp(n){se(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 Np(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=q(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 Bp(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 Qr=class extends G{constructor(e){super(),K(this,e,Bp,Np,V,{block:0,elements:2},Rp)}},xu=Qr;var u2=require("obsidian");function Lp(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=J(t=n[1].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function Fp(n,e,t){let i,{block:a}=e,s=Ue("monster");Se(n,s,c=>t(4,i=c));let r=i;s.subscribe(c=>r=c);let o=Ue("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 Zr=class extends G{constructor(e){super(),K(this,e,Fp,Lp,V,{block:2})}},Au=Zr;function Wp(n){se(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 Hp(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"),ze(e,"--statblock-column-width",n[0])},m(i,a){D(i,e,a),y(e,t),n[7](t)},p(i,[a]){a&1&&ze(e,"--statblock-column-width",i[0])},i:N,o:N,d(i){i&&x(e),n[7](null)}}}function zp(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=m=>{m.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)m.appendChild(M),M.querySelectorAll(".statblock-item-container:empty").forEach(w=>w.detach());b.detach()},h;pn(()=>{i("mounted"),h&&(u(h),i("built"))});function f(m){Re[m?"unshift":"push"](()=>{h=m,t(1,h)})}return n.$$set=m=>{"columns"in m&&t(2,a=m.columns),"targets"in m&&t(3,s=m.targets),"columnWidth"in m&&t(0,r=m.columnWidth),"heights"in m&&t(4,o=m.heights),"split"in m&&t(5,l=m.split),"classes"in m&&t(6,c=m.classes)},[r,h,a,s,o,l,c,f]}var Zr=class extends G{constructor(e){super(),K(this,e,zp,Hp,V,{columns:2,targets:3,columnWidth:0,heights:4,split:5,classes:6},Wp)}},eo=Zr;function qp(n){se(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 jp(n){let e,t,i,a,s,r,o;return i=new gt({props:{property:`${n[0].level}:`}}),r=new gt({props:{property:n[0].spells}}),{c(){e=v("li"),t=v("span"),ie(i.$$.fragment),a=R(),s=v("span"),ie(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 Vp(n){let e,t,i;return t=new gt({props:{property:n[0].spells}}),{c(){e=v("span"),ie(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 Up(n){let e,t,i,a,s=[Vp,jp],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"),re(e,"first",n[1]),re(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):(le(),I(r[d],1,1,()=>{r[d]=null}),ce(),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)&&re(e,"first",l[1]),(!a||c&4)&&re(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 Gp(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 to=class extends G{constructor(e){super(),K(this,e,Gp,Up,V,{spell:0,first:1,last:2},qp)}},Tu=to;var na=require("obsidian");function Kp(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","action")},m(s,r){D(s,e,r),i||(a=J(t=n[0].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function $p(n,e,t){let{block:i}=e,{monster:a}=e,s=r=>{new na.ExtraButtonComponent(r).setIcon(i.icon).onClick(()=>{if(i.callback?.trim()?.length)try{new Function("monster",i.callback).call(void 0,a)}catch(o){new na.Notice(`There was an error executing the provided callback for the action block. + 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 Hp(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"),ze(e,"--statblock-column-width",n[0])},m(i,a){D(i,e,a),y(e,t),n[7](t)},p(i,[a]){a&1&&ze(e,"--statblock-column-width",i[0])},i:N,o:N,d(i){i&&x(e),n[7](null)}}}function zp(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=m=>{m.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)m.appendChild(M),M.querySelectorAll(".statblock-item-container:empty").forEach(w=>w.detach());b.detach()},h;pn(()=>{i("mounted"),h&&(u(h),i("built"))});function f(m){Re[m?"unshift":"push"](()=>{h=m,t(1,h)})}return n.$$set=m=>{"columns"in m&&t(2,a=m.columns),"targets"in m&&t(3,s=m.targets),"columnWidth"in m&&t(0,r=m.columnWidth),"heights"in m&&t(4,o=m.heights),"split"in m&&t(5,l=m.split),"classes"in m&&t(6,c=m.classes)},[r,h,a,s,o,l,c,f]}var eo=class extends G{constructor(e){super(),K(this,e,zp,Hp,V,{columns:2,targets:3,columnWidth:0,heights:4,split:5,classes:6},Wp)}},to=eo;function qp(n){se(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 jp(n){let e,t,i,a,s,r,o;return i=new gt({props:{property:`${n[0].level}:`}}),r=new gt({props:{property:n[0].spells}}),{c(){e=v("li"),t=v("span"),ie(i.$$.fragment),a=R(),s=v("span"),ie(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 Vp(n){let e,t,i;return t=new gt({props:{property:n[0].spells}}),{c(){e=v("span"),ie(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 Up(n){let e,t,i,a,s=[Vp,jp],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"),re(e,"first",n[1]),re(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):(le(),I(r[d],1,1,()=>{r[d]=null}),ce(),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)&&re(e,"first",l[1]),(!a||c&4)&&re(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 Gp(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 no=class extends G{constructor(e){super(),K(this,e,Gp,Up,V,{spell:0,first:1,last:2},qp)}},Tu=no;var na=require("obsidian");function Kp(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","action")},m(s,r){D(s,e,r),i||(a=J(t=n[0].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function $p(n,e,t){let{block:i}=e,{monster:a}=e,s=r=>{new na.ExtraButtonComponent(r).setIcon(i.icon).onClick(()=>{if(i.callback?.trim()?.length)try{new Function("monster",i.callback).call(void 0,a)}catch(o){new na.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 na.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 no=class extends G{constructor(e){super(),K(this,e,$p,Kp,V,{block:1,monster:2})}},Du=no;function Eu(n){let e,t;return e=new eo({props:{heights:n[7],targets:n[2],columns:n[1],columnWidth:n[3],split:n[5],classes:n[0]}}),{c(){ie(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 Yp(n){let e,t,i=n[4]&&Eu(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=Eu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function Jp(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,f=[],{plugin:m}=e,p=Ue("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(j=>S(j)):O.type=="ifelse"||O.type=="javascript"||O.type=="layout"||!("properties"in O)||!O.properties.length?!0:O.properties.some(j=>!!(j in b&&(Array.isArray(b[j])&&b[j].length||typeof b[j]=="string"&&b[j].length||typeof b[j]=="number"))),C=Ar(),M=(O,j={})=>j.container?j.container.createDiv(`statblock-item-container ${mt(O.type)}-container ${(j.classes??[]).join(" ")}`):createDiv(`statblock-item-container ${mt(O.type)}-container ${(j.classes??[]).join(" ")}`),w=(O,j={})=>{if(!S(O))return[];let{container:Z,classes:ee}=j,ae=[],$=M(O,{container:Z,classes:ee});switch(C.set("item",O),ae.push($),O.type){case"group":{O.heading&&new Ti({target:$,props:{monster:b,item:O},context:C});for(let W of O.nested??[]){let Y=w(W,{container:$,classes:O.cls?[...ee??[],O.cls]:ee??[]});ae.push(...Y)}break}case"action":{new Du({target:$,props:{block:O,monster:b}});break}case"javascript":{new Au({target:$,props:{block:O}});break}case"collapse":{let W=[];for(let Y of O.nested){let F=w(Y);W.push(...F)}new xu({target:$,props:{block:O,elements:W}});break}case"heading":{let W=new au({target:$,props:{monster:b,item:O},context:C});W.$on("save",Y=>s("save",Y.detail)),W.$on("export",Y=>s("export",Y.detail));break}case"ifelse":{for(let W=0;W{if(typeof H=="string"&&(H.charAt(H.length-1)==":"||!H.includes(":"))){let U={header:_(H),spells:[]};return F.push(U),F}let he=F[F.length-1],ue;if(typeof H=="string")ue={spells:ut.linkifySpells(H,C.get("context"))};else try{ue={level:Object.keys(H).shift(),spells:ut.linkifySpells(ye(Object.values(H).shift()),C.get("context"))}}catch{return F}if(he)he.spells.push(ue);else{let U={header:`${b.name} knows the following spells:`,spells:[ue]};F.push(U)}return F},[]);for(let F=0;F0){new ta({target:Y.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(!f.length)for(let O of r){let j=w(O);j?.length&&f.push(...j)}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=[],B,L=()=>{let O=document.body.createDiv({cls:"statblock-detached markdown-preview-view",attr:{style:`width: ${k}`}});new eo({target:O.createDiv({cls:["obsidian-statblock-plugin","statblock",...l]}),props:{heights:P,targets:f,columns:1,columnWidth:k,classes:l}}).$on("built",()=>{let Z=O.querySelector(".column");for(let ee of f)P.push(ee.scrollHeight);b.forceColumns?t(5,B=Z.scrollHeight/u):b.columns&&b.columns>0?t(5,B=Math.max(Z.scrollHeight/b.columns,Z.scrollHeight/d)):t(5,B=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,m=O.plugin)},n.$$.update=()=>{n.$$.dirty&16384&&(i=!isNaN(Number(b.columnHeight))&&b.columnHeight>0?b.columnHeight:1/0),n.$$.dirty&512&&o&&L()},[l,d,f,k,A,B,p,P,r,o,c,u,h,m,b]}var io=class extends G{constructor(e){super(),K(this,e,Jp,Yp,V,{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]}},Mu=io;function Xp(n){se(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( +${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 io=class extends G{constructor(e){super(),K(this,e,$p,Kp,V,{block:1,monster:2})}},Du=io;function Eu(n){let e,t;return e=new to({props:{heights:n[7],targets:n[2],columns:n[1],columnWidth:n[3],split:n[5],classes:n[0]}}),{c(){ie(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 Yp(n){let e,t,i=n[4]&&Eu(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=Eu(a),i.c(),E(i,1),i.m(e.parentNode,e)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function Jp(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,f=[],{plugin:m}=e,p=Ue("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(j=>S(j)):O.type=="ifelse"||O.type=="javascript"||O.type=="layout"||!("properties"in O)||!O.properties.length?!0:O.properties.some(j=>!!(j in b&&(Array.isArray(b[j])&&b[j].length||typeof b[j]=="string"&&b[j].length||typeof b[j]=="number"))),C=Tr(),M=(O,j={})=>j.container?j.container.createDiv(`statblock-item-container ${mt(O.type)}-container ${(j.classes??[]).join(" ")}`):createDiv(`statblock-item-container ${mt(O.type)}-container ${(j.classes??[]).join(" ")}`),w=(O,j={})=>{if(!S(O))return[];let{container:Z,classes:ee}=j,ae=[],$=M(O,{container:Z,classes:ee});switch(C.set("item",O),ae.push($),O.type){case"group":{O.heading&&new Ti({target:$,props:{monster:b,item:O},context:C});for(let W of O.nested??[]){let Y=w(W,{container:$,classes:O.cls?[...ee??[],O.cls]:ee??[]});ae.push(...Y)}break}case"action":{new Du({target:$,props:{block:O,monster:b}});break}case"javascript":{new Au({target:$,props:{block:O}});break}case"collapse":{let W=[];for(let Y of O.nested){let F=w(Y);W.push(...F)}new xu({target:$,props:{block:O,elements:W}});break}case"heading":{let W=new au({target:$,props:{monster:b,item:O},context:C});W.$on("save",Y=>s("save",Y.detail)),W.$on("export",Y=>s("export",Y.detail));break}case"ifelse":{for(let W=0;W{if(typeof H=="string"&&(H.charAt(H.length-1)==":"||!H.includes(":"))){let U={header:_(H),spells:[]};return F.push(U),F}let he=F[F.length-1],ue;if(typeof H=="string")ue={spells:ut.linkifySpells(H,C.get("context"))};else try{ue={level:Object.keys(H).shift(),spells:ut.linkifySpells(ye(Object.values(H).shift()),C.get("context"))}}catch{return F}if(he)he.spells.push(ue);else{let U={header:`${b.name} knows the following spells:`,spells:[ue]};F.push(U)}return F},[]);for(let F=0;F0){new ta({target:Y.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(!f.length)for(let O of r){let j=w(O);j?.length&&f.push(...j)}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=[],B,L=()=>{let O=document.body.createDiv({cls:"statblock-detached markdown-preview-view",attr:{style:`width: ${k}`}});new to({target:O.createDiv({cls:["obsidian-statblock-plugin","statblock",...l]}),props:{heights:P,targets:f,columns:1,columnWidth:k,classes:l}}).$on("built",()=>{let Z=O.querySelector(".column");for(let ee of f)P.push(ee.scrollHeight);b.forceColumns?t(5,B=Z.scrollHeight/u):b.columns&&b.columns>0?t(5,B=Math.max(Z.scrollHeight/b.columns,Z.scrollHeight/d)):t(5,B=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,m=O.plugin)},n.$$.update=()=>{n.$$.dirty&16384&&(i=!isNaN(Number(b.columnHeight))&&b.columnHeight>0?b.columnHeight:1/0),n.$$.dirty&512&&o&&L()},[l,d,f,k,A,B,p,P,r,o,c,u,h,m,b]}var ao=class extends G{constructor(e){super(),K(this,e,Jp,Yp,V,{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]}},Mu=ao;function Xp(n){se(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( @@ -505,9 +505,9 @@ ${o.message}`),console.error(o)}})};return n.$$set=r=>{"block"in r&&t(1,i=r.bloc --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 Iu(n){let e,t=n[8],i,a,s,r,o=Pu(n),l=n[3]&&Ru(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"),re(e,"obsidian-statblock-plugin",!0),re(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&&V(t,t=c[8])?(le(),I(o,1,1,N),ce(),o=Pu(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)&&re(e,"obsidian-statblock-plugin",!0),(!r||d[0]&32)&&re(e,"statblock",!0),c[3]?l?l.p(c,d):(l=Ru(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 Qp(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 Zp(n){let e,t,i=n[7],a,s,r;e=new Nr({});let o=Ou(n);return s=new Nr({}),{c(){ie(e.$$.fragment),t=R(),o.c(),a=R(),ie(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&&V(i,i=l[7])?(le(),I(o,1,1,N),ce(),o=Ou(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 Ou(n){let e,t;return e=new Mu({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(){ie(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 Pu(n){let e,t,i,a,s=[Zp,Qp],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):(le(),I(r[d],1,1,()=>{r[d]=null}),ce(),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 Ru(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=[J(t=n[11].call(null,e)),q(e,"click",n[12])],i=!0)},p:N,d(s){s&&x(e),i=!1,oe(a)}}}function eb(n){let e,t,i=n[6]&&Iu(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=Iu(a),i.c(),E(i,1),i.m(e,null)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},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 tb(n,e,t){let i,a,s,r,o,l,c=Me(),{monster:d}=e,{context:u}=e,{plugin:h}=e,{statblock:f}=e,{renderer:m}=e,{layout:p}=e,{canSave:b=!0}=e,{icons:_=!0}=e,S=Le(d);Se(n,S,H=>t(8,l=H));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;Mt("plugin",h),Mt("tryToRenderLinks",h.settings.tryToRenderLinks),Mt("context",u),Mt("monster",S),Mt("dice",k),Mt("render",A),Mt("renderer",m),Mt("layout",p);let P=Le(!1);Mt("reset",P);let B,L=()=>{if(d.forceColumns??p.forceColumns){t(7,i=C),j.disconnect();return}let H=B.clientWidth;t(7,i=Math.min(Math.max(Math.floor(H/w),1),C))},O=(0,$t.debounce)(()=>{L(),a||t(6,a=!0)},100,!1),j=new ResizeObserver(O);pn(()=>{O(),j.observe(B)}),bn(()=>{j.disconnect()});let Z=H=>{new $t.ExtraButtonComponent(H).setIcon("vertical-three-dots")},ee=new $t.Menu;ee.addItem(H=>H.setIcon("save").setTitle("Save to Bestiary").setDisabled(!b).onClick(()=>c("save"))),ee.addItem(H=>{H.setTitle("Copy YAML").setIcon("code").onClick(async()=>{try{await navigator.clipboard.writeText((0,$t.stringifyYaml)(d)),new $t.Notice("Creature YAML copied to clipboard")}catch(he){new $t.Notice(`There was an issue copying the yaml: + );--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 Iu(n){let e,t=n[8],i,a,s,r,o=Pu(n),l=n[3]&&Ru(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"),re(e,"obsidian-statblock-plugin",!0),re(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&&V(t,t=c[8])?(le(),I(o,1,1,N),ce(),o=Pu(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)&&re(e,"obsidian-statblock-plugin",!0),(!r||d[0]&32)&&re(e,"statblock",!0),c[3]?l?l.p(c,d):(l=Ru(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 Qp(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 Zp(n){let e,t,i=n[7],a,s,r;e=new Br({});let o=Ou(n);return s=new Br({}),{c(){ie(e.$$.fragment),t=R(),o.c(),a=R(),ie(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&&V(i,i=l[7])?(le(),I(o,1,1,N),ce(),o=Ou(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 Ou(n){let e,t;return e=new Mu({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(){ie(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 Pu(n){let e,t,i,a,s=[Zp,Qp],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):(le(),I(r[d],1,1,()=>{r[d]=null}),ce(),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 Ru(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=[J(t=n[11].call(null,e)),q(e,"click",n[12])],i=!0)},p:N,d(s){s&&x(e),i=!1,oe(a)}}}function eb(n){let e,t,i=n[6]&&Iu(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=Iu(a),i.c(),E(i,1),i.m(e,null)):i&&(le(),I(i,1,1,()=>{i=null}),ce())},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 tb(n,e,t){let i,a,s,r,o,l,c=Me(),{monster:d}=e,{context:u}=e,{plugin:h}=e,{statblock:f}=e,{renderer:m}=e,{layout:p}=e,{canSave:b=!0}=e,{icons:_=!0}=e,S=Le(d);Se(n,S,H=>t(8,l=H));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;Mt("plugin",h),Mt("tryToRenderLinks",h.settings.tryToRenderLinks),Mt("context",u),Mt("monster",S),Mt("dice",k),Mt("render",A),Mt("renderer",m),Mt("layout",p);let P=Le(!1);Mt("reset",P);let B,L=()=>{if(d.forceColumns??p.forceColumns){t(7,i=C),j.disconnect();return}let H=B.clientWidth;t(7,i=Math.min(Math.max(Math.floor(H/w),1),C))},O=(0,$t.debounce)(()=>{L(),a||t(6,a=!0)},100,!1),j=new ResizeObserver(O);pn(()=>{O(),j.observe(B)}),bn(()=>{j.disconnect()});let Z=H=>{new $t.ExtraButtonComponent(H).setIcon("vertical-three-dots")},ee=new $t.Menu;ee.addItem(H=>H.setIcon("save").setTitle("Save to Bestiary").setDisabled(!b).onClick(()=>c("save"))),ee.addItem(H=>{H.setTitle("Copy YAML").setIcon("code").onClick(async()=>{try{await navigator.clipboard.writeText((0,$t.stringifyYaml)(d)),new $t.Notice("Creature YAML copied to clipboard")}catch(he){new $t.Notice(`There was an issue copying the yaml: -${he.message}`)}})}),ee.addItem(H=>H.setIcon("image-down").setTitle("Export as PNG").onClick(()=>c("export"))),k&&ee.addItem(H=>H.setIcon("reset").setTitle("Reset Dice").onClick(()=>{P.set(!0),P.set(!1)}));let ae=H=>{ee.showAtMouseEvent(H)},$=H=>{let he=[];for(let ue of H){if(ue.type=="layout"){let U=h.manager.getAllLayouts().find(z=>z.id==ue.layout);U&&he.push(ki(U.name))}"nested"in ue&&he.push(...$(ue.nested))}return he};function W(H){Ge.call(this,n,H)}function Y(H){Ge.call(this,n,H)}function F(H){Re[H?"unshift":"push"](()=>{B=H,t(4,B)})}return n.$$set=H=>{"monster"in H&&t(13,d=H.monster),"context"in H&&t(14,u=H.context),"plugin"in H&&t(0,h=H.plugin),"statblock"in H&&t(1,f=H.statblock),"renderer"in H&&t(15,m=H.renderer),"layout"in H&&t(2,p=H.layout),"canSave"in H&&t(16,b=H.canSave),"icons"in H&&t(3,_=H.icons)},n.$$.update=()=>{n.$$.dirty[0]&8192&&Ae(S,l=d,l),n.$$.dirty[0]&8192&&t(18,s=ki(d.name??"","no-name")),n.$$.dirty[0]&4&&t(17,r=ki(p.name,"no-layout")),n.$$.dirty[0]&393218&&t(5,o=[s,r,...$(f)].filter(H=>H?.length))},t(7,i=C),t(6,a=!1),[h,f,p,_,B,o,a,i,l,S,C,Z,ae,d,u,m,b,r,s,W,Y,F]}var ao=class extends G{constructor(e){super(),K(this,e,tb,eb,V,{monster:13,context:14,plugin:0,statblock:1,renderer:15,layout:2,canSave:16,icons:3},Xp,[-1,-1])}},Nu=ao;var wt=require("obsidian");function ia(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 so(){return ia('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 ro=class extends wt.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 wt.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 wt.TFile&&this.watchPaths.has(i.path)&&this.delete(i.path)}));let t=wt.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 wt.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 wt.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,wt.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 wt.TFolder)for(let a of t.children)i.push(a.path);return t instanceof wt.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 ro;var nb=[{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. +${he.message}`)}})}),ee.addItem(H=>H.setIcon("image-down").setTitle("Export as PNG").onClick(()=>c("export"))),k&&ee.addItem(H=>H.setIcon("reset").setTitle("Reset Dice").onClick(()=>{P.set(!0),P.set(!1)}));let ae=H=>{ee.showAtMouseEvent(H)},$=H=>{let he=[];for(let ue of H){if(ue.type=="layout"){let U=h.manager.getAllLayouts().find(z=>z.id==ue.layout);U&&he.push(ki(U.name))}"nested"in ue&&he.push(...$(ue.nested))}return he};function W(H){Ge.call(this,n,H)}function Y(H){Ge.call(this,n,H)}function F(H){Re[H?"unshift":"push"](()=>{B=H,t(4,B)})}return n.$$set=H=>{"monster"in H&&t(13,d=H.monster),"context"in H&&t(14,u=H.context),"plugin"in H&&t(0,h=H.plugin),"statblock"in H&&t(1,f=H.statblock),"renderer"in H&&t(15,m=H.renderer),"layout"in H&&t(2,p=H.layout),"canSave"in H&&t(16,b=H.canSave),"icons"in H&&t(3,_=H.icons)},n.$$.update=()=>{n.$$.dirty[0]&8192&&Ae(S,l=d,l),n.$$.dirty[0]&8192&&t(18,s=ki(d.name??"","no-name")),n.$$.dirty[0]&4&&t(17,r=ki(p.name,"no-layout")),n.$$.dirty[0]&393218&&t(5,o=[s,r,...$(f)].filter(H=>H?.length))},t(7,i=C),t(6,a=!1),[h,f,p,_,B,o,a,i,l,S,C,Z,ae,d,u,m,b,r,s,W,Y,F]}var so=class extends G{constructor(e){super(),K(this,e,tb,eb,V,{monster:13,context:14,plugin:0,statblock:1,renderer:15,layout:2,canSave:16,icons:3},Xp,[-1,-1])}},Nu=so;var wt=require("obsidian");function ia(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 ro(){return ia('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 oo=class extends wt.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 wt.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 wt.TFile&&this.watchPaths.has(i.path)&&this.delete(i.path)}));let t=wt.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 wt.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 wt.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,wt.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 wt.TFolder)for(let a of t.children)i.push(a.path);return t instanceof wt.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 oo;var nb=[{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. @@ -742,26 +742,26 @@ Slowing Breath. The dragon exhales gas in a 30-foot cone. Each creature in that 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}]}],aa=new Map(nb.map(n=>[n.name,n]));var Ne,zt,On,sa,un,Zn,ra,$e,Qn,tt,lo,co,Di,oo=class{constructor(){Be(this,$e);Be(this,Ne,new Map);Be(this,zt,new Map);Be(this,On,new Map);Be(this,sa,!1);Be(this,un,new Map);Be(this,Zn,new Map);Be(this,ra,new Map);Be(this,tt)}getSortedBy(e){return X(this,ra).get(e)??[]}onSortedBy(e,t){let i=X(this,tt).on(`fantasy-statblocks:bestiary:sorted:${e}`,a=>t(a));return()=>{X(this,tt).offref(i)}}registerSorter(e,t){X(this,Zn).has(e)||X(this,Zn).set(e,t),Oe(this,$e,Qn).call(this,e)}getIndices(){return X(this,un)}getIndex(e){return X(this,un).get(e)??new Map}registerIndex(e){X(this,un).has(e)||X(this,un).set(e,new Map)}onIndexUpdated(e,t){if(!X(this,un).has(e))return()=>{};let i=X(this,tt).on(`fantasy-statblocks:bestiary:indexed:${e}`,()=>t());return()=>{X(this,tt).offref(i)}}initialize(e){this.registerIndex("source"),this.registerSorter("name",(t,i)=>t.name.localeCompare(i.name)),an(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?an(this,Ne,new Map([...aa,...X(this,Ne)])):an(this,Ne,new Map([...X(this,zt),...X(this,On)]))})),this.enableSRD=!e.settings.disableSRD,this.enableSRD&&an(this,Ne,new Map(aa));for(let[,t]of e.settings.monsters)this.addLocalCreature(t)}hasLocal(e){return X(this,zt).has(e)}getLocal(e){return X(this,zt).get(e)}isLocal(e){return X(this,zt).has(e)&&X(this,Ne).get(e)===X(this,zt).get(e)}addLocalCreature(e){e.name&&(X(this,zt).set(e.name,e),X(this,Ne).set(e.name,e),Oe(this,$e,lo).call(this,e),Oe(this,$e,Di).call(this),Oe(this,$e,Qn).call(this))}removeLocalCreature(e){X(this,Ne).has(e)&&X(this,Ne).get(e)===X(this,zt).get(e)&&X(this,Ne).delete(e),Oe(this,$e,co).call(this,X(this,zt).get(e)),X(this,zt).delete(e),X(this,On).has(e)?X(this,Ne).set(e,X(this,On).get(e)):this.enableSRD&&aa.has(e)&&X(this,Ne).set(e,aa.get(e)),Oe(this,$e,Di).call(this),Oe(this,$e,Qn).call(this)}addEphemeralCreature(e){e.name&&(X(this,On).set(e.name,e),X(this,Ne).set(e.name,e),X(this,tt).trigger("fantasy-statblocks:bestiary:creature-added",e),Oe(this,$e,lo).call(this,e),Oe(this,$e,Qn).call(this),Oe(this,$e,Di).call(this))}removeEphemeralCreature(e){Oe(this,$e,co).call(this,X(this,Ne).get(e)),X(this,Ne).delete(e),X(this,On).delete(e),Oe(this,$e,Di).call(this),Oe(this,$e,Qn).call(this)}removeCreatures(...e){for(let t of e)this.isLocal(t)?this.removeLocalCreature(t):this.removeEphemeralCreature(t)}isResolved(){return X(this,sa)}setResolved(e){an(this,sa,e),e&&(X(this,tt).trigger("fantasy-statblocks:bestiary:resolved"),Oe(this,$e,Di).call(this),Oe(this,$e,Qn).call(this))}onResolved(e){let t;return this.isResolved()?e():t=X(this,tt).on("fantasy-statblocks:bestiary:resolved",()=>e()),()=>{t&&X(this,tt).offref(t)}}onUpdated(e){let t;return this.isResolved()?e():t=X(this,tt).on("fantasy-statblocks:bestiary:updated",()=>e()),()=>{t&&X(this,tt).offref(t)}}size(){return X(this,Ne).size}getBestiary(){return X(this,Ne)}getBestiaryCreatures(){return Array.from(X(this,Ne).values())}getBestiaryNames(){return Array.from(X(this,Ne).keys()).sort()}hasCreature(e){return X(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=X(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=X(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=X(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=X(this,Ne).get(e);return Object.assign({},...this.getExtensions(t,new Set(t.name)),t)}get(e){return X(this,Ne).get(e)}};Ne=new WeakMap,zt=new WeakMap,On=new WeakMap,sa=new WeakMap,un=new WeakMap,Zn=new WeakMap,ra=new WeakMap,$e=new WeakSet,Qn=function(...e){this.isResolved()&&setTimeout(()=>{for(let t of e&&e.length?e:[...X(this,Zn).keys()])X(this,ra).set(t,this.getBestiaryCreatures().sort((i,a)=>X(this,Zn).get(t)(i,a))),X(this,tt).trigger(`fantasy-statblocks:bestiary:sorted:${t}`,this.getSortedBy(t))},0)},tt=new WeakMap,lo=function(e){setTimeout(()=>{for(let[t,i]of X(this,un))if(t in e){let a=[];if(Array.isArray(e[t]))for(let s of e[t])a.push(ye(s));else a.push(ye(e[t]));for(let s of a)i.has(s)?i.get(s).add(e.name):i.set(s,new Set([e.name]));X(this,tt).trigger(`fantasy-statblocks:bestiary:indexed:${t}`)}},0)},co=function(e){setTimeout(()=>{for(let[t,i]of X(this,un))if(t in e){let a=ye(e[t]);i.has(a)&&i.get(a).delete(e.name),X(this,tt).trigger(`fantasy-statblocks:bestiary:indexed:${t}`)}},0)},Di=function(){this.isResolved()&&X(this,tt).trigger("fantasy-statblocks:bestiary:updated")};var ve=new oo;var Yt=class extends Bu.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 Ct.TFile){let r=(0,Ct.getFrontMatterInfo)(await this.plugin.app.vault.cachedRead(s));r.exists&&Object.assign(t,Ze((0,Ct.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 uo(`${s}-`,l))r.delete(c.name);for(let c of uo(s,l))r.set(c.name,c);for(let c of uo(`${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]:_r(t[s],o)});break}default:if(`${s}+`in t&&s in t){let r=_r(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 Nu({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 fo(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,Ct.parseYaml)(ut.transformYamlSource((0,Ct.stringifyYaml)(t).replace(/\\#/g,"#")))}};async function fo(n,e,t={cta:"Yes",secondary:"No"}){return new Promise((i,a)=>{let s=new ho(n,e,t);s.onClose=()=>{i(s.confirmed)},s.open()})}var ho=class extends Ct.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 Ct.ButtonComponent(i).setButtonText(this.buttons.cta).setCta().onClick(()=>{this.confirmed=!0,this.close()}),new Ct.ButtonComponent(i).setButtonText(this.buttons.secondary).onClick(()=>{this.close()})})}onOpen(){this.display()}};function uo(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 nn=require("obsidian");var oa=[["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 ls(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=f=>Math.sqrt(f)*120,easing:h=ls}=i;return{delay:d,duration:Pe(u)?u(Math.sqrt(l*l+c*c)):u,easing:h,css:(f,m)=>{let p=m*l,b=m*c,_=f+m*e.width/t.width,S=f+m*e.height/t.height;return`transform: ${s} translate(${p}px, ${b}px) scale(${_}, ${S});`}}}function Lu(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 ds(n){for(var e=1;e=0)&&(t[a]=n[a]);return t}function ab(n,e){if(n==null)return{};var t=ib(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 sb(n,e){return ob(n)||cb(n,e)||So(n,e)||db()}function jt(n){return rb(n)||lb(n)||So(n)||ub()}function rb(n){if(Array.isArray(n))return go(n)}function ob(n){if(Array.isArray(n))return n}function lb(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function cb(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 So(n,e){if(n){if(typeof n=="string")return go(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 go(n,e)}}function go(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=new Array(e);t[n.name,n]));var Ne,zt,On,sa,un,Zn,ra,$e,Qn,tt,co,uo,Di,lo=class{constructor(){Be(this,$e);Be(this,Ne,new Map);Be(this,zt,new Map);Be(this,On,new Map);Be(this,sa,!1);Be(this,un,new Map);Be(this,Zn,new Map);Be(this,ra,new Map);Be(this,tt)}getSortedBy(e){return X(this,ra).get(e)??[]}onSortedBy(e,t){let i=X(this,tt).on(`fantasy-statblocks:bestiary:sorted:${e}`,a=>t(a));return()=>{X(this,tt).offref(i)}}registerSorter(e,t){X(this,Zn).has(e)||X(this,Zn).set(e,t),Oe(this,$e,Qn).call(this,e)}getIndices(){return X(this,un)}getIndex(e){return X(this,un).get(e)??new Map}registerIndex(e){X(this,un).has(e)||X(this,un).set(e,new Map)}onIndexUpdated(e,t){if(!X(this,un).has(e))return()=>{};let i=X(this,tt).on(`fantasy-statblocks:bestiary:indexed:${e}`,()=>t());return()=>{X(this,tt).offref(i)}}initialize(e){this.registerIndex("source"),this.registerSorter("name",(t,i)=>t.name.localeCompare(i.name)),an(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?an(this,Ne,new Map([...aa,...X(this,Ne)])):an(this,Ne,new Map([...X(this,zt),...X(this,On)]))})),this.enableSRD=!e.settings.disableSRD,this.enableSRD&&an(this,Ne,new Map(aa));for(let[,t]of e.settings.monsters)this.addLocalCreature(t)}hasLocal(e){return X(this,zt).has(e)}getLocal(e){return X(this,zt).get(e)}isLocal(e){return X(this,zt).has(e)&&X(this,Ne).get(e)===X(this,zt).get(e)}addLocalCreature(e){e.name&&(X(this,zt).set(e.name,e),X(this,Ne).set(e.name,e),Oe(this,$e,co).call(this,e),Oe(this,$e,Di).call(this),Oe(this,$e,Qn).call(this))}removeLocalCreature(e){X(this,Ne).has(e)&&X(this,Ne).get(e)===X(this,zt).get(e)&&X(this,Ne).delete(e),Oe(this,$e,uo).call(this,X(this,zt).get(e)),X(this,zt).delete(e),X(this,On).has(e)?X(this,Ne).set(e,X(this,On).get(e)):this.enableSRD&&aa.has(e)&&X(this,Ne).set(e,aa.get(e)),Oe(this,$e,Di).call(this),Oe(this,$e,Qn).call(this)}addEphemeralCreature(e){e.name&&(X(this,On).set(e.name,e),X(this,Ne).set(e.name,e),X(this,tt).trigger("fantasy-statblocks:bestiary:creature-added",e),Oe(this,$e,co).call(this,e),Oe(this,$e,Qn).call(this),Oe(this,$e,Di).call(this))}removeEphemeralCreature(e){Oe(this,$e,uo).call(this,X(this,Ne).get(e)),X(this,Ne).delete(e),X(this,On).delete(e),Oe(this,$e,Di).call(this),Oe(this,$e,Qn).call(this)}removeCreatures(...e){for(let t of e)this.isLocal(t)?this.removeLocalCreature(t):this.removeEphemeralCreature(t)}isResolved(){return X(this,sa)}setResolved(e){an(this,sa,e),e&&(X(this,tt).trigger("fantasy-statblocks:bestiary:resolved"),Oe(this,$e,Di).call(this),Oe(this,$e,Qn).call(this))}onResolved(e){let t;return this.isResolved()?e():t=X(this,tt).on("fantasy-statblocks:bestiary:resolved",()=>e()),()=>{t&&X(this,tt).offref(t)}}onUpdated(e){let t;return this.isResolved()?e():t=X(this,tt).on("fantasy-statblocks:bestiary:updated",()=>e()),()=>{t&&X(this,tt).offref(t)}}size(){return X(this,Ne).size}getBestiary(){return X(this,Ne)}getBestiaryCreatures(){return Array.from(X(this,Ne).values())}getBestiaryNames(){return Array.from(X(this,Ne).keys()).sort()}hasCreature(e){return X(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=X(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=X(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=X(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=X(this,Ne).get(e);return Object.assign({},...this.getExtensions(t,new Set(t.name)),t)}get(e){return X(this,Ne).get(e)}};Ne=new WeakMap,zt=new WeakMap,On=new WeakMap,sa=new WeakMap,un=new WeakMap,Zn=new WeakMap,ra=new WeakMap,$e=new WeakSet,Qn=function(...e){this.isResolved()&&setTimeout(()=>{for(let t of e&&e.length?e:[...X(this,Zn).keys()])X(this,ra).set(t,this.getBestiaryCreatures().sort((i,a)=>X(this,Zn).get(t)(i,a))),X(this,tt).trigger(`fantasy-statblocks:bestiary:sorted:${t}`,this.getSortedBy(t))},0)},tt=new WeakMap,co=function(e){setTimeout(()=>{for(let[t,i]of X(this,un))if(t in e){let a=[];if(Array.isArray(e[t]))for(let s of e[t])a.push(ye(s));else a.push(ye(e[t]));for(let s of a)i.has(s)?i.get(s).add(e.name):i.set(s,new Set([e.name]));X(this,tt).trigger(`fantasy-statblocks:bestiary:indexed:${t}`)}},0)},uo=function(e){setTimeout(()=>{for(let[t,i]of X(this,un))if(t in e){let a=ye(e[t]);i.has(a)&&i.get(a).delete(e.name),X(this,tt).trigger(`fantasy-statblocks:bestiary:indexed:${t}`)}},0)},Di=function(){this.isResolved()&&X(this,tt).trigger("fantasy-statblocks:bestiary:updated")};var ve=new lo;var Yt=class extends Bu.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 Ct.TFile){let r=(0,Ct.getFrontMatterInfo)(await this.plugin.app.vault.cachedRead(s));r.exists&&Object.assign(t,Ze((0,Ct.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 ls(s,l))r.set(c.name,c);for(let c of ls(`${s}-`,l))r.delete(c.name);for(let c of ls(`${s}~`,l))r.has(c.name)&&r.set(c.name,c);for(let c of ls(`${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]:Sr(t[s],o)});break}default:if(`${s}+`in t&&s in t){let r=Sr(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 Nu({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 fo(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,Ct.parseYaml)(ut.transformYamlSource((0,Ct.stringifyYaml)(t).replace(/\\#/g,"#")))}};async function fo(n,e,t={cta:"Yes",secondary:"No"}){return new Promise((i,a)=>{let s=new ho(n,e,t);s.onClose=()=>{i(s.confirmed)},s.open()})}var ho=class extends Ct.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 Ct.ButtonComponent(i).setButtonText(this.buttons.cta).setCta().onClick(()=>{this.confirmed=!0,this.close()}),new Ct.ButtonComponent(i).setButtonText(this.buttons.secondary).onClick(()=>{this.close()})})}onOpen(){this.display()}};function ls(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 nn=require("obsidian");var oa=[["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 cs(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=f=>Math.sqrt(f)*120,easing:h=cs}=i;return{delay:d,duration:Pe(u)?u(Math.sqrt(l*l+c*c)):u,easing:h,css:(f,m)=>{let p=m*l,b=m*c,_=f+m*e.width/t.width,S=f+m*e.height/t.height;return`transform: ${s} translate(${p}px, ${b}px) scale(${_}, ${S});`}}}function Lu(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 hs(n){for(var e=1;e=0)&&(t[a]=n[a]);return t}function ab(n,e){if(n==null)return{};var t=ib(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 sb(n,e){return ob(n)||cb(n,e)||So(n,e)||db()}function jt(n){return rb(n)||lb(n)||So(n)||ub()}function rb(n){if(Array.isArray(n))return go(n)}function ob(n){if(Array.isArray(n))return n}function lb(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function cb(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 So(n,e){if(n){if(typeof n=="string")return go(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 go(n,e)}}function go(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 hb="finalize",fb="consider";function Oi(n,e,t){n.dispatchEvent(new CustomEvent(hb,{detail:{items:e,info:t}}))}function Fn(n,e,t){n.dispatchEvent(new CustomEvent(fb,{detail:{items:e,info:t}}))}var vs="draggedEntered",ga="draggedLeft",ks="draggedOverIndex",Co="draggedLeftDocument",hs={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function mb(n,e,t){n.dispatchEvent(new CustomEvent(vs,{detail:{indexObj:e,draggedEl:t}}))}function gb(n,e,t){n.dispatchEvent(new CustomEvent(ga,{detail:{draggedEl:e,type:hs.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function pb(n,e){n.dispatchEvent(new CustomEvent(ga,{detail:{draggedEl:e,type:hs.OUTSIDE_OF_ANY}}))}function bb(n,e,t){n.dispatchEvent(new CustomEvent(ks,{detail:{indexObj:e,draggedEl:t}}))}function yb(n){window.dispatchEvent(new CustomEvent(Co,{detail:{draggedEl:n}}))}var Ye={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:vs,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:ks,DRAGGED_LEFT:ga,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},je={POINTER:"pointer",KEYBOARD:"keyboard"},ws="isDndShadowItem",xo="data-is-dnd-shadow-item-internal",vb="data-is-dnd-shadow-item-hint",ii="id:dnd-shadow-placeholder-0000",kb="dnd-action-dragged-el",nt="id",po=0;function Ju(){po++}function Xu(){if(po===0)throw new Error("Bug! trying to decrement when there are no dropzones");po--}var Ao=typeof window>"u",xe=function(){};function bo(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,f=r?t.height/r:n.offsetHeight;return{x:d,y:u,width:h,height:f,top:u,right:d+h,bottom:u+f,left:d}}else return t}function Qu(n){var e=bo(n);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function Zu(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 ed(n){return{x:(n.left+n.right)/2,y:(n.top+n.bottom)/2}}function wb(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function _s(n,e){return n.y<=e.bottom&&n.y>=e.top&&n.x>=e.left&&n.x<=e.right}function da(n){return ed(Zu(n))}function Fu(n,e){var t=da(n),i=Qu(e);return _s(t,i)}function _b(n,e){var t=da(n),i=da(e);return wb(t,i)}function Sb(n){var e=Zu(n);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}var Ei;function To(){xe(function(){return"resetting indexes cache"}),Ei=new Map}To();function Cb(n){var e=Array.from(n.children).findIndex(function(t){return t.getAttribute(xo)});if(e>=0)return Ei.has(n)||Ei.set(n,new Map),Ei.get(n).set(e,Qu(n.children[e])),e}function xb(n,e){if(!Fu(n,e))return null;var t=e.children;if(t.length===0)return{index:0,isProximityBased:!0};for(var i=Cb(e),a=0;a1&&arguments[1]!==void 0?arguments[1]:0;return n.parentElement?td(n.parentElement,e+1):e-1}function Ab(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 Tb(n,e){if(n.length!==e.length)return!1;for(var t=0;t2&&arguments[2]!==void 0?arguments[2]:Db,i=arguments.length>3?arguments[3]:void 0,a,s,r=!1,o,l=Array.from(e).sort(function(d,u){return fs(u)-fs(d)});function c(){var d=da(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=Nb(n),i=Array.from(t).sort(function(l,c){return fs(c)-fs(l)}),a=Ib(),s=a.scrollIfNeeded,r=a.resetScrolling;function o(){var l=e();if(!l||!i)return!1;for(var c=i.filter(function(h){return _s(l,h.getBoundingClientRect())||h===document.scrollingElement}),d=0;d0?o:function(){return!1},destroy:function(){return r()}}}function Rb(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 Nb(n){var e=new Set,t=ma(n),i;try{for(t.s();!(i=t.n()).done;){var a=i.value;Rb(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 Bb(n){var e=n.cloneNode(!0),t=[],i=n.tagName==="SELECT",a=i?[n]:jt(n.querySelectorAll("select")),s=ma(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]:jt(e.querySelectorAll("select")),c=0;c0)for(var p=f?[e]:jt(e.querySelectorAll("canvas")),b=0;b0&&_.height>0&&S.getContext("2d").drawImage(_,0,0)}return e}var ha=Object.freeze({USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT:"USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT"}),Lb=Ii({},ha.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT,!1);function nd(n){if(!ha[n])throw new Error("Can't get non existing feature flag ".concat(n,"! Supported flags: ").concat(Object.keys(ha)));return Lb[n]}var Fb=.2;function ei(n){return"".concat(n," ").concat(Fb,"s ease")}function Wb(n,e){var t=n.getBoundingClientRect(),i=Bb(n);id(n,i),i.id=kb,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=ed(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(ei("top"),", ").concat(ei("left"),", ").concat(ei("background-color"),", ").concat(ei("opacity"),", ").concat(ei("color")," "),window.setTimeout(function(){return i.style.transition+=", ".concat(ei("width"),", ").concat(ei("height"))},0),i.style.zIndex="9999",i.style.cursor="grabbing",i}function Hb(n){n.style.cursor="grab"}function zb(n,e,t,i){id(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};nd(ha.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 id(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"||nd(ha.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 qb(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 ad(n){n.style.display="none",n.style.position="fixed",n.style.zIndex="-5"}function jb(n){n.style.visibility="hidden",n.setAttribute(xo,"true")}function Vb(n){n.style.visibility="",n.removeAttribute(xo)}function us(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 ms(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 Ub(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 Gb="--any--",Kb=100,$b=20,Hu=3,zu={outline:"rgba(255, 255, 102, 0.7) solid 2px"},qu="data-is-dnd-original-dragged-item",Jt,ft,xt,Ss,qe,Cs,Ln,ht,Nn,Ot,Rn=!1,Do=!1,Eo,pa=!1,ca=[],gs,Zt=new Map,Xe=new Map,mo=new WeakMap;function Yb(n,e){xe(function(){return"registering drop-zone if absent"}),Zt.has(e)||Zt.set(e,new Set),Zt.get(e).has(n)||(Zt.get(e).add(n),Ju())}function ju(n,e){Zt.get(e).delete(n),Xu(),Zt.get(e).size===0&&Zt.delete(e)}function Jb(){xe(function(){return"watching dragged element"});var n=Zt.get(Ss),e=ma(n),t;try{for(e.s();!(t=e.n()).done;){var i=t.value;i.addEventListener(vs,sd),i.addEventListener(ga,rd),i.addEventListener(ks,od)}}catch(r){e.e(r)}finally{e.f()}window.addEventListener(Co,Pi);var a=Math.max.apply(Math,jt(Array.from(n.keys()).map(function(r){return Xe.get(r).dropAnimationDurationMs}))),s=a===0?$b:Math.max(a,Kb);gs=Pb(n,function(){return Ot}),Eb(ft,n,s*1.07,gs)}function Xb(){xe(function(){return"unwatching dragged element"});var n=Zt.get(Ss),e=ma(n),t;try{for(e.s();!(t=e.n()).done;){var i=t.value;i.removeEventListener(vs,sd),i.removeEventListener(ga,rd),i.removeEventListener(ks,od)}}catch(a){e.e(a)}finally{e.f()}window.removeEventListener(Co,Pi),gs.destroy(),gs=void 0,Mb()}function xs(n){return n.findIndex(function(e){return!!e[ws]})}function Qb(n){var e;return ds(ds({},n),{},(e={},Ii(e,ws,!0),Ii(e,nt,ii),e))}function sd(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!==qe){xe(function(){return"ignoring dragged entered because drop is currently disabled"});return}if(pa=!1,t=t.filter(function(d){return d[nt]!==Ln[nt]}),xe(function(){return"dragged entered items ".concat(dn(t))}),qe!==n.currentTarget){var a=Xe.get(qe).items,s=a.filter(function(d){return!d[ws]});Fn(qe,s,{trigger:Ye.DRAGGED_ENTERED_ANOTHER,id:xt[nt],source:je.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,Ln),Fn(n.currentTarget,t,{trigger:Ye.DRAGGED_ENTERED,id:xt[nt],source:je.POINTER})}function rd(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!==qe&&n.currentTarget!==ht){xe(function(){return"drop is currently disabled"});return}var a=jt(t),s=xs(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===hs.OUTSIDE_OF_ANY||l===hs.LEFT_FOR_ANOTHER&&c!==qe&&Xe.get(c).dropFromOthersDisabled){xe(function(){return"dragged left all, putting shadow element back in the origin dz"}),pa=!0,ht=qe;var d=r===qe?a:jt(Xe.get(qe).items);d.splice(Cs,0,Ln),Fn(qe,d,{trigger:Ye.DRAGGED_LEFT_ALL,id:xt[nt],source:je.POINTER})}Fn(n.currentTarget,a,{trigger:Ye.DRAGGED_LEFT,id:xt[nt],source:je.POINTER})}}function od(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!==qe){xe(function(){return"drop is currently disabled"});return}var a=jt(t);pa=!1;var s=n.detail.indexObj.index,r=xs(a);r!==-1&&a.splice(r,1),a.splice(s,0,Ln),Fn(n.currentTarget,a,{trigger:Ye.DRAGGED_OVER_INDEX,id:xt[nt],source:je.POINTER})}function ps(n){n.preventDefault();var e=n.touches?n.touches[0]:n;Ot={x:e.clientX,y:e.clientY},ft.style.transform="translate3d(".concat(Ot.x-Nn.x,"px, ").concat(Ot.y-Nn.y,"px, 0)")}function Pi(){xe(function(){return"dropped"}),Do=!0,window.removeEventListener("mousemove",ps),window.removeEventListener("touchmove",ps),window.removeEventListener("mouseup",Pi),window.removeEventListener("touchend",Pi),Xb(),Hb(ft),ht||(xe(function(){return"element was dropped right after it left origin but before entering somewhere else"}),ht=qe),xe(function(){return["dropped in dz",ht]});var n=Xe.get(ht),e=n.items,t=n.type;ms(Zt.get(t),function(s){return Xe.get(s).dropTargetStyle},function(s){return Xe.get(s).dropTargetClasses});var i=xs(e);i===-1&&ht===qe&&(i=Cs),e=e.map(function(s){return s[ws]?xt:s});function a(){Eo(),Oi(ht,e,{trigger:pa?Ye.DROPPED_OUTSIDE_OF_ANY:Ye.DROPPED_INTO_ZONE,id:xt[nt],source:je.POINTER}),ht!==qe&&Oi(qe,Xe.get(qe).items,{trigger:Ye.DROPPED_INTO_ANOTHER,id:xt[nt],source:je.POINTER}),i!==-1&&Vb(ht.children[i]),t1()}Zb(i,a)}function Zb(n,e){var t=n>-1?bo(ht.children[n]):bo(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 e1(n,e){ca.push({dz:n,destroy:e}),window.requestAnimationFrame(function(){ad(n),document.body.appendChild(n)})}function t1(){ft.remove(),Jt.remove(),ca.length&&(xe(function(){return["will destroy zones that were removed during drag",ca]}),ca.forEach(function(n){var e=n.dz,t=n.destroy;t(),e.remove()}),ca=[]),ft=void 0,Jt=void 0,xt=void 0,Ss=void 0,qe=void 0,Cs=void 0,Ln=void 0,ht=void 0,Nn=void 0,Ot=void 0,Rn=!1,Do=!1,Eo=void 0,pa=!1}function n1(n,e){var t=!1,i={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:zu,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(),Jt=void 0,Nn=void 0,Ot=void 0,h.type==="touchend"&&h.target.click()}function l(h){h.preventDefault();var f=h.touches?h.touches[0]:h;Ot={x:f.clientX,y:f.clientY},(Math.abs(Ot.x-Nn.x)>=Hu||Math.abs(Ot.y-Nn.y)>=Hu)&&(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 f=h.touches?h.touches[0]:h;Nn={x:f.clientX,y:f.clientY},Ot=ds({},Nn),Jt=h.currentTarget,s()}function d(){xe(function(){return["drag start config: ".concat(dn(i)),Jt]}),Rn=!0;var h=a.get(Jt);Cs=h,qe=Jt.parentElement;var f=qe.closest("dialog")||qe.getRootNode(),m=f.body||f,p=i.items,b=i.type,_=i.centreDraggedOnCursor,S=jt(p);xt=S[h],Ss=b,Ln=Qb(xt),ft=Wb(Jt,_&&Ot),Jt.setAttribute(qu,!0);function C(){ft.parentElement?window.requestAnimationFrame(C):(m.appendChild(ft),ft.focus(),Jb(),ad(Jt),m.appendChild(Jt),Ln[nt]=xt[nt])}window.requestAnimationFrame(C),us(Array.from(Zt.get(i.type)).filter(function(M){return M===qe||!Xe.get(M).dropFromOthersDisabled}),function(M){return Xe.get(M).dropTargetStyle},function(M){return Xe.get(M).dropTargetClasses}),S.splice(h,1,Ln),Eo=Ub(qe),Fn(qe,S,{trigger:Ye.DRAG_STARTED,id:xt[nt],source:je.POINTER}),window.addEventListener("mousemove",ps,{passive:!1}),window.addEventListener("touchmove",ps,{passive:!1,capture:!1}),window.addEventListener("mouseup",Pi,{passive:!1}),window.addEventListener("touchend",Pi,{passive:!1})}function u(h){var f=h.items,m=f===void 0?void 0:f,p=h.flipDurationMs,b=p===void 0?0:p,_=h.type,S=_===void 0?Gb:_,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,B=h.dropTargetStyle,L=B===void 0?zu:B,O=h.dropTargetClasses,j=O===void 0?[]:O,Z=h.transformDraggedElement,ee=Z===void 0?function(){}:Z,ae=h.centreDraggedOnCursor,$=ae===void 0?!1:ae;i.dropAnimationDurationMs=b,i.type&&S!==i.type&&ju(n,i.type),i.type=S,i.items=jt(m),i.dragDisabled=M,i.morphDisabled=k,i.transformDraggedElement=ee,i.centreDraggedOnCursor=$,t&&Rn&&!Do&&(!Ab(L,i.dropTargetStyle)||!Tb(j,i.dropTargetClasses))&&(ms([n],function(){return i.dropTargetStyle},function(){return j}),us([n],function(){return L},function(){return j})),i.dropTargetStyle=L,i.dropTargetClasses=jt(j);function W(he,ue){return Xe.get(he)?Xe.get(he)[ue]:i[ue]}t&&Rn&&i.dropFromOthersDisabled!==P&&(P?ms([n],function(he){return W(he,"dropTargetStyle")},function(he){return W(he,"dropTargetClasses")}):us([n],function(he){return W(he,"dropTargetStyle")},function(he){return W(he,"dropTargetClasses")})),i.dropFromOthersDisabled=P,Xe.set(n,i),Yb(n,S);for(var Y=Rn?xs(i.items):-1,F=0;F".concat(e,"

"),t.style.display="none",t.style.position="fixed",t.style.zIndex="-5",t}function Mi(n){if(!Ao){Je||ko(),Je.innerHTML="";var e=document.createTextNode(n);Je.appendChild(e),Je.style.display="none",Je.style.display="inline"}}var o1="--any--",Vu={outline:"rgba(255, 255, 102, 0.7) solid 2px"},qt=!1,wo,pt,ni="",ti,Xt,Bn="",bs=new WeakSet,Uu=new WeakMap,Gu=new WeakMap,_o=new Map,dt=new Map,Qt=new Map,ys;function l1(n,e){xe(function(){return"registering drop-zone if absent"}),Qt.size===0&&(xe(function(){return"adding global keydown and click handlers"}),ys=a1(),window.addEventListener("keydown",cd),window.addEventListener("click",ud)),Qt.has(e)||Qt.set(e,new Set),Qt.get(e).has(n)||(Qt.get(e).add(n),Ju())}function Ku(n,e){xe(function(){return"unregistering drop-zone"}),pt===n&&fa(),Qt.get(e).delete(n),Xu(),Qt.get(e).size===0&&Qt.delete(e),Qt.size===0&&(xe(function(){return"removing global keydown and click handlers"}),window.removeEventListener("keydown",cd),window.removeEventListener("click",ud),ys=void 0,s1())}function cd(n){if(qt)switch(n.key){case"Escape":{fa();break}}}function ud(){qt&&(bs.has(document.activeElement)||(xe(function(){return"clicked outside of any draggable"}),fa()))}function c1(n){if(xe(function(){return"zone focus"}),!!qt){var e=n.currentTarget;if(e!==pt){ni=e.getAttribute("aria-label")||"";var t=dt.get(pt),i=t.items,a=i.find(function(u){return u[nt]===Xt}),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(pt).autoAriaDisabled||Mi("Stopped dragging item ".concat(Bn)),bs.has(document.activeElement)&&document.activeElement.blur(),n&&Fn(pt,dt.get(pt).items,{trigger:Ye.DRAG_STOPPED,id:Xt,source:je.KEYBOARD}),ms(Qt.get(wo),function(e){return dt.get(e).dropTargetStyle},function(e){return dt.get(e).dropTargetClasses}),ti=null,Xt=null,Bn="",wo=null,pt=null,ni="",qt=!1,dd()}function u1(n,e){var t={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Vu,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)&&!bs.has(d.target))return;d.preventDefault(),d.stopPropagation(),qt?fa():s(d);break}case"ArrowDown":case"ArrowRight":{if(!qt)return;d.preventDefault(),d.stopPropagation();var u=dt.get(n),h=u.items,f=Array.from(n.children),m=f.indexOf(d.currentTarget);xe(function(){return["arrow down",m]}),m0&&(t.autoAriaDisabled||Mi("Moved item ".concat(Bn," to position ").concat(S," in the list ").concat(ni)),i(b,S,S-1),Oi(n,b,{trigger:Ye.DROPPED_INTO_ZONE,id:Xt,source:je.KEYBOARD}));break}}}function s(d){xe(function(){return"drag start"}),o(d.currentTarget),pt=n,wo=t.type,qt=!0;var u=Array.from(Qt.get(t.type)).filter(function(f){return f===pt||!dt.get(f).dropFromOthersDisabled});if(us(u,function(f){return dt.get(f).dropTargetStyle},function(f){return dt.get(f).dropTargetClasses}),!t.autoAriaDisabled){var h="Started dragging item ".concat(Bn,". Use the arrow keys to move it within its list ").concat(ni);u.length>1&&(h+=", or tab to another list in order to move the item into it"),Mi(h)}Fn(n,dt.get(n).items,{trigger:Ye.DRAG_STARTED,id:Xt,source:je.KEYBOARD}),dd()}function r(d){qt&&d.currentTarget!==ti&&(d.stopPropagation(),fa(!1),s(d))}function o(d){var u=dt.get(n),h=u.items,f=Array.from(n.children),m=f.indexOf(d);ti=d,ti.tabIndex=t.zoneItemTabIndex,Xt=h[m][nt],Bn=f[m].getAttribute("aria-label")||""}function l(d){var u=d.items,h=u===void 0?[]:u,f=d.type,m=f===void 0?o1:f,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?Vu:A,B=d.dropTargetClasses,L=B===void 0?[]:B,O=d.autoAriaDisabled,j=O===void 0?!1:O;t.items=jt(h),t.dragDisabled=b,t.dropFromOthersDisabled=k,t.zoneTabIndex=S,t.zoneItemTabIndex=M,t.dropTargetStyle=P,t.dropTargetClasses=L,t.autoAriaDisabled=j,t.type&&m!==t.type&&Ku(n,t.type),t.type=m,l1(n,m),j||(n.setAttribute("aria-disabled",b),n.setAttribute("role","list"),n.setAttribute("aria-describedby",b?ys.DND_ZONE_DRAG_DISABLED:ys.DND_ZONE_ACTIVE)),dt.set(n,t),qt?n.tabIndex=n===pt||ti.contains(n)||t.dropFromOthersDisabled||pt&&t.type!==dt.get(pt).type?-1:0:n.tabIndex=t.zoneTabIndex,n.addEventListener("focus",c1);for(var Z=function($){var W=n.children[$];bs.add(W),W.tabIndex=qt?-1:t.zoneItemTabIndex,j||W.setAttribute("role","listitem"),W.removeEventListener("keydown",Uu.get(W)),W.removeEventListener("click",Gu.get(W)),b||(W.addEventListener("keydown",a),Uu.set(W,a),W.addEventListener("click",r),Gu.set(W,r)),qt&&t.items[$][nt]===Xt&&(xe(function(){return["focusing on",{i:$,focusedItemId:Xt}]}),ti=W,ti.tabIndex=t.zoneItemTabIndex,W.focus())},ee=0;ee0&&console.warn("dndzone will ignore unknown options",m),!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(ua(d),", ").concat(dn(d)));if(o&&!Yu(o))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(ua(o),", ").concat(dn(o)));if(l&&!Yu(l))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(ua(l),", ").concat(dn(l)))}function Yu(n){return!isNaN(n)&&function(e){return(e|0)===e}(parseFloat(n))}function f1(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 WS=f1(!0);var As=require("obsidian");var hd=require("@codemirror/view"),Fe=(n,e)=>{(0,As.setIcon)(n,e)};function ba(n,e,t,i,a="js"){let s=new As.TextAreaComponent(n).setValue(e);return s.inputEl.addClasses(["statblock-textarea",...t]),Lt(s.inputEl,hd.EditorView.updateListener.of(r=>{r.docChanged&&i(r.state.doc.toString())}),a)}function m1(n){se(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 fd(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 md(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 g1(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 p1(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 gd(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=J(t=Fe.call(null,e,"heading-glyph")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function pd(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=J(t=Fe.call(null,e,"help-circle")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function bd(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=J(t=Fe.call(null,e,"code-glyph")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function yd(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=J(t=Fe.call(null,e,"dices")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function vd(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=J(t=Fe.call(null,e,"markdown-icon")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function b1(n){let e,t,i,a,s=n[1](n[0].type)+"",r,o,l,c,d,u,h,f,m,p,b=n[0].type=="heading"&&fd(n),_=n[0].type=="table"&&n[0].headers?.length&&md(n);function S(L,O){return L[0].type!="layout"?p1:g1}let C=S(n,-1),M=C(n),w="heading"in n[0]&&gd(n),k=n[0].conditioned&&pd(n),A="callback"in n[0]&&bd(n),P=("dice"in n[0]&&n[0].dice||"diceCallback"in n[0]&&n[0].diceCallback?.length)&&yd(n),B="markdown"in n[0]&&n[0].markdown&&vd(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(),f=R(),A&&A.c(),m=R(),P&&P.c(),p=R(),B&&B.c(),g(t,"class","info svelte-r3p86y"),g(u,"class","context svelte-r3p86y"),g(e,"class","property-block-container svelte-r3p86y")},m(L,O){D(L,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,f),A&&A.m(u,null),y(u,m),P&&P.m(u,null),y(u,p),B&&B.m(u,null)},p(L,[O]){O&1&&s!==(s=L[1](L[0].type)+"")&&we(r,s),L[0].type=="heading"?b?b.p(L,O):(b=fd(L),b.c(),b.m(i,l)):b&&(b.d(1),b=null),L[0].type=="table"&&L[0].headers?.length?_?_.p(L,O):(_=md(L),_.c(),_.m(i,null)):_&&(_.d(1),_=null),C===(C=S(L,O))&&M?M.p(L,O):(M.d(1),M=C(L),M&&(M.c(),M.m(t,null))),"heading"in L[0]?w||(w=gd(L),w.c(),w.m(u,h)):w&&(w.d(1),w=null),L[0].conditioned?k||(k=pd(L),k.c(),k.m(u,f)):k&&(k.d(1),k=null),"callback"in L[0]?A||(A=bd(L),A.c(),A.m(u,m)):A&&(A.d(1),A=null),"dice"in L[0]&&L[0].dice||"diceCallback"in L[0]&&L[0].diceCallback?.length?P||(P=yd(L),P.c(),P.m(u,p)):P&&(P.d(1),P=null),"markdown"in L[0]&&L[0].markdown?B||(B=vd(L),B.c(),B.m(u,null)):B&&(B.d(1),B=null)},i:N,o:N,d(L){L&&x(e),b&&b.d(),_&&_.d(),M.d(),w&&w.d(),k&&k.d(),A&&A.d(),P&&P.d(),B&&B.d()}}}function y1(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 Mo=class extends G{constructor(e){super(),K(this,e,y1,b1,V,{block:0,plugin:3},m1)}},kd=Mo;var Rs=require("obsidian");var fe=require("obsidian");var Sd=require("obsidian");function v1(n){se(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 wd(n,e,t){let i=n.slice();return i[11]=e[t],i}function _d(n,e){let t,i,a=e[11].name+"",s,r,o,l,c,d,u=N,h,f;function m(){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||(f=[J(l=e[5].call(null,o)),q(o,"click",m)],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:Io})},d(p){p&&x(t),h=!1,oe(f)}}}function k1(n){let e,t,i=[],a=new Map,s,r,o,l=be(n[0].filter(n[7])),c=d=>d[11].id;for(let d=0;d({name:m,id:Q()})),r=!1;function o(m){let{items:p,info:{source:b,trigger:_}}=m.detail;t(0,s=[...p])}function l(m){let{items:p,info:{source:b}}=m.detail;t(0,s=[...p]),i("sorted",s)}function c(m){m.preventDefault(),t(1,r=!1)}let d=m=>{t(0,s=s.filter(p=>p.id!=m.id)),i("sorted",s)},u=m=>{new Sd.ExtraButtonComponent(m).setIcon("cross-in-box")},h=m=>m.id!==ii,f=m=>d(m);return n.$$set=m=>{"headers"in m&&t(6,a=m.headers)},[s,r,o,l,d,u,a,h,f]}var Oo=class extends G{constructor(e){super(),K(this,e,w1,k1,V,{headers:6},v1)}},Cd=Oo;var Ts=require("obsidian");function _1(n){se(n,"svelte-mn2hp8",".setting-item.svelte-mn2hp8{align-items:center}.icon.svelte-mn2hp8{display:flex;align-items:center}")}function xd(n,e,t){let i=n.slice();return i[18]=e[t],i[19]=e,i[20]=t,i}function S1(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 C1(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=q(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 x1(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=[q(e,"click",s),J(t=n[10].call(null,e))],i=!0)},p(r,o){n=r},d(r){r&&x(e),i=!1,oe(a)}}}function A1(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=[q(e,"click",s),J(t=n[11].call(null,e))],i=!0)},p(r,o){n=r},d(r){r&&x(e),i=!1,oe(a)}}}function Ad(n,e){let t,i,a,s,r,o,l,c,d,u,h,f,m,p;function b(A,P){return A[1]==A[18].id?C1:S1}let _=b(e,-1),S=_(e);function C(A,P){return A[1]==A[18].id?A1:x1}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"),f=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,f),m||(p=[J(s=Fe.call(null,i,"grip-vertical")),q(i,"mousedown",e[5]),q(i,"touchstart",e[5]),q(u,"click",k),J(h=e[7].call(null,u))],m=!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(),m=!1,oe(p)}}}function T1(n){let e,t=[],i=new Map,a,s,r,o=be(n[2]),l=c=>c[18].id;for(let c=0;cP)),A===je.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 Ts.ExtraButtonComponent(w).setIcon("trash")},h,f=w=>{t(1,h=w.id)},m=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 Ts.ExtraButtonComponent(w).setIcon("pencil")},b=w=>{new Ts.ExtraButtonComponent(w).setIcon("check")};function _(w,k){w[k].prop=this.value,t(2,i),t(12,a)}let S=w=>m(w),C=w=>f(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,f,m,p,b,a,_,S,C,M]}var Po=class extends G{constructor(e){super(),K(this,e,D1,T1,V,{properties:12},_1)}},Dd=Po;var Fd=require("obsidian");function Ri(n,{delay:e=0,duration:t=400,easing:i=ls,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]}`]),f=parseFloat(s[`margin${d[0]}`]),m=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]}: ${_*f}px;margin-${c[1]}: ${_*m}px;border-${c[0]}-width: ${_*p}px;border-${c[1]}-width: ${_*b}px;`}}var Nd=require("obsidian");var E1=require("obsidian");function ai(n){switch(n){case"inline":case"group":return{type:n,id:Q(),properties:[],nested:[]};case"heading":return{type:"heading",id:Q(),properties:[],size:1};case"property":return{type:"property",id:Q(),properties:[]};case"saves":return{type:"saves",id:Q(),properties:[]};case"traits":return{type:"traits",id:Q(),properties:[]};case"spells":return{type:"spells",id:Q(),properties:[]};case"subheading":return{type:"subheading",id:Q(),properties:[]};case"image":return{type:"image",id:Q(),properties:[]};case"table":return{type:"table",id:Q(),properties:[],headers:[],calculate:!0};case"text":return{type:"text",id:Q(),properties:[],text:null};case"ifelse":return{type:"ifelse",id:Q(),conditions:[]};case"collapse":return{type:"collapse",id:Q(),heading:null,hasRule:!1,conditioned:!1,nested:[ai("group")],open:!1};case"javascript":return{type:"javascript",id:Q(),conditioned:!1,code:""};case"layout":return{type:"layout",id:Q(),layout:null};case"action":return{type:"action",id:Q(),icon:"clapperboard"}}}var Ni=require("obsidian");var Ed=require("@codemirror/view");function M1(n){se(n,"svelte-1ss6215",".setting-item-info.svelte-1ss6215{width:100%}.setting-item-name.svelte-1ss6215{display:flex;align-items:center;gap:0.25rem}")}function I1(n){let e;function t(s,r){return!s[0]||!s[0].condition?R1:P1}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 O1(n){let e,t,i,a;return{c(){e=v("div")},m(s,r){D(s,e,r),i||(a=J(t=n[4].call(null,e)),i=!0)},p:N,d(s){s&&x(e),i=!1,a()}}}function P1(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 R1(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=J(t=Fe.call(null,e,"alert-triangle")),s=!0)},p:N,d(o){o&&(x(e),x(i),x(a)),s=!1,r()}}}function N1(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","edit")},m(s,r){D(s,e,r),i||(a=[q(e,"click",n[8]),J(t=n[5].call(null,e))],i=!0)},p:N,d(s){s&&x(e),i=!1,oe(a)}}}function B1(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","done")},m(s,r){D(s,e,r),i||(a=[q(e,"click",n[3]),J(t=n[6].call(null,e))],i=!0)},p:N,d(s){s&&x(e),i=!1,oe(a)}}}function L1(n){let e,t,i,a,s,r,o,l;function c(p,b){return p[1]?O1:I1}let d=c(n,-1),u=d(n);function h(p,b){return p[1]?B1:N1}let f=h(n,-1),m=f(n);return{c(){e=v("div"),u.c(),t=R(),i=v("div"),m.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),m.m(i,null),y(i,a),y(i,s),o||(l=[q(s,"click",n[9]),J(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))),f===(f=h(p,b))&&m?m.p(p,b):(m.d(1),m=f(p),m&&(m.c(),m.m(i,a)))},i:N,o:N,d(p){p&&(x(e),x(t),x(i)),u.d(),m.d(),o=!1,oe(l)}}}function F1(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=m=>{let p=new Ni.TextAreaComponent(m).setValue(a?.condition?a.condition:"");r=Lt(p.inputEl,Ed.EditorView.updateListener.of(b=>{b.docChanged&&t(0,a.condition=b.state.doc.toString(),a)}))},c=m=>{new Ni.ExtraButtonComponent(m).setIcon("pencil")},d=m=>{new Ni.ExtraButtonComponent(m).setIcon("check")},u=m=>{new Ni.ExtraButtonComponent(m).setIcon("trash")};bn(()=>{r?.destroy()});let h=()=>i("edit"),f=()=>i("delete");return n.$$set=m=>{"condition"in m&&t(0,a=m.condition),"editing"in m&&t(1,s=m.editing)},[a,s,i,o,l,c,d,u,h,f]}var Ro=class extends G{constructor(e){super(),K(this,e,F1,L1,V,{condition:0,editing:1},M1)}},Md=Ro;function W1(n){se(n,"svelte-mn2hp8",".setting-item.svelte-mn2hp8{align-items:center}.icon.svelte-mn2hp8{display:flex;align-items:center}")}function Id(n,e,t){let i=n.slice();return i[15]=e[t],i}function Od(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 f(){return n[13](n[15])}return r=new Md({props:{condition:n[15].prop,editing:n[1]==n[15].id}}),r.$on("delete",u),r.$on("edit",h),r.$on("done",f),{c(){e=v("div"),t=v("div"),s=R(),ie(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(m,p){D(m,e,p),y(e,t),y(e,s),te(r,e,null),y(e,o),l=!0,c||(d=[J(a=Fe.call(null,t,"grip-vertical")),q(t,"mousedown",n[6]),q(t,"touchstart",n[6])],c=!0)},p(m,p){n=m,(!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(m){l||(E(r.$$.fragment,m),l=!0)},o(m){I(r.$$.fragment,m),l=!1},d(m){m&&x(e),ne(r),c=!1,oe(d)}}}function Pd(n,e){let t,i=e[1],a,s,r=Od(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&&V(i,i=e[1])?(le(),I(r,1,1,N),ce(),r=Od(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 H1(n){let e,t,i,a,s,r=[],o=new Map,l,c,d,u,h=be(n[3]),f=m=>m[15].id;for(let m=0;m(s(),s=Dt(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===je.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===je.POINTER&&t(2,d=!0)}function f(M){M.preventDefault(),t(2,d=!1)}let m=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 Nd.Setting(M).setName("Add new condition").addButton(w=>w.setIcon("plus").onClick(()=>{let k=Q();t(1,l=k),t(3,i=[...i,{prop:{nested:[ai("group")],condition:null},id:k}]),c("sorted",i.map(({prop:A})=>A))}))},_=M=>m(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:Q()})))},[o,l,d,i,u,h,f,m,p,b,a,_,S,C]}var No=class extends G{constructor(e){super(),K(this,e,z1,H1,V,{conditions:0},W1)}},Bd=No;function q1(n){se(n,"svelte-131x181",".condition-builder-container.svelte-131x181 .setting-item.svelte-131x181{align-items:flex-start}")}function Ld(n){let e,t,i;return{c(){e=v("div"),e.innerHTML=`Conditions are used to determine what block is +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 hb="finalize",fb="consider";function Oi(n,e,t){n.dispatchEvent(new CustomEvent(hb,{detail:{items:e,info:t}}))}function Fn(n,e,t){n.dispatchEvent(new CustomEvent(fb,{detail:{items:e,info:t}}))}var ks="draggedEntered",ga="draggedLeft",ws="draggedOverIndex",Co="draggedLeftDocument",fs={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function mb(n,e,t){n.dispatchEvent(new CustomEvent(ks,{detail:{indexObj:e,draggedEl:t}}))}function gb(n,e,t){n.dispatchEvent(new CustomEvent(ga,{detail:{draggedEl:e,type:fs.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function pb(n,e){n.dispatchEvent(new CustomEvent(ga,{detail:{draggedEl:e,type:fs.OUTSIDE_OF_ANY}}))}function bb(n,e,t){n.dispatchEvent(new CustomEvent(ws,{detail:{indexObj:e,draggedEl:t}}))}function yb(n){window.dispatchEvent(new CustomEvent(Co,{detail:{draggedEl:n}}))}var Ye={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:ks,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:ws,DRAGGED_LEFT:ga,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},je={POINTER:"pointer",KEYBOARD:"keyboard"},_s="isDndShadowItem",xo="data-is-dnd-shadow-item-internal",vb="data-is-dnd-shadow-item-hint",ii="id:dnd-shadow-placeholder-0000",kb="dnd-action-dragged-el",nt="id",po=0;function Ju(){po++}function Xu(){if(po===0)throw new Error("Bug! trying to decrement when there are no dropzones");po--}var Ao=typeof window>"u",xe=function(){};function bo(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,f=r?t.height/r:n.offsetHeight;return{x:d,y:u,width:h,height:f,top:u,right:d+h,bottom:u+f,left:d}}else return t}function Qu(n){var e=bo(n);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function Zu(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 ed(n){return{x:(n.left+n.right)/2,y:(n.top+n.bottom)/2}}function wb(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function Ss(n,e){return n.y<=e.bottom&&n.y>=e.top&&n.x>=e.left&&n.x<=e.right}function da(n){return ed(Zu(n))}function Fu(n,e){var t=da(n),i=Qu(e);return Ss(t,i)}function _b(n,e){var t=da(n),i=da(e);return wb(t,i)}function Sb(n){var e=Zu(n);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}var Ei;function To(){xe(function(){return"resetting indexes cache"}),Ei=new Map}To();function Cb(n){var e=Array.from(n.children).findIndex(function(t){return t.getAttribute(xo)});if(e>=0)return Ei.has(n)||Ei.set(n,new Map),Ei.get(n).set(e,Qu(n.children[e])),e}function xb(n,e){if(!Fu(n,e))return null;var t=e.children;if(t.length===0)return{index:0,isProximityBased:!0};for(var i=Cb(e),a=0;a1&&arguments[1]!==void 0?arguments[1]:0;return n.parentElement?td(n.parentElement,e+1):e-1}function Ab(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 Tb(n,e){if(n.length!==e.length)return!1;for(var t=0;t2&&arguments[2]!==void 0?arguments[2]:Db,i=arguments.length>3?arguments[3]:void 0,a,s,r=!1,o,l=Array.from(e).sort(function(d,u){return ms(u)-ms(d)});function c(){var d=da(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=Nb(n),i=Array.from(t).sort(function(l,c){return ms(c)-ms(l)}),a=Ib(),s=a.scrollIfNeeded,r=a.resetScrolling;function o(){var l=e();if(!l||!i)return!1;for(var c=i.filter(function(h){return Ss(l,h.getBoundingClientRect())||h===document.scrollingElement}),d=0;d0?o:function(){return!1},destroy:function(){return r()}}}function Rb(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 Nb(n){var e=new Set,t=ma(n),i;try{for(t.s();!(i=t.n()).done;){var a=i.value;Rb(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 Bb(n){var e=n.cloneNode(!0),t=[],i=n.tagName==="SELECT",a=i?[n]:jt(n.querySelectorAll("select")),s=ma(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]:jt(e.querySelectorAll("select")),c=0;c0)for(var p=f?[e]:jt(e.querySelectorAll("canvas")),b=0;b0&&_.height>0&&S.getContext("2d").drawImage(_,0,0)}return e}var ha=Object.freeze({USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT:"USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT"}),Lb=Ii({},ha.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT,!1);function nd(n){if(!ha[n])throw new Error("Can't get non existing feature flag ".concat(n,"! Supported flags: ").concat(Object.keys(ha)));return Lb[n]}var Fb=.2;function ei(n){return"".concat(n," ").concat(Fb,"s ease")}function Wb(n,e){var t=n.getBoundingClientRect(),i=Bb(n);id(n,i),i.id=kb,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=ed(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(ei("top"),", ").concat(ei("left"),", ").concat(ei("background-color"),", ").concat(ei("opacity"),", ").concat(ei("color")," "),window.setTimeout(function(){return i.style.transition+=", ".concat(ei("width"),", ").concat(ei("height"))},0),i.style.zIndex="9999",i.style.cursor="grabbing",i}function Hb(n){n.style.cursor="grab"}function zb(n,e,t,i){id(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};nd(ha.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 id(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"||nd(ha.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 qb(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 ad(n){n.style.display="none",n.style.position="fixed",n.style.zIndex="-5"}function jb(n){n.style.visibility="hidden",n.setAttribute(xo,"true")}function Vb(n){n.style.visibility="",n.removeAttribute(xo)}function ds(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 gs(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 Ub(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 Gb="--any--",Kb=100,$b=20,Hu=3,zu={outline:"rgba(255, 255, 102, 0.7) solid 2px"},qu="data-is-dnd-original-dragged-item",Jt,ft,xt,Cs,qe,xs,Ln,ht,Nn,Ot,Rn=!1,Do=!1,Eo,pa=!1,ca=[],ps,Zt=new Map,Xe=new Map,mo=new WeakMap;function Yb(n,e){xe(function(){return"registering drop-zone if absent"}),Zt.has(e)||Zt.set(e,new Set),Zt.get(e).has(n)||(Zt.get(e).add(n),Ju())}function ju(n,e){Zt.get(e).delete(n),Xu(),Zt.get(e).size===0&&Zt.delete(e)}function Jb(){xe(function(){return"watching dragged element"});var n=Zt.get(Cs),e=ma(n),t;try{for(e.s();!(t=e.n()).done;){var i=t.value;i.addEventListener(ks,sd),i.addEventListener(ga,rd),i.addEventListener(ws,od)}}catch(r){e.e(r)}finally{e.f()}window.addEventListener(Co,Pi);var a=Math.max.apply(Math,jt(Array.from(n.keys()).map(function(r){return Xe.get(r).dropAnimationDurationMs}))),s=a===0?$b:Math.max(a,Kb);ps=Pb(n,function(){return Ot}),Eb(ft,n,s*1.07,ps)}function Xb(){xe(function(){return"unwatching dragged element"});var n=Zt.get(Cs),e=ma(n),t;try{for(e.s();!(t=e.n()).done;){var i=t.value;i.removeEventListener(ks,sd),i.removeEventListener(ga,rd),i.removeEventListener(ws,od)}}catch(a){e.e(a)}finally{e.f()}window.removeEventListener(Co,Pi),ps.destroy(),ps=void 0,Mb()}function As(n){return n.findIndex(function(e){return!!e[_s]})}function Qb(n){var e;return hs(hs({},n),{},(e={},Ii(e,_s,!0),Ii(e,nt,ii),e))}function sd(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!==qe){xe(function(){return"ignoring dragged entered because drop is currently disabled"});return}if(pa=!1,t=t.filter(function(d){return d[nt]!==Ln[nt]}),xe(function(){return"dragged entered items ".concat(dn(t))}),qe!==n.currentTarget){var a=Xe.get(qe).items,s=a.filter(function(d){return!d[_s]});Fn(qe,s,{trigger:Ye.DRAGGED_ENTERED_ANOTHER,id:xt[nt],source:je.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,Ln),Fn(n.currentTarget,t,{trigger:Ye.DRAGGED_ENTERED,id:xt[nt],source:je.POINTER})}function rd(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!==qe&&n.currentTarget!==ht){xe(function(){return"drop is currently disabled"});return}var a=jt(t),s=As(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===fs.OUTSIDE_OF_ANY||l===fs.LEFT_FOR_ANOTHER&&c!==qe&&Xe.get(c).dropFromOthersDisabled){xe(function(){return"dragged left all, putting shadow element back in the origin dz"}),pa=!0,ht=qe;var d=r===qe?a:jt(Xe.get(qe).items);d.splice(xs,0,Ln),Fn(qe,d,{trigger:Ye.DRAGGED_LEFT_ALL,id:xt[nt],source:je.POINTER})}Fn(n.currentTarget,a,{trigger:Ye.DRAGGED_LEFT,id:xt[nt],source:je.POINTER})}}function od(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!==qe){xe(function(){return"drop is currently disabled"});return}var a=jt(t);pa=!1;var s=n.detail.indexObj.index,r=As(a);r!==-1&&a.splice(r,1),a.splice(s,0,Ln),Fn(n.currentTarget,a,{trigger:Ye.DRAGGED_OVER_INDEX,id:xt[nt],source:je.POINTER})}function bs(n){n.preventDefault();var e=n.touches?n.touches[0]:n;Ot={x:e.clientX,y:e.clientY},ft.style.transform="translate3d(".concat(Ot.x-Nn.x,"px, ").concat(Ot.y-Nn.y,"px, 0)")}function Pi(){xe(function(){return"dropped"}),Do=!0,window.removeEventListener("mousemove",bs),window.removeEventListener("touchmove",bs),window.removeEventListener("mouseup",Pi),window.removeEventListener("touchend",Pi),Xb(),Hb(ft),ht||(xe(function(){return"element was dropped right after it left origin but before entering somewhere else"}),ht=qe),xe(function(){return["dropped in dz",ht]});var n=Xe.get(ht),e=n.items,t=n.type;gs(Zt.get(t),function(s){return Xe.get(s).dropTargetStyle},function(s){return Xe.get(s).dropTargetClasses});var i=As(e);i===-1&&ht===qe&&(i=xs),e=e.map(function(s){return s[_s]?xt:s});function a(){Eo(),Oi(ht,e,{trigger:pa?Ye.DROPPED_OUTSIDE_OF_ANY:Ye.DROPPED_INTO_ZONE,id:xt[nt],source:je.POINTER}),ht!==qe&&Oi(qe,Xe.get(qe).items,{trigger:Ye.DROPPED_INTO_ANOTHER,id:xt[nt],source:je.POINTER}),i!==-1&&Vb(ht.children[i]),t1()}Zb(i,a)}function Zb(n,e){var t=n>-1?bo(ht.children[n]):bo(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 e1(n,e){ca.push({dz:n,destroy:e}),window.requestAnimationFrame(function(){ad(n),document.body.appendChild(n)})}function t1(){ft.remove(),Jt.remove(),ca.length&&(xe(function(){return["will destroy zones that were removed during drag",ca]}),ca.forEach(function(n){var e=n.dz,t=n.destroy;t(),e.remove()}),ca=[]),ft=void 0,Jt=void 0,xt=void 0,Cs=void 0,qe=void 0,xs=void 0,Ln=void 0,ht=void 0,Nn=void 0,Ot=void 0,Rn=!1,Do=!1,Eo=void 0,pa=!1}function n1(n,e){var t=!1,i={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:zu,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(),Jt=void 0,Nn=void 0,Ot=void 0,h.type==="touchend"&&h.target.click()}function l(h){h.preventDefault();var f=h.touches?h.touches[0]:h;Ot={x:f.clientX,y:f.clientY},(Math.abs(Ot.x-Nn.x)>=Hu||Math.abs(Ot.y-Nn.y)>=Hu)&&(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 f=h.touches?h.touches[0]:h;Nn={x:f.clientX,y:f.clientY},Ot=hs({},Nn),Jt=h.currentTarget,s()}function d(){xe(function(){return["drag start config: ".concat(dn(i)),Jt]}),Rn=!0;var h=a.get(Jt);xs=h,qe=Jt.parentElement;var f=qe.closest("dialog")||qe.getRootNode(),m=f.body||f,p=i.items,b=i.type,_=i.centreDraggedOnCursor,S=jt(p);xt=S[h],Cs=b,Ln=Qb(xt),ft=Wb(Jt,_&&Ot),Jt.setAttribute(qu,!0);function C(){ft.parentElement?window.requestAnimationFrame(C):(m.appendChild(ft),ft.focus(),Jb(),ad(Jt),m.appendChild(Jt),Ln[nt]=xt[nt])}window.requestAnimationFrame(C),ds(Array.from(Zt.get(i.type)).filter(function(M){return M===qe||!Xe.get(M).dropFromOthersDisabled}),function(M){return Xe.get(M).dropTargetStyle},function(M){return Xe.get(M).dropTargetClasses}),S.splice(h,1,Ln),Eo=Ub(qe),Fn(qe,S,{trigger:Ye.DRAG_STARTED,id:xt[nt],source:je.POINTER}),window.addEventListener("mousemove",bs,{passive:!1}),window.addEventListener("touchmove",bs,{passive:!1,capture:!1}),window.addEventListener("mouseup",Pi,{passive:!1}),window.addEventListener("touchend",Pi,{passive:!1})}function u(h){var f=h.items,m=f===void 0?void 0:f,p=h.flipDurationMs,b=p===void 0?0:p,_=h.type,S=_===void 0?Gb:_,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,B=h.dropTargetStyle,L=B===void 0?zu:B,O=h.dropTargetClasses,j=O===void 0?[]:O,Z=h.transformDraggedElement,ee=Z===void 0?function(){}:Z,ae=h.centreDraggedOnCursor,$=ae===void 0?!1:ae;i.dropAnimationDurationMs=b,i.type&&S!==i.type&&ju(n,i.type),i.type=S,i.items=jt(m),i.dragDisabled=M,i.morphDisabled=k,i.transformDraggedElement=ee,i.centreDraggedOnCursor=$,t&&Rn&&!Do&&(!Ab(L,i.dropTargetStyle)||!Tb(j,i.dropTargetClasses))&&(gs([n],function(){return i.dropTargetStyle},function(){return j}),ds([n],function(){return L},function(){return j})),i.dropTargetStyle=L,i.dropTargetClasses=jt(j);function W(he,ue){return Xe.get(he)?Xe.get(he)[ue]:i[ue]}t&&Rn&&i.dropFromOthersDisabled!==P&&(P?gs([n],function(he){return W(he,"dropTargetStyle")},function(he){return W(he,"dropTargetClasses")}):ds([n],function(he){return W(he,"dropTargetStyle")},function(he){return W(he,"dropTargetClasses")})),i.dropFromOthersDisabled=P,Xe.set(n,i),Yb(n,S);for(var Y=Rn?As(i.items):-1,F=0;F".concat(e,"

"),t.style.display="none",t.style.position="fixed",t.style.zIndex="-5",t}function Mi(n){if(!Ao){Je||ko(),Je.innerHTML="";var e=document.createTextNode(n);Je.appendChild(e),Je.style.display="none",Je.style.display="inline"}}var o1="--any--",Vu={outline:"rgba(255, 255, 102, 0.7) solid 2px"},qt=!1,wo,pt,ni="",ti,Xt,Bn="",ys=new WeakSet,Uu=new WeakMap,Gu=new WeakMap,_o=new Map,dt=new Map,Qt=new Map,vs;function l1(n,e){xe(function(){return"registering drop-zone if absent"}),Qt.size===0&&(xe(function(){return"adding global keydown and click handlers"}),vs=a1(),window.addEventListener("keydown",cd),window.addEventListener("click",ud)),Qt.has(e)||Qt.set(e,new Set),Qt.get(e).has(n)||(Qt.get(e).add(n),Ju())}function Ku(n,e){xe(function(){return"unregistering drop-zone"}),pt===n&&fa(),Qt.get(e).delete(n),Xu(),Qt.get(e).size===0&&Qt.delete(e),Qt.size===0&&(xe(function(){return"removing global keydown and click handlers"}),window.removeEventListener("keydown",cd),window.removeEventListener("click",ud),vs=void 0,s1())}function cd(n){if(qt)switch(n.key){case"Escape":{fa();break}}}function ud(){qt&&(ys.has(document.activeElement)||(xe(function(){return"clicked outside of any draggable"}),fa()))}function c1(n){if(xe(function(){return"zone focus"}),!!qt){var e=n.currentTarget;if(e!==pt){ni=e.getAttribute("aria-label")||"";var t=dt.get(pt),i=t.items,a=i.find(function(u){return u[nt]===Xt}),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(pt).autoAriaDisabled||Mi("Stopped dragging item ".concat(Bn)),ys.has(document.activeElement)&&document.activeElement.blur(),n&&Fn(pt,dt.get(pt).items,{trigger:Ye.DRAG_STOPPED,id:Xt,source:je.KEYBOARD}),gs(Qt.get(wo),function(e){return dt.get(e).dropTargetStyle},function(e){return dt.get(e).dropTargetClasses}),ti=null,Xt=null,Bn="",wo=null,pt=null,ni="",qt=!1,dd()}function u1(n,e){var t={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Vu,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)&&!ys.has(d.target))return;d.preventDefault(),d.stopPropagation(),qt?fa():s(d);break}case"ArrowDown":case"ArrowRight":{if(!qt)return;d.preventDefault(),d.stopPropagation();var u=dt.get(n),h=u.items,f=Array.from(n.children),m=f.indexOf(d.currentTarget);xe(function(){return["arrow down",m]}),m0&&(t.autoAriaDisabled||Mi("Moved item ".concat(Bn," to position ").concat(S," in the list ").concat(ni)),i(b,S,S-1),Oi(n,b,{trigger:Ye.DROPPED_INTO_ZONE,id:Xt,source:je.KEYBOARD}));break}}}function s(d){xe(function(){return"drag start"}),o(d.currentTarget),pt=n,wo=t.type,qt=!0;var u=Array.from(Qt.get(t.type)).filter(function(f){return f===pt||!dt.get(f).dropFromOthersDisabled});if(ds(u,function(f){return dt.get(f).dropTargetStyle},function(f){return dt.get(f).dropTargetClasses}),!t.autoAriaDisabled){var h="Started dragging item ".concat(Bn,". Use the arrow keys to move it within its list ").concat(ni);u.length>1&&(h+=", or tab to another list in order to move the item into it"),Mi(h)}Fn(n,dt.get(n).items,{trigger:Ye.DRAG_STARTED,id:Xt,source:je.KEYBOARD}),dd()}function r(d){qt&&d.currentTarget!==ti&&(d.stopPropagation(),fa(!1),s(d))}function o(d){var u=dt.get(n),h=u.items,f=Array.from(n.children),m=f.indexOf(d);ti=d,ti.tabIndex=t.zoneItemTabIndex,Xt=h[m][nt],Bn=f[m].getAttribute("aria-label")||""}function l(d){var u=d.items,h=u===void 0?[]:u,f=d.type,m=f===void 0?o1:f,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?Vu:A,B=d.dropTargetClasses,L=B===void 0?[]:B,O=d.autoAriaDisabled,j=O===void 0?!1:O;t.items=jt(h),t.dragDisabled=b,t.dropFromOthersDisabled=k,t.zoneTabIndex=S,t.zoneItemTabIndex=M,t.dropTargetStyle=P,t.dropTargetClasses=L,t.autoAriaDisabled=j,t.type&&m!==t.type&&Ku(n,t.type),t.type=m,l1(n,m),j||(n.setAttribute("aria-disabled",b),n.setAttribute("role","list"),n.setAttribute("aria-describedby",b?vs.DND_ZONE_DRAG_DISABLED:vs.DND_ZONE_ACTIVE)),dt.set(n,t),qt?n.tabIndex=n===pt||ti.contains(n)||t.dropFromOthersDisabled||pt&&t.type!==dt.get(pt).type?-1:0:n.tabIndex=t.zoneTabIndex,n.addEventListener("focus",c1);for(var Z=function($){var W=n.children[$];ys.add(W),W.tabIndex=qt?-1:t.zoneItemTabIndex,j||W.setAttribute("role","listitem"),W.removeEventListener("keydown",Uu.get(W)),W.removeEventListener("click",Gu.get(W)),b||(W.addEventListener("keydown",a),Uu.set(W,a),W.addEventListener("click",r),Gu.set(W,r)),qt&&t.items[$][nt]===Xt&&(xe(function(){return["focusing on",{i:$,focusedItemId:Xt}]}),ti=W,ti.tabIndex=t.zoneItemTabIndex,W.focus())},ee=0;ee0&&console.warn("dndzone will ignore unknown options",m),!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(ua(d),", ").concat(dn(d)));if(o&&!Yu(o))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(ua(o),", ").concat(dn(o)));if(l&&!Yu(l))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(ua(l),", ").concat(dn(l)))}function Yu(n){return!isNaN(n)&&function(e){return(e|0)===e}(parseFloat(n))}function f1(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 WS=f1(!0);var Ts=require("obsidian");var hd=require("@codemirror/view"),Fe=(n,e)=>{(0,Ts.setIcon)(n,e)};function ba(n,e,t,i,a="js"){let s=new Ts.TextAreaComponent(n).setValue(e);return s.inputEl.addClasses(["statblock-textarea",...t]),Lt(s.inputEl,hd.EditorView.updateListener.of(r=>{r.docChanged&&i(r.state.doc.toString())}),a)}function m1(n){se(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 fd(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 md(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 g1(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 p1(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 gd(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=J(t=Fe.call(null,e,"heading-glyph")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function pd(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=J(t=Fe.call(null,e,"help-circle")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function bd(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=J(t=Fe.call(null,e,"code-glyph")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function yd(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=J(t=Fe.call(null,e,"dices")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function vd(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=J(t=Fe.call(null,e,"markdown-icon")),i=!0)},d(s){s&&x(e),i=!1,a()}}}function b1(n){let e,t,i,a,s=n[1](n[0].type)+"",r,o,l,c,d,u,h,f,m,p,b=n[0].type=="heading"&&fd(n),_=n[0].type=="table"&&n[0].headers?.length&&md(n);function S(L,O){return L[0].type!="layout"?p1:g1}let C=S(n,-1),M=C(n),w="heading"in n[0]&&gd(n),k=n[0].conditioned&&pd(n),A="callback"in n[0]&&bd(n),P=("dice"in n[0]&&n[0].dice||"diceCallback"in n[0]&&n[0].diceCallback?.length)&&yd(n),B="markdown"in n[0]&&n[0].markdown&&vd(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(),f=R(),A&&A.c(),m=R(),P&&P.c(),p=R(),B&&B.c(),g(t,"class","info svelte-r3p86y"),g(u,"class","context svelte-r3p86y"),g(e,"class","property-block-container svelte-r3p86y")},m(L,O){D(L,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,f),A&&A.m(u,null),y(u,m),P&&P.m(u,null),y(u,p),B&&B.m(u,null)},p(L,[O]){O&1&&s!==(s=L[1](L[0].type)+"")&&we(r,s),L[0].type=="heading"?b?b.p(L,O):(b=fd(L),b.c(),b.m(i,l)):b&&(b.d(1),b=null),L[0].type=="table"&&L[0].headers?.length?_?_.p(L,O):(_=md(L),_.c(),_.m(i,null)):_&&(_.d(1),_=null),C===(C=S(L,O))&&M?M.p(L,O):(M.d(1),M=C(L),M&&(M.c(),M.m(t,null))),"heading"in L[0]?w||(w=gd(L),w.c(),w.m(u,h)):w&&(w.d(1),w=null),L[0].conditioned?k||(k=pd(L),k.c(),k.m(u,f)):k&&(k.d(1),k=null),"callback"in L[0]?A||(A=bd(L),A.c(),A.m(u,m)):A&&(A.d(1),A=null),"dice"in L[0]&&L[0].dice||"diceCallback"in L[0]&&L[0].diceCallback?.length?P||(P=yd(L),P.c(),P.m(u,p)):P&&(P.d(1),P=null),"markdown"in L[0]&&L[0].markdown?B||(B=vd(L),B.c(),B.m(u,null)):B&&(B.d(1),B=null)},i:N,o:N,d(L){L&&x(e),b&&b.d(),_&&_.d(),M.d(),w&&w.d(),k&&k.d(),A&&A.d(),P&&P.d(),B&&B.d()}}}function y1(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 Mo=class extends G{constructor(e){super(),K(this,e,y1,b1,V,{block:0,plugin:3},m1)}},kd=Mo;var Ns=require("obsidian");var fe=require("obsidian");var Sd=require("obsidian");function v1(n){se(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 wd(n,e,t){let i=n.slice();return i[11]=e[t],i}function _d(n,e){let t,i,a=e[11].name+"",s,r,o,l,c,d,u=N,h,f;function m(){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||(f=[J(l=e[5].call(null,o)),q(o,"click",m)],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:Io})},d(p){p&&x(t),h=!1,oe(f)}}}function k1(n){let e,t,i=[],a=new Map,s,r,o,l=be(n[0].filter(n[7])),c=d=>d[11].id;for(let d=0;d({name:m,id:Q()})),r=!1;function o(m){let{items:p,info:{source:b,trigger:_}}=m.detail;t(0,s=[...p])}function l(m){let{items:p,info:{source:b}}=m.detail;t(0,s=[...p]),i("sorted",s)}function c(m){m.preventDefault(),t(1,r=!1)}let d=m=>{t(0,s=s.filter(p=>p.id!=m.id)),i("sorted",s)},u=m=>{new Sd.ExtraButtonComponent(m).setIcon("cross-in-box")},h=m=>m.id!==ii,f=m=>d(m);return n.$$set=m=>{"headers"in m&&t(6,a=m.headers)},[s,r,o,l,d,u,a,h,f]}var Oo=class extends G{constructor(e){super(),K(this,e,w1,k1,V,{headers:6},v1)}},Cd=Oo;var Ds=require("obsidian");function _1(n){se(n,"svelte-mn2hp8",".setting-item.svelte-mn2hp8{align-items:center}.icon.svelte-mn2hp8{display:flex;align-items:center}")}function xd(n,e,t){let i=n.slice();return i[18]=e[t],i[19]=e,i[20]=t,i}function S1(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 C1(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=q(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 x1(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=[q(e,"click",s),J(t=n[10].call(null,e))],i=!0)},p(r,o){n=r},d(r){r&&x(e),i=!1,oe(a)}}}function A1(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=[q(e,"click",s),J(t=n[11].call(null,e))],i=!0)},p(r,o){n=r},d(r){r&&x(e),i=!1,oe(a)}}}function Ad(n,e){let t,i,a,s,r,o,l,c,d,u,h,f,m,p;function b(A,P){return A[1]==A[18].id?C1:S1}let _=b(e,-1),S=_(e);function C(A,P){return A[1]==A[18].id?A1:x1}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"),f=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,f),m||(p=[J(s=Fe.call(null,i,"grip-vertical")),q(i,"mousedown",e[5]),q(i,"touchstart",e[5]),q(u,"click",k),J(h=e[7].call(null,u))],m=!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(),m=!1,oe(p)}}}function T1(n){let e,t=[],i=new Map,a,s,r,o=be(n[2]),l=c=>c[18].id;for(let c=0;cP)),A===je.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 Ds.ExtraButtonComponent(w).setIcon("trash")},h,f=w=>{t(1,h=w.id)},m=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 Ds.ExtraButtonComponent(w).setIcon("pencil")},b=w=>{new Ds.ExtraButtonComponent(w).setIcon("check")};function _(w,k){w[k].prop=this.value,t(2,i),t(12,a)}let S=w=>m(w),C=w=>f(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,f,m,p,b,a,_,S,C,M]}var Po=class extends G{constructor(e){super(),K(this,e,D1,T1,V,{properties:12},_1)}},Dd=Po;var Fd=require("obsidian");function Ri(n,{delay:e=0,duration:t=400,easing:i=cs,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]}`]),f=parseFloat(s[`margin${d[0]}`]),m=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]}: ${_*f}px;margin-${c[1]}: ${_*m}px;border-${c[0]}-width: ${_*p}px;border-${c[1]}-width: ${_*b}px;`}}var Nd=require("obsidian");var E1=require("obsidian");function ai(n){switch(n){case"inline":case"group":return{type:n,id:Q(),properties:[],nested:[]};case"heading":return{type:"heading",id:Q(),properties:[],size:1};case"property":return{type:"property",id:Q(),properties:[]};case"saves":return{type:"saves",id:Q(),properties:[]};case"traits":return{type:"traits",id:Q(),properties:[]};case"spells":return{type:"spells",id:Q(),properties:[]};case"subheading":return{type:"subheading",id:Q(),properties:[]};case"image":return{type:"image",id:Q(),properties:[]};case"table":return{type:"table",id:Q(),properties:[],headers:[],calculate:!0};case"text":return{type:"text",id:Q(),properties:[],text:null};case"ifelse":return{type:"ifelse",id:Q(),conditions:[]};case"collapse":return{type:"collapse",id:Q(),heading:null,hasRule:!1,conditioned:!1,nested:[ai("group")],open:!1};case"javascript":return{type:"javascript",id:Q(),conditioned:!1,code:""};case"layout":return{type:"layout",id:Q(),layout:null};case"action":return{type:"action",id:Q(),icon:"clapperboard"}}}var Ni=require("obsidian");var Ed=require("@codemirror/view");function M1(n){se(n,"svelte-1ss6215",".setting-item-info.svelte-1ss6215{width:100%}.setting-item-name.svelte-1ss6215{display:flex;align-items:center;gap:0.25rem}")}function I1(n){let e;function t(s,r){return!s[0]||!s[0].condition?R1:P1}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 O1(n){let e,t,i,a;return{c(){e=v("div")},m(s,r){D(s,e,r),i||(a=J(t=n[4].call(null,e)),i=!0)},p:N,d(s){s&&x(e),i=!1,a()}}}function P1(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 R1(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=J(t=Fe.call(null,e,"alert-triangle")),s=!0)},p:N,d(o){o&&(x(e),x(i),x(a)),s=!1,r()}}}function N1(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","edit")},m(s,r){D(s,e,r),i||(a=[q(e,"click",n[8]),J(t=n[5].call(null,e))],i=!0)},p:N,d(s){s&&x(e),i=!1,oe(a)}}}function B1(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","done")},m(s,r){D(s,e,r),i||(a=[q(e,"click",n[3]),J(t=n[6].call(null,e))],i=!0)},p:N,d(s){s&&x(e),i=!1,oe(a)}}}function L1(n){let e,t,i,a,s,r,o,l;function c(p,b){return p[1]?O1:I1}let d=c(n,-1),u=d(n);function h(p,b){return p[1]?B1:N1}let f=h(n,-1),m=f(n);return{c(){e=v("div"),u.c(),t=R(),i=v("div"),m.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),m.m(i,null),y(i,a),y(i,s),o||(l=[q(s,"click",n[9]),J(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))),f===(f=h(p,b))&&m?m.p(p,b):(m.d(1),m=f(p),m&&(m.c(),m.m(i,a)))},i:N,o:N,d(p){p&&(x(e),x(t),x(i)),u.d(),m.d(),o=!1,oe(l)}}}function F1(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=m=>{let p=new Ni.TextAreaComponent(m).setValue(a?.condition?a.condition:"");r=Lt(p.inputEl,Ed.EditorView.updateListener.of(b=>{b.docChanged&&t(0,a.condition=b.state.doc.toString(),a)}))},c=m=>{new Ni.ExtraButtonComponent(m).setIcon("pencil")},d=m=>{new Ni.ExtraButtonComponent(m).setIcon("check")},u=m=>{new Ni.ExtraButtonComponent(m).setIcon("trash")};bn(()=>{r?.destroy()});let h=()=>i("edit"),f=()=>i("delete");return n.$$set=m=>{"condition"in m&&t(0,a=m.condition),"editing"in m&&t(1,s=m.editing)},[a,s,i,o,l,c,d,u,h,f]}var Ro=class extends G{constructor(e){super(),K(this,e,F1,L1,V,{condition:0,editing:1},M1)}},Md=Ro;function W1(n){se(n,"svelte-mn2hp8",".setting-item.svelte-mn2hp8{align-items:center}.icon.svelte-mn2hp8{display:flex;align-items:center}")}function Id(n,e,t){let i=n.slice();return i[15]=e[t],i}function Od(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 f(){return n[13](n[15])}return r=new Md({props:{condition:n[15].prop,editing:n[1]==n[15].id}}),r.$on("delete",u),r.$on("edit",h),r.$on("done",f),{c(){e=v("div"),t=v("div"),s=R(),ie(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(m,p){D(m,e,p),y(e,t),y(e,s),te(r,e,null),y(e,o),l=!0,c||(d=[J(a=Fe.call(null,t,"grip-vertical")),q(t,"mousedown",n[6]),q(t,"touchstart",n[6])],c=!0)},p(m,p){n=m,(!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(m){l||(E(r.$$.fragment,m),l=!0)},o(m){I(r.$$.fragment,m),l=!1},d(m){m&&x(e),ne(r),c=!1,oe(d)}}}function Pd(n,e){let t,i=e[1],a,s,r=Od(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&&V(i,i=e[1])?(le(),I(r,1,1,N),ce(),r=Od(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 H1(n){let e,t,i,a,s,r=[],o=new Map,l,c,d,u,h=be(n[3]),f=m=>m[15].id;for(let m=0;m(s(),s=Dt(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===je.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===je.POINTER&&t(2,d=!0)}function f(M){M.preventDefault(),t(2,d=!1)}let m=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 Nd.Setting(M).setName("Add new condition").addButton(w=>w.setIcon("plus").onClick(()=>{let k=Q();t(1,l=k),t(3,i=[...i,{prop:{nested:[ai("group")],condition:null},id:k}]),c("sorted",i.map(({prop:A})=>A))}))},_=M=>m(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:Q()})))},[o,l,d,i,u,h,f,m,p,b,a,_,S,C]}var No=class extends G{constructor(e){super(),K(this,e,z1,H1,V,{conditions:0},W1)}},Bd=No;function q1(n){se(n,"svelte-131x181",".condition-builder-container.svelte-131x181 .setting-item.svelte-131x181{align-items:flex-start}")}function Ld(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, and the plugin parameter, which is a reference to the Fantasy Statblocks plugin and can be used for accessing app and plugin settings.

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&&It(()=>{i&&(t||(t=Jn(e,Ri,{},!0)),t.run(1))}),i=!0)},o(a){a&&(t||(t=Jn(e,Ri,{},!1)),t.run(0)),i=!1},d(a){a&&x(e),a&&t&&t.end()}}}function j1(n){let e,t,i,a,s,r,o,l,c,d,u,h,f=n[1]&&Ld(n);return c=new Bd({props:{conditions:n[2]}}),c.$on("sorted",n[7]),{c(){e=v("div"),t=v("div"),i=v("div"),f&&f.c(),a=R(),s=v("div"),r=v("div"),l=R(),ie(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(m,p){D(m,e,p),y(e,t),y(t,i),f&&f.m(i,null),y(t,a),y(t,s),y(s,r),y(e,l),te(c,e,null),d=!0,u||(h=[J(o=n[4].call(null,r)),q(r,"click",n[6])],u=!0)},p(m,[p]){m[1]?f?p&2&&E(f,1):(f=Ld(m),f.c(),E(f,1),f.m(i,null)):f&&(le(),I(f,1,1,()=>{f=null}),ce())},i(m){d||(E(f),E(c.$$.fragment,m),d=!0)},o(m){I(f),I(c.$$.fragment,m),d=!1},d(m){m&&x(e),f&&f.d(),ne(c),u=!1,oe(h)}}}function V1(n,e,t){let i,{plugin:a}=e,{block:s}=e,r=Le(s.conditions),o=async()=>{t(5,a.settings.hideConditionHelp=!a.settings.hideConditionHelp,a),await a.saveSettings()},l=u=>{new Fd.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 Bo=class extends G{constructor(e){super(),K(this,e,V1,j1,V,{plugin:5,block:0},q1)}},Wd=Bo;var Hn=require("@codemirror/view");var Ho=La(Ds()),Es=class extends Ho.FuzzyInputSuggest{getItemText(e){return e.name}renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item.name,t.match.matches)}},Ms=class extends Ho.FuzzyInputSuggest{renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item,t.match.matches)}getItemText(e){return e}};var Ud=require("obsidian"),_t=class extends Ud.Modal{constructor(t){super(t.app);this.plugin=t;this.modalEl.addClass("fantasy-statblocks-modal"),t.register(()=>this.close())}};function Ps(n,e,t){switch(e.type){case"group":case"inline":return new zo(n,e);case"action":return new Go(n,e);case"collapse":return new qo(n,e);case"ifelse":return new Uo(n,e);case"javascript":return new jo(n,e);case"heading":return new Ko(n,e);case"layout":return new Vo(n,e,t);case"property":return new $o(n,e);case"saves":return new Yo(n,e);case"spells":return new Jo(n,e);case"subheading":return new Xo(n,e);case"table":return new Qo(n,e);case"traits":return new Zo(n,e);case"text":return new el(n,e);default:return new si(n,e)}}var Wn=class extends _t{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 fe.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){}},zo=class extends Wn{async display(){this.contentEl.empty(),new fe.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 fe.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 fe.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 fe.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)})})}},qo=class extends Wn{async display(){this.contentEl.empty(),new fe.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 fe.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 fe.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())}},jo=class extends Wn{async display(){this.contentEl.empty(),new fe.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 fe.TextAreaComponent(this.contentEl).setValue(this.block.code);e.inputEl.addClass("statblock-textarea"),this.editor=Lt(e.inputEl,Hn.EditorView.updateListener.of(t=>{t.docChanged&&(this.block.code=t.state.doc.toString())})),this.buildButtons(this.contentEl.createDiv())}},Vo=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 fe.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())}},Uo=class extends Wn{async display(){this.contentEl.empty(),this.buildConditions(this.contentEl.createDiv()),this.buildButtons(this.contentEl.createDiv())}buildConditions(e){new Wd({target:e,props:{plugin:this.plugin,block:this.block}})}},Os,Gd,Is=class extends Wn{constructor(){super(...arguments);Be(this,Os);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,Os,Gd).call(this,this.advancedEl),this.buildButtons(this.buttonsEl)}onClose(){this.editor?.destroy()}buildProperties(t){}buildSeparator(t){}buildConditions(t){}buildDice(t){}};Os=new WeakSet,Gd=function(t){t.empty(),t.ontoggle=()=>{this.plugin.settings.showAdvanced=t.open,this.plugin.saveSettings()};let i=t.createEl("summary");new fe.Setting(i).setHeading().setName("Advanced Settings"),i.createDiv("collapser").createDiv("handle"),this.buildAdvanced(t.createDiv())};var Go=class extends Is{buildProperties(e){e.empty(),new fe.Setting(e).setName("Icon").setDesc("Choose the icon to use for the button.").addText(t=>{t.setValue(this.block.icon);let i=(0,fe.getIconIds)().map(s=>s.replace(/^lucide-/,""));new Ms(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 fe.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 Es(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 fe.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 fe.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}},si=class extends Is{addPropertyAsCssClassToggleSetting(e){new fe.Setting(e).setName("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(t=>{t.setValue(!this.block.doNotAddClass).onChange(i=>{this.block.doNotAddClass=!i,this.display()})})}buildProperties(e){e.empty();let t=this.block;new fe.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 fe.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"),fe.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 fe.Component),i.createEl("br"),i.createEl("span",{text:"For example: "}),i.createEl("br"),fe.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 fe.Component)}));let t=new fe.TextAreaComponent(e).setValue(this.block.diceCallback);t.inputEl.addClasses(["statblock-textarea","statblock-textarea-small"]),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.diceCallback=i.state.doc.toString())}))}}buildSeparator(e){}buildConditions(e){e.empty();let t=this.block;new fe.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 fe.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 fe.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 fe.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 fe.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})}))}},ri=class extends si{buildAdvanced(e){super.buildAdvanced(e)}},Ko=class extends si{buildProperties(e){super.buildProperties(e),new fe.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))})}},$o=class extends ri{buildAdvanced(e){super.buildAdvanced(e),new fe.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 fe.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}onClose(){this.editor?.destroy()}buildProperties(e){super.buildProperties(e),super.addPropertyAsCssClassToggleSetting(e),new fe.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 ri{buildProperties(e){super.buildProperties(e),super.addPropertyAsCssClassToggleSetting(e),new fe.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)})}buildAdvanced(e){super.buildAdvanced(e),new fe.Setting(e).setHeading().setName("Callback").setDesc(createFragment(i=>{i.createSpan({text:"The block will run the callback on each save object and use the returned object as the save."}),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 an object with a single key and value. For example: "}),i.createEl("code",{text:'return {"fort": property.fortitude}'}),i.createEl("br"),i.createEl("strong",{text:"Please Note: This will not run if a dice callback is provided."})}));let t=new fe.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}},Jo=class extends ri{buildProperties(e){super.buildProperties(e),new fe.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)})}},Xo=class extends si{buildProperties(e){e.empty();let t=this.block,i=e.createDiv("statblock-additional-container"),a="";new fe.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 fe.Notice("A valid property must be supplied.");return}t.properties.push(a),this.buildProperties(e)}));let s=i.createDiv("additional");new Dd({target:s,props:{properties:this.block.properties.map(o=>({prop:o,id:Q()}))}}).$on("sorted",o=>{t.properties=[...o.detail]})}buildSeparator(e){e.empty(),new fe.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})})}},Qo=class extends si{buildAdvanced(e){super.buildAdvanced(e),new fe.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 fe.TextAreaComponent(e).setValue(this.block.modifier);t.inputEl.addClasses(["statblock-textarea","statblock-textarea-small"]),this.editor=Lt(t.inputEl,Hn.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 fe.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 fe.Notice("A valid property must be supplied.");return}this.block.headers.push(i),this.buildProperties(e)}));let a=t.createDiv("additional");new Cd({target:a,props:{headers:this.block.headers}}).$on("sorted",s=>{this.block.headers=[...s.detail?.map(r=>r.name)??[]]}),new fe.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})}),super.addPropertyAsCssClassToggleSetting(e)}},Zo=class extends ri{buildProperties(e){super.buildProperties(e),super.addPropertyAsCssClassToggleSetting(e),new fe.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 fe.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 fe.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 fe.TextAreaComponent(this.contentEl).setValue(this.block.subheadingText).onChange(i=>this.block.subheadingText=i)}buildAdvanced(e){super.buildAdvanced(e),new fe.Setting(e).setHeading().setName("Callback").setDesc(createFragment(i=>{i.createSpan({text:"The block will run the callback on each trait and use the returned string as the trait description."}),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 fe.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}},el=class extends ri{buildAdvanced(e){super.buildAdvanced(e),new fe.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 fe.TextAreaComponent(e).setValue(this.block.text).onChange(t=>{this.block.text=t})}buildProperties(e){super.buildProperties(e),new fe.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 fe.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 n0(n){se(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 i0(n){let e,t;return e=new kd({props:{block:n[0],plugin:n[1]}}),{c(){ie(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 a0(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 Kd(n){let e,t,i,a,s=[a0,i0],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"),re(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&&(le(),I(r[d],1,1,()=>{r[d]=null}),ce()),~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)&&re(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 s0(n){let e,t=n[0],i,a,s,r,o,l,c,d,u,h,f=Kd(n);return{c(){e=v("div"),f.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(m,p){D(m,e,p),f.m(e,null),y(e,i),y(e,a),y(a,s),y(a,o),y(a,l),d=!0,u||(h=[J(r=n[2].call(null,s)),J(c=n[3].call(null,l))],u=!0)},p(m,[p]){p&1&&V(t,t=m[0])?(le(),I(f,1,1,N),ce(),f=Kd(m),f.c(),E(f,1),f.m(e,i)):f.p(m,p)},i(m){d||(E(f),d=!0)},o(m){I(f),d=!1},d(m){m&&x(e),f.d(m),u=!1,oe(h)}}}function r0(n,e,t){let{block:i}=e,{plugin:a}=e,{layout:s}=e,r=Me(),o=()=>{let u=Ps(a,i,s);u.onClose=()=>{u.saved&&r("edited",u.block)},u.open()},l=u=>{new Rs.ExtraButtonComponent(u).setIcon("pencil").setTooltip("Edit Block").onClick(()=>{o()})},c=u=>{new Rs.ExtraButtonComponent(u).setIcon("plus").setTooltip("Add Condition").onClick(()=>{})},d=u=>{new Rs.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 tl=class extends G{constructor(e){super(),K(this,e,r0,s0,V,{block:0,plugin:1,layout:4},n0)}},$d=tl;var oi=require("obsidian");function o0(n){se(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 Yd(n,e,t){let i=n.slice();return i[32]=e[t],i[33]=e,i[34]=t,i}function Jd(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 Xd(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=[J(i=Fe.call(null,e,"grip-vertical")),q(e,"mousedown",n[8]),q(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,oe(s)}}}function l0(n){let e,t,i;return t=new $d({props:{plugin:n[1],block:n[32],layout:n[2]}}),t.$on("trash",n[28]),t.$on("edited",n[29]),{c(){e=v("div"),ie(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 c0(n){let e,t,i,a,s,r,o,l,c,d,u=n[32].icon&&Qd(n);function h(){return n[26](n[32])}function f(){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(m,p){D(m,e,p),u&&u.m(e,null),y(e,t),y(e,i),y(i,a),y(i,r),y(i,o),c||(d=[J(s=n[13].call(null,a)),q(a,"click",h),J(l=n[14].call(null,o)),q(o,"click",f)],c=!0)},p(m,p){n=m,n[32].icon?u?u.p(n,p):(u=Qd(n),u.c(),u.m(e,t)):u&&(u.d(1),u=null)},i:N,o:N,d(m){m&&x(e),u&&u.d(),c=!1,oe(d)}}}function u0(n){let e,t,i,a,s=[],r=new Map,o,l,c,d,u,h,f,m,p,b,_=be(n[32].conditions),S=w=>w[35];for(let w=0;w<_.length;w+=1){let k=Jd(n,_,w),A=S(k);r.set(A,s[w]=Zd(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;wWt(c,"blocks",B)),Re.push(()=>Wt(c,"plugin",L));function j(){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(),ie(c.$$.fragment),h=R(),f=v("div"),m=v("div"),b=R(),_=v("div"),g(o,"class","collapsible svelte-1swdhxf"),g(i,"class","statblock-creator-block collapse-container svelte-1swdhxf"),g(m,"class","icon svelte-1swdhxf"),g(_,"class","icon svelte-1swdhxf"),g(f,"class","icons svelte-1swdhxf"),g(t,"class","statblock-creator-container svelte-1swdhxf"),g(e,"class","item svelte-1swdhxf")},m(ee,ae){D(ee,e,ae),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,f),y(f,m),y(f,b),y(f,_),C=!0,M||(w=[J(s=Fe.call(null,a,"chevrons-down-up")),J(p=n[13].call(null,m)),q(m,"click",j),J(S=n[14].call(null,_)),q(_,"click",Z)],M=!0)},p(ee,ae){n=ee,A===(A=k(n,ae))&&P?P.p(n,ae):(P.d(1),P=A(n),P&&(P.c(),P.m(o,l)));let $={};!d&&ae[0]&1&&(d=!0,$.blocks=n[32].nested,Ft(()=>d=!1)),!u&&ae[0]&2&&(u=!0,$.plugin=n[1],Ft(()=>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,oe(w)}}}function h0(n){let e,t,i,a,s,r=n[32],o,l;function c(f){n[16](f,n[32])}function d(f){n[17](f)}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 Bi({props:u}),Re.push(()=>Wt(t,"blocks",c)),Re.push(()=>Wt(t,"plugin",d));let h=eh(n);return{c(){e=v("div"),ie(t.$$.fragment),s=R(),h.c(),o=_e(),g(e,"class","item svelte-1swdhxf"),re(e,"group",n[32].type=="group"||n[32].type=="inline")},m(f,m){D(f,e,m),te(t,e,null),D(f,s,m),h.m(f,m),D(f,o,m),l=!0},p(f,m){n=f;let p={};m[0]&1&&(p.inline=n[32].type=="inline"),!i&&m[0]&1&&(i=!0,p.blocks=n[32].nested,Ft(()=>i=!1)),!a&&m[0]&2&&(a=!0,p.plugin=n[1],Ft(()=>a=!1)),t.$set(p),(!l||m[0]&1)&&re(e,"group",n[32].type=="group"||n[32].type=="inline"),m[0]&1&&V(r,r=n[32])?(h.d(1),h=eh(n),h.c(),h.m(o.parentNode,o)):h.p(n,m)},i(f){l||(E(t.$$.fragment,f),l=!0)},o(f){I(t.$$.fragment,f),l=!1},d(f){f&&(x(e),x(s),x(o)),ne(t),h.d(f)}}}function Qd(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=J(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 Zd(n,e){let t,i,a,s,r=e[35]+"",o,l,c,d,u,h,f;function m(_){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 Bi({props:b}),Re.push(()=>Wt(c,"blocks",m)),Re.push(()=>Wt(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(),ie(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),f=!0},p(_,S){e=_,(!f||S[0]&1)&&r!==(r=e[35]+"")&&we(o,r);let C={};!d&&S[0]&1&&(d=!0,C.blocks=e[36],Ft(()=>d=!1)),!u&&S[0]&2&&(u=!0,C.plugin=e[1],Ft(()=>u=!1)),c.$set(C)},i(_){f||(E(c.$$.fragment,_),f=!0)},o(_){I(c.$$.fragment,_),f=!1},d(_){_&&x(t),ne(c)}}}function f0(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 m0(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 eh(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=J(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 th(n){let e,t,i;return t=new os({}),{c(){e=v("div"),ie(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 nh(n,e){let t,i,a,s,r,o,l,c,d,u=N,h,f=e[3]&&Xd(e),m=[h0,d0,u0,c0,l0],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]=m[r](e);let _="hasRule"in e[32]&&e[32].hasRule&&th(e);return{key:n,first:null,c(){t=v("div"),i=v("div"),a=v("div"),f&&f.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),f&&f.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]?f?f.p(e,C):(f=Xd(e),f.c(),f.m(a,s)):f&&(f.d(1),f=null);let M=r;r=b(e,C),r===M?p[r].p(e,C):(le(),I(p[M],1,1,()=>{p[M]=null}),ce(),o=p[r],o?o.p(e,C):(o=p[r]=m[r](e),o.c()),E(o,1),o.m(a,null)),"hasRule"in e[32]&&e[32].hasRule?_?C[0]&1&&E(_,1):(_=th(e),_.c(),E(_,1),_.m(i,null)):_&&(le(),I(_,1,1,()=>{_=null}),ce())},r(){d=t.getBoundingClientRect()},f(){Dn(t),u()},a(){u(),u=Tn(t,d,Pn,{duration:nl})},i(S){h||(E(o),E(_),h=!0)},o(S){I(o),I(_),h=!1},d(S){S&&x(t),f&&f.d(),p[r].d(),_&&_.d()}}}function g0(n){let e,t,i=[],a=new Map,s,r,o,l,c=be(n[0].filter(n[15])),d=u=>u[32].id;for(let u=0;u{t(0,a=a.filter(H=>H.id!=F.id)),i("sorted",a)},m=F=>{let H=a.findIndex(he=>he.id==F.id);a.splice(H,1,F),t(0,a)},p=F=>{let H=Ps(l,F,s);H.onClose=()=>{H.saved&&m(H.block)},H.open()},b=async(F,H)=>{if(!("nested"in F))return;let he=new oi.Menu().setNoIcon();oa.forEach(ue=>{if(ue[1]=="separator"){he.addSeparator();return}he.addItem(U=>{U.setTitle(ue[1]).onClick(()=>{let z=ai(ue[0]);z&&(F.nested=[...F.nested,z],t(0,a),i("sorted",a))})})}),he.showAtMouseEvent(H)},_=(F,H)=>{new oi.ExtraButtonComponent(F).setIcon(r?"vertical-three-dots":"plus-circle"),F.onclick=he=>{r?new oi.Menu().addItem(ue=>{ue.setTitle("Add").setIcon("plus-with-circle").onClick(U=>{b(H,he)})}).addItem(ue=>ue.setTitle("Edit").setIcon("pencil").onClick(()=>{p(H)})).addItem(ue=>ue.setTitle("Delete").setIcon("trash").onClick(()=>f(H))).showAtMouseEvent(he):b(H,he)}},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!==ii;function w(F,H){n.$$.not_equal(H.nested,F)&&(H.nested=F,t(0,a))}function k(F){l=F,t(1,l)}function A(F,H){n.$$.not_equal(H.nested,F)&&(H.nested=F,t(0,a))}function P(F){l=F,t(1,l)}let B=F=>p(F),L=F=>f(F);function O(F,H,he,ue){he[ue].nested=F,t(0,a)}function j(F){l=F,t(1,l)}let Z=F=>p(F),ee=F=>f(F),ae=F=>p(F),$=F=>f(F),W=F=>f(F.detail),Y=F=>m(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,f,m,p,_,S,C,M,w,k,A,P,B,L,O,j,Z,ee,ae,$,W,Y]}var Bi=class extends G{constructor(e){super(),K(this,e,p0,g0,V,{blocks:0,layout:2,draggable:3,inline:4,plugin:1},o0,[-1,-1])}},ih=Bi;var Ns=require("obsidian");function At(n){return Ue(n)}function li(n,e){return Mt(n,e)}function b0(n){let e,t,i,a,s,r,o,l;return s=new ih({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(),ie(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=J(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 y0(n,e,t){let i,a,s=At("layout");Se(n,s,d=>t(0,a=d));let r=At("plugin"),o=d=>{Ae(s,a.blocks=[...d.detail],a)},l=d=>{new Ns.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 Ns.Menu().setNoIcon();oa.forEach(h=>{if(h[1]=="separator"){u.addSeparator();return}u.addItem(f=>{f.setTitle(h[1]).onClick(()=>{let m=ai(h[0]);m&&Ae(s,a.blocks=[...a.blocks,m],a)})})}),u.showAtMouseEvent(d)};return n.$$.update=()=>{n.$$.dirty&1&&t(1,i=a.blocks)},[a,i,s,r,o,l]}var il=class extends G{constructor(e){super(),K(this,e,y0,b0,V,{})}},al=il;var ka=require("obsidian");var ya=require("obsidian");function v0(n){se(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 ah(n,e,t){let i=n.slice();return i[15]=e[t],i}function sh(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=[J(i=Fe.call(null,e,"grip-vertical")),q(e,"mousedown",n[6]),q(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,oe(s)}}}function rh(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=[J(i=n[9].call(null,t,n[15])),J(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,oe(l)}}}function oh(n,e){let t,i,a,s,r,o,l,c=N,d,u=e[2]&&sh(e);var h=e[4];function f(p,b){return{props:{item:p[15]}}}h&&(s=xr(h,f(e)));let m=e[3]&&rh(e);return{key:n,first:null,c(){t=v("div"),u&&u.c(),i=R(),a=v("div"),s&&ie(s.$$.fragment),r=R(),m&&m.c(),o=R(),g(a,"class","drop-item"),re(a,"type",e[1]),g(t,"class","drop-item-container svelte-1cgghnt"),re(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),m&&m.m(t,null),y(t,o),d=!0},p(p,b){if(e=p,e[2]?u?u.p(e,b):(u=sh(e),u.c(),u.m(t,i)):u&&(u.d(1),u=null),b&16&&h!==(h=e[4])){if(s){le();let _=s;I(_.$$.fragment,1,0,()=>{ne(_,1)}),ce()}h?(s=xr(h,f(e,b)),ie(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)&&re(a,"type",e[1]),e[3]?m?m.p(e,b):(m=rh(e),m.c(),m.m(t,o)):m&&(m.d(1),m=null),(!d||b&4)&&re(t,"draggable",e[2])},r(){l=t.getBoundingClientRect()},f(){Dn(t),c()},a(){c(),c=Tn(t,l,Pn,{duration:sl})},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),m&&m.d()}}}function k0(n){let e,t=[],i=new Map,a,s,r,o,l=be(n[0].filter(n[12])),c=d=>d[15].id;for(let d=0;d{new ya.ExtraButtonComponent(S).setIcon("wrench").onClick(()=>c("advanced",C))},b=(S,C)=>{new ya.ExtraButtonComponent(S).setIcon("trash").onClick(()=>c("trash",C))},_=S=>S.id!==ii;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,f,m,p,b,l,_]}var rl=class extends G{constructor(e){super(),K(this,e,w0,k0,V,{items:0,type:1,draggable:2,showIcons:3,component:4,onDrop:11},v0)}},lh=rl;function ch(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 _0(n){let e,t,i,a,s=n[0].regex+"",r,o,l,c=n[0].desc&&ch(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=ch(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 S0(n,e,t){let{item:i}=e;return n.$$set=a=>{"item"in a&&t(0,i=a.item)},[i]}var ol=class extends G{constructor(e){super(),K(this,e,S0,_0,V,{item:0})}},uh=ol;var en=require("obsidian");var va=class extends _t{constructor(t,i){super(t);this.item={regex:"",parser:"",id:Q()};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 en.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 en.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 en.Setting(t).setHeading().setName("Regular Expression").setDesc(""),this.regex=ba(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:"}),en.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 en.Component),t.createEl("br"),t.createEl("span",{text:"For example: "}),t.createEl("br"),en.MarkdownRenderer.render(this.plugin.app,'```ts\nreturn { text: "1d20 + 3" };\n```',t.createDiv(),"",new en.Component)})}buildParser(t){t.empty();let i=new en.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=ba(t,this.item.parser,[],a=>{this.item.parser=a})}};function C0(n){se(n,"svelte-tnyfuy",".defaults.svelte-tnyfuy{color:var(--text-muted);font-style:italic;font-size:smaller}")}function x0(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 + example: return monster.ac > 1`,g(e,"class","setting-item-description")},m(a,s){D(a,e,s),i=!0},i(a){i||(a&&It(()=>{i&&(t||(t=Jn(e,Ri,{},!0)),t.run(1))}),i=!0)},o(a){a&&(t||(t=Jn(e,Ri,{},!1)),t.run(0)),i=!1},d(a){a&&x(e),a&&t&&t.end()}}}function j1(n){let e,t,i,a,s,r,o,l,c,d,u,h,f=n[1]&&Ld(n);return c=new Bd({props:{conditions:n[2]}}),c.$on("sorted",n[7]),{c(){e=v("div"),t=v("div"),i=v("div"),f&&f.c(),a=R(),s=v("div"),r=v("div"),l=R(),ie(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(m,p){D(m,e,p),y(e,t),y(t,i),f&&f.m(i,null),y(t,a),y(t,s),y(s,r),y(e,l),te(c,e,null),d=!0,u||(h=[J(o=n[4].call(null,r)),q(r,"click",n[6])],u=!0)},p(m,[p]){m[1]?f?p&2&&E(f,1):(f=Ld(m),f.c(),E(f,1),f.m(i,null)):f&&(le(),I(f,1,1,()=>{f=null}),ce())},i(m){d||(E(f),E(c.$$.fragment,m),d=!0)},o(m){I(f),I(c.$$.fragment,m),d=!1},d(m){m&&x(e),f&&f.d(),ne(c),u=!1,oe(h)}}}function V1(n,e,t){let i,{plugin:a}=e,{block:s}=e,r=Le(s.conditions),o=async()=>{t(5,a.settings.hideConditionHelp=!a.settings.hideConditionHelp,a),await a.saveSettings()},l=u=>{new Fd.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 Bo=class extends G{constructor(e){super(),K(this,e,V1,j1,V,{plugin:5,block:0},q1)}},Wd=Bo;var Hn=require("@codemirror/view");var Ho=La(Es()),Ms=class extends Ho.FuzzyInputSuggest{getItemText(e){return e.name}renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item.name,t.match.matches)}},Is=class extends Ho.FuzzyInputSuggest{renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item,t.match.matches)}getItemText(e){return e}};var Ud=require("obsidian"),_t=class extends Ud.Modal{constructor(t){super(t.app);this.plugin=t;this.modalEl.addClass("fantasy-statblocks-modal"),t.register(()=>this.close())}};function Rs(n,e,t){switch(e.type){case"group":case"inline":return new zo(n,e);case"action":return new Go(n,e);case"collapse":return new qo(n,e);case"ifelse":return new Uo(n,e);case"javascript":return new jo(n,e);case"heading":return new Ko(n,e);case"layout":return new Vo(n,e,t);case"property":return new $o(n,e);case"saves":return new Yo(n,e);case"spells":return new Jo(n,e);case"subheading":return new Xo(n,e);case"table":return new Qo(n,e);case"traits":return new Zo(n,e);case"text":return new el(n,e);default:return new si(n,e)}}var Wn=class extends _t{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 fe.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){}},zo=class extends Wn{async display(){this.contentEl.empty(),new fe.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 fe.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 fe.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 fe.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)})})}},qo=class extends Wn{async display(){this.contentEl.empty(),new fe.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 fe.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 fe.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())}},jo=class extends Wn{async display(){this.contentEl.empty(),new fe.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 fe.TextAreaComponent(this.contentEl).setValue(this.block.code);e.inputEl.addClass("statblock-textarea"),this.editor=Lt(e.inputEl,Hn.EditorView.updateListener.of(t=>{t.docChanged&&(this.block.code=t.state.doc.toString())})),this.buildButtons(this.contentEl.createDiv())}},Vo=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 fe.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())}},Uo=class extends Wn{async display(){this.contentEl.empty(),this.buildConditions(this.contentEl.createDiv()),this.buildButtons(this.contentEl.createDiv())}buildConditions(e){new Wd({target:e,props:{plugin:this.plugin,block:this.block}})}},Ps,Gd,Os=class extends Wn{constructor(){super(...arguments);Be(this,Ps);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,Ps,Gd).call(this,this.advancedEl),this.buildButtons(this.buttonsEl)}onClose(){this.editor?.destroy()}buildProperties(t){}buildSeparator(t){}buildConditions(t){}buildDice(t){}};Ps=new WeakSet,Gd=function(t){t.empty(),t.ontoggle=()=>{this.plugin.settings.showAdvanced=t.open,this.plugin.saveSettings()};let i=t.createEl("summary");new fe.Setting(i).setHeading().setName("Advanced Settings"),i.createDiv("collapser").createDiv("handle"),this.buildAdvanced(t.createDiv())};var Go=class extends Os{buildProperties(e){e.empty(),new fe.Setting(e).setName("Icon").setDesc("Choose the icon to use for the button.").addText(t=>{t.setValue(this.block.icon);let i=(0,fe.getIconIds)().map(s=>s.replace(/^lucide-/,""));new Is(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 fe.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 Ms(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 fe.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 fe.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}},si=class extends Os{addPropertyAsCssClassToggleSetting(e){new fe.Setting(e).setName("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(t=>{t.setValue(!this.block.doNotAddClass).onChange(i=>{this.block.doNotAddClass=!i,this.display()})})}buildProperties(e){e.empty();let t=this.block;new fe.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 fe.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"),fe.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 fe.Component),i.createEl("br"),i.createEl("span",{text:"For example: "}),i.createEl("br"),fe.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 fe.Component)}));let t=new fe.TextAreaComponent(e).setValue(this.block.diceCallback);t.inputEl.addClasses(["statblock-textarea","statblock-textarea-small"]),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.diceCallback=i.state.doc.toString())}))}}buildSeparator(e){}buildConditions(e){e.empty();let t=this.block;new fe.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 fe.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 fe.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 fe.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 fe.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})}))}},ri=class extends si{buildAdvanced(e){super.buildAdvanced(e)}},Ko=class extends si{buildProperties(e){super.buildProperties(e),new fe.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))})}},$o=class extends ri{buildAdvanced(e){super.buildAdvanced(e),new fe.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 fe.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}onClose(){this.editor?.destroy()}buildProperties(e){super.buildProperties(e),super.addPropertyAsCssClassToggleSetting(e),new fe.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 ri{buildProperties(e){super.buildProperties(e),super.addPropertyAsCssClassToggleSetting(e),new fe.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)})}buildAdvanced(e){super.buildAdvanced(e),new fe.Setting(e).setHeading().setName("Callback").setDesc(createFragment(i=>{i.createSpan({text:"The block will run the callback on each save object and use the returned object as the save."}),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 an object with a single key and value. For example: "}),i.createEl("code",{text:'return {"fort": property.fortitude}'}),i.createEl("br"),i.createEl("strong",{text:"Please Note: This will not run if a dice callback is provided."})}));let t=new fe.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}},Jo=class extends ri{buildProperties(e){super.buildProperties(e),new fe.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)})}},Xo=class extends si{buildProperties(e){e.empty();let t=this.block,i=e.createDiv("statblock-additional-container"),a="";new fe.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 fe.Notice("A valid property must be supplied.");return}t.properties.push(a),this.buildProperties(e)}));let s=i.createDiv("additional");new Dd({target:s,props:{properties:this.block.properties.map(o=>({prop:o,id:Q()}))}}).$on("sorted",o=>{t.properties=[...o.detail]})}buildSeparator(e){e.empty(),new fe.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})})}},Qo=class extends si{buildAdvanced(e){super.buildAdvanced(e),new fe.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 fe.TextAreaComponent(e).setValue(this.block.modifier);t.inputEl.addClasses(["statblock-textarea","statblock-textarea-small"]),this.editor=Lt(t.inputEl,Hn.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 fe.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 fe.Notice("A valid property must be supplied.");return}this.block.headers.push(i),this.buildProperties(e)}));let a=t.createDiv("additional");new Cd({target:a,props:{headers:this.block.headers}}).$on("sorted",s=>{this.block.headers=[...s.detail?.map(r=>r.name)??[]]}),new fe.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})}),super.addPropertyAsCssClassToggleSetting(e)}},Zo=class extends ri{buildProperties(e){super.buildProperties(e),super.addPropertyAsCssClassToggleSetting(e),new fe.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 fe.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 fe.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 fe.TextAreaComponent(this.contentEl).setValue(this.block.subheadingText).onChange(i=>this.block.subheadingText=i)}buildAdvanced(e){super.buildAdvanced(e),new fe.Setting(e).setHeading().setName("Callback").setDesc(createFragment(i=>{i.createSpan({text:"The block will run the callback on each trait and use the returned string as the trait description."}),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 fe.TextAreaComponent(e).setValue(this.block.callback);t.inputEl.addClass("statblock-textarea"),this.editor=Lt(t.inputEl,Hn.EditorView.updateListener.of(i=>{i.docChanged&&(this.block.callback=i.state.doc.toString())}))}},el=class extends ri{buildAdvanced(e){super.buildAdvanced(e),new fe.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 fe.TextAreaComponent(e).setValue(this.block.text).onChange(t=>{this.block.text=t})}buildProperties(e){super.buildProperties(e),new fe.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 fe.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 n0(n){se(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 i0(n){let e,t;return e=new kd({props:{block:n[0],plugin:n[1]}}),{c(){ie(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 a0(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 Kd(n){let e,t,i,a,s=[a0,i0],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"),re(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&&(le(),I(r[d],1,1,()=>{r[d]=null}),ce()),~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)&&re(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 s0(n){let e,t=n[0],i,a,s,r,o,l,c,d,u,h,f=Kd(n);return{c(){e=v("div"),f.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(m,p){D(m,e,p),f.m(e,null),y(e,i),y(e,a),y(a,s),y(a,o),y(a,l),d=!0,u||(h=[J(r=n[2].call(null,s)),J(c=n[3].call(null,l))],u=!0)},p(m,[p]){p&1&&V(t,t=m[0])?(le(),I(f,1,1,N),ce(),f=Kd(m),f.c(),E(f,1),f.m(e,i)):f.p(m,p)},i(m){d||(E(f),d=!0)},o(m){I(f),d=!1},d(m){m&&x(e),f.d(m),u=!1,oe(h)}}}function r0(n,e,t){let{block:i}=e,{plugin:a}=e,{layout:s}=e,r=Me(),o=()=>{let u=Rs(a,i,s);u.onClose=()=>{u.saved&&r("edited",u.block)},u.open()},l=u=>{new Ns.ExtraButtonComponent(u).setIcon("pencil").setTooltip("Edit Block").onClick(()=>{o()})},c=u=>{new Ns.ExtraButtonComponent(u).setIcon("plus").setTooltip("Add Condition").onClick(()=>{})},d=u=>{new Ns.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 tl=class extends G{constructor(e){super(),K(this,e,r0,s0,V,{block:0,plugin:1,layout:4},n0)}},$d=tl;var oi=require("obsidian");function o0(n){se(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 Yd(n,e,t){let i=n.slice();return i[32]=e[t],i[33]=e,i[34]=t,i}function Jd(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 Xd(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=[J(i=Fe.call(null,e,"grip-vertical")),q(e,"mousedown",n[8]),q(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,oe(s)}}}function l0(n){let e,t,i;return t=new $d({props:{plugin:n[1],block:n[32],layout:n[2]}}),t.$on("trash",n[28]),t.$on("edited",n[29]),{c(){e=v("div"),ie(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 c0(n){let e,t,i,a,s,r,o,l,c,d,u=n[32].icon&&Qd(n);function h(){return n[26](n[32])}function f(){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(m,p){D(m,e,p),u&&u.m(e,null),y(e,t),y(e,i),y(i,a),y(i,r),y(i,o),c||(d=[J(s=n[13].call(null,a)),q(a,"click",h),J(l=n[14].call(null,o)),q(o,"click",f)],c=!0)},p(m,p){n=m,n[32].icon?u?u.p(n,p):(u=Qd(n),u.c(),u.m(e,t)):u&&(u.d(1),u=null)},i:N,o:N,d(m){m&&x(e),u&&u.d(),c=!1,oe(d)}}}function u0(n){let e,t,i,a,s=[],r=new Map,o,l,c,d,u,h,f,m,p,b,_=be(n[32].conditions),S=w=>w[35];for(let w=0;w<_.length;w+=1){let k=Jd(n,_,w),A=S(k);r.set(A,s[w]=Zd(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;wWt(c,"blocks",B)),Re.push(()=>Wt(c,"plugin",L));function j(){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(),ie(c.$$.fragment),h=R(),f=v("div"),m=v("div"),b=R(),_=v("div"),g(o,"class","collapsible svelte-1swdhxf"),g(i,"class","statblock-creator-block collapse-container svelte-1swdhxf"),g(m,"class","icon svelte-1swdhxf"),g(_,"class","icon svelte-1swdhxf"),g(f,"class","icons svelte-1swdhxf"),g(t,"class","statblock-creator-container svelte-1swdhxf"),g(e,"class","item svelte-1swdhxf")},m(ee,ae){D(ee,e,ae),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,f),y(f,m),y(f,b),y(f,_),C=!0,M||(w=[J(s=Fe.call(null,a,"chevrons-down-up")),J(p=n[13].call(null,m)),q(m,"click",j),J(S=n[14].call(null,_)),q(_,"click",Z)],M=!0)},p(ee,ae){n=ee,A===(A=k(n,ae))&&P?P.p(n,ae):(P.d(1),P=A(n),P&&(P.c(),P.m(o,l)));let $={};!d&&ae[0]&1&&(d=!0,$.blocks=n[32].nested,Ft(()=>d=!1)),!u&&ae[0]&2&&(u=!0,$.plugin=n[1],Ft(()=>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,oe(w)}}}function h0(n){let e,t,i,a,s,r=n[32],o,l;function c(f){n[16](f,n[32])}function d(f){n[17](f)}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 Bi({props:u}),Re.push(()=>Wt(t,"blocks",c)),Re.push(()=>Wt(t,"plugin",d));let h=eh(n);return{c(){e=v("div"),ie(t.$$.fragment),s=R(),h.c(),o=_e(),g(e,"class","item svelte-1swdhxf"),re(e,"group",n[32].type=="group"||n[32].type=="inline")},m(f,m){D(f,e,m),te(t,e,null),D(f,s,m),h.m(f,m),D(f,o,m),l=!0},p(f,m){n=f;let p={};m[0]&1&&(p.inline=n[32].type=="inline"),!i&&m[0]&1&&(i=!0,p.blocks=n[32].nested,Ft(()=>i=!1)),!a&&m[0]&2&&(a=!0,p.plugin=n[1],Ft(()=>a=!1)),t.$set(p),(!l||m[0]&1)&&re(e,"group",n[32].type=="group"||n[32].type=="inline"),m[0]&1&&V(r,r=n[32])?(h.d(1),h=eh(n),h.c(),h.m(o.parentNode,o)):h.p(n,m)},i(f){l||(E(t.$$.fragment,f),l=!0)},o(f){I(t.$$.fragment,f),l=!1},d(f){f&&(x(e),x(s),x(o)),ne(t),h.d(f)}}}function Qd(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=J(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 Zd(n,e){let t,i,a,s,r=e[35]+"",o,l,c,d,u,h,f;function m(_){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 Bi({props:b}),Re.push(()=>Wt(c,"blocks",m)),Re.push(()=>Wt(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(),ie(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),f=!0},p(_,S){e=_,(!f||S[0]&1)&&r!==(r=e[35]+"")&&we(o,r);let C={};!d&&S[0]&1&&(d=!0,C.blocks=e[36],Ft(()=>d=!1)),!u&&S[0]&2&&(u=!0,C.plugin=e[1],Ft(()=>u=!1)),c.$set(C)},i(_){f||(E(c.$$.fragment,_),f=!0)},o(_){I(c.$$.fragment,_),f=!1},d(_){_&&x(t),ne(c)}}}function f0(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 m0(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 eh(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=J(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 th(n){let e,t,i;return t=new os({}),{c(){e=v("div"),ie(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 nh(n,e){let t,i,a,s,r,o,l,c,d,u=N,h,f=e[3]&&Xd(e),m=[h0,d0,u0,c0,l0],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]=m[r](e);let _="hasRule"in e[32]&&e[32].hasRule&&th(e);return{key:n,first:null,c(){t=v("div"),i=v("div"),a=v("div"),f&&f.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),f&&f.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]?f?f.p(e,C):(f=Xd(e),f.c(),f.m(a,s)):f&&(f.d(1),f=null);let M=r;r=b(e,C),r===M?p[r].p(e,C):(le(),I(p[M],1,1,()=>{p[M]=null}),ce(),o=p[r],o?o.p(e,C):(o=p[r]=m[r](e),o.c()),E(o,1),o.m(a,null)),"hasRule"in e[32]&&e[32].hasRule?_?C[0]&1&&E(_,1):(_=th(e),_.c(),E(_,1),_.m(i,null)):_&&(le(),I(_,1,1,()=>{_=null}),ce())},r(){d=t.getBoundingClientRect()},f(){Dn(t),u()},a(){u(),u=Tn(t,d,Pn,{duration:nl})},i(S){h||(E(o),E(_),h=!0)},o(S){I(o),I(_),h=!1},d(S){S&&x(t),f&&f.d(),p[r].d(),_&&_.d()}}}function g0(n){let e,t,i=[],a=new Map,s,r,o,l,c=be(n[0].filter(n[15])),d=u=>u[32].id;for(let u=0;u{t(0,a=a.filter(H=>H.id!=F.id)),i("sorted",a)},m=F=>{let H=a.findIndex(he=>he.id==F.id);a.splice(H,1,F),t(0,a)},p=F=>{let H=Rs(l,F,s);H.onClose=()=>{H.saved&&m(H.block)},H.open()},b=async(F,H)=>{if(!("nested"in F))return;let he=new oi.Menu().setNoIcon();oa.forEach(ue=>{if(ue[1]=="separator"){he.addSeparator();return}he.addItem(U=>{U.setTitle(ue[1]).onClick(()=>{let z=ai(ue[0]);z&&(F.nested=[...F.nested,z],t(0,a),i("sorted",a))})})}),he.showAtMouseEvent(H)},_=(F,H)=>{new oi.ExtraButtonComponent(F).setIcon(r?"vertical-three-dots":"plus-circle"),F.onclick=he=>{r?new oi.Menu().addItem(ue=>{ue.setTitle("Add").setIcon("plus-with-circle").onClick(U=>{b(H,he)})}).addItem(ue=>ue.setTitle("Edit").setIcon("pencil").onClick(()=>{p(H)})).addItem(ue=>ue.setTitle("Delete").setIcon("trash").onClick(()=>f(H))).showAtMouseEvent(he):b(H,he)}},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!==ii;function w(F,H){n.$$.not_equal(H.nested,F)&&(H.nested=F,t(0,a))}function k(F){l=F,t(1,l)}function A(F,H){n.$$.not_equal(H.nested,F)&&(H.nested=F,t(0,a))}function P(F){l=F,t(1,l)}let B=F=>p(F),L=F=>f(F);function O(F,H,he,ue){he[ue].nested=F,t(0,a)}function j(F){l=F,t(1,l)}let Z=F=>p(F),ee=F=>f(F),ae=F=>p(F),$=F=>f(F),W=F=>f(F.detail),Y=F=>m(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,f,m,p,_,S,C,M,w,k,A,P,B,L,O,j,Z,ee,ae,$,W,Y]}var Bi=class extends G{constructor(e){super(),K(this,e,p0,g0,V,{blocks:0,layout:2,draggable:3,inline:4,plugin:1},o0,[-1,-1])}},ih=Bi;var Bs=require("obsidian");function At(n){return Ue(n)}function li(n,e){return Mt(n,e)}function b0(n){let e,t,i,a,s,r,o,l;return s=new ih({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(),ie(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=J(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 y0(n,e,t){let i,a,s=At("layout");Se(n,s,d=>t(0,a=d));let r=At("plugin"),o=d=>{Ae(s,a.blocks=[...d.detail],a)},l=d=>{new Bs.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 Bs.Menu().setNoIcon();oa.forEach(h=>{if(h[1]=="separator"){u.addSeparator();return}u.addItem(f=>{f.setTitle(h[1]).onClick(()=>{let m=ai(h[0]);m&&Ae(s,a.blocks=[...a.blocks,m],a)})})}),u.showAtMouseEvent(d)};return n.$$.update=()=>{n.$$.dirty&1&&t(1,i=a.blocks)},[a,i,s,r,o,l]}var il=class extends G{constructor(e){super(),K(this,e,y0,b0,V,{})}},al=il;var ka=require("obsidian");var ya=require("obsidian");function v0(n){se(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 ah(n,e,t){let i=n.slice();return i[15]=e[t],i}function sh(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=[J(i=Fe.call(null,e,"grip-vertical")),q(e,"mousedown",n[6]),q(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,oe(s)}}}function rh(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=[J(i=n[9].call(null,t,n[15])),J(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,oe(l)}}}function oh(n,e){let t,i,a,s,r,o,l,c=N,d,u=e[2]&&sh(e);var h=e[4];function f(p,b){return{props:{item:p[15]}}}h&&(s=Ar(h,f(e)));let m=e[3]&&rh(e);return{key:n,first:null,c(){t=v("div"),u&&u.c(),i=R(),a=v("div"),s&&ie(s.$$.fragment),r=R(),m&&m.c(),o=R(),g(a,"class","drop-item"),re(a,"type",e[1]),g(t,"class","drop-item-container svelte-1cgghnt"),re(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),m&&m.m(t,null),y(t,o),d=!0},p(p,b){if(e=p,e[2]?u?u.p(e,b):(u=sh(e),u.c(),u.m(t,i)):u&&(u.d(1),u=null),b&16&&h!==(h=e[4])){if(s){le();let _=s;I(_.$$.fragment,1,0,()=>{ne(_,1)}),ce()}h?(s=Ar(h,f(e,b)),ie(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)&&re(a,"type",e[1]),e[3]?m?m.p(e,b):(m=rh(e),m.c(),m.m(t,o)):m&&(m.d(1),m=null),(!d||b&4)&&re(t,"draggable",e[2])},r(){l=t.getBoundingClientRect()},f(){Dn(t),c()},a(){c(),c=Tn(t,l,Pn,{duration:sl})},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),m&&m.d()}}}function k0(n){let e,t=[],i=new Map,a,s,r,o,l=be(n[0].filter(n[12])),c=d=>d[15].id;for(let d=0;d{new ya.ExtraButtonComponent(S).setIcon("wrench").onClick(()=>c("advanced",C))},b=(S,C)=>{new ya.ExtraButtonComponent(S).setIcon("trash").onClick(()=>c("trash",C))},_=S=>S.id!==ii;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,f,m,p,b,l,_]}var rl=class extends G{constructor(e){super(),K(this,e,w0,k0,V,{items:0,type:1,draggable:2,showIcons:3,component:4,onDrop:11},v0)}},lh=rl;function ch(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 _0(n){let e,t,i,a,s=n[0].regex+"",r,o,l,c=n[0].desc&&ch(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=ch(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 S0(n,e,t){let{item:i}=e;return n.$$set=a=>{"item"in a&&t(0,i=a.item)},[i]}var ol=class extends G{constructor(e){super(),K(this,e,S0,_0,V,{item:0})}},uh=ol;var en=require("obsidian");var va=class extends _t{constructor(t,i){super(t);this.item={regex:"",parser:"",id:Q()};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 en.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 en.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 en.Setting(t).setHeading().setName("Regular Expression").setDesc(""),this.regex=ba(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:"}),en.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 en.Component),t.createEl("br"),t.createEl("span",{text:"For example: "}),t.createEl("br"),en.MarkdownRenderer.render(this.plugin.app,'```ts\nreturn { text: "1d20 + 3" };\n```',t.createDiv(),"",new en.Component)})}buildParser(t){t.empty();let i=new en.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=ba(t,this.item.parser,[],a=>{this.item.parser=a})}};function C0(n){se(n,"svelte-tnyfuy",".defaults.svelte-tnyfuy{color:var(--text-muted);font-style:italic;font-size:smaller}")}function x0(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=J(t=n[7].call(null,e)),s=!0)},d(o){o&&(x(e),x(i),x(a)),s=!1,r()}}}function A0(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=J(t=n[7].call(null,e)),s=!0)},d(o){o&&(x(e),x(i),x(a)),s=!1,r()}}}function dh(n){let e,t;return e=new lh({props:{type:"dice",component:uh,items:n[1]??is(),onDrop:n[3],showIcons:n[1]!=null,draggable:n[1]!=null}}),e.$on("advanced",n[11]),e.$on("trash",n[12]),{c(){ie(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,a){let s={};a&2&&(s.items=i[1]??is()),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 T0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S,C,M,w,k,A,P,B=n[1],L,O,j;function Z(W,Y){if(!W[1])return A0;if(W[1].length==0)return x0}let ee=Z(n,-1),ae=ee&&ee(n),$=dh(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(),f=v("div"),m=v("div"),m.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"),ae&&ae.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(m,"class","setting-item-info"),g(b,"class","setting-item-control"),g(f,"class","setting-item"),g(A,"class","additional"),g(k,"class","dice-parsing statblock-additional-container")},m(W,Y){D(W,e,Y),y(e,t),y(e,i),y(e,a),y(a,s),ct(s,n[0].columns),D(W,r,Y),D(W,o,Y),y(o,l),y(o,c),y(o,d),y(d,u),ct(u,n[0].columnWidth),D(W,h,Y),D(W,f,Y),y(f,m),y(f,p),y(f,b),D(W,S,Y),D(W,C,Y),D(W,w,Y),D(W,k,Y),y(k,A),ae&&ae.m(A,null),y(A,P),$.m(A,null),L=!0,O||(j=[q(s,"input",n[9]),q(u,"input",n[10]),J(_=n[8].call(null,b)),J(M=n[6].call(null,C))],O=!0)},p(W,[Y]){Y&1&&$n(s.value)!==W[0].columns&&ct(s,W[0].columns),Y&1&&$n(u.value)!==W[0].columnWidth&&ct(u,W[0].columnWidth),ee!==(ee=Z(W,Y))&&(ae&&ae.d(1),ae=ee&&ee(W),ae&&(ae.c(),ae.m(A,P))),Y&2&&V(B,B=W[1])?(le(),I($,1,1,N),ce(),$=dh(W),$.c(),E($,1),$.m(A,null)):$.p(W,Y)},i(W){L||(E($),L=!0)},o(W){I($),L=!1},d(W){W&&(x(e),x(r),x(o),x(h),x(f),x(S),x(C),x(w),x(k)),ae&&ae.d(),$.d(W),O=!1,oe(j)}}}function D0(n,e,t){let i,a,s=At("layout");Se(n,s,_=>t(0,a=_));let r=At("plugin");function o(_){Ae(s,a.diceParsing=[..._],a)}let l=_=>{let S=new va(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 ka.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 ka.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 ka.ToggleComponent(_).setValue(a.forceColumns).onChange(()=>{Ae(s,a.forceColumns=!a.forceColumns,a)})};function f(){a.columns=$n(this.value),s.set(a)}function m(){a.columnWidth=$n(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,f,m,p,b]}var ll=class extends G{constructor(e){super(),K(this,e,D0,T0,V,{},C0)}},cl=ll;var rA=require("obsidian");var fl=require("obsidian");var _a=["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"],ul={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 dl(n,e,t){let i=new Set,a=Li(n,e,t);for(;_a.includes(a)&&!i.has(a);)i.add(a),a=Li(n,a,t);return i}function hh(n,e,t){let i=Li(n,e,t);return i!=null&&_a.includes(i)}function Li(n,e,t){return(t!=Te.None?n?.[t]?.[e]:null)??n?.[e]??ul[e]??null}function Bs(n,e,t,i=new Set){i.add(e);let a=Li(n,e,t);return _a.includes(a)?i.has(a)?null:Bs(n,a,t,i):a}var ge=Object.freeze({Number:"Number",Color:"Color",Font:"Font",Size:"Size",Style:"Style",Variant:"Variant",Weight:"Weight"}),hl=[{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"}]}],wa=new Map;for(let n of hl)for(let e of n.properties)wa.has(e.type)||wa.set(e.type,[]),wa.get(e.type).push(e);function fh(n,e,t){let i=n.slice();return i[19]=e[t],i}function E0(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=q(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 M0(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=q(e,"change",n[15]),t=!0)},p(a,s){s&16&&(e.value=a[4])},d(a){a&&x(e),t=!1,i()}}}function I0(n){let e,t,i,a=be(n[1]),s=[];for(let r=0;rt(18,a=k));let u=At("mode");Se(n,u,k=>t(17,i=k));let h=kt([d,u],([k,A])=>wa.get(c.type).filter(P=>P.property!=c.property&&!dl(k.cssProperties,P.property,A).has(c.property)));Se(n,h,k=>t(1,s=k));let f=kt([d,u],([k,A])=>Bs(k.cssProperties,c.property,A)??"");Se(n,f,k=>t(4,l=k));let m=kt([d,u,h],([k,A,P])=>Li(k.cssProperties,c.property,A)??P[0].property);Se(n,m,k=>t(3,o=k));let p=kt([d,u],([k,A])=>hh(k.cssProperties,c.property,A));Se(n,p,k=>t(2,r=k));let b=k=>{new fl.ExtraButtonComponent(k).setIcon(r?"unlink":"link").onClick(()=>{S(r?Bs(a.cssProperties,c.property,i):s.find(A=>!dl(a.cssProperties,A.property,i).has(c.property)).property)})},_=k=>{new fl.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,f,m,p,b,_,S,C,M,w]}var ml=class extends G{constructor(e){super(),K(this,e,P0,O0,V,{property:0})}},ph=ml;var bh=require("obsidian");function R0(n){se(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 N0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,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"),f=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(f,"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"),re(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,f),y(e,p),y(e,b),w&&w.m(b,null),e.open=n[0],_=!0,S||(C=[J(m=n[4].call(null,f)),q(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)&&re(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,oe(C)}}}function B0(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,bh.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 gl=class extends G{constructor(e){super(),K(this,e,B0,N0,V,{open:0,name:1,desc:2,alwaysOpen:3},R0)}},Sa=gl;function yh(n,e,t){let i=n.slice();return i[1]=e[t],i}function vh(n){let e,t;return e=new ph({props:{property:n[1]}}),{c(){ie(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 L0(n){let e,t,i=be(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 pl=class extends G{constructor(e){super(),K(this,e,W0,F0,V,{group:0})}},kh=pl;function H0(n){se(n,"svelte-1obegcf",".appearance-parent.svelte-1obegcf{overflow:hidden}.property-groups.svelte-1obegcf{overflow:auto;height:100%}")}function z0(n,e,t){let i=n.slice();return i[5]=e[t],i}function q0(n){let e,t;return e=new kh({props:{group:n[5]}}),{c(){ie(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 j0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S=be(hl),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"),f=R(),m=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 bl=class extends G{constructor(e){super(),K(this,e,V0,j0,V,{},H0)}},wh=bl;var tn=require("obsidian");var yl=require("obsidian"),_h=La(Ds());var Fi=class extends _h.FuzzyInputSuggest{constructor(){super(...arguments);this.field="name"}getItemText(t){return ye(t[this.field])}renderNote(t,i){let{item:a,match:s}=i;(0,yl.renderMatches)(t,ye(a.source),s.matches)}renderTitle(t,i){let{item:a,match:s}=i;(0,yl.renderMatches)(t,ye(a.name),s.matches)}};function U0(n){se(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 G0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,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"),f=v("div"),f.textContent="Scale preview",m=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"),re(s,"mod-cta",n[2]==Te.Light),g(l,"aria-label","Dark"),re(l,"mod-cta",n[2]==Te.Dark),g(a,"class","setting-item-control"),g(e,"class","setting-item"),g(f,"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,B){D(P,e,B),y(e,t),y(e,i),y(e,a),y(a,s),y(a,o),y(a,l),D(P,d,B),D(P,u,B),y(u,h),y(h,f),y(h,m),y(h,p),y(p,b),y(p,_),y(u,S),y(u,C),y(C,M),ct(M,n[1]),k||(A=[J(r=Fe.call(null,s,"sun")),q(s,"click",n[14]),J(c=Fe.call(null,l,"moon")),q(l,"click",n[15]),q(M,"change",n[16]),q(M,"input",n[16]),J(w=n[10].call(null,C))],k=!0)},p(P,B){B&4&&re(s,"mod-cta",P[2]==Te.Light),B&4&&re(l,"mod-cta",P[2]==Te.Dark),B&2&&we(_,P[1]),B&2&&ct(M,P[1])},d(P){P&&(x(e),x(d),x(u)),k=!1,oe(A)}}}function K0(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=J(t=n[6].call(null,e)),i=!0)},p:N,d(s){s&&x(e),i=!1,a()}}}function $0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_;return d=new Sa({props:{name:"Settings",desc:n[3],open:!1,$$slots:{default:[G0]},$$scope:{ctx:n}}}),f=new Sa({props:{name:"Editor",open:!1,$$slots:{default:[K0]},$$scope:{ctx:n}}}),{c(){e=v("div"),t=v("div"),t.textContent=`Select a creature to preview the layout, or enter your own definition + 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=J(t=n[7].call(null,e)),s=!0)},d(o){o&&(x(e),x(i),x(a)),s=!1,r()}}}function dh(n){let e,t;return e=new lh({props:{type:"dice",component:uh,items:n[1]??is(),onDrop:n[3],showIcons:n[1]!=null,draggable:n[1]!=null}}),e.$on("advanced",n[11]),e.$on("trash",n[12]),{c(){ie(e.$$.fragment)},m(i,a){te(e,i,a),t=!0},p(i,a){let s={};a&2&&(s.items=i[1]??is()),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 T0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S,C,M,w,k,A,P,B=n[1],L,O,j;function Z(W,Y){if(!W[1])return A0;if(W[1].length==0)return x0}let ee=Z(n,-1),ae=ee&&ee(n),$=dh(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(),f=v("div"),m=v("div"),m.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"),ae&&ae.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(m,"class","setting-item-info"),g(b,"class","setting-item-control"),g(f,"class","setting-item"),g(A,"class","additional"),g(k,"class","dice-parsing statblock-additional-container")},m(W,Y){D(W,e,Y),y(e,t),y(e,i),y(e,a),y(a,s),ct(s,n[0].columns),D(W,r,Y),D(W,o,Y),y(o,l),y(o,c),y(o,d),y(d,u),ct(u,n[0].columnWidth),D(W,h,Y),D(W,f,Y),y(f,m),y(f,p),y(f,b),D(W,S,Y),D(W,C,Y),D(W,w,Y),D(W,k,Y),y(k,A),ae&&ae.m(A,null),y(A,P),$.m(A,null),L=!0,O||(j=[q(s,"input",n[9]),q(u,"input",n[10]),J(_=n[8].call(null,b)),J(M=n[6].call(null,C))],O=!0)},p(W,[Y]){Y&1&&$n(s.value)!==W[0].columns&&ct(s,W[0].columns),Y&1&&$n(u.value)!==W[0].columnWidth&&ct(u,W[0].columnWidth),ee!==(ee=Z(W,Y))&&(ae&&ae.d(1),ae=ee&&ee(W),ae&&(ae.c(),ae.m(A,P))),Y&2&&V(B,B=W[1])?(le(),I($,1,1,N),ce(),$=dh(W),$.c(),E($,1),$.m(A,null)):$.p(W,Y)},i(W){L||(E($),L=!0)},o(W){I($),L=!1},d(W){W&&(x(e),x(r),x(o),x(h),x(f),x(S),x(C),x(w),x(k)),ae&&ae.d(),$.d(W),O=!1,oe(j)}}}function D0(n,e,t){let i,a,s=At("layout");Se(n,s,_=>t(0,a=_));let r=At("plugin");function o(_){Ae(s,a.diceParsing=[..._],a)}let l=_=>{let S=new va(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 ka.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 ka.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 ka.ToggleComponent(_).setValue(a.forceColumns).onChange(()=>{Ae(s,a.forceColumns=!a.forceColumns,a)})};function f(){a.columns=$n(this.value),s.set(a)}function m(){a.columnWidth=$n(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,f,m,p,b]}var ll=class extends G{constructor(e){super(),K(this,e,D0,T0,V,{},C0)}},cl=ll;var rA=require("obsidian");var fl=require("obsidian");var _a=["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"],ul={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 dl(n,e,t){let i=new Set,a=Li(n,e,t);for(;_a.includes(a)&&!i.has(a);)i.add(a),a=Li(n,a,t);return i}function hh(n,e,t){let i=Li(n,e,t);return i!=null&&_a.includes(i)}function Li(n,e,t){return(t!=Te.None?n?.[t]?.[e]:null)??n?.[e]??ul[e]??null}function Ls(n,e,t,i=new Set){i.add(e);let a=Li(n,e,t);return _a.includes(a)?i.has(a)?null:Ls(n,a,t,i):a}var ge=Object.freeze({Number:"Number",Color:"Color",Font:"Font",Size:"Size",Style:"Style",Variant:"Variant",Weight:"Weight"}),hl=[{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"}]}],wa=new Map;for(let n of hl)for(let e of n.properties)wa.has(e.type)||wa.set(e.type,[]),wa.get(e.type).push(e);function fh(n,e,t){let i=n.slice();return i[19]=e[t],i}function E0(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=q(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 M0(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=q(e,"change",n[15]),t=!0)},p(a,s){s&16&&(e.value=a[4])},d(a){a&&x(e),t=!1,i()}}}function I0(n){let e,t,i,a=be(n[1]),s=[];for(let r=0;rt(18,a=k));let u=At("mode");Se(n,u,k=>t(17,i=k));let h=kt([d,u],([k,A])=>wa.get(c.type).filter(P=>P.property!=c.property&&!dl(k.cssProperties,P.property,A).has(c.property)));Se(n,h,k=>t(1,s=k));let f=kt([d,u],([k,A])=>Ls(k.cssProperties,c.property,A)??"");Se(n,f,k=>t(4,l=k));let m=kt([d,u,h],([k,A,P])=>Li(k.cssProperties,c.property,A)??P[0].property);Se(n,m,k=>t(3,o=k));let p=kt([d,u],([k,A])=>hh(k.cssProperties,c.property,A));Se(n,p,k=>t(2,r=k));let b=k=>{new fl.ExtraButtonComponent(k).setIcon(r?"unlink":"link").onClick(()=>{S(r?Ls(a.cssProperties,c.property,i):s.find(A=>!dl(a.cssProperties,A.property,i).has(c.property)).property)})},_=k=>{new fl.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,f,m,p,b,_,S,C,M,w]}var ml=class extends G{constructor(e){super(),K(this,e,P0,O0,V,{property:0})}},ph=ml;var bh=require("obsidian");function R0(n){se(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 N0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,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"),f=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(f,"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"),re(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,f),y(e,p),y(e,b),w&&w.m(b,null),e.open=n[0],_=!0,S||(C=[J(m=n[4].call(null,f)),q(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)&&re(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,oe(C)}}}function B0(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,bh.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 gl=class extends G{constructor(e){super(),K(this,e,B0,N0,V,{open:0,name:1,desc:2,alwaysOpen:3},R0)}},Sa=gl;function yh(n,e,t){let i=n.slice();return i[1]=e[t],i}function vh(n){let e,t;return e=new ph({props:{property:n[1]}}),{c(){ie(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 L0(n){let e,t,i=be(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 pl=class extends G{constructor(e){super(),K(this,e,W0,F0,V,{group:0})}},kh=pl;function H0(n){se(n,"svelte-1obegcf",".appearance-parent.svelte-1obegcf{overflow:hidden}.property-groups.svelte-1obegcf{overflow:auto;height:100%}")}function z0(n,e,t){let i=n.slice();return i[5]=e[t],i}function q0(n){let e,t;return e=new kh({props:{group:n[5]}}),{c(){ie(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 j0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S=be(hl),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"),f=R(),m=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 bl=class extends G{constructor(e){super(),K(this,e,V0,j0,V,{},H0)}},wh=bl;var tn=require("obsidian");var yl=require("obsidian"),_h=La(Es());var Fi=class extends _h.FuzzyInputSuggest{constructor(){super(...arguments);this.field="name"}getItemText(t){return ye(t[this.field])}renderNote(t,i){let{item:a,match:s}=i;(0,yl.renderMatches)(t,ye(a.source),s.matches)}renderTitle(t,i){let{item:a,match:s}=i;(0,yl.renderMatches)(t,ye(a.name),s.matches)}};function U0(n){se(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 G0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,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"),f=v("div"),f.textContent="Scale preview",m=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"),re(s,"mod-cta",n[2]==Te.Light),g(l,"aria-label","Dark"),re(l,"mod-cta",n[2]==Te.Dark),g(a,"class","setting-item-control"),g(e,"class","setting-item"),g(f,"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,B){D(P,e,B),y(e,t),y(e,i),y(e,a),y(a,s),y(a,o),y(a,l),D(P,d,B),D(P,u,B),y(u,h),y(h,f),y(h,m),y(h,p),y(p,b),y(p,_),y(u,S),y(u,C),y(C,M),ct(M,n[1]),k||(A=[J(r=Fe.call(null,s,"sun")),q(s,"click",n[14]),J(c=Fe.call(null,l,"moon")),q(l,"click",n[15]),q(M,"change",n[16]),q(M,"input",n[16]),J(w=n[10].call(null,C))],k=!0)},p(P,B){B&4&&re(s,"mod-cta",P[2]==Te.Light),B&4&&re(l,"mod-cta",P[2]==Te.Dark),B&2&&we(_,P[1]),B&2&&ct(M,P[1])},d(P){P&&(x(e),x(d),x(u)),k=!1,oe(A)}}}function K0(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=J(t=n[6].call(null,e)),i=!0)},p:N,d(s){s&&x(e),i=!1,a()}}}function $0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_;return d=new Sa({props:{name:"Settings",desc:n[3],open:!1,$$slots:{default:[G0]},$$scope:{ctx:n}}}),f=new Sa({props:{name:"Editor",open:!1,$$slots:{default:[K0]},$$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(),ie(d.$$.fragment),u=R(),h=v("div"),ie(f.$$.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",m=`--scale: ${n[1]}`),re(e,"theme-light",n[2]===Te.Light),re(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(f,h,null),p=!0,b||(_=J(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}),f.$set(w),(!p||C&2&&m!==(m=`--scale: ${S[1]}`))&&g(e,"style",m),(!p||C&4)&&re(e,"theme-light",S[2]===Te.Light),(!p||C&4)&&re(e,"theme-dark",S[2]===Te.Dark)},i(S){p||(E(d.$$.fragment,S),E(f.$$.fragment,S),p=!0)},o(S){I(d.$$.fragment,S),I(f.$$.fragment,S),p=!1},d(S){S&&x(e),n[13](null),ne(d),ne(f),b=!1,_()}}}function Y0(n,e,t){let i,a,s,r,{previewed:o}=e,l=At("plugin"),c=At("layout");Se(n,c,L=>t(19,s=L));let d=Me(),u=(L,O)=>{L.empty(),f.setCreature({monster:O}),f.init()},h,f;pn(()=>{let L={};try{L={...L,...(0,tn.parseYaml)(o)}}catch{}f=new Yt({plugin:l,container:h,layout:s,monster:L},!1)});let m=L=>{let O=new tn.SearchComponent(L).setPlaceholder("Find a creature");new Fi(l.app,O,l.api.getBestiaryCreatures()).onSelect(async Z=>{if(Z.item){O.setValue("");let ee=(0,tn.stringifyYaml)(Z.item);d("update",ee),p.dispatch({changes:[{from:0,to:p.state.doc.length,insert:ee}]})}})},p,b=L=>{p=ba(L,o,[],(0,tn.debounce)(O=>{try{let j=(0,tn.parseYaml)(O);d("update",O),u(h,j)}catch{}},500))},_=Le(Te.None);Se(n,_,L=>t(2,a=L));let S=L=>{a==L?Ae(_,a=Te.None,a):Ae(_,a=L,a)};bn(()=>{p&&p.destroy()});let C=Le(1);Se(n,C,L=>t(1,i=L));let M=L=>{new tn.ExtraButtonComponent(L).setIcon("undo").onClick(()=>{Ae(C,i=1,i)})},w=kt([_,C],([L,O])=>{let j=[`Scale: ${O}`];return L===Te.Light&&j.push("Mode: Light"),L===Te.Dark&&j.push("Mode: Dark"),j.join(", ")});Se(n,w,L=>t(3,r=L));function k(L){Re[L?"unshift":"push"](()=>{h=L,t(0,h)})}let A=()=>S(Te.Light),P=()=>S(Te.Dark);function B(){i=$n(this.value),C.set(i)}return n.$$set=L=>{"previewed"in L&&t(12,o=L.previewed)},[h,i,a,r,c,m,b,_,S,C,M,w,o,k,A,P,B]}var vl=class extends G{constructor(e){super(),K(this,e,Y0,$0,V,{previewed:12},U0)}},Sh=vl;function J0(n){se(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 Ch(n,e,t){let i=n.slice();return i[16]=e[t],i}function X0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S;return f=new cl({}),p=new al({}),{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(),ie(f.$$.fragment),m=R(),ie(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(f,e,null),y(e,m),te(p,e,null),b=!0,_||(S=[J(a=n[5].call(null,i)),J(l=n[6].call(null,o)),J(u=n[7].call(null,d))],_=!0)},p:N,i(C){b||(E(f.$$.fragment,C),E(p.$$.fragment,C),b=!0)},o(C){I(f.$$.fragment,C),I(p.$$.fragment,C),b=!1},d(C){C&&x(e),ne(f),ne(p),_=!1,oe(S)}}}function Q0(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S,C,M,w,k,A,P,B,L=be(n[4]),O=[];for(let $=0;${j=null}),ce()),$[1]==="Appearance"?Z?W&2&&E(Z,1):(Z=Th($),Z.c(),E(Z,1),Z.m(S,M)):Z&&(le(),I(Z,1,1,()=>{Z=null}),ce()),$[1]==="Advanced"?ee?W&2&&E(ee,1):(ee=Dh($),ee.c(),E(ee,1),ee.m(S,w)):ee&&(le(),I(ee,1,1,()=>{ee=null}),ce()),$[1]==="Previewer"?ae?(ae.p($,W),W&2&&E(ae,1)):(ae=Eh($),ae.c(),E(ae,1),ae.m(S,null)):ae&&(le(),I(ae,1,1,()=>{ae=null}),ce()),(!A||W&2&&k!==(k="vertical-tab-content-container "+$[1].toLowerCase()+"s svelte-1idjk8u"))&&g(_,"class",k)},i($){A||(E(j),E(Z),E(ee),E(ae),A=!0)},o($){I(j),I(Z),I(ee),I(ae),A=!1},d($){$&&(x(e),x(b),x(_)),He(O,$),j&&j.d(),Z&&Z.d(),ee&&ee.d(),ae&&ae.d(),P=!1,oe(B)}}}function xh(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"),re(e,"is-active",n[1]===n[16])},m(s,r){D(s,e,r),t||(i=q(e,"click",a),t=!0)},p(s,r){n=s,r&18&&re(e,"is-active",n[1]===n[16])},d(s){s&&x(e),t=!1,i()}}}function Ah(n){let e,t;return e=new al({}),{c(){ie(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 Th(n){let e,t;return e=new wh({}),{c(){ie(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 Dh(n){let e,t;return e=new cl({}),{c(){ie(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 Eh(n){let e,t;return e=new Sh({props:{previewed:n[0]}}),e.$on("update",n[12]),{c(){ie(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 Z0(n){let e,t=``,i,a,s,r,o,l=[Q0,X0],c=[];function d(u,h){return nn.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 ey(n,e,t){let i,a,{layout:s}=e,{plugin:r}=e,o=Le(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 nn.TextComponent(C).setValue(M).onChange(k=>{M=k});let w=C.createDiv("buttons");new nn.ExtraButtonComponent(w).setIcon("checkmark").setTooltip("Save").onClick(()=>{u=!1,Ae(o,i.name=M,i),h(C)}),new nn.ExtraButtonComponent(w).setIcon("cross-in-box").setTooltip("Cancel").onClick(()=>{u=!1,h(C)})}else C.createEl("h5",{text:i.name}),new nn.ExtraButtonComponent(C.createDiv("buttons")).setIcon("pencil").setTooltip("Edit Name").onClick(()=>{u=!0,h(C)})},f=Me(),m=C=>{new nn.ButtonComponent(C).setIcon("checkmark").setCta().setTooltip("Save").onClick(()=>{f("saved")})},p=C=>{new nn.ExtraButtonComponent(C).setIcon("cross").setTooltip("Cancel").onClick(()=>{f("cancel")})},b=kt(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,m,p,b,s,r,_,S]}var kl=class extends G{constructor(e){super(),K(this,e,ey,Z0,V,{layout:9,plugin:10},J0)}},Mh=kl;var Wi=(n=>(n.None="None",n.Average="Average",n.Roll="Roll",n))(Wi||{});var xf=La(Ds());function wl(){return ia('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:e.name,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 Hi=require("obsidian");var _l=class extends _t{constructor(){super(...arguments);this.saved=!1}display(){this.titleEl.createSpan({text:"Set Sources"}),new Hi.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 Hi.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()}},ty=async n=>new Promise(e=>{let t=new _l(n);t.onClose=()=>{t.saved||e(null),e(t.source)},t.open()}),Ca=class{constructor(e){this.plugin=e;this.workers=new Map}async import(e,t){return new Promise(i=>{let a=new wl,s=Q();this.workers.set(s,a),a.onmessage=async r=>{let{monsters:o}=r.data??{monsters:[]};if(o){new Hi.Notice(`Successfully imported ${o.length} Monsters`);let l=o.filter(d=>d.source=="Unknown"||!d.source),c;l.length&&(c=await ty(this.plugin))&&l.forEach(d=>d.source=c)}a.terminate(),this.workers.delete(s),i(o)},a.onerror=r=>{new Hi.Notice(`There was an error importing the file. + `)&&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 ey(n,e,t){let i,a,{layout:s}=e,{plugin:r}=e,o=Le(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 nn.TextComponent(C).setValue(M).onChange(k=>{M=k});let w=C.createDiv("buttons");new nn.ExtraButtonComponent(w).setIcon("checkmark").setTooltip("Save").onClick(()=>{u=!1,Ae(o,i.name=M,i),h(C)}),new nn.ExtraButtonComponent(w).setIcon("cross-in-box").setTooltip("Cancel").onClick(()=>{u=!1,h(C)})}else C.createEl("h5",{text:i.name}),new nn.ExtraButtonComponent(C.createDiv("buttons")).setIcon("pencil").setTooltip("Edit Name").onClick(()=>{u=!0,h(C)})},f=Me(),m=C=>{new nn.ButtonComponent(C).setIcon("checkmark").setCta().setTooltip("Save").onClick(()=>{f("saved")})},p=C=>{new nn.ExtraButtonComponent(C).setIcon("cross").setTooltip("Cancel").onClick(()=>{f("cancel")})},b=kt(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,m,p,b,s,r,_,S]}var kl=class extends G{constructor(e){super(),K(this,e,ey,Z0,V,{layout:9,plugin:10},J0)}},Mh=kl;var Wi=(n=>(n.None="None",n.Average="Average",n.Roll="Roll",n))(Wi||{});var xf=La(Es());function wl(){return ia('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(/{@atkr m}/g,"Melee Attack Roll:").replace(/{@atkr r}/g,"Ranged Attack Roll:").replace(/{@atkr m,r}/g,"Melee or Ranged Attack Roll:").replace(/{@hom}/g,"Hit or Miss:").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").replace(/{@actSave str}/g,"Strength Saving Throw:").replace(/{@actSave dex}/g,"Dexterity Saving Throw:").replace(/{@actSave con}/g,"Constitution Saving Throw:").replace(/{@actSave int}/g,"Inteligence Saving Throw:").replace(/{@actSave wis}/g,"Wisdom Saving Throw:").replace(/{@actSave cha}/g,"Charisma Saving Throw:").replace(/{@actSaveFail}/g,"Failure:").replace(/{@actSaveSuccess}/g,"Success:").replace(/{actSaveSuccessOrFail}/g,"Failure or Success:").replace(/{@variantrule (.+?)( \\[|\\|).+?}/g,"$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:e.name,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 Hi=require("obsidian");var _l=class extends _t{constructor(){super(...arguments);this.saved=!1}display(){this.titleEl.createSpan({text:"Set Sources"}),new Hi.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 Hi.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()}},ty=async n=>new Promise(e=>{let t=new _l(n);t.onClose=()=>{t.saved||e(null),e(t.source)},t.open()}),Ca=class{constructor(e){this.plugin=e;this.workers=new Map}async import(e,t){return new Promise(i=>{let a=new wl,s=Q();this.workers.set(s,a),a.onmessage=async r=>{let{monsters:o}=r.data??{monsters:[]};if(o){new Hi.Notice(`Successfully imported ${o.length} Monsters`);let l=o.filter(d=>d.source=="Unknown"||!d.source),c;l.length&&(c=await ty(this.plugin))&&l.forEach(d=>d.source=c)}a.terminate(),this.workers.delete(s),i(o)},a.onerror=r=>{new Hi.Notice(`There was an error importing the file. ${r.message}`),a.terminate(),this.workers.delete(s),i([])},a.postMessage({files:e,source:t})})}};var ny=[{type:"inline",id:Q(),properties:[],hasRule:!0,nested:[{type:"group",id:Q(),properties:["name","description","aspects","temporaryAspects"],nested:[{type:"heading",id:Q(),properties:["name"],conditioned:!0,size:1},{type:"text",id:Q(),properties:["description"],conditioned:!0,markdown:!0,text:null,dice:!1},{type:"text",id:Q(),properties:["aspects"],markdown:!0,text:null,dice:!1,conditioned:!0,heading:"Aspects"},{type:"text",id:Q(),properties:["temporaryAspects"],markdown:!0,text:null,dice:!1,conditioned:!0,heading:"Temporary Aspects"}],conditioned:!0},{type:"image",id:Q(),properties:["image"],conditioned:!0}]},{type:"table",id:Q(),properties:["stress"],headers:["Physical","Mental"],calculate:!1,hasRule:!0,conditioned:!0},{type:"traits",id:Q(),properties:["consequences"],conditioned:!0,heading:"Consequences"},{type:"traits",id:Q(),properties:["skills"],conditioned:!0,hasRule:!1,heading:"Skills"},{type:"traits",id:Q(),properties:["stunts"],markdown:!0,dice:!1,conditioned:!0,heading:"Stunts"},{type:"traits",id:Q(),properties:["items"],heading:"Items",conditioned:!0,markdown:!0,dice:!1},{type:"traits",id:Q(),properties:["extras"],heading:"Extras",conditioned:!0,markdown:!0,dice:!1}],Ih={blocks:ny,id:"basic-fate-core-layout",name:"Basic Fate Core Layout",edited:!1};var Oh={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:Q(),desc:"(1d8+3)"},{regex:/(\w+?) ([+-])(\d+)/.source,parser:`let [, initial, sign, number] = matches; @@ -1078,23 +1078,23 @@ typeBlock.append(typeText) headingBlock.append(typeBlock); -return headingBlock;`}],hasRule:!1},{type:"group",id:"098a5a785abb",properties:[],nested:[{type:"heading",id:"3b8bb868c818",properties:["name"],size:1,fallback:"Card Name"}],hasRule:!1},{type:"group",id:"cbbaeab91a3b",properties:[],nested:[{type:"property",id:"281afa3a39d9",properties:["text"],fallback:"-"}]}],cls:"daggerheart-card"}],id:"daggerheart-card",name:"Daggerheart Card",edited:!1},Wh={blocks:[{type:"group",id:"9beb08f99a5a",properties:[],nested:[{type:"heading",id:"89998949fb0b",properties:["name"],size:1,fallback:"-",conditioned:!0},{type:"property",id:"982ba9097959",properties:["tier"],fallback:"",callback:'return monster.tier + " " + monster.type;',conditioned:!0,display:"Tier"},{type:"text",id:"a8196bebf98a",properties:["description"],text:"",fallback:"-",conditioned:!0},{type:"property",id:"a8988bca599a",properties:["impulses"],fallback:"-",display:"Impulses:",conditioned:!0},{type:"group",id:"c90a4a79fb0b",properties:[],nested:[{type:"inline",id:"ab385a3b1869",properties:[],nested:[{type:"property",id:"781b3bdbd86b",properties:["difficulty"],fallback:"-",display:"Difficulty:",conditioned:!0}]},{type:"inline",id:"694abb2acaf9",properties:[],nested:[{type:"property",id:"58a80a396ba9",properties:["potential_adversaries"],fallback:"-",display:"Potential Adversaries:",conditioned:!0}],hasRule:!0}],hasRule:!1},{type:"traits",id:"eb590bb8cb9b",properties:["feats"],fallback:"-",heading:"Features",conditioned:!0,headingProp:!1,callback:"return property.text;"}],heading:"",cls:"daggerheart-environment"}],id:"daggerheart-environment",name:"Daggerheart Environment",edited:!1};var ci=[rn,Ih,Oh,Ph,Rh,Nh,Bh,Lh,Fh,Wh];var ui=require("obsidian");function iy(n){se(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 Hh(n,e,t){let i=n.slice();return i[16]=e[t],i}function ay(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"),re(e,"active",n[16]==n[3])},m(l,c){D(l,e,c),y(e,i),y(e,a),s||(r=q(e,"click",o),s=!0)},p(l,c){n=l,c&16&&t!==(t=n[16]+"")&&we(i,t),c&24&&re(e,"active",n[16]==n[3])},d(l){l&&x(e),s=!1,r()}}}function sy(n){let e,t,i;return{c(){e=v("span"),e.textContent="..."},m(a,s){D(a,e,s),t||(i=q(e,"click",n[13]),t=!0)},p:N,d(a){a&&x(e),t=!1,i()}}}function zh(n){let e;function t(s,r){return s[16]==null?sy:ay}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 ry(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S=be(n[4]),C=[];for(let M=0;M(r(),r=Dt(p,B=>t(3,s=B)),p),l,c=N,d=()=>(c(),c=Dt(b,B=>t(12,l=B)),b),u,h=N,f=()=>(h(),h=Dt(m,B=>t(15,u=B)),m);n.$$.on_destroy.push(()=>r()),n.$$.on_destroy.push(()=>c()),n.$$.on_destroy.push(()=>h());let{slice:m}=e;f();let{page:p}=e;o();let{pages:b}=e;d();let _=B=>{new ui.DropdownComponent(B).addOptions({10:"10",25:"25",50:"50",100:"100",200:"200"}).setValue(`${u}`).onChange(L=>Ae(m,u=Number(L),u))},S,C=B=>{t(9,S=new ui.ExtraButtonComponent(B).setIcon("chevron-left").setDisabled(s==1).onClick(()=>{Ae(p,s=s-1,s)}))},M,w=B=>{t(10,M=new ui.ExtraButtonComponent(B).setIcon("chevron-right").setDisabled(s==l).onClick(()=>{Ae(p,s=Math.min(s+1,l),s)}))},k=B=>{let L=new ui.Menu;for(let O of i)L.addItem(j=>{j.setTitle(`${O}`).onClick(()=>{Ae(p,s=O,s)})});L.showAtMouseEvent(B)},A=B=>k(B),P=B=>Ae(p,s=B,s);return n.$$set=B=>{"slice"in B&&f(t(0,m=B.slice)),"page"in B&&o(t(1,p=B.page)),"pages"in B&&d(t(2,b=B.pages))},n.$$.update=()=>{n.$$.dirty&4096&&t(11,i=[...Array(l).keys()].map(B=>B+1)),n.$$.dirty&5640&&M&&S&&(M.setDisabled(s==l),S.setDisabled(s==1)),n.$$.dirty&6152&&t(4,a=i.reduce((B,L)=>(L==1||s==1&&(L==2||L==3)||L==l||s==l&&(L==l-1||L==l-2)||L==s-1||L==s||L==s+1?B.push(L):B.length>=1&&B[B.length-1]!=null&&B.push(null),B),[]))},[m,p,b,s,a,_,C,w,k,S,M,i,l,A,P]}var Sl=class extends G{constructor(e){super(),K(this,e,oy,ry,V,{slice:0,page:1,pages:2},iy)}},qh=Sl;var qi=require("obsidian");var Fs=require("obsidian");var Pt=require("obsidian");function ly(n){se(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 jh(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=q(e,"blur",n[12]),i=!0)},p:N,d(s){s&&x(e),n[11](null),i=!1,a()}}}function cy(n){let e,t,i,a,s,r,o,l,c,d,u,h=n[0],f,m,p,b,_,S,C,M,w,k=jh(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(),f=R(),m=v("div"),p=v("div"),_=R(),S=v("div"),g(r,"class","svelte-1m3i208"),re(r,"active",!n[0]),g(c,"class","svelte-1m3i208"),re(c,"active",n[0]),g(s,"class","json svelte-1m3i208"),g(a,"class","top-level svelte-1m3i208"),g(m,"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,f),y(e,m),y(m,p),y(m,_),y(m,S),M||(w=[J(o=n[3].call(null,r)),q(r,"click",n[9]),J(d=n[2].call(null,c)),q(c,"click",n[10]),J(b=n[4].call(null,p)),J(C=n[5].call(null,S))],M=!0)},p(A,[P]){P&1&&re(r,"active",!A[0]),P&1&&re(c,"active",A[0]),P&1&&V(h,h=A[0])?(k.d(1),k=jh(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,oe(w)}}}function uy(n,e,t){let i=Me(),{monster:a={}}=e,s=!1,r,o=_=>{new Pt.ExtraButtonComponent(_).setIcon("code-glyph").setTooltip("JSON")},l=_=>{new Pt.ExtraButtonComponent(_).setIcon("lines-of-text").setTooltip("YAML")},c=_=>{new Pt.ButtonComponent(_).setIcon("checkmark").setTooltip("Save Changes").onClick(()=>{if(s)try{s?t(8,a=JSON.parse(r.value)):t(8,a=(0,Pt.parseYaml)(r.value))}catch(S){console.error(S),new Pt.Notice(`There was an error saving the creaturen +return headingBlock;`}],hasRule:!1},{type:"group",id:"098a5a785abb",properties:[],nested:[{type:"heading",id:"3b8bb868c818",properties:["name"],size:1,fallback:"Card Name"}],hasRule:!1},{type:"group",id:"cbbaeab91a3b",properties:[],nested:[{type:"property",id:"281afa3a39d9",properties:["text"],fallback:"-"}]}],cls:"daggerheart-card"}],id:"daggerheart-card",name:"Daggerheart Card",edited:!1},Wh={blocks:[{type:"group",id:"9beb08f99a5a",properties:[],nested:[{type:"heading",id:"89998949fb0b",properties:["name"],size:1,fallback:"-",conditioned:!0},{type:"property",id:"982ba9097959",properties:["tier"],fallback:"",callback:'return monster.tier + " " + monster.type;',conditioned:!0,display:"Tier"},{type:"text",id:"a8196bebf98a",properties:["description"],text:"",fallback:"-",conditioned:!0},{type:"property",id:"a8988bca599a",properties:["impulses"],fallback:"-",display:"Impulses:",conditioned:!0},{type:"group",id:"c90a4a79fb0b",properties:[],nested:[{type:"inline",id:"ab385a3b1869",properties:[],nested:[{type:"property",id:"781b3bdbd86b",properties:["difficulty"],fallback:"-",display:"Difficulty:",conditioned:!0}]},{type:"inline",id:"694abb2acaf9",properties:[],nested:[{type:"property",id:"58a80a396ba9",properties:["potential_adversaries"],fallback:"-",display:"Potential Adversaries:",conditioned:!0}],hasRule:!0}],hasRule:!1},{type:"traits",id:"eb590bb8cb9b",properties:["feats"],fallback:"-",heading:"Features",conditioned:!0,headingProp:!1,callback:"return property.text;"}],heading:"",cls:"daggerheart-environment"}],id:"daggerheart-environment",name:"Daggerheart Environment",edited:!1};var ci=[rn,Ih,Oh,Ph,Rh,Nh,Bh,Lh,Fh,Wh];var ui=require("obsidian");function iy(n){se(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 Hh(n,e,t){let i=n.slice();return i[16]=e[t],i}function ay(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"),re(e,"active",n[16]==n[3])},m(l,c){D(l,e,c),y(e,i),y(e,a),s||(r=q(e,"click",o),s=!0)},p(l,c){n=l,c&16&&t!==(t=n[16]+"")&&we(i,t),c&24&&re(e,"active",n[16]==n[3])},d(l){l&&x(e),s=!1,r()}}}function sy(n){let e,t,i;return{c(){e=v("span"),e.textContent="..."},m(a,s){D(a,e,s),t||(i=q(e,"click",n[13]),t=!0)},p:N,d(a){a&&x(e),t=!1,i()}}}function zh(n){let e;function t(s,r){return s[16]==null?sy:ay}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 ry(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S=be(n[4]),C=[];for(let M=0;M(r(),r=Dt(p,B=>t(3,s=B)),p),l,c=N,d=()=>(c(),c=Dt(b,B=>t(12,l=B)),b),u,h=N,f=()=>(h(),h=Dt(m,B=>t(15,u=B)),m);n.$$.on_destroy.push(()=>r()),n.$$.on_destroy.push(()=>c()),n.$$.on_destroy.push(()=>h());let{slice:m}=e;f();let{page:p}=e;o();let{pages:b}=e;d();let _=B=>{new ui.DropdownComponent(B).addOptions({10:"10",25:"25",50:"50",100:"100",200:"200"}).setValue(`${u}`).onChange(L=>Ae(m,u=Number(L),u))},S,C=B=>{t(9,S=new ui.ExtraButtonComponent(B).setIcon("chevron-left").setDisabled(s==1).onClick(()=>{Ae(p,s=s-1,s)}))},M,w=B=>{t(10,M=new ui.ExtraButtonComponent(B).setIcon("chevron-right").setDisabled(s==l).onClick(()=>{Ae(p,s=Math.min(s+1,l),s)}))},k=B=>{let L=new ui.Menu;for(let O of i)L.addItem(j=>{j.setTitle(`${O}`).onClick(()=>{Ae(p,s=O,s)})});L.showAtMouseEvent(B)},A=B=>k(B),P=B=>Ae(p,s=B,s);return n.$$set=B=>{"slice"in B&&f(t(0,m=B.slice)),"page"in B&&o(t(1,p=B.page)),"pages"in B&&d(t(2,b=B.pages))},n.$$.update=()=>{n.$$.dirty&4096&&t(11,i=[...Array(l).keys()].map(B=>B+1)),n.$$.dirty&5640&&M&&S&&(M.setDisabled(s==l),S.setDisabled(s==1)),n.$$.dirty&6152&&t(4,a=i.reduce((B,L)=>(L==1||s==1&&(L==2||L==3)||L==l||s==l&&(L==l-1||L==l-2)||L==s-1||L==s||L==s+1?B.push(L):B.length>=1&&B[B.length-1]!=null&&B.push(null),B),[]))},[m,p,b,s,a,_,C,w,k,S,M,i,l,A,P]}var Sl=class extends G{constructor(e){super(),K(this,e,oy,ry,V,{slice:0,page:1,pages:2},iy)}},qh=Sl;var qi=require("obsidian");var Ws=require("obsidian");var Pt=require("obsidian");function ly(n){se(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 jh(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=q(e,"blur",n[12]),i=!0)},p:N,d(s){s&&x(e),n[11](null),i=!1,a()}}}function cy(n){let e,t,i,a,s,r,o,l,c,d,u,h=n[0],f,m,p,b,_,S,C,M,w,k=jh(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(),f=R(),m=v("div"),p=v("div"),_=R(),S=v("div"),g(r,"class","svelte-1m3i208"),re(r,"active",!n[0]),g(c,"class","svelte-1m3i208"),re(c,"active",n[0]),g(s,"class","json svelte-1m3i208"),g(a,"class","top-level svelte-1m3i208"),g(m,"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,f),y(e,m),y(m,p),y(m,_),y(m,S),M||(w=[J(o=n[3].call(null,r)),q(r,"click",n[9]),J(d=n[2].call(null,c)),q(c,"click",n[10]),J(b=n[4].call(null,p)),J(C=n[5].call(null,S))],M=!0)},p(A,[P]){P&1&&re(r,"active",!A[0]),P&1&&re(c,"active",A[0]),P&1&&V(h,h=A[0])?(k.d(1),k=jh(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,oe(w)}}}function uy(n,e,t){let i=Me(),{monster:a={}}=e,s=!1,r,o=_=>{new Pt.ExtraButtonComponent(_).setIcon("code-glyph").setTooltip("JSON")},l=_=>{new Pt.ExtraButtonComponent(_).setIcon("lines-of-text").setTooltip("YAML")},c=_=>{new Pt.ButtonComponent(_).setIcon("checkmark").setTooltip("Save Changes").onClick(()=>{if(s)try{s?t(8,a=JSON.parse(r.value)):t(8,a=(0,Pt.parseYaml)(r.value))}catch(S){console.error(S),new Pt.Notice(`There was an error saving the creaturen -${S.message}`);return}i("save",a)})},d=_=>{new Pt.ExtraButtonComponent(_).setIcon("cross").setTooltip("Cancel").onClick(()=>{i("cancel")})};function u(){return s?JSON.stringify(a,null,2):!a||!Object.keys(a??{})?.length?"":(0,Pt.stringifyYaml)(a).trim()}function h(){try{s?t(8,a=JSON.parse(r.value)):t(8,a=(0,Pt.parseYaml)(r.value))}catch(_){console.error(_)}}let f=()=>t(0,s=!1),m=()=>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,f,m,p,b]}var Cl=class extends G{constructor(e){super(),K(this,e,uy,cy,V,{monster:8},ly)}},Vh=Cl;var zi=class extends _t{constructor(t,i={}){super(t);this.monster=i}onOpen(){this._instance=new Vh({target:this.contentEl,props:{monster:this.monster}}),this._instance.$on("cancel",()=>{this.close()}),this._instance.$on("save",async({detail:t})=>{if(!t.name){new Fs.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 _t{constructor(t,i){super(t);this.monster=i}async display(){Fs.Platform.isMobile||(this.contentEl.style.maxWidth="85vw"),new Yt({container:this.contentEl,monster:this.monster,plugin:this.plugin})}onOpen(){this.display()}};var wn=Le(""),di=Le([]),Ws="None",Uh=kt([wn,di],([n,e])=>(n?.length?1:0)+(e?.length?1:0));function dy(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","creature")},m(s,r){D(s,e,r),i||(a=J(t=n[0].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function hy(n,e,t){let i;Se(n,wn,c=>t(3,i=c));let{item:a}=e,s=Me(),r=At("plugin"),o,l=c=>{t(2,o=new qi.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=ye(h,0,", ",!1)}else d=a.source;if(o.setDesc(d??""),u&&o.descEl.setAttr("aria-label",ye(a.source,0,", ",!1)),ve.isLocal(a.name))o.addExtraButton(h=>{h.setIcon("pencil").setTooltip("Edit").onClick(()=>{new zi(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(f=>{f.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,qi.prepareSimpleSearch)(i)(a.name);c&&(o.nameEl.empty(),(0,qi.renderMatches)(o.nameEl,a.name,c.matches))}else o.setName(a.name)},[l,a,o,i]}var xl=class extends G{constructor(e){super(),K(this,e,hy,dy,V,{item:1})}},Gh=xl;var js=require("obsidian");var Hs=require("obsidian");function fy(n){se(n,"svelte-1xutc2s",".search.svelte-1xutc2s,.search.svelte-1xutc2s input{width:100%}")}function my(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=J(t=n[1].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function gy(n,e,t){let i,a=N,s=()=>(a(),a=Dt(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 Hs.SearchComponent(c).setPlaceholder(o).onChange((0,Hs.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 Al=class extends G{constructor(e){super(),K(this,e,gy,my,V,{filter:0,placeholder:2},fy)}},Kh=Al;function py(n){se(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 by(n){let e,t=`${n[0]} transparent ${n[0]} +${S.message}`);return}i("save",a)})},d=_=>{new Pt.ExtraButtonComponent(_).setIcon("cross").setTooltip("Cancel").onClick(()=>{i("cancel")})};function u(){return s?JSON.stringify(a,null,2):!a||!Object.keys(a??{})?.length?"":(0,Pt.stringifyYaml)(a).trim()}function h(){try{s?t(8,a=JSON.parse(r.value)):t(8,a=(0,Pt.parseYaml)(r.value))}catch(_){console.error(_)}}let f=()=>t(0,s=!1),m=()=>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,f,m,p,b]}var Cl=class extends G{constructor(e){super(),K(this,e,uy,cy,V,{monster:8},ly)}},Vh=Cl;var zi=class extends _t{constructor(t,i={}){super(t);this.monster=i}onOpen(){this._instance=new Vh({target:this.contentEl,props:{monster:this.monster}}),this._instance.$on("cancel",()=>{this.close()}),this._instance.$on("save",async({detail:t})=>{if(!t.name){new Ws.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()}},Fs=class extends _t{constructor(t,i){super(t);this.monster=i}async display(){Ws.Platform.isMobile||(this.contentEl.style.maxWidth="85vw"),new Yt({container:this.contentEl,monster:this.monster,plugin:this.plugin})}onOpen(){this.display()}};var wn=Le(""),di=Le([]),Hs="None",Uh=kt([wn,di],([n,e])=>(n?.length?1:0)+(e?.length?1:0));function dy(n){let e,t,i,a;return{c(){e=v("div"),g(e,"class","creature")},m(s,r){D(s,e,r),i||(a=J(t=n[0].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function hy(n,e,t){let i;Se(n,wn,c=>t(3,i=c));let{item:a}=e,s=Me(),r=At("plugin"),o,l=c=>{t(2,o=new qi.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=ye(h,0,", ",!1)}else d=a.source;if(o.setDesc(d??""),u&&o.descEl.setAttr("aria-label",ye(a.source,0,", ",!1)),ve.isLocal(a.name))o.addExtraButton(h=>{h.setIcon("pencil").setTooltip("Edit").onClick(()=>{new zi(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(f=>{f.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 Fs(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,qi.prepareSimpleSearch)(i)(a.name);c&&(o.nameEl.empty(),(0,qi.renderMatches)(o.nameEl,a.name,c.matches))}else o.setName(a.name)},[l,a,o,i]}var xl=class extends G{constructor(e){super(),K(this,e,hy,dy,V,{item:1})}},Gh=xl;var Vs=require("obsidian");var zs=require("obsidian");function fy(n){se(n,"svelte-1xutc2s",".search.svelte-1xutc2s,.search.svelte-1xutc2s input{width:100%}")}function my(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=J(t=n[1].call(null,e)),i=!0)},p:N,i:N,o:N,d(s){s&&x(e),i=!1,a()}}}function gy(n,e,t){let i,a=N,s=()=>(a(),a=Dt(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 zs.SearchComponent(c).setPlaceholder(o).onChange((0,zs.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 Al=class extends G{constructor(e){super(),K(this,e,gy,my,V,{filter:0,placeholder:2},fy)}},Kh=Al;function py(n){se(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 by(n){let e,t=`${n[0]} transparent ${n[0]} ${n[0]}`;return{c(){e=v("div"),ze(e,"--duration",n[1]),g(e,"class","svelte-66wdl1"),ze(e,"border-color",t),ze(e,"width",n[2]),ze(e,"height",n[2])},m(i,a){D(i,e,a)},p(i,[a]){a&2&&ze(e,"--duration",i[1]);let s=a&2;(a&3&&t!==(t=`${i[0]} transparent ${i[0]} - ${i[0]}`)||s)&&ze(e,"border-color",t),(a&6||s)&&ze(e,"width",i[2]),(a&6||s)&&ze(e,"height",i[2])},i:N,o:N,d(i){i&&x(e)}}}function yy(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 Tl=class extends G{constructor(e){super(),K(this,e,yy,by,V,{color:0,duration:1,size:2},py)}},Dl=Tl;function zs(n){return Object.prototype.toString.call(n)==="[object Date]"}function El(n,e,t,i){if(typeof t=="number"||zs(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)El(n,e[s],t[s],i[s]));if(typeof t=="object"){let a={};for(let s in t)a[s]=El(n,e[s],t[s],i[s]);return a}else throw new Error(`Cannot spring ${typeof t} values`)}}function $h(n,e={}){let t=Le(n),{stiffness:i=.15,damping:a=.8,precision:s=.01}=e,r,o,l,c=n,d=n,u=1,h=0,f=!1;function m(b,_={}){d=b;let S=l={};return n==null||_.hard||p.stiffness>=1&&p.damping>=1?(f=!0,r=An(),c=b,t.set(n=d),Promise.resolve()):(_.soft&&(h=1/((_.soft===!0?.5:+_.soft)*60),u=0),o||(r=An(),f=!1,o=Kn(C=>{if(f)return f=!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=El(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:m,update:(b,_)=>m(b(d,n),_),subscribe:t.subscribe,stiffness:i,damping:a,precision:s};return p}function vy(n){let e,t=`rotate(${n[0].angle}deg) scale(${n[0].scale}) translate(${n[0].dx}px, + ${i[0]}`)||s)&&ze(e,"border-color",t),(a&6||s)&&ze(e,"width",i[2]),(a&6||s)&&ze(e,"height",i[2])},i:N,o:N,d(i){i&&x(e)}}}function yy(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 Tl=class extends G{constructor(e){super(),K(this,e,yy,by,V,{color:0,duration:1,size:2},py)}},Dl=Tl;function qs(n){return Object.prototype.toString.call(n)==="[object Date]"}function El(n,e,t,i){if(typeof t=="number"||qs(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)El(n,e[s],t[s],i[s]));if(typeof t=="object"){let a={};for(let s in t)a[s]=El(n,e[s],t[s],i[s]);return a}else throw new Error(`Cannot spring ${typeof t} values`)}}function $h(n,e={}){let t=Le(n),{stiffness:i=.15,damping:a=.8,precision:s=.01}=e,r,o,l,c=n,d=n,u=1,h=0,f=!1;function m(b,_={}){d=b;let S=l={};return n==null||_.hard||p.stiffness>=1&&p.damping>=1?(f=!0,r=An(),c=b,t.set(n=d),Promise.resolve()):(_.soft&&(h=1/((_.soft===!0?.5:+_.soft)*60),u=0),o||(r=An(),f=!1,o=Kn(C=>{if(f)return f=!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=El(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:m,update:(b,_)=>m(b(d,n),_),subscribe:t.subscribe,stiffness:i,damping:a,precision:s};return p}function vy(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(),ze(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)`)&&ze(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 ky(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:f=.1}=e,m={angle:0,scale:1,dx:0,dy:0},p=$h(m,{stiffness:h,damping:f});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,f=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}:m)},[i,p,r,o,l,c,d,u,h,f,s,a]}var Ml=class extends G{constructor(e){super(),K(this,e,ky,vy,V,{wiggle:2,angle:3,scale:4,dx:5,dy:6,duration:7,stiffness:8,damping:9})}},Il=Ml;function wy(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),Ut(i)))},e=Ut(e),[e]}var Ol=class extends G{constructor(e){super(),K(this,e,_y,wy,V,{})}},Pl=Ol;function Sy(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),Ut(i)))},e=Ut(e),[e]}var Rl=class extends G{constructor(e){super(),K(this,e,Cy,Sy,V,{})}},qs=Rl;function xy(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),Ut(i)))},e=Ut(e),[e]}var Nl=class extends G{constructor(e){super(),K(this,e,Ay,xy,V,{})}},Bl=Nl;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 xa(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:Ty}=Yi;function Dy(n){se(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 Ey=n=>({searchText:n[0]&8,msgType:n[0]&1073810458,msg:n[0]&1073843226}),Yh=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 Fl(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 Jh(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 My=n=>({option:n[0]&33554434}),Xh=n=>({option:n[118],idx:n[125]}),Iy=n=>({option:n[0]&33554434}),Qh=n=>({option:n[118],idx:n[125]}),Oy=n=>({}),Zh=n=>({}),Py=n=>({}),ef=n=>({}),Ry=n=>({}),tf=n=>({}),Ny=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}),nf=n=>({selected:n[4],disabled:n[42],invalid:n[7],id:n[18],placeholder:n[34],open:n[8],required:n[38]});function af(n,e,t){let i=n.slice();return i[118]=e[t],i[125]=t,i}var By=n=>({}),sf=n=>({}),Ly=n=>({option:n[0]&16,idx:n[0]&16}),rf=n=>({option:n[118],idx:n[125]}),Fy=n=>({option:n[0]&16,idx:n[0]&16}),of=n=>({option:n[118],idx:n[125]}),Wy=n=>({open:n[0]&256}),lf=n=>({open:n[8]});function Hy(n){let e,t;return e=new Pl({props:{width:"15px",style:"min-width: 1em; padding: 0 1pt; cursor: pointer;"}}),{c(){ie(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 zy(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 qy(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 jy(n){let e;function t(s,r){return s[32]?qy:zy}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 Vy(n){let e,t=n[69].default,i=st(t,n,n[107],rf),a=i||jy(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,Ly):lt(s[107]),rf):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 cf(n){let e,t,i,a,s,r=n[69]["remove-icon"],o=st(r,n,n[107],sf),l=o||Uy(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=[q(e,"mouseup",ln(c)),q(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,By):lt(n[107]),sf),(!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,oe(s)}}}function Uy(n){let e,t;return e=new qs({props:{width:"15px"}}),{c(){ie(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 uf(n,e){let t,i,a,s,r,o,l=N,c,d,u,h=e[69].selected,f=st(h,e,e[107],of),m=f||Vy(e),p=!e[42]&&(e[37]===null||e[4].length>e[37])&&cf(e);function b(){return e[91](e[125])}return{key:n,first:null,c(){t=v("li"),m&&m.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=xa(e[118],"selected")),re(t,"active",e[46]===e[125]),this.first=t},m(_,S){D(_,t,S),m&&m.m(t,null),y(t,i),p&&p.m(t,null),c=!0,d||(u=[q(t,"dragstart",function(){Pe(e[57](e[125]))&&e[57](e[125]).apply(this,arguments)}),q(t,"drop",Cr(function(){Pe(e[56](e[125]))&&e[56](e[125]).apply(this,arguments)})),q(t,"dragenter",b),q(t,"dragover",Cr(e[85]))],d=!0)},p(_,S){e=_,f?f.p&&(!c||S[0]&16|S[3]&16384)&&ot(f,h,e,e[107],c?rt(h,e[107],S,Fy):lt(e[107]),of):m&&m.p&&(!c||S[0]&16|S[1]&2|S[3]&16384)&&m.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=cf(e),p.c(),E(p,1),p.m(t,null)):p&&(le(),I(p,1,1,()=>{p=null}),ce()),(!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=xa(e[118],"selected")))&&g(t,"style",r),(!c||S[0]&8388624|S[1]&32768)&&re(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(m,_),E(p),c=!0)},o(_){I(m,_),I(p),c=!1},d(_){_&&x(t),m&&m.d(_),p&&p.d(),d=!1,oe(u)}}}function df(n){let e,t=n[69].spinner,i=st(t,n,n[107],tf),a=i||Gy(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,Ry):lt(s[107]),tf)},i(s){e||(E(a,s),e=!0)},o(s){I(a,s),e=!1},d(s){a&&a.d(s)}}}function Gy(n){let e,t;return e=new Dl({}),{c(){ie(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 Ky(n){let e,t,i,a=n[26]&&(n[26]>1||n[27])&&hf(n),s=n[26]!==1&&n[4].length>1&&ff(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=hf(r),a.c(),E(a,1),a.m(e.parentNode,e)):a&&(le(),I(a,1,1,()=>{a=null}),ce()),r[26]!==1&&r[4].length>1?s?(s.p(r,o),o[0]&67108880&&E(s,1)):(s=ff(r),s.c(),E(s,1),s.m(t.parentNode,t)):s&&(le(),I(s,1,1,()=>{s=null}),ce())},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 $y(n){let e,t=n[69]["disabled-icon"],i=st(t,n,n[107],ef),a=i||Xy(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,Py):lt(s[107]),ef)},i(s){e||(E(a,s),e=!0)},o(s){I(a,s),e=!1},d(s){a&&a.d(s)}}}function hf(n){let e,t,i;function a(r){n[94](r)}let s={angle:20,$$slots:{default:[Yy]},$$scope:{ctx:n}};return n[43]!==void 0&&(s.wiggle=n[43]),e=new Il({props:s}),Re.push(()=>Wt(e,"wiggle",a)),{c(){ie(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],Ft(()=>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 Yy(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 ff(n){let e,t,i,a,s=n[69]["remove-icon"],r=st(s,n,n[107],Zh),o=r||Jy(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=[q(e,"mouseup",ln(n[53])),q(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,Oy):lt(l[107]),Zh),(!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,oe(a)}}}function Jy(n){let e,t;return e=new qs({props:{width:"15px"}}),{c(){ie(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 Xy(n){let e,t;return e=new Bl({props:{width:"14pt",style:"margin: 0 2pt;","data-name":"disabled-icon"}}),{c(){ie(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 mf(n){let e,t,i,a,s,r,o=be(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]&&pf(Fl(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),re(e,"hidden",!n[8])},m(u,h){D(u,e,h);for(let f=0;f{d=null}),ce()),(!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)&&re(e,"hidden",!u[8])},i(u){if(!r){for(let h=0;h{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function bf(n){let e,t,i,a,s=n[69]["user-msg"],r=st(s,n,n[107],Yh),o=r||nv(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"),re(e,"active",n[44]),ze(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=[q(e,"mousedown",ln(n[70])),q(e,"mouseup",ln(n[100])),q(e,"mouseover",n[101]),q(e,"focus",n[102]),q(e,"mouseout",n[103]),q(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,Ey):lt(l[107]),Yh):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)&&re(e,"active",l[44]),c[0]&1073810458&&ze(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,oe(a)}}}function nv(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 iv(n){let e,t,i,a,s,r,o,l=[],c=new Map,d,u,h,f,m,p,b,_,S,C,M,w,k,A,P,B,L;It(n[86]);let O=n[69]["expand-icon"],j=st(O,n,n[107],lf),Z=j||Hy(n),ee=be(n[4]),ae=U=>U[16]?[U[17](U[118]),U[125]]:U[17](U[118]);for(let U=0;U0?1:-1}~(C=he(n,[-1,-1,-1,-1,-1]))&&(M=H[C]=F[C](n));let ue=(n[3]&&n[30]||n[2]?.length>0)&&mf(n);return{c(){e=v("div"),t=v("input"),s=R(),Z&&Z.c(),r=R(),o=v("ul");for(let U=0;U=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",f=n[4].length==0?n[34]:null),g(u,"aria-invalid",m=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"),re(e,"disabled",n[42]),re(e,"single",n[26]===1),re(e,"open",n[8]),re(e,"invalid",n[7])},m(U,z){D(U,e,z),y(e,t),n[87](t),y(e,s),Z&&Z.m(e,null),y(e,r),y(e,o);for(let me=0;me=Number(U[38])?JSON.stringify(U[4]):null)&&t.value!==a)&&(t.value=a),j&&j.p&&(!P||z[0]&256|z[3]&16384)&&ot(j,O,U,U[107],P?rt(O,U[107],z,Wy):lt(U[107]),lf),z[0]&8585232|z[1]&109611362|z[3]&16384){ee=be(U[4]),le();for(let Ce=0;Ce{Y=null}),ce());let me=C;C=he(U,z),C===me?~C&&H[C].p(U,z):(M&&(le(),I(H[me],1,1,()=>{H[me]=null}),ce()),~C?(M=H[C],M?M.p(U,z):(M=H[C]=F[C](U),M.c()),E(M,1),M.m(e,w)):M=null),U[3]&&U[30]||U[2]?.length>0?ue?(ue.p(U,z),z[0]&1073741836&&E(ue,1)):(ue=mf(U),ue.c(),E(ue,1),ue.m(e,null)):ue&&(le(),I(ue,1,1,()=>{ue=null}),ce()),(!P||z[1]&1&&k!==(k="multiselect "+U[31]+" svelte-1r2hsto"))&&g(e,"class",k),(!P||z[0]&16384|z[1]&2048&&A!==(A=U[42]?U[14]:null))&&g(e,"title",A),(!P||z[0]&262144)&&g(e,"data-id",U[18]),(!P||z[1]&2049)&&re(e,"disabled",U[42]),(!P||z[0]&67108864|z[1]&1)&&re(e,"single",U[26]===1),(!P||z[0]&256|z[1]&1)&&re(e,"open",U[8]),(!P||z[0]&128|z[1]&1)&&re(e,"invalid",U[7])},i(U){if(!P){E(Z,U);for(let z=0;z`${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:B=null}=e,{inputClass:L=""}=e,{inputmode:O=null}=e,{invalid:j=!1}=e,{liActiveOptionClass:Z=""}=e,{liOptionClass:ee=""}=e,{liSelectedClass:ae=""}=e,{loading:$=!1}=e,{matchingOptions:W=[]}=e,{maxOptions:Y=void 0}=e,{maxSelect:F=null}=e,{maxSelectMsg:H=(T,Ee)=>Ee>1?`${T}/${Ee}`:""}=e,{maxSelectMsgClass:he=""}=e,{name:ue=null}=e,{noMatchingOptionsMsg:U="No matching options"}=e,{open:z=!1}=e,{options:me}=e,{outerDiv:Ce=null}=e,{outerDivClass:Ie=""}=e,{parseLabelsAsHtml:et=!1}=e,{pattern:Tt=null}=e,{placeholder:mi=null}=e,{removeAllTitle:gi="Remove all"}=e,{removeBtnTitle:Rt="Remove"}=e,{minSelect:Nt=null}=e,{required:bt=!1}=e,{resetFilterOnAdd:Xs=!0}=e,{searchText:Qe=""}=e,{selected:De=me?.filter(T=>T instanceof Object&&T?.preselected).slice(0,F??void 0)??[]}=e,{sortSelected:Vn=!1}=e,{selectedOptionsDraggable:Qs=!Vn}=e,{ulOptionsClass:Kl=""}=e,{ulSelectedClass:$l=""}=e,{value:Pa=null}=e,Tf=T=>{t(59,Pa=F===1?T[0]??null:T)},Df=T=>{F===1?t(4,De=T?[T]:[]):t(4,De=T??[])},Ra=!1;me?.length>0||(c||$||p||d?me=[]: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 bt=="number"&&bt>F&&console.error(`MultiSelect maxSelect=${F} < required=${bt}, 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!"),Vn&&Qs&&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.`),Y&&(typeof Y!="number"||Y<0||Y%1!=0)&&console.error(`MultiSelect's maxOptions must be undefined or a positive integer, got ${Y}`);let mn=Me(),Un=!1,Zs;if(r!==null&&!W[r])throw`Run time error, activeIndex=${r} is out of bounds, matchingOptions.length=${W.length}`;function ji(T,Ee){F&&F>1&&De.length>=F&&t(43,Ra=!0),!isNaN(Number(T))&&typeof De.map(it)[0]=="number"&&(T=Number(T));let Ke=De.map(C).includes(C(T));if((F===null||F===1||De.length0&&(typeof me[0]=="object"?T={label:Qe}:(["number","undefined"].includes(typeof me[0])&&!isNaN(Number(Qe))?T=Number(Qe):T=Qe,mn("create",{option:T})),c==="append"&&t(2,me=[...me,T])),Xs&&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]),Vn===!0?t(4,De=De.sort((nr,Gn)=>{let[Ui,Ba]=[it(nr),it(Gn)];return`${Ui}`.localeCompare(`${Ba}`)})):typeof Vn=="function"&&t(4,De=De.sort(Vn)));let yt=De.length===F,pi=w===!0||w==="desktop"&&ZsC(yt)===C(T)),[Ke]=De.splice(Ee,1);if(Ke===void 0&&c&&(Ke=typeof me[0]?{label:T}:T),Ke===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,j=!1),k?.setCustomValidity(""),mn("remove",{option:Ke}),mn("change",{option:Ke,type:"remove"})}function Yl(T){p||(t(8,z=!0),T instanceof FocusEvent||B?.focus(),mn("open",{event:T}))}function er(T){t(8,z=!1),B?.blur(),t(0,r=null),mn("close",{event:T})}async function Ef(T){if(T.key==="Escape"||T.key==="Tab")er(T),t(3,Qe="");else if(T.key==="Enter")T.preventDefault(),o?(De.includes(o)?Vi(o):ji(o,T),t(3,Qe="")):c&&Qe.length>0?ji(Qe,T):Yl(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,Un=!Un);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 Xa();let Ke=document.querySelector("ul.options > li.active");Ke&&Ke.scrollIntoViewIfNeeded?.()}}else T.key==="Backspace"&&De.length>0&&!Qe?Vi(De.at(-1)):W.length>0&&t(0,r=0)}function Mf(){mn("removeAll",{options:De}),mn("change",{options:De,type:"removeAll"}),t(4,De=[]),t(3,Qe="")}let If=T=>Ee=>{["Enter","Space"].includes(Ee.code)&&(Ee.preventDefault(),T())};function Of(T){Ce&&!Ce.contains(T.target)&&er(T)}let tr=null,Pf=T=>Ee=>{if(!Ee.dataTransfer)return;Ee.dataTransfer.dropEffect="move";let Ke=parseInt(Ee.dataTransfer.getData("text/plain")),yt=[...De];KeEe=>{Ee.dataTransfer&&(Ee.dataTransfer.effectAllowed="move",Ee.dataTransfer.dropEffect="move",Ee.dataTransfer.setData("text/plain",`${T}`))},Na;function Nf(T){if(!A||typeof CSS>"u"||!CSS.highlights)return;CSS.highlights.clear();let Ee=T?.target?.value.trim().toLowerCase();if(!Ee)return;let Ke=document.createTreeWalker(Na,NodeFilter.SHOW_TEXT,{acceptNode:Gn=>Gn?.textContent===U?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),yt=[],pi=Ke.nextNode();for(;pi;)yt.push(pi),pi=Ke.nextNode();let nr=yt.map(Gn=>{let Ui=Gn.textContent?.toLowerCase(),Ba=[],ir=0;for(;Ui&&ir{let ar=new Range;return ar.setStart(Gn,bi),ar.setEnd(Gn,bi+Ee.length),ar})});CSS.highlights.set("sms-search-matches",new Highlight(...nr.flat()))}function Bf(T){Ge.call(this,n,T)}function Lf(T){Ge.call(this,n,T)}function Ff(T){Ge.call(this,n,T)}function Wf(T){Ge.call(this,n,T)}function Hf(T){Ge.call(this,n,T)}function zf(T){Ge.call(this,n,T)}function qf(T){Ge.call(this,n,T)}function jf(T){Ge.call(this,n,T)}function Vf(T){Ge.call(this,n,T)}function Uf(T){Ge.call(this,n,T)}function Gf(T){Ge.call(this,n,T)}function Kf(T){Ge.call(this,n,T)}function $f(T){Ge.call(this,n,T)}function Yf(T){Ge.call(this,n,T)}function Jf(T){Ge.call(this,n,T)}function Xf(T){Ge.call(this,n,T)}function Qf(){t(45,Zs=window.innerWidth)}function Zf(T){Re[T?"unshift":"push"](()=>{k=T,t(5,k)})}let em=()=>{t(7,j=!0);let T;F&&F>1&&Number(bt)>1?T=`Please select between ${bt} and ${F} options`:Number(bt)>1?T=`Please select at least ${bt} options`:T="Please select an option",k?.setCustomValidity(T)},tm=T=>Vi(T),nm=T=>Vi(T),im=T=>t(46,tr=T);function am(T){Re[T?"unshift":"push"](()=>{B=T,t(6,B)})}function sm(){Qe=this.value,t(3,Qe)}function rm(T){Ra=T,t(43,Ra)}let om=(T,Ee,Ke)=>{T||ji(Ee,Ke)},lm=(T,Ee)=>{T||t(0,r=Ee)},cm=(T,Ee)=>{T||t(0,r=Ee)},um=()=>t(0,r=null),dm=()=>t(0,r=null),hm=T=>{c&&ji(Qe,T)},fm=()=>t(44,Un=!0),mm=()=>t(44,Un=!0),gm=()=>t(44,Un=!1),pm=()=>t(44,Un=!1);function bm(T){Re[T?"unshift":"push"](()=>{Na=T,t(47,Na)})}function ym(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,f=T.breakpoint),"defaultDisabledTitle"in T&&t(13,m=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,B=T.input),"inputClass"in T&&t(19,L=T.inputClass),"inputmode"in T&&t(20,O=T.inputmode),"invalid"in T&&t(7,j=T.invalid),"liActiveOptionClass"in T&&t(21,Z=T.liActiveOptionClass),"liOptionClass"in T&&t(22,ee=T.liOptionClass),"liSelectedClass"in T&&t(23,ae=T.liSelectedClass),"loading"in T&&t(24,$=T.loading),"matchingOptions"in T&&t(1,W=T.matchingOptions),"maxOptions"in T&&t(25,Y=T.maxOptions),"maxSelect"in T&&t(26,F=T.maxSelect),"maxSelectMsg"in T&&t(27,H=T.maxSelectMsg),"maxSelectMsgClass"in T&&t(28,he=T.maxSelectMsgClass),"name"in T&&t(29,ue=T.name),"noMatchingOptionsMsg"in T&&t(30,U=T.noMatchingOptionsMsg),"open"in T&&t(8,z=T.open),"options"in T&&t(2,me=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,Tt=T.pattern),"placeholder"in T&&t(34,mi=T.placeholder),"removeAllTitle"in T&&t(35,gi=T.removeAllTitle),"removeBtnTitle"in T&&t(36,Rt=T.removeBtnTitle),"minSelect"in T&&t(37,Nt=T.minSelect),"required"in T&&t(38,bt=T.required),"resetFilterOnAdd"in T&&t(67,Xs=T.resetFilterOnAdd),"searchText"in T&&t(3,Qe=T.searchText),"selected"in T&&t(4,De=T.selected),"sortSelected"in T&&t(68,Vn=T.sortSelected),"selectedOptionsDraggable"in T&&t(39,Qs=T.selectedOptionsDraggable),"ulOptionsClass"in T&&t(40,Kl=T.ulOptionsClass),"ulSelectedClass"in T&&t(41,$l=T.ulSelectedClass),"value"in T&&t(59,Pa=T.value),"$$scope"in T&&t(107,s=T.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&16&&Tf(De),n.$$.dirty[1]&268435456&&Df(Pa),n.$$.dirty[0]&196636|n.$$.dirty[2]&4&&t(1,W=me.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,me,Qe,De,k,B,j,z,Ce,l,c,u,m,b,_,S,C,P,L,O,Z,ee,ae,$,Y,F,H,he,ue,U,Ie,et,Tt,mi,gi,Rt,Nt,bt,Qs,Kl,$l,p,Ra,Un,Zs,tr,Na,i,ji,Vi,Yl,Ef,Mf,If,Of,Pf,Rf,Nf,Pa,o,d,h,f,M,w,A,Xs,Vn,a,Bf,Lf,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,dm,hm,fm,mm,gm,pm,bm,ym,s]}var Wl=class extends G{constructor(e){super(),K(this,e,av,iv,V,{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},Dy,[-1,-1,-1,-1,-1])}},Aa=Wl;function sv(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=sv);function rv(n){se(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 ov(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 Aa({props:r}),Re.push(()=>Wt(t,"selected",s)),{c(){e=v("div"),ie(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],Ft(()=>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 lv(n,e,t){let i,a=N,s=()=>(a(),a=Dt(r,u=>t(2,i=u)),r);n.$$.on_destroy.push(()=>a());let{filter:r}=e;s();let{options:o}=e,l=[...o,Ws],{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 Hl=class extends G{constructor(e){super(),K(this,e,lv,ov,V,{filter:0,options:4,placeholder:1},rv)}},yf=Hl;function cv(n){se(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 vf(n){let e,t,i,a;return t=new yf({props:{options:n[1],placeholder:"Sources",filter:di}}),{c(){e=v("div"),ie(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&&It(()=>{a&&(i||(i=Jn(e,Ri,{easing:on},!0)),i.run(1))}),a=!0)},o(s){I(t.$$.fragment,s),s&&(i||(i=Jn(e,Ri,{easing:on},!1)),i.run(0)),a=!1},d(s){s&&x(e),ne(t),s&&i&&i.end()}}}function uv(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S,C,M;i=new Kh({props:{filter:wn,placeholder:"Search Creatures"}});let w=n[0]&&vf(n);return{c(){e=v("div"),t=v("div"),ie(i.$$.fragment),a=R(),s=v("div"),r=v("div"),l=R(),c=v("div"),d=pe(n[2]),u=R(),h=v("div"),m=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,m),y(t,p),y(e,_),w&&w.m(e,null),S=!0,C||(M=[J(o=n[7].call(null,r)),q(s,"click",n[9]),J(f=n[5].call(null,h)),q(h,"click",n[10]),J(b=n[6].call(null,p)),q(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=vf(k),w.c(),E(w,1),w.m(e,null)):w&&(le(),I(w,1,1,()=>{w=null}),ce())},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,oe(M)}}}function dv(n,e,t){let i,a,s,r;Se(n,di,_=>t(12,i=_)),Se(n,wn,_=>t(13,a=_)),Se(n,Uh,_=>t(2,r=_));let o=Le([...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 js.ExtraButtonComponent(_).setIcon("reset")},u=_=>{new js.ExtraButtonComponent(_).setIcon("trash")},h=_=>{new js.ExtraButtonComponent(_).setIcon("filter")},f=()=>{Ae(wn,a="",a),Ae(di,i=[],i)};return[c,s,r,o,l,d,u,h,f,()=>t(0,c=!c),()=>f(),()=>l("remove")]}var zl=class extends G{constructor(e){super(),K(this,e,dv,uv,V,{},cv)}},kf=zl;var Sf=require("obsidian");function hv(n){se(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 wf(n,e,t){let i=n.slice();return i[16]=e[t],i}function _f(n,e){let t,i,a;return i=new Gh({props:{item:e[16]}}),i.$on("close",e[13]),{key:n,first:null,c(){t=_e(),ie(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 fv(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,f=[],m=new Map,p,b,_,S;i=new kf({}),i.$on("remove",n[12]);let C=be(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=Le(50),h=Le(1),f=kt([c,wn,di],([C,M,w])=>{let k=[];for(let A of C){let P=!0;M.length&&((0,Sf.prepareSimpleSearch)(M)(A.name)||(P=!1)),w.length&&![A.source].flat().some(B=>B&&w.includes(B))&&(P=!1),!A.source&&w.includes(Ws)&&(P=!0),P&&k.push(A)}return k});Se(n,f,C=>t(2,i=C));let m=async()=>{i.length&&await fo(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=kt([u,f],([C,M])=>Math.ceil(M.length/C)),b=kt([f,u,h],([C,M,w])=>C.slice((w-1)*M,w*M));Se(n,b,C=>t(3,s=C));let _=()=>m();function S(C){Ge.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,f,m,p,b,r,_,S]}var ql=class extends G{constructor(e){super(),K(this,e,mv,fv,V,{plugin:11,backgroundColor:0,paddingTop:1},hv)}},Cf=ql;var Da=class extends ke.PluginSettingTab{constructor(t,i){super(t,i);this.plugin=i;this.results=[];this.importer=new Ca(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:Wi.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 xf.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 f=new FileReader;f.onload=async m=>{try{let p=JSON.parse(m.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=Q(),!this.plugin.settings.alwaysImport&&p.blocks.find(b=>b.type=="javascript")&&!await gv(this.plugin)&&u(),this.plugin.settings.layouts.push(this.getDuplicate(p)),u()}catch(p){h(p)}},f.readAsText(d)}).catch(u=>{new ke.Notice(`There was an error importing the layout: + ${r[0].dy}px)`)&&ze(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 ky(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:f=.1}=e,m={angle:0,scale:1,dx:0,dy:0},p=$h(m,{stiffness:h,damping:f});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,f=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}:m)},[i,p,r,o,l,c,d,u,h,f,s,a]}var Ml=class extends G{constructor(e){super(),K(this,e,ky,vy,V,{wiggle:2,angle:3,scale:4,dx:5,dy:6,duration:7,stiffness:8,damping:9})}},Il=Ml;function wy(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),Ut(i)))},e=Ut(e),[e]}var Ol=class extends G{constructor(e){super(),K(this,e,_y,wy,V,{})}},Pl=Ol;function Sy(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),Ut(i)))},e=Ut(e),[e]}var Rl=class extends G{constructor(e){super(),K(this,e,Cy,Sy,V,{})}},js=Rl;function xy(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),Ut(i)))},e=Ut(e),[e]}var Nl=class extends G{constructor(e){super(),K(this,e,Ay,xy,V,{})}},Bl=Nl;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 xa(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:Ty}=Yi;function Dy(n){se(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 Ey=n=>({searchText:n[0]&8,msgType:n[0]&1073810458,msg:n[0]&1073843226}),Yh=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 Fl(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 Jh(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 My=n=>({option:n[0]&33554434}),Xh=n=>({option:n[118],idx:n[125]}),Iy=n=>({option:n[0]&33554434}),Qh=n=>({option:n[118],idx:n[125]}),Oy=n=>({}),Zh=n=>({}),Py=n=>({}),ef=n=>({}),Ry=n=>({}),tf=n=>({}),Ny=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}),nf=n=>({selected:n[4],disabled:n[42],invalid:n[7],id:n[18],placeholder:n[34],open:n[8],required:n[38]});function af(n,e,t){let i=n.slice();return i[118]=e[t],i[125]=t,i}var By=n=>({}),sf=n=>({}),Ly=n=>({option:n[0]&16,idx:n[0]&16}),rf=n=>({option:n[118],idx:n[125]}),Fy=n=>({option:n[0]&16,idx:n[0]&16}),of=n=>({option:n[118],idx:n[125]}),Wy=n=>({open:n[0]&256}),lf=n=>({open:n[8]});function Hy(n){let e,t;return e=new Pl({props:{width:"15px",style:"min-width: 1em; padding: 0 1pt; cursor: pointer;"}}),{c(){ie(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 zy(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 qy(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 jy(n){let e;function t(s,r){return s[32]?qy:zy}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 Vy(n){let e,t=n[69].default,i=st(t,n,n[107],rf),a=i||jy(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,Ly):lt(s[107]),rf):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 cf(n){let e,t,i,a,s,r=n[69]["remove-icon"],o=st(r,n,n[107],sf),l=o||Uy(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=[q(e,"mouseup",ln(c)),q(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,By):lt(n[107]),sf),(!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,oe(s)}}}function Uy(n){let e,t;return e=new js({props:{width:"15px"}}),{c(){ie(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 uf(n,e){let t,i,a,s,r,o,l=N,c,d,u,h=e[69].selected,f=st(h,e,e[107],of),m=f||Vy(e),p=!e[42]&&(e[37]===null||e[4].length>e[37])&&cf(e);function b(){return e[91](e[125])}return{key:n,first:null,c(){t=v("li"),m&&m.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=xa(e[118],"selected")),re(t,"active",e[46]===e[125]),this.first=t},m(_,S){D(_,t,S),m&&m.m(t,null),y(t,i),p&&p.m(t,null),c=!0,d||(u=[q(t,"dragstart",function(){Pe(e[57](e[125]))&&e[57](e[125]).apply(this,arguments)}),q(t,"drop",xr(function(){Pe(e[56](e[125]))&&e[56](e[125]).apply(this,arguments)})),q(t,"dragenter",b),q(t,"dragover",xr(e[85]))],d=!0)},p(_,S){e=_,f?f.p&&(!c||S[0]&16|S[3]&16384)&&ot(f,h,e,e[107],c?rt(h,e[107],S,Fy):lt(e[107]),of):m&&m.p&&(!c||S[0]&16|S[1]&2|S[3]&16384)&&m.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=cf(e),p.c(),E(p,1),p.m(t,null)):p&&(le(),I(p,1,1,()=>{p=null}),ce()),(!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=xa(e[118],"selected")))&&g(t,"style",r),(!c||S[0]&8388624|S[1]&32768)&&re(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(m,_),E(p),c=!0)},o(_){I(m,_),I(p),c=!1},d(_){_&&x(t),m&&m.d(_),p&&p.d(),d=!1,oe(u)}}}function df(n){let e,t=n[69].spinner,i=st(t,n,n[107],tf),a=i||Gy(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,Ry):lt(s[107]),tf)},i(s){e||(E(a,s),e=!0)},o(s){I(a,s),e=!1},d(s){a&&a.d(s)}}}function Gy(n){let e,t;return e=new Dl({}),{c(){ie(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 Ky(n){let e,t,i,a=n[26]&&(n[26]>1||n[27])&&hf(n),s=n[26]!==1&&n[4].length>1&&ff(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=hf(r),a.c(),E(a,1),a.m(e.parentNode,e)):a&&(le(),I(a,1,1,()=>{a=null}),ce()),r[26]!==1&&r[4].length>1?s?(s.p(r,o),o[0]&67108880&&E(s,1)):(s=ff(r),s.c(),E(s,1),s.m(t.parentNode,t)):s&&(le(),I(s,1,1,()=>{s=null}),ce())},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 $y(n){let e,t=n[69]["disabled-icon"],i=st(t,n,n[107],ef),a=i||Xy(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,Py):lt(s[107]),ef)},i(s){e||(E(a,s),e=!0)},o(s){I(a,s),e=!1},d(s){a&&a.d(s)}}}function hf(n){let e,t,i;function a(r){n[94](r)}let s={angle:20,$$slots:{default:[Yy]},$$scope:{ctx:n}};return n[43]!==void 0&&(s.wiggle=n[43]),e=new Il({props:s}),Re.push(()=>Wt(e,"wiggle",a)),{c(){ie(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],Ft(()=>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 Yy(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 ff(n){let e,t,i,a,s=n[69]["remove-icon"],r=st(s,n,n[107],Zh),o=r||Jy(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=[q(e,"mouseup",ln(n[53])),q(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,Oy):lt(l[107]),Zh),(!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,oe(a)}}}function Jy(n){let e,t;return e=new js({props:{width:"15px"}}),{c(){ie(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 Xy(n){let e,t;return e=new Bl({props:{width:"14pt",style:"margin: 0 2pt;","data-name":"disabled-icon"}}),{c(){ie(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 mf(n){let e,t,i,a,s,r,o=be(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]&&pf(Fl(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),re(e,"hidden",!n[8])},m(u,h){D(u,e,h);for(let f=0;f{d=null}),ce()),(!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)&&re(e,"hidden",!u[8])},i(u){if(!r){for(let h=0;h{i=null}),ce())},i(a){t||(E(i),t=!0)},o(a){I(i),t=!1},d(a){a&&x(e),i&&i.d(a)}}}function bf(n){let e,t,i,a,s=n[69]["user-msg"],r=st(s,n,n[107],Yh),o=r||nv(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"),re(e,"active",n[44]),ze(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=[q(e,"mousedown",ln(n[70])),q(e,"mouseup",ln(n[100])),q(e,"mouseover",n[101]),q(e,"focus",n[102]),q(e,"mouseout",n[103]),q(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,Ey):lt(l[107]),Yh):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)&&re(e,"active",l[44]),c[0]&1073810458&&ze(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,oe(a)}}}function nv(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 iv(n){let e,t,i,a,s,r,o,l=[],c=new Map,d,u,h,f,m,p,b,_,S,C,M,w,k,A,P,B,L;It(n[86]);let O=n[69]["expand-icon"],j=st(O,n,n[107],lf),Z=j||Hy(n),ee=be(n[4]),ae=U=>U[16]?[U[17](U[118]),U[125]]:U[17](U[118]);for(let U=0;U0?1:-1}~(C=he(n,[-1,-1,-1,-1,-1]))&&(M=H[C]=F[C](n));let ue=(n[3]&&n[30]||n[2]?.length>0)&&mf(n);return{c(){e=v("div"),t=v("input"),s=R(),Z&&Z.c(),r=R(),o=v("ul");for(let U=0;U=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",f=n[4].length==0?n[34]:null),g(u,"aria-invalid",m=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"),re(e,"disabled",n[42]),re(e,"single",n[26]===1),re(e,"open",n[8]),re(e,"invalid",n[7])},m(U,z){D(U,e,z),y(e,t),n[87](t),y(e,s),Z&&Z.m(e,null),y(e,r),y(e,o);for(let me=0;me=Number(U[38])?JSON.stringify(U[4]):null)&&t.value!==a)&&(t.value=a),j&&j.p&&(!P||z[0]&256|z[3]&16384)&&ot(j,O,U,U[107],P?rt(O,U[107],z,Wy):lt(U[107]),lf),z[0]&8585232|z[1]&109611362|z[3]&16384){ee=be(U[4]),le();for(let Ce=0;Ce{Y=null}),ce());let me=C;C=he(U,z),C===me?~C&&H[C].p(U,z):(M&&(le(),I(H[me],1,1,()=>{H[me]=null}),ce()),~C?(M=H[C],M?M.p(U,z):(M=H[C]=F[C](U),M.c()),E(M,1),M.m(e,w)):M=null),U[3]&&U[30]||U[2]?.length>0?ue?(ue.p(U,z),z[0]&1073741836&&E(ue,1)):(ue=mf(U),ue.c(),E(ue,1),ue.m(e,null)):ue&&(le(),I(ue,1,1,()=>{ue=null}),ce()),(!P||z[1]&1&&k!==(k="multiselect "+U[31]+" svelte-1r2hsto"))&&g(e,"class",k),(!P||z[0]&16384|z[1]&2048&&A!==(A=U[42]?U[14]:null))&&g(e,"title",A),(!P||z[0]&262144)&&g(e,"data-id",U[18]),(!P||z[1]&2049)&&re(e,"disabled",U[42]),(!P||z[0]&67108864|z[1]&1)&&re(e,"single",U[26]===1),(!P||z[0]&256|z[1]&1)&&re(e,"open",U[8]),(!P||z[0]&128|z[1]&1)&&re(e,"invalid",U[7])},i(U){if(!P){E(Z,U);for(let z=0;z`${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:B=null}=e,{inputClass:L=""}=e,{inputmode:O=null}=e,{invalid:j=!1}=e,{liActiveOptionClass:Z=""}=e,{liOptionClass:ee=""}=e,{liSelectedClass:ae=""}=e,{loading:$=!1}=e,{matchingOptions:W=[]}=e,{maxOptions:Y=void 0}=e,{maxSelect:F=null}=e,{maxSelectMsg:H=(T,Ee)=>Ee>1?`${T}/${Ee}`:""}=e,{maxSelectMsgClass:he=""}=e,{name:ue=null}=e,{noMatchingOptionsMsg:U="No matching options"}=e,{open:z=!1}=e,{options:me}=e,{outerDiv:Ce=null}=e,{outerDivClass:Ie=""}=e,{parseLabelsAsHtml:et=!1}=e,{pattern:Tt=null}=e,{placeholder:mi=null}=e,{removeAllTitle:gi="Remove all"}=e,{removeBtnTitle:Rt="Remove"}=e,{minSelect:Nt=null}=e,{required:bt=!1}=e,{resetFilterOnAdd:Qs=!0}=e,{searchText:Qe=""}=e,{selected:De=me?.filter(T=>T instanceof Object&&T?.preselected).slice(0,F??void 0)??[]}=e,{sortSelected:Vn=!1}=e,{selectedOptionsDraggable:Zs=!Vn}=e,{ulOptionsClass:Kl=""}=e,{ulSelectedClass:$l=""}=e,{value:Pa=null}=e,Tf=T=>{t(59,Pa=F===1?T[0]??null:T)},Df=T=>{F===1?t(4,De=T?[T]:[]):t(4,De=T??[])},Ra=!1;me?.length>0||(c||$||p||d?me=[]: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 bt=="number"&&bt>F&&console.error(`MultiSelect maxSelect=${F} < required=${bt}, 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!"),Vn&&Zs&&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.`),Y&&(typeof Y!="number"||Y<0||Y%1!=0)&&console.error(`MultiSelect's maxOptions must be undefined or a positive integer, got ${Y}`);let mn=Me(),Un=!1,er;if(r!==null&&!W[r])throw`Run time error, activeIndex=${r} is out of bounds, matchingOptions.length=${W.length}`;function ji(T,Ee){F&&F>1&&De.length>=F&&t(43,Ra=!0),!isNaN(Number(T))&&typeof De.map(it)[0]=="number"&&(T=Number(T));let Ke=De.map(C).includes(C(T));if((F===null||F===1||De.length0&&(typeof me[0]=="object"?T={label:Qe}:(["number","undefined"].includes(typeof me[0])&&!isNaN(Number(Qe))?T=Number(Qe):T=Qe,mn("create",{option:T})),c==="append"&&t(2,me=[...me,T])),Qs&&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]),Vn===!0?t(4,De=De.sort((ir,Gn)=>{let[Ui,Ba]=[it(ir),it(Gn)];return`${Ui}`.localeCompare(`${Ba}`)})):typeof Vn=="function"&&t(4,De=De.sort(Vn)));let yt=De.length===F,pi=w===!0||w==="desktop"&&erC(yt)===C(T)),[Ke]=De.splice(Ee,1);if(Ke===void 0&&c&&(Ke=typeof me[0]?{label:T}:T),Ke===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,j=!1),k?.setCustomValidity(""),mn("remove",{option:Ke}),mn("change",{option:Ke,type:"remove"})}function Yl(T){p||(t(8,z=!0),T instanceof FocusEvent||B?.focus(),mn("open",{event:T}))}function tr(T){t(8,z=!1),B?.blur(),t(0,r=null),mn("close",{event:T})}async function Ef(T){if(T.key==="Escape"||T.key==="Tab")tr(T),t(3,Qe="");else if(T.key==="Enter")T.preventDefault(),o?(De.includes(o)?Vi(o):ji(o,T),t(3,Qe="")):c&&Qe.length>0?ji(Qe,T):Yl(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,Un=!Un);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 Xa();let Ke=document.querySelector("ul.options > li.active");Ke&&Ke.scrollIntoViewIfNeeded?.()}}else T.key==="Backspace"&&De.length>0&&!Qe?Vi(De.at(-1)):W.length>0&&t(0,r=0)}function Mf(){mn("removeAll",{options:De}),mn("change",{options:De,type:"removeAll"}),t(4,De=[]),t(3,Qe="")}let If=T=>Ee=>{["Enter","Space"].includes(Ee.code)&&(Ee.preventDefault(),T())};function Of(T){Ce&&!Ce.contains(T.target)&&tr(T)}let nr=null,Pf=T=>Ee=>{if(!Ee.dataTransfer)return;Ee.dataTransfer.dropEffect="move";let Ke=parseInt(Ee.dataTransfer.getData("text/plain")),yt=[...De];KeEe=>{Ee.dataTransfer&&(Ee.dataTransfer.effectAllowed="move",Ee.dataTransfer.dropEffect="move",Ee.dataTransfer.setData("text/plain",`${T}`))},Na;function Nf(T){if(!A||typeof CSS>"u"||!CSS.highlights)return;CSS.highlights.clear();let Ee=T?.target?.value.trim().toLowerCase();if(!Ee)return;let Ke=document.createTreeWalker(Na,NodeFilter.SHOW_TEXT,{acceptNode:Gn=>Gn?.textContent===U?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),yt=[],pi=Ke.nextNode();for(;pi;)yt.push(pi),pi=Ke.nextNode();let ir=yt.map(Gn=>{let Ui=Gn.textContent?.toLowerCase(),Ba=[],ar=0;for(;Ui&&ar{let sr=new Range;return sr.setStart(Gn,bi),sr.setEnd(Gn,bi+Ee.length),sr})});CSS.highlights.set("sms-search-matches",new Highlight(...ir.flat()))}function Bf(T){Ge.call(this,n,T)}function Lf(T){Ge.call(this,n,T)}function Ff(T){Ge.call(this,n,T)}function Wf(T){Ge.call(this,n,T)}function Hf(T){Ge.call(this,n,T)}function zf(T){Ge.call(this,n,T)}function qf(T){Ge.call(this,n,T)}function jf(T){Ge.call(this,n,T)}function Vf(T){Ge.call(this,n,T)}function Uf(T){Ge.call(this,n,T)}function Gf(T){Ge.call(this,n,T)}function Kf(T){Ge.call(this,n,T)}function $f(T){Ge.call(this,n,T)}function Yf(T){Ge.call(this,n,T)}function Jf(T){Ge.call(this,n,T)}function Xf(T){Ge.call(this,n,T)}function Qf(){t(45,er=window.innerWidth)}function Zf(T){Re[T?"unshift":"push"](()=>{k=T,t(5,k)})}let em=()=>{t(7,j=!0);let T;F&&F>1&&Number(bt)>1?T=`Please select between ${bt} and ${F} options`:Number(bt)>1?T=`Please select at least ${bt} options`:T="Please select an option",k?.setCustomValidity(T)},tm=T=>Vi(T),nm=T=>Vi(T),im=T=>t(46,nr=T);function am(T){Re[T?"unshift":"push"](()=>{B=T,t(6,B)})}function sm(){Qe=this.value,t(3,Qe)}function rm(T){Ra=T,t(43,Ra)}let om=(T,Ee,Ke)=>{T||ji(Ee,Ke)},lm=(T,Ee)=>{T||t(0,r=Ee)},cm=(T,Ee)=>{T||t(0,r=Ee)},um=()=>t(0,r=null),dm=()=>t(0,r=null),hm=T=>{c&&ji(Qe,T)},fm=()=>t(44,Un=!0),mm=()=>t(44,Un=!0),gm=()=>t(44,Un=!1),pm=()=>t(44,Un=!1);function bm(T){Re[T?"unshift":"push"](()=>{Na=T,t(47,Na)})}function ym(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,f=T.breakpoint),"defaultDisabledTitle"in T&&t(13,m=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,B=T.input),"inputClass"in T&&t(19,L=T.inputClass),"inputmode"in T&&t(20,O=T.inputmode),"invalid"in T&&t(7,j=T.invalid),"liActiveOptionClass"in T&&t(21,Z=T.liActiveOptionClass),"liOptionClass"in T&&t(22,ee=T.liOptionClass),"liSelectedClass"in T&&t(23,ae=T.liSelectedClass),"loading"in T&&t(24,$=T.loading),"matchingOptions"in T&&t(1,W=T.matchingOptions),"maxOptions"in T&&t(25,Y=T.maxOptions),"maxSelect"in T&&t(26,F=T.maxSelect),"maxSelectMsg"in T&&t(27,H=T.maxSelectMsg),"maxSelectMsgClass"in T&&t(28,he=T.maxSelectMsgClass),"name"in T&&t(29,ue=T.name),"noMatchingOptionsMsg"in T&&t(30,U=T.noMatchingOptionsMsg),"open"in T&&t(8,z=T.open),"options"in T&&t(2,me=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,Tt=T.pattern),"placeholder"in T&&t(34,mi=T.placeholder),"removeAllTitle"in T&&t(35,gi=T.removeAllTitle),"removeBtnTitle"in T&&t(36,Rt=T.removeBtnTitle),"minSelect"in T&&t(37,Nt=T.minSelect),"required"in T&&t(38,bt=T.required),"resetFilterOnAdd"in T&&t(67,Qs=T.resetFilterOnAdd),"searchText"in T&&t(3,Qe=T.searchText),"selected"in T&&t(4,De=T.selected),"sortSelected"in T&&t(68,Vn=T.sortSelected),"selectedOptionsDraggable"in T&&t(39,Zs=T.selectedOptionsDraggable),"ulOptionsClass"in T&&t(40,Kl=T.ulOptionsClass),"ulSelectedClass"in T&&t(41,$l=T.ulSelectedClass),"value"in T&&t(59,Pa=T.value),"$$scope"in T&&t(107,s=T.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&16&&Tf(De),n.$$.dirty[1]&268435456&&Df(Pa),n.$$.dirty[0]&196636|n.$$.dirty[2]&4&&t(1,W=me.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,me,Qe,De,k,B,j,z,Ce,l,c,u,m,b,_,S,C,P,L,O,Z,ee,ae,$,Y,F,H,he,ue,U,Ie,et,Tt,mi,gi,Rt,Nt,bt,Zs,Kl,$l,p,Ra,Un,er,nr,Na,i,ji,Vi,Yl,Ef,Mf,If,Of,Pf,Rf,Nf,Pa,o,d,h,f,M,w,A,Qs,Vn,a,Bf,Lf,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,dm,hm,fm,mm,gm,pm,bm,ym,s]}var Wl=class extends G{constructor(e){super(),K(this,e,av,iv,V,{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},Dy,[-1,-1,-1,-1,-1])}},Aa=Wl;function sv(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=sv);function rv(n){se(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 ov(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 Aa({props:r}),Re.push(()=>Wt(t,"selected",s)),{c(){e=v("div"),ie(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],Ft(()=>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 lv(n,e,t){let i,a=N,s=()=>(a(),a=Dt(r,u=>t(2,i=u)),r);n.$$.on_destroy.push(()=>a());let{filter:r}=e;s();let{options:o}=e,l=[...o,Hs],{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 Hl=class extends G{constructor(e){super(),K(this,e,lv,ov,V,{filter:0,options:4,placeholder:1},rv)}},yf=Hl;function cv(n){se(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 vf(n){let e,t,i,a;return t=new yf({props:{options:n[1],placeholder:"Sources",filter:di}}),{c(){e=v("div"),ie(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&&It(()=>{a&&(i||(i=Jn(e,Ri,{easing:on},!0)),i.run(1))}),a=!0)},o(s){I(t.$$.fragment,s),s&&(i||(i=Jn(e,Ri,{easing:on},!1)),i.run(0)),a=!1},d(s){s&&x(e),ne(t),s&&i&&i.end()}}}function uv(n){let e,t,i,a,s,r,o,l,c,d,u,h,f,m,p,b,_,S,C,M;i=new Kh({props:{filter:wn,placeholder:"Search Creatures"}});let w=n[0]&&vf(n);return{c(){e=v("div"),t=v("div"),ie(i.$$.fragment),a=R(),s=v("div"),r=v("div"),l=R(),c=v("div"),d=pe(n[2]),u=R(),h=v("div"),m=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,m),y(t,p),y(e,_),w&&w.m(e,null),S=!0,C||(M=[J(o=n[7].call(null,r)),q(s,"click",n[9]),J(f=n[5].call(null,h)),q(h,"click",n[10]),J(b=n[6].call(null,p)),q(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=vf(k),w.c(),E(w,1),w.m(e,null)):w&&(le(),I(w,1,1,()=>{w=null}),ce())},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,oe(M)}}}function dv(n,e,t){let i,a,s,r;Se(n,di,_=>t(12,i=_)),Se(n,wn,_=>t(13,a=_)),Se(n,Uh,_=>t(2,r=_));let o=Le([...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 Vs.ExtraButtonComponent(_).setIcon("reset")},u=_=>{new Vs.ExtraButtonComponent(_).setIcon("trash")},h=_=>{new Vs.ExtraButtonComponent(_).setIcon("filter")},f=()=>{Ae(wn,a="",a),Ae(di,i=[],i)};return[c,s,r,o,l,d,u,h,f,()=>t(0,c=!c),()=>f(),()=>l("remove")]}var zl=class extends G{constructor(e){super(),K(this,e,dv,uv,V,{},cv)}},kf=zl;var Sf=require("obsidian");function hv(n){se(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 wf(n,e,t){let i=n.slice();return i[16]=e[t],i}function _f(n,e){let t,i,a;return i=new Gh({props:{item:e[16]}}),i.$on("close",e[13]),{key:n,first:null,c(){t=_e(),ie(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 fv(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,f=[],m=new Map,p,b,_,S;i=new kf({}),i.$on("remove",n[12]);let C=be(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=Le(50),h=Le(1),f=kt([c,wn,di],([C,M,w])=>{let k=[];for(let A of C){let P=!0;M.length&&((0,Sf.prepareSimpleSearch)(M)(A.name)||(P=!1)),w.length&&![A.source].flat().some(B=>B&&w.includes(B))&&(P=!1),!A.source&&w.includes(Hs)&&(P=!0),P&&k.push(A)}return k});Se(n,f,C=>t(2,i=C));let m=async()=>{i.length&&await fo(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=kt([u,f],([C,M])=>Math.ceil(M.length/C)),b=kt([f,u,h],([C,M,w])=>C.slice((w-1)*M,w*M));Se(n,b,C=>t(3,s=C));let _=()=>m();function S(C){Ge.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,f,m,p,b,r,_,S]}var ql=class extends G{constructor(e){super(),K(this,e,mv,fv,V,{plugin:11,backgroundColor:0,paddingTop:1},hv)}},Cf=ql;var Da=class extends ke.PluginSettingTab{constructor(t,i){super(t,i);this.plugin=i;this.results=[];this.importer=new Ca(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:Wi.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 xf.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 f=new FileReader;f.onload=async m=>{try{let p=JSON.parse(m.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=Q(),!this.plugin.settings.alwaysImport&&p.blocks.find(b=>b.type=="javascript")&&!await gv(this.plugin)&&u(),this.plugin.settings.layouts.push(this.getDuplicate(p)),u()}catch(p){h(p)}},f.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 Ta(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:Q()}}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 Ta(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 Ta(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 f=new ke.Setting(a).setName("Import TetraCube Data").setDesc("Only import content that you own."),m=createEl("input",{attr:{type:"file",name:"tetra",accept:".json, .monster",multiple:!0}});m.onchange=async()=>{let{files:w}=m;if(!w?.length)return;let k=await this.importer.import(w,"tetra");k&&k.length&&await this.plugin.saveMonsters(k),this.display()},f.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import TetraCube Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(m),w.onClick(()=>m.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 zi(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 Cf({target:i,props:{plugin:this.plugin,backgroundColor:s,paddingTop:r}})}hide(){this.$UI.$destroy()}},Ta=class extends _t{constructor(t,i={name:"Layout",blocks:[],id:Q()}){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 Mh({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 gv(n){return new Promise((e,t)=>{try{let i=new jl(n);i.onClose=()=>{e(i.confirmed)},i.open()}catch{t()}})}var jl=class extends _t{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 Us=require("obsidian");var pv=["creature","name","layout","source","dice","render","columns","forceColumns","columnWidth","columnHeight","extends"],Vs=class extends Us.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([...pv,...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}: +${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 Ta(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:Q()}}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 Ta(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 Ta(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 f=new ke.Setting(a).setName("Import TetraCube Data").setDesc("Only import content that you own."),m=createEl("input",{attr:{type:"file",name:"tetra",accept:".json, .monster",multiple:!0}});m.onchange=async()=>{let{files:w}=m;if(!w?.length)return;let k=await this.importer.import(w,"tetra");k&&k.length&&await this.plugin.saveMonsters(k),this.display()},f.addButton(w=>{w.setButtonText("Choose File(s)").setTooltip("Import TetraCube Data"),w.buttonEl.addClass("statblock-file-upload"),w.buttonEl.appendChild(m),w.onClick(()=>m.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 zi(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 Cf({target:i,props:{plugin:this.plugin,backgroundColor:s,paddingTop:r}})}hide(){this.$UI.$destroy()}},Ta=class extends _t{constructor(t,i={name:"Layout",blocks:[],id:Q()}){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 Mh({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 gv(n){return new Promise((e,t)=>{try{let i=new jl(n);i.onClose=()=>{e(i.confirmed)},i.open()}catch{t()}})}var jl=class extends _t{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 Gs=require("obsidian");var pv=["creature","name","layout","source","dice","render","columns","forceColumns","columnWidth","columnHeight","extends"],Us=class extends Gs.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([...pv,...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,f]=d;return f==="true"||f==="false"?null:{end:t,start:{ch:h.length+2,line:t.line},query:f}}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,f]=d;return ve.getBestiaryNames().find(m=>m.toLowerCase()==f.toLowerCase())?null:{end:t,start:{ch:h.length+2,line:t.line},query:f}}if(/^(layout):/m.test(c)){this._context=0;let d=c.match(/^(layout):\s?(.*)\n?/);if(!d)return null;let[u,h,f]=d;return this.plugin.manager.getAllLayouts().find(p=>p.name.toLowerCase()==f.toLowerCase())?null:{end:t,start:{ch:h.length+2,line:t.line},query:f}}try{let d=i.getValue().split(` -`);d.splice(t.line,1),d=d.slice(l+1);let u=d.findIndex(f=>/^```$/.test(f));u<0&&(u=d.length);let h=(0,Us.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,St,Vl,Gs,Ma,fn,_n,Ia,Ul,Gl,Ea=class{constructor(){Be(this,St);Be(this,fi,new Map);Be(this,Ma);Be(this,fn,new Map);Be(this,_n,new Map);Be(this,Ia,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 X(this,fi).values())e.detach()}addStyleSheet(e){this.removeStyleSheet(e.id);let t=this.generateStyleSheet(e);t&&X(this,fi).set(e.id,t)}removeStyleSheet(e){X(this,fi).has(e)&&X(this,fi).get(e).detach()}getSheetRules(e){if(!e.cssProperties)return[];let t=`.${ki(e.name)}`,i=[Oe(this,St,Gs).call(this,t,{...ul,...e.cssProperties})];return Te.Light in e.cssProperties&&i.push(Oe(this,St,Gs).call(this,`.theme-light ${t}`,e.cssProperties[Te.Light])),Te.Dark in e.cssProperties&&i.push(Oe(this,St,Gs).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){X(this,fn).delete(e),this.setDefaultLayouts({[t.id]:t}),this.addStyleSheet(t)}removeDefaultLayout(e){X(this,fn).delete(e),this.removeStyleSheet(e)}setDefaultLayouts(e){for(let t of ci)X(this,fn).set(t.id,t.id in e?e[t.id]:t);setTimeout(()=>{for(let t of X(this,fn).values())Oe(this,St,Ul).call(this,t)},0)}setDefaultLayout(e){an(this,Ma,e)}getDefaultLayout(){return this.getAllLayouts()?.find(e=>e.id==X(this,Ma))??rn}setLayouts(e){for(let t of e)X(this,_n).set(t.id,t);setTimeout(()=>{for(let t of e)Oe(this,St,Ul).call(this,t)},0)}getCustomLayouts(){return X(this,_n).values()}getAllLayouts(){return[...X(this,fn).values(),...X(this,_n).values()].filter(e=>!("removed"in e)||!e.removed)}getAllDefaultLayouts(){return[...X(this,fn).values()]}getLayout(e){return X(this,_n).get(e)??X(this,fn).get(e)??null}getLayoutOrDefault(e){return this.getAllLayouts().find(t=>t.name==e)??this.getDefaultLayout()}updateLayout(e,t){X(this,_n).delete(e),this.setLayouts([t]),this.addStyleSheet(t)}removeLayout(e){X(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 X(this,Ia).get(t)}};fi=new WeakMap,St=new WeakSet,Vl=function(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)},Gs=function(e,t){let i=[];for(let[a,s]of Object.entries(t)){if(a==Te.Dark||a==Te.Light)continue;let r=_a.includes(s)?`var(--statblock-${Oe(this,St,Vl).call(this,s)})`:s;i.push(` +`);d.splice(t.line,1),d=d.slice(l+1);let u=d.findIndex(f=>/^```$/.test(f));u<0&&(u=d.length);let h=(0,Gs.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,St,Vl,Ks,Ma,fn,_n,Ia,Ul,Gl,Ea=class{constructor(){Be(this,St);Be(this,fi,new Map);Be(this,Ma);Be(this,fn,new Map);Be(this,_n,new Map);Be(this,Ia,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 X(this,fi).values())e.detach()}addStyleSheet(e){this.removeStyleSheet(e.id);let t=this.generateStyleSheet(e);t&&X(this,fi).set(e.id,t)}removeStyleSheet(e){X(this,fi).has(e)&&X(this,fi).get(e).detach()}getSheetRules(e){if(!e.cssProperties)return[];let t=`.${ki(e.name)}`,i=[Oe(this,St,Ks).call(this,t,{...ul,...e.cssProperties})];return Te.Light in e.cssProperties&&i.push(Oe(this,St,Ks).call(this,`.theme-light ${t}`,e.cssProperties[Te.Light])),Te.Dark in e.cssProperties&&i.push(Oe(this,St,Ks).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){X(this,fn).delete(e),this.setDefaultLayouts({[t.id]:t}),this.addStyleSheet(t)}removeDefaultLayout(e){X(this,fn).delete(e),this.removeStyleSheet(e)}setDefaultLayouts(e){for(let t of ci)X(this,fn).set(t.id,t.id in e?e[t.id]:t);setTimeout(()=>{for(let t of X(this,fn).values())Oe(this,St,Ul).call(this,t)},0)}setDefaultLayout(e){an(this,Ma,e)}getDefaultLayout(){return this.getAllLayouts()?.find(e=>e.id==X(this,Ma))??rn}setLayouts(e){for(let t of e)X(this,_n).set(t.id,t);setTimeout(()=>{for(let t of e)Oe(this,St,Ul).call(this,t)},0)}getCustomLayouts(){return X(this,_n).values()}getAllLayouts(){return[...X(this,fn).values(),...X(this,_n).values()].filter(e=>!("removed"in e)||!e.removed)}getAllDefaultLayouts(){return[...X(this,fn).values()]}getLayout(e){return X(this,_n).get(e)??X(this,fn).get(e)??null}getLayoutOrDefault(e){return this.getAllLayouts().find(t=>t.name==e)??this.getDefaultLayout()}updateLayout(e,t){X(this,_n).delete(e),this.setLayouts([t]),this.addStyleSheet(t)}removeLayout(e){X(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 X(this,Ia).get(t)}};fi=new WeakMap,St=new WeakSet,Vl=function(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)},Ks=function(e,t){let i=[];for(let[a,s]of Object.entries(t)){if(a==Te.Dark||a==Te.Light)continue;let r=_a.includes(s)?`var(--statblock-${Oe(this,St,Vl).call(this,s)})`:s;i.push(` --statblock-${Oe(this,St,Vl).call(this,a)}: ${r};`)}return`${e} {${i.join("")} - }`},Ma=new WeakMap,fn=new WeakMap,_n=new WeakMap,Ia=new WeakMap,Ul=function(e){let t=new Map;X(this,Ia).set(e,Oe(this,St,Gl).call(this,e.blocks,t))},Gl=function(e,t){for(let i of e){if("nested"in i){Oe(this,St,Gl).call(this,i.nested,t);continue}if("properties"in i)for(let a of i.properties)t.set(a,i)}return t};var zn=require("obsidian");var Sn="fantasy-statblocks-creature-pane",Oa=class extends zn.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,zn.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 zn.SearchComponent(this.topEl).setPlaceholder("Find a creature"),i=new Fi(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 zn.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 $s=require("obsidian");var qn,Ks=class{constructor(e){Be(this,qn);an(this,qn,e)}getVersion(){return X(this,qn).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 Yt({container:t,monster:a,plugin:X(this,qn),context:"STATBLOCK_RENDERER"})):new $s.Component}isStatblockLink(e){return Ht.isStatblockLink(e)}parseStatblockLink(e){return Ht.stringifyLinks(e)}stringifyLinks(e){return Ht.stringifyLinks(e)}transformLinks(e){return Ht.transformSource(e)}renderMarkdown(e,t,i="",a=X(this,qn)){$s.MarkdownRenderer.render(X(this,qn).app,e,t,i,a)}};qn=new WeakMap;var hi="FANTASY_STATBLOCKS_PLUGIN",bv={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},Js,Ys=class extends jn.Plugin{constructor(){super(...arguments);this.manager=new Ea;this.api=new Ks(this);Be(this,Js,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 Oa)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",X(this,Js).bind(this)),(0,jn.addIcon)("markdown-icon",''),this.addSettingTab(new Da(this.app,this)),(window.FantasyStatblocks=this.api)&&this.register(()=>delete window.FantasyStatblocks),this.registerMarkdownCodeBlockProcessor("statblock",this.postprocessor.bind(this)),this.registerEditorSuggest(new Vs(this)),this.registerView(Sn,t=>new Oa(t,this)),this.canUseDiceRoller&&window.DiceRoller.registerSource(hi,{showDice:!0,shouldRender:this.settings.renderDice,showFormula:!1,showParens:!1,expectedValue:Wi.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:Wi.Average,text:null})}))}async loadSettings(){let t=await this.loadData();if(this.settings={...bv,...t},!this.settings.defaultLayoutsIntegrated){for(let s of this.settings.layouts)s.id=Q();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,Af.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 jn.Notice(`There was an error creating the image: + }`},Ma=new WeakMap,fn=new WeakMap,_n=new WeakMap,Ia=new WeakMap,Ul=function(e){let t=new Map;X(this,Ia).set(e,Oe(this,St,Gl).call(this,e.blocks,t))},Gl=function(e,t){for(let i of e){if("nested"in i){Oe(this,St,Gl).call(this,i.nested,t);continue}if("properties"in i)for(let a of i.properties)t.set(a,i)}return t};var zn=require("obsidian");var Sn="fantasy-statblocks-creature-pane",Oa=class extends zn.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,zn.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 zn.SearchComponent(this.topEl).setPlaceholder("Find a creature"),i=new Fi(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 zn.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 Ys=require("obsidian");var qn,$s=class{constructor(e){Be(this,qn);an(this,qn,e)}getVersion(){return X(this,qn).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 Yt({container:t,monster:a,plugin:X(this,qn),context:"STATBLOCK_RENDERER"})):new Ys.Component}isStatblockLink(e){return Ht.isStatblockLink(e)}parseStatblockLink(e){return Ht.stringifyLinks(e)}stringifyLinks(e){return Ht.stringifyLinks(e)}transformLinks(e){return Ht.transformSource(e)}renderMarkdown(e,t,i="",a=X(this,qn)){Ys.MarkdownRenderer.render(X(this,qn).app,e,t,i,a)}};qn=new WeakMap;var hi="FANTASY_STATBLOCKS_PLUGIN",bv={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},Xs,Js=class extends jn.Plugin{constructor(){super(...arguments);this.manager=new Ea;this.api=new $s(this);Be(this,Xs,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 Oa)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",X(this,Xs).bind(this)),(0,jn.addIcon)("markdown-icon",''),this.addSettingTab(new Da(this.app,this)),(window.FantasyStatblocks=this.api)&&this.register(()=>delete window.FantasyStatblocks),this.registerMarkdownCodeBlockProcessor("statblock",this.postprocessor.bind(this)),this.registerEditorSuggest(new Us(this)),this.registerView(Sn,t=>new Oa(t,this)),this.canUseDiceRoller&&window.DiceRoller.registerSource(hi,{showDice:!0,shouldRender:this.settings.renderDice,showFormula:!1,showParens:!1,expectedValue:Wi.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:Wi.Average,text:null})}))}async loadSettings(){let t=await this.loadData();if(this.settings={...bv,...t},!this.settings.defaultLayoutsIntegrated){for(let s of this.settings.layouts)s.id=Q();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,Af.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 jn.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,jn.parseYaml)(t);i.addClass("statblock-plugin-container"),i.parentElement?.addClass("statblock-plugin-parent");let r=new Yt({container:i,plugin:this,params:s,context:a.sourcePath});a.addChild(r)}catch(s){console.error(`Obsidian Statblock Error: ${s}`),createEl("pre").setText(`\`\`\`statblock @@ -1102,6 +1102,6 @@ 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)}};Js=new WeakMap; +\`\`\``)}}render(t,i,a){this.api.render(t,i,a)}};Xs=new WeakMap; /* nosourcemap */ \ No newline at end of file diff --git a/CAWS/.obsidian/plugins/obsidian-5e-statblocks/manifest.json b/CAWS/.obsidian/plugins/obsidian-5e-statblocks/manifest.json index 6ed10b1..9747727 100644 --- a/CAWS/.obsidian/plugins/obsidian-5e-statblocks/manifest.json +++ b/CAWS/.obsidian/plugins/obsidian-5e-statblocks/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-5e-statblocks", "name": "Fantasy Statblocks", - "version": "4.10.2", + "version": "4.10.3", "description": "Create Fantasy Statblocks in Obsidian.md", "minAppVersion": "0.12.0", "author": "Jeremy Valentine", diff --git a/CAWS/.obsidian/workspace.json b/CAWS/.obsidian/workspace.json index dfb5cc1..77426ec 100644 --- a/CAWS/.obsidian/workspace.json +++ b/CAWS/.obsidian/workspace.json @@ -8,17 +8,17 @@ "type": "tabs", "children": [ { - "id": "4e540ae4fa5ff532", + "id": "6e87b26ee03fcbc1", "type": "leaf", "state": { "type": "markdown", "state": { - "file": "Charaktere/Dungeons and Dragons Charaktere/Sserina.md", + "file": "Charaktere/Dungeons and Dragons Charaktere/Katharina Lavalié.md", "mode": "source", "source": false }, "icon": "lucide-file", - "title": "Sserina" + "title": "Katharina Lavalié" } } ] @@ -142,13 +142,13 @@ "state": { "type": "outline", "state": { - "file": "Regionen/Enwinmar.md", + "file": "Charaktere/Dungeons and Dragons Charaktere/Katharina Lavalié.md", "followCursor": false, "showSearch": false, "searchQuery": "" }, "icon": "lucide-list", - "title": "Gliederung von Enwinmar" + "title": "Gliederung von Katharina Lavalié" } }, { @@ -157,11 +157,21 @@ "state": { "type": "footnotes", "state": { - "file": "Regionen/Enwinmar.md" + "file": "Charaktere/Dungeons and Dragons Charaktere/Katharina Lavalié.md" }, "icon": "lucide-file-signature", "title": "Footnotes" } + }, + { + "id": "2d9076717d8162df", + "type": "leaf", + "state": { + "type": "git-view", + "state": {}, + "icon": "git-pull-request", + "title": "Source Control" + } } ], "currentTab": 3 @@ -180,38 +190,42 @@ "daily-notes:Heutige Notiz öffnen": false, "templates:Vorlage einfügen": false, "command-palette:Befehlspalette öffnen": false, - "workspaces:Workspace-Layouts verwalten": false + "workspaces:Workspace-Layouts verwalten": false, + "obsidian-git:Open Git source control": false } }, - "active": "4e540ae4fa5ff532", + "active": "6e87b26ee03fcbc1", "lastOpenFiles": [ - "Charaktere/Dungeons and Dragons Charaktere/images/xanaphina.webp", - "Charaktere/Dungeons and Dragons Charaktere/images/xanaphina.webp.0.pdnSave", - "Charaktere/Dungeons and Dragons Charaktere/images/sserina.webp", - "Charaktere/Dungeons and Dragons Charaktere/images/sserina.webp.0.pdnSave", - "Charaktere/Dungeons and Dragons Charaktere/images/quelana_gown.webp", - "Charaktere/Dungeons and Dragons Charaktere/images/quelana_gown.webp.0.pdnSave", - "Charaktere/Dungeons and Dragons Charaktere/images/sserina_elv.webp", - "Charaktere/Dungeons and Dragons Charaktere/images/sserina_elv.webp.0.pdnSave", - "Charaktere/Dungeons and Dragons Charaktere/images/quelana_aralar.webp", - "Charaktere/Dungeons and Dragons Charaktere/images/quelana_aralar.webp.0.pdnSave", - "Charaktere/Dungeons and Dragons Charaktere/images/xanaphina.png", - "Charaktere/Dungeons and Dragons Charaktere/images/arabian_elf_8_upscayl_4x_remacri.png", - "Charaktere/Dungeons and Dragons Charaktere/images/sserina.jpg", - "Charaktere/Dungeons and Dragons Charaktere/images/quelana_gown.jpg", - "Charaktere/Dungeons and Dragons Charaktere/images/quelana_aralar.jpg", - "Charaktere/Dungeons and Dragons Charaktere/images/sserina_elv.png", - "Charaktere/Dungeons and Dragons Charaktere/images", - "Charaktere/Dungeons and Dragons Charaktere/Neuer Ordner", - "Unbenannt.base", - "Charaktere/Charakter Übersicht.md", + "Charaktere/Dungeons and Dragons Charaktere/images/schwester_vampir_katharina_ph.webp.0.pdnSave", + "Charaktere/Dungeons and Dragons Charaktere/images/mutter_vampir_katharina_ph.webp.0.pdnSave", + "Charaktere/Dungeons and Dragons Charaktere/images/katharina_lavalie_ph.webp.0.pdnSave", + "Charaktere/Dungeons and Dragons Charaktere/images/katharina_lavalie.jpg", + "Charaktere/Dungeons and Dragons Charaktere/images/mutter_vampir_katharina_ph.webp", + "Charaktere/Dungeons and Dragons Charaktere/images/katharina_lavalie_ph.webp", + "Charaktere/Dungeons and Dragons Charaktere/images/xanaphina_ph.webp", + "Charaktere/Dungeons and Dragons Charaktere/images/schwester_vampir_katharina_ph.webp", + "Charaktere/Dungeons and Dragons Charaktere/images/schwester_vampir_katharina.webp", + "Charaktere/Dungeons and Dragons Charaktere/images/mutter_vampir_katharina.webp", + "Charaktere/Dungeons and Dragons Charaktere/images/_vampir_katharina.webp", + "Charaktere/Dungeons and Dragons Charaktere/images/schwester_vampir_katharina.webp.0.pdnSave", + "Charaktere/Dungeons and Dragons Charaktere/images/mutter_vampir_katharina.webp.0.pdnSave", + "Charaktere/Dungeons and Dragons Charaktere/images/katharina_lavalie.webp", + "Charaktere/Dungeons and Dragons Charaktere/images/katharina_lavalie.webp.0.pdnSave", + "Charaktere/Dungeons and Dragons Charaktere/images/vampire_lady_1_upscayl_4x_realesrgan-x4plus.png", + "Charaktere/Dungeons and Dragons Charaktere/Katharina Lavalié.md", + "Charaktere/Dungeons and Dragons Charaktere/Unbenannt.base", + "Charaktere/Dungeons and Dragons Charaktere/Unbenannt.canvas", + "Charaktere/Dungeons and Dragons Charaktere/Unbenannt.md", "Charaktere/Dungeons and Dragons Charaktere/Quelana Aralar.md", - "Dungeons and Dragons Charaktere/Quelana Aralar.md", "Charaktere/Dungeons and Dragons Charaktere/Sserina.md", - "Dungeons and Dragons Charaktere", "Regionen/Enwinmar.md", "{Kontinent}.md", - "Enwimar - die alten Lande im Süden.md", - "Regionen" + "Charaktere/Dungeons and Dragons Charaktere/images/xanaphina.webp.0.pdnSave", + "Charaktere/Dungeons and Dragons Charaktere/images/sserina.webp.0.pdnSave", + "Charaktere/Dungeons and Dragons Charaktere/images/quelana_gown.webp.0.pdnSave", + "Charaktere/Dungeons and Dragons Charaktere/images/sserina_elv.webp.0.pdnSave", + "Charaktere/Charakter Übersicht.md", + "Dungeons and Dragons Charaktere/Quelana Aralar.md", + "Enwimar - die alten Lande im Süden.md" ] } \ No newline at end of file diff --git a/CAWS/Charaktere/Dungeons and Dragons Charaktere/Katharina Lavalié.md b/CAWS/Charaktere/Dungeons and Dragons Charaktere/Katharina Lavalié.md new file mode 100644 index 0000000..1fbb555 --- /dev/null +++ b/CAWS/Charaktere/Dungeons and Dragons Charaktere/Katharina Lavalié.md @@ -0,0 +1,43 @@ +- Volk: Vampir +- Klasse: Vampir +- Hintergrund: Adlig +## Eigenschaften + +| **Eigenschaft** | **Katharina** | +| --------------- | ------------- | +| Gesinnung | Neutral Gut | +| Glaube | | +| Geschlecht | Weiblich | +| Alter | 25 | +| Augenfarbe | Rot | +| Haar | Weiß | +| Haut | Blassweiß | +| Größe | 171 | +| Gewicht | 62 | + +## Persönlichkeitsmerkmale +Ein Leben, in dem meine Entscheidungen die Richtung vorgeben und niemand anderer. Freiheit, die ich mir hart erkämpft habe. +### Ideale +Mein Siegelring ist meine schützende Tarnung, die mich vor anderen Vampiren, insbesondere meinen Eltern und den Vampiren in Ravenloft verbirgt. Mein Streben gilt der Freiheit. +### Bindungen +Die Hochnäsigkeit und Eigenheiten des Adels wurzeln tief in mir und stellen einen ständigen inneren Konflikt dar. +### Makel +Entschlossen und eigensinnig, das gebe ich zu. Dennoch empfinde ich Befriedigung darin, anderen beizustehen und ihnen die Möglichkeit zu geben, ein verbessertes Leben zu führen, im Vergleich zu dem, was ich einst erlebte. +## Aussehen +Katharina ist eine Vampirin von menschlichen Ursprungs, entstammend einem Volk, welches als Vampir bereits auf die Welt kommt. Sie hat blasse Haut, akzentuierten hohen Wangenknochen und schwarz roten Lippen, sowie Augen die von einem kraftvollen Lidschatten umrahmt sind. Immer an ihrer Seite ist ein prächtiger gold-schwarzer Sonnenschirm, der nicht nur als modisches Accessoire dient, sondern auch als schützender Schirm, der sie vor den schädlichen Strahlen der Sonne bewahrt und auch im Kampf und bei Magie einen Mehrwert bieten kann. Auch wenn Katharina solche Situationen eher vermeiden will. In ihrer Garderobe bevorzugt Katharina adlige Kleider, die perfekt zu ihrem zeitlosen Stil passen. Sie trägt mit Liebe zum Detail gestaltete Ballkleider in den nuancenreichen Farben von intensivem Rot, strahlendem Weiß, königlichem Gold und tiefem Schwarz. + +![[images/katharina_lavalie_ph.webp]] +## Hintergrund +Katharina Lavalié wurde in Zorgrad geboren und ist die Tochter des Vampirlords Mortan von Sangrast sowie ihrer namensgebenden Mutter. Sie hat eine ältere Schwester und beide genossen von Kindesbeinen an eine exzellente Erziehung, geprägt von vornehmer Bildung und tadellosem Benehmen. +Mit 24 Jahren sollte sie dem Adel beitreten und debütieren, genau wie ihre Schwester. Trotz ihrer Verpflichtungen gegenüber ihren Eltern und der Vampiraristokratie fand sie in einem ungewöhnlichen Verbündeten, einem betagten Vampir, einen wahren Freund. Dieser weihte sie in die Geheimnisse der Magie ein, insbesondere in die Kunst der Blutmagie, und teilte viele faszinierende Geschichten aus seiner Zeit als Weltenbummler und Abenteurer. + +Kurz bevor der Tag des Eintritts in den Adel kommen sollte, entschied sich Katharina zur Flucht. Hals über Kopf suchte sie Zuflucht bei ihrem einzigen Vertrauten in der Stadt, dem alten Abenteurer, der ihr beistand und ihr einen Ring schenkte, um sie vor den Blicken anderer Vampire zu schützen. + +Seit diesem Tag befindet sich Katharina auf der Flucht, stets auf der Suche nach einem Weg, ein eigenes Leben als Abenteurerin zu führen, ohne dabei jedoch ihre adlige Herkunft zu verleugnen. Ihr Ziel ist es, die Ketten der Vergangenheit abzuwerfen und endlich ihre eigene Bestimmung zu formen, während sie in den Schatten der Nacht vor ihren Verfolgern davonhuscht. +## Beziehungen + +## {Mutter} +![[mutter_vampir_katharina_ph.webp]] + +### {Schwester} +![[schwester_vampir_katharina_ph.webp]] \ No newline at end of file diff --git a/CAWS/Charaktere/Dungeons and Dragons Charaktere/Sserina.md b/CAWS/Charaktere/Dungeons and Dragons Charaktere/Sserina.md index 6412ec2..76e0f50 100644 --- a/CAWS/Charaktere/Dungeons and Dragons Charaktere/Sserina.md +++ b/CAWS/Charaktere/Dungeons and Dragons Charaktere/Sserina.md @@ -14,7 +14,7 @@ | Haar | Lange wellige braune Haare mit blonden Strähnen | | | | Haut | Hell, leicht bronzene Tönung | glänzend braune Schuppe, leicht grün irisierend | | | Größe | | Aufgerichtet bis 200 cm, Länge gesamt 380 cm | 170 cm | -| Gewicht | | 136 | 64 | +| Gewicht | | 136 kg | 64 kg | ## Persönlichkeitsmerkmale - freundlich, aber dennoch leicht hochnäsig @@ -26,6 +26,9 @@ Sserina will neu anfangen und ist gewillt, alles dafür zu geben. ### Bindungen Xanaphina, eine Elfe aus Calimshan, die sich auf das Schneidern von Kleidung insbesondere für Frauen spezialisiert hat. ### Makel +Hin und hergerissen +- Dendar +- Flucht vor der Yuan-Ti Gesellschaft ## Aussehen diff --git a/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/katharina_lavalie_ph.webp b/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/katharina_lavalie_ph.webp new file mode 100644 index 0000000..29a28da Binary files /dev/null and b/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/katharina_lavalie_ph.webp differ diff --git a/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/mutter_vampir_katharina_ph.webp b/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/mutter_vampir_katharina_ph.webp new file mode 100644 index 0000000..9c5f503 Binary files /dev/null and b/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/mutter_vampir_katharina_ph.webp differ diff --git a/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/schwester_vampir_katharina_ph.webp b/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/schwester_vampir_katharina_ph.webp new file mode 100644 index 0000000..4b06120 Binary files /dev/null and b/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/schwester_vampir_katharina_ph.webp differ diff --git a/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/xanaphina.webp b/CAWS/Charaktere/Dungeons and Dragons Charaktere/images/xanaphina_ph.webp similarity index 100% rename from CAWS/Charaktere/Dungeons and Dragons Charaktere/images/xanaphina.webp rename to CAWS/Charaktere/Dungeons and Dragons Charaktere/images/xanaphina_ph.webp diff --git a/CAWS/Regionen/Enwinmar.md b/CAWS/Regionen/Enwinmar.md index 03d7996..f965a4e 100644 --- a/CAWS/Regionen/Enwinmar.md +++ b/CAWS/Regionen/Enwinmar.md @@ -135,7 +135,7 @@ Die aktuell sieben großen Haupthäuser der Dunkelelfen bilden die herrschende M ### Völker #### Vampire -.. +Hauptstadt #### Ents .. #### Dryaden