/* 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 vC=Object.create;var xl=Object.defineProperty;var yC=Object.getOwnPropertyDescriptor;var bC=Object.getOwnPropertyNames;var _C=Object.getPrototypeOf,wC=Object.prototype.hasOwnProperty;var kC=(i,e,t)=>e in i?xl(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var De=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),SC=(i,e)=>{for(var t in e)xl(i,t,{get:e[t],enumerable:!0})},dy=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of bC(e))!wC.call(i,r)&&r!==t&&xl(i,r,{get:()=>e[r],enumerable:!(n=yC(e,r))||n.enumerable});return i};var xp=(i,e,t)=>(t=i!=null?vC(_C(i)):{},dy(e||!i||!i.__esModule?xl(t,"default",{value:i,enumerable:!0}):t,i)),xC=i=>dy(xl({},"__esModule",{value:!0}),i);var te=(i,e,t)=>(kC(i,typeof e!="symbol"?e+"":e,t),t),hy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Zu=(i,e,t)=>(hy(i,e,"read from private field"),t?t.call(i):e.get(i)),Pl=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)};var Pp=(i,e,t)=>(hy(i,e,"access private method"),t);var Vp=De((gF,wy)=>{"use strict";var Fp=Object.defineProperty,uE=Object.getOwnPropertyDescriptor,fE=Object.getOwnPropertyNames,dE=Object.prototype.hasOwnProperty,hE=(i,e)=>{for(var t in e)Fp(i,t,{get:e[t],enumerable:!0})},pE=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of fE(e))!dE.call(i,r)&&r!==t&&Fp(i,r,{get:()=>e[r],enumerable:!(n=uE(e,r))||n.enumerable});return i},mE=i=>pE(Fp({},"__esModule",{value:!0}),i),_y={};hE(_y,{FileInputSuggest:()=>OE,FolderInputSuggest:()=>gE,FuzzyInputSuggest:()=>Bp,setNodeIcon:()=>bE});wy.exports=mE(_y);var $p=require("obsidian"),Bp=class extends $p.AbstractInputSuggest{constructor(i,e,t){super(i,e.inputEl),this.items=t}getSuggestions(i){let e=(0,$p.prepareSimpleSearch)(i),t=[];for(let n of this.items){let r=e(this.getItemText(n));r&&t.push({item:n,match:r})}return t}renderSuggestion(i,e){e.addClass("mod-complex");let t=e.createDiv({cls:"suggestion-content"});if(!i?.item){t.setText("No match found"),t.parentElement?.addClass("is-selected");return}let n=t.createDiv("suggestion-title");this.renderTitle(n,i);let r=t.createDiv("suggestion-note");this.renderNote(r,i)}renderMatches(i,e,t,n){(0,$p.renderMatches)(i,e,t,n)}},yy=require("obsidian"),gE=class extends Bp{getItemText(i){return i.path}renderNote(i,e){let{item:t,match:n}=e;(0,yy.renderMatches)(i,t.path,n.matches)}renderTitle(i,e){let{item:t,match:n}=e;(0,yy.renderMatches)(i,t.name,n.matches,t.path.length-t.name.length)}},by=require("obsidian"),OE=class extends Bp{getItemText(i){return i.path}renderNote(i,e){let{item:t,match:n}=e;(0,by.renderMatches)(i,t.path,n.matches)}renderTitle(i,e){let{item:t,match:n}=e;(0,by.renderMatches)(i,t.name,n.matches,t.path.length-t.name.length)}},vE=require("obsidian"),yE={"has-node-icon":"helpers_has-node-icon","x-small":"helpers_x-small",small:"helpers_small",medium:"helpers_medium",large:"helpers_large","x-large":"helpers_x-large"};function bE(i,e){i.addClass(yE["has-node-icon"]),(0,vE.setIcon)(i,e)}});var iu=De(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.regexpCode=pt.getEsmExportName=pt.getProperty=pt.safeStringify=pt.stringify=pt.strConcat=pt.addCodeArg=pt.str=pt._=pt.nil=pt._Code=pt.Name=pt.IDENTIFIER=pt._CodeOrName=void 0;var eu=class{};pt._CodeOrName=eu;pt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Uo=class extends eu{constructor(e){if(super(),!pt.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};pt.Name=Uo;var Bn=class extends eu{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((t,n)=>`${t}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((t,n)=>(n instanceof Uo&&(t[n.str]=(t[n.str]||0)+1),t),{})}};pt._Code=Bn;pt.nil=new Bn("");function a4(i,...e){let t=[i[0]],n=0;for(;n{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0});Ki.ValueScope=Ki.ValueScopeName=Ki.Scope=Ki.varKinds=Ki.UsedValueState=void 0;var On=iu(),xO=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},PO;(function(i){i[i.Started=0]="Started",i[i.Completed=1]="Completed"})(PO=Ki.UsedValueState||(Ki.UsedValueState={}));Ki.varKinds={const:new On.Name("const"),let:new On.Name("let"),var:new On.Name("var")};var Ih=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof On.Name?e:this.name(e)}name(e){return new On.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){var t,n;if(!((n=(t=this._parent)===null||t===void 0?void 0:t._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Ki.Scope=Ih;var Nh=class extends On.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=(0,On._)`.${new On.Name(t)}[${n}]`}};Ki.ValueScopeName=Nh;var jN=(0,On._)`\n`,CO=class extends Ih{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?jN:On.nil}}get(){return this._scope}name(e){return new Nh(e,this._newName(e))}value(e,t){var n;if(t.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let r=this.toName(e),{prefix:s}=r,o=(n=t.key)!==null&&n!==void 0?n:t.ref,a=this._values[s];if(a){let u=a.get(o);if(u)return u}else a=this._values[s]=new Map;a.set(o,r);let l=this._scope[s]||(this._scope[s]=[]),c=l.length;return l[c]=t.ref,r.setValue(t,{property:s,itemIndex:c}),r}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,On._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,r=>{if(r.value===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return r.value.code},t,n)}_reduceValues(e,t,n={},r){let s=On.nil;for(let o in e){let a=e[o];if(!a)continue;let l=n[o]=n[o]||new Map;a.forEach(c=>{if(l.has(c))return;l.set(c,PO.Started);let u=t(c);if(u){let f=this.opts.es5?Ki.varKinds.var:Ki.varKinds.const;s=(0,On._)`${s}${f} ${c} = ${u};${this.opts._n}`}else if(u=r?.(c))s=(0,On._)`${s}${u}${this.opts._n}`;else throw new xO(c);l.set(c,PO.Completed)})}return s}};Ki.ValueScope=CO});var Je=De(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.or=Ue.and=Ue.not=Ue.CodeGen=Ue.operators=Ue.varKinds=Ue.ValueScopeName=Ue.ValueScope=Ue.Scope=Ue.Name=Ue.regexpCode=Ue.stringify=Ue.getProperty=Ue.nil=Ue.strConcat=Ue.str=Ue._=void 0;var st=iu(),yr=EO(),no=iu();Object.defineProperty(Ue,"_",{enumerable:!0,get:function(){return no._}});Object.defineProperty(Ue,"str",{enumerable:!0,get:function(){return no.str}});Object.defineProperty(Ue,"strConcat",{enumerable:!0,get:function(){return no.strConcat}});Object.defineProperty(Ue,"nil",{enumerable:!0,get:function(){return no.nil}});Object.defineProperty(Ue,"getProperty",{enumerable:!0,get:function(){return no.getProperty}});Object.defineProperty(Ue,"stringify",{enumerable:!0,get:function(){return no.stringify}});Object.defineProperty(Ue,"regexpCode",{enumerable:!0,get:function(){return no.regexpCode}});Object.defineProperty(Ue,"Name",{enumerable:!0,get:function(){return no.Name}});var qh=EO();Object.defineProperty(Ue,"Scope",{enumerable:!0,get:function(){return qh.Scope}});Object.defineProperty(Ue,"ValueScope",{enumerable:!0,get:function(){return qh.ValueScope}});Object.defineProperty(Ue,"ValueScopeName",{enumerable:!0,get:function(){return qh.ValueScopeName}});Object.defineProperty(Ue,"varKinds",{enumerable:!0,get:function(){return qh.varKinds}});Ue.operators={GT:new st._Code(">"),GTE:new st._Code(">="),LT:new st._Code("<"),LTE:new st._Code("<="),EQ:new st._Code("==="),NEQ:new st._Code("!=="),NOT:new st._Code("!"),OR:new st._Code("||"),AND:new st._Code("&&"),ADD:new st._Code("+")};var ys=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},TO=class extends ys{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let n=e?yr.varKinds.var:this.varKind,r=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${r};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=al(this.rhs,e,t)),this}get names(){return this.rhs instanceof st._CodeOrName?this.rhs.names:{}}},jh=class extends ys{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(!(this.lhs instanceof st.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=al(this.rhs,e,t),this}get names(){let e=this.lhs instanceof st.Name?{}:{...this.lhs.names};return zh(e,this.rhs)}},AO=class extends jh{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},DO=class extends ys{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},QO=class extends ys{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},RO=class extends ys{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},MO=class extends ys{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=al(this.code,e,t),this}get names(){return this.code instanceof st._CodeOrName?this.code.names:{}}},nu=class extends ys{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let s=n[r];s.optimizeNames(e,t)||(ZN(e,s.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>Ko(e,t.names),{})}},bs=class extends nu{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},IO=class extends nu{},ol=class extends bs{};ol.kind="else";var Ho=class i extends bs{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let t=this.else;if(t){let n=t.optimizeNodes();t=this.else=Array.isArray(n)?new ol(n):n}if(t)return e===!1?t instanceof i?t:t.nodes:this.nodes.length?this:new i(c4(e),t instanceof i?[t]:t.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,t){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,t),!!(super.optimizeNames(e,t)||this.else))return this.condition=al(this.condition,e,t),this}get names(){let e=super.names;return zh(e,this.condition),this.else&&Ko(e,this.else.names),e}};Ho.kind="if";var Go=class extends bs{};Go.kind="for";var NO=class extends Go{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=al(this.iteration,e,t),this}get names(){return Ko(super.names,this.iteration.names)}},jO=class extends Go{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?yr.varKinds.var:this.varKind,{name:n,from:r,to:s}=this;return`for(${t} ${n}=${r}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=zh(super.names,this.from);return zh(e,this.to)}},Zh=class extends Go{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=al(this.iterable,e,t),this}get names(){return Ko(super.names,this.iterable.names)}},ru=class extends bs{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};ru.kind="func";var su=class extends nu{render(e){return"return "+super.render(e)}};su.kind="return";var ZO=class extends bs{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(t=this.finally)===null||t===void 0||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)===null||n===void 0||n.optimizeNames(e,t),(r=this.finally)===null||r===void 0||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&Ko(e,this.catch.names),this.finally&&Ko(e,this.finally.names),e}},ou=class extends bs{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ou.kind="catch";var au=class extends bs{render(e){return"finally"+super.render(e)}};au.kind="finally";var zO=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?` `:""},this._extScope=e,this._scope=new yr.Scope({parent:e}),this._nodes=[new IO]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let s=this._scope.toName(t);return n!==void 0&&r&&(this._constants[s.str]=n),this._leafNode(new TO(e,s,n)),s}const(e,t,n){return this._def(yr.varKinds.const,e,t,n)}let(e,t,n){return this._def(yr.varKinds.let,e,t,n)}var(e,t,n){return this._def(yr.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new jh(e,t,n))}add(e,t){return this._leafNode(new AO(e,Ue.operators.ADD,t))}code(e){return typeof e=="function"?e():e!==st.nil&&this._leafNode(new MO(e)),this}object(...e){let t=["{"];for(let[n,r]of e)t.length>1&&t.push(","),t.push(n),(n!==r||this.opts.es5)&&(t.push(":"),(0,st.addCodeArg)(t,r));return t.push("}"),new st._Code(t)}if(e,t,n){if(this._blockNode(new Ho(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Ho(e))}else(){return this._elseNode(new ol)}endIf(){return this._endBlockNode(Ho,ol)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new NO(e),t)}forRange(e,t,n,r,s=this.opts.es5?yr.varKinds.var:yr.varKinds.let){let o=this._scope.toName(e);return this._for(new jO(s,o,t,n),()=>r(o))}forOf(e,t,n,r=yr.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let o=t instanceof st.Name?t:this.var("_arr",t);return this.forRange("_i",0,(0,st._)`${o}.length`,a=>{this.var(s,(0,st._)`${o}[${a}]`),n(s)})}return this._for(new Zh("of",r,s,t),()=>n(s))}forIn(e,t,n,r=this.opts.es5?yr.varKinds.var:yr.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,st._)`Object.keys(${t})`,n);let s=this._scope.toName(e);return this._for(new Zh("in",r,s,t),()=>n(s))}endFor(){return this._endBlockNode(Go)}label(e){return this._leafNode(new DO(e))}break(e){return this._leafNode(new QO(e))}return(e){let t=new su;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(su)}try(e,t,n){if(!t&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let r=new ZO;if(this._blockNode(r),this.code(e),t){let s=this.name("e");this._currNode=r.catch=new ou(s),t(s)}return n&&(this._currNode=r.finally=new au,this.code(n)),this._endBlockNode(ou,au)}throw(e){return this._leafNode(new RO(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=st.nil,n,r){return this._blockNode(new ru(e,t,n)),r&&this.code(r).endFunc(),this}endFunc(){return this._endBlockNode(ru)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof Ho))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};Ue.CodeGen=zO;function Ko(i,e){for(let t in e)i[t]=(i[t]||0)+(e[t]||0);return i}function zh(i,e){return e instanceof st._CodeOrName?Ko(i,e.names):i}function al(i,e,t){if(i instanceof st.Name)return n(i);if(!r(i))return i;return new st._Code(i._items.reduce((s,o)=>(o instanceof st.Name&&(o=n(o)),o instanceof st._Code?s.push(...o._items):s.push(o),s),[]));function n(s){let o=t[s.str];return o===void 0||e[s.str]!==1?s:(delete e[s.str],o)}function r(s){return s instanceof st._Code&&s._items.some(o=>o instanceof st.Name&&e[o.str]===1&&t[o.str]!==void 0)}}function ZN(i,e){for(let t in e)i[t]=(i[t]||0)-(e[t]||0)}function c4(i){return typeof i=="boolean"||typeof i=="number"||i===null?!i:(0,st._)`!${qO(i)}`}Ue.not=c4;var zN=u4(Ue.operators.AND);function qN(...i){return i.reduce(zN)}Ue.and=qN;var LN=u4(Ue.operators.OR);function $N(...i){return i.reduce(LN)}Ue.or=$N;function u4(i){return(e,t)=>e===st.nil?t:t===st.nil?e:(0,st._)`${qO(e)} ${i} ${qO(t)}`}function qO(i){return i instanceof st.Name?i:(0,st._)`(${i})`}});var mt=De(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.checkStrictMode=He.getErrorPath=He.Type=He.useFunc=He.setEvaluated=He.evaluatedPropsToName=He.mergeEvaluated=He.eachItem=He.unescapeJsonPointer=He.escapeJsonPointer=He.escapeFragment=He.unescapeFragment=He.schemaRefOrVal=He.schemaHasRulesButRef=He.schemaHasRules=He.checkUnknownRules=He.alwaysValidSchema=He.toHash=void 0;var Qt=Je(),FN=iu();function BN(i){let e={};for(let t of i)e[t]=!0;return e}He.toHash=BN;function VN(i,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(h4(i,e),!p4(e,i.self.RULES.all))}He.alwaysValidSchema=VN;function h4(i,e=i.schema){let{opts:t,self:n}=i;if(!t.strictSchema||typeof e=="boolean")return;let r=n.RULES.keywords;for(let s in e)r[s]||v4(i,`unknown keyword: "${s}"`)}He.checkUnknownRules=h4;function p4(i,e){if(typeof i=="boolean")return!i;for(let t in i)if(e[t])return!0;return!1}He.schemaHasRules=p4;function WN(i,e){if(typeof i=="boolean")return!i;for(let t in i)if(t!=="$ref"&&e.all[t])return!0;return!1}He.schemaHasRulesButRef=WN;function XN({topSchemaRef:i,schemaPath:e},t,n,r){if(!r){if(typeof t=="number"||typeof t=="boolean")return t;if(typeof t=="string")return(0,Qt._)`${t}`}return(0,Qt._)`${i}${e}${(0,Qt.getProperty)(n)}`}He.schemaRefOrVal=XN;function YN(i){return m4(decodeURIComponent(i))}He.unescapeFragment=YN;function UN(i){return encodeURIComponent(LO(i))}He.escapeFragment=UN;function LO(i){return typeof i=="number"?`${i}`:i.replace(/~/g,"~0").replace(/\//g,"~1")}He.escapeJsonPointer=LO;function m4(i){return i.replace(/~1/g,"/").replace(/~0/g,"~")}He.unescapeJsonPointer=m4;function HN(i,e){if(Array.isArray(i))for(let t of i)e(t);else e(i)}He.eachItem=HN;function f4({mergeNames:i,mergeToName:e,mergeValues:t,resultToName:n}){return(r,s,o,a)=>{let l=o===void 0?s:o instanceof Qt.Name?(s instanceof Qt.Name?i(r,s,o):e(r,s,o),o):s instanceof Qt.Name?(e(r,o,s),s):t(s,o);return a===Qt.Name&&!(l instanceof Qt.Name)?n(r,l):l}}He.mergeEvaluated={props:f4({mergeNames:(i,e,t)=>i.if((0,Qt._)`${t} !== true && ${e} !== undefined`,()=>{i.if((0,Qt._)`${e} === true`,()=>i.assign(t,!0),()=>i.assign(t,(0,Qt._)`${t} || {}`).code((0,Qt._)`Object.assign(${t}, ${e})`))}),mergeToName:(i,e,t)=>i.if((0,Qt._)`${t} !== true`,()=>{e===!0?i.assign(t,!0):(i.assign(t,(0,Qt._)`${t} || {}`),$O(i,t,e))}),mergeValues:(i,e)=>i===!0?!0:{...i,...e},resultToName:g4}),items:f4({mergeNames:(i,e,t)=>i.if((0,Qt._)`${t} !== true && ${e} !== undefined`,()=>i.assign(t,(0,Qt._)`${e} === true ? true : ${t} > ${e} ? ${t} : ${e}`)),mergeToName:(i,e,t)=>i.if((0,Qt._)`${t} !== true`,()=>i.assign(t,e===!0?!0:(0,Qt._)`${t} > ${e} ? ${t} : ${e}`)),mergeValues:(i,e)=>i===!0?!0:Math.max(i,e),resultToName:(i,e)=>i.var("items",e)})};function g4(i,e){if(e===!0)return i.var("props",!0);let t=i.var("props",(0,Qt._)`{}`);return e!==void 0&&$O(i,t,e),t}He.evaluatedPropsToName=g4;function $O(i,e,t){Object.keys(t).forEach(n=>i.assign((0,Qt._)`${e}${(0,Qt.getProperty)(n)}`,!0))}He.setEvaluated=$O;var d4={};function GN(i,e){return i.scopeValue("func",{ref:e,code:d4[e.code]||(d4[e.code]=new FN._Code(e.code))})}He.useFunc=GN;var O4;(function(i){i[i.Num=0]="Num",i[i.Str=1]="Str"})(O4=He.Type||(He.Type={}));function KN(i,e,t){if(i instanceof Qt.Name){let n=e===O4.Num;return t?n?(0,Qt._)`"[" + ${i} + "]"`:(0,Qt._)`"['" + ${i} + "']"`:n?(0,Qt._)`"/" + ${i}`:(0,Qt._)`"/" + ${i}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return t?(0,Qt.getProperty)(i).toString():"/"+LO(i)}He.getErrorPath=KN;function v4(i,e,t=i.opts.strictSchema){if(t){if(e=`strict mode: ${e}`,t===!0)throw new Error(e);i.self.logger.warn(e)}}He.checkStrictMode=v4});var _s=De(FO=>{"use strict";Object.defineProperty(FO,"__esModule",{value:!0});var Li=Je(),JN={data:new Li.Name("data"),valCxt:new Li.Name("valCxt"),instancePath:new Li.Name("instancePath"),parentData:new Li.Name("parentData"),parentDataProperty:new Li.Name("parentDataProperty"),rootData:new Li.Name("rootData"),dynamicAnchors:new Li.Name("dynamicAnchors"),vErrors:new Li.Name("vErrors"),errors:new Li.Name("errors"),this:new Li.Name("this"),self:new Li.Name("self"),scope:new Li.Name("scope"),json:new Li.Name("json"),jsonPos:new Li.Name("jsonPos"),jsonLen:new Li.Name("jsonLen"),jsonPart:new Li.Name("jsonPart")};FO.default=JN});var lu=De($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.extendErrors=$i.resetErrorsCount=$i.reportExtraError=$i.reportError=$i.keyword$DataError=$i.keywordError=void 0;var ft=Je(),Lh=mt(),Ji=_s();$i.keywordError={message:({keyword:i})=>(0,ft.str)`must pass "${i}" keyword validation`};$i.keyword$DataError={message:({keyword:i,schemaType:e})=>e?(0,ft.str)`"${i}" keyword must be ${e} ($data)`:(0,ft.str)`"${i}" keyword is invalid ($data)`};function ej(i,e=$i.keywordError,t,n){let{it:r}=i,{gen:s,compositeRule:o,allErrors:a}=r,l=_4(i,e,t);n??(o||a)?y4(s,l):b4(r,(0,ft._)`[${l}]`)}$i.reportError=ej;function tj(i,e=$i.keywordError,t){let{it:n}=i,{gen:r,compositeRule:s,allErrors:o}=n,a=_4(i,e,t);y4(r,a),s||o||b4(n,Ji.default.vErrors)}$i.reportExtraError=tj;function ij(i,e){i.assign(Ji.default.errors,e),i.if((0,ft._)`${Ji.default.vErrors} !== null`,()=>i.if(e,()=>i.assign((0,ft._)`${Ji.default.vErrors}.length`,e),()=>i.assign(Ji.default.vErrors,null)))}$i.resetErrorsCount=ij;function nj({gen:i,keyword:e,schemaValue:t,data:n,errsCount:r,it:s}){if(r===void 0)throw new Error("ajv implementation error");let o=i.name("err");i.forRange("i",r,Ji.default.errors,a=>{i.const(o,(0,ft._)`${Ji.default.vErrors}[${a}]`),i.if((0,ft._)`${o}.instancePath === undefined`,()=>i.assign((0,ft._)`${o}.instancePath`,(0,ft.strConcat)(Ji.default.instancePath,s.errorPath))),i.assign((0,ft._)`${o}.schemaPath`,(0,ft.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(i.assign((0,ft._)`${o}.schema`,t),i.assign((0,ft._)`${o}.data`,n))})}$i.extendErrors=nj;function y4(i,e){let t=i.const("err",e);i.if((0,ft._)`${Ji.default.vErrors} === null`,()=>i.assign(Ji.default.vErrors,(0,ft._)`[${t}]`),(0,ft._)`${Ji.default.vErrors}.push(${t})`),i.code((0,ft._)`${Ji.default.errors}++`)}function b4(i,e){let{gen:t,validateName:n,schemaEnv:r}=i;r.$async?t.throw((0,ft._)`new ${i.ValidationError}(${e})`):(t.assign((0,ft._)`${n}.errors`,e),t.return(!1))}var Jo={keyword:new ft.Name("keyword"),schemaPath:new ft.Name("schemaPath"),params:new ft.Name("params"),propertyName:new ft.Name("propertyName"),message:new ft.Name("message"),schema:new ft.Name("schema"),parentSchema:new ft.Name("parentSchema")};function _4(i,e,t){let{createErrors:n}=i.it;return n===!1?(0,ft._)`{}`:rj(i,e,t)}function rj(i,e,t={}){let{gen:n,it:r}=i,s=[sj(r,t),oj(i,t)];return aj(i,e,s),n.object(...s)}function sj({errorPath:i},{instancePath:e}){let t=e?(0,ft.str)`${i}${(0,Lh.getErrorPath)(e,Lh.Type.Str)}`:i;return[Ji.default.instancePath,(0,ft.strConcat)(Ji.default.instancePath,t)]}function oj({keyword:i,it:{errSchemaPath:e}},{schemaPath:t,parentSchema:n}){let r=n?e:(0,ft.str)`${e}/${i}`;return t&&(r=(0,ft.str)`${r}${(0,Lh.getErrorPath)(t,Lh.Type.Str)}`),[Jo.schemaPath,r]}function aj(i,{params:e,message:t},n){let{keyword:r,data:s,schemaValue:o,it:a}=i,{opts:l,propertyName:c,topSchemaRef:u,schemaPath:f}=a;n.push([Jo.keyword,r],[Jo.params,typeof e=="function"?e(i):e||(0,ft._)`{}`]),l.messages&&n.push([Jo.message,typeof t=="function"?t(i):t]),l.verbose&&n.push([Jo.schema,o],[Jo.parentSchema,(0,ft._)`${u}${f}`],[Ji.default.data,s]),c&&n.push([Jo.propertyName,c])}});var k4=De(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});ll.boolOrEmptySchema=ll.topBoolOrEmptySchema=void 0;var lj=lu(),cj=Je(),uj=_s(),fj={message:"boolean schema is false"};function dj(i){let{gen:e,schema:t,validateName:n}=i;t===!1?w4(i,!1):typeof t=="object"&&t.$async===!0?e.return(uj.default.data):(e.assign((0,cj._)`${n}.errors`,null),e.return(!0))}ll.topBoolOrEmptySchema=dj;function hj(i,e){let{gen:t,schema:n}=i;n===!1?(t.var(e,!1),w4(i)):t.var(e,!0)}ll.boolOrEmptySchema=hj;function w4(i,e){let{gen:t,data:n}=i,r={gen:t,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:i};(0,lj.reportError)(r,fj,void 0,e)}});var BO=De(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});cl.getRules=cl.isJSONType=void 0;var pj=["string","number","integer","boolean","null","object","array"],mj=new Set(pj);function gj(i){return typeof i=="string"&&mj.has(i)}cl.isJSONType=gj;function Oj(){let i={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...i,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},i.number,i.string,i.array,i.object],post:{rules:[]},all:{},keywords:{}}}cl.getRules=Oj});var VO=De(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.shouldUseRule=ro.shouldUseGroup=ro.schemaHasRulesForType=void 0;function vj({schema:i,self:e},t){let n=e.RULES.types[t];return n&&n!==!0&&S4(i,n)}ro.schemaHasRulesForType=vj;function S4(i,e){return e.rules.some(t=>x4(i,t))}ro.shouldUseGroup=S4;function x4(i,e){var t;return i[e.keyword]!==void 0||((t=e.definition.implements)===null||t===void 0?void 0:t.some(n=>i[n]!==void 0))}ro.shouldUseRule=x4});var uu=De(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.reportTypeError=Qi.checkDataTypes=Qi.checkDataType=Qi.coerceAndCheckDataType=Qi.getJSONTypes=Qi.getSchemaTypes=Qi.DataType=void 0;var yj=BO(),bj=VO(),_j=lu(),Ve=Je(),P4=mt(),cu;(function(i){i[i.Correct=0]="Correct",i[i.Wrong=1]="Wrong"})(cu=Qi.DataType||(Qi.DataType={}));function wj(i){let e=C4(i.type);if(e.includes("null")){if(i.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&i.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');i.nullable===!0&&e.push("null")}return e}Qi.getSchemaTypes=wj;function C4(i){let e=Array.isArray(i)?i:i?[i]:[];if(e.every(yj.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Qi.getJSONTypes=C4;function kj(i,e){let{gen:t,data:n,opts:r}=i,s=Sj(e,r.coerceTypes),o=e.length>0&&!(s.length===0&&e.length===1&&(0,bj.schemaHasRulesForType)(i,e[0]));if(o){let a=XO(e,n,r.strictNumbers,cu.Wrong);t.if(a,()=>{s.length?xj(i,e,s):YO(i)})}return o}Qi.coerceAndCheckDataType=kj;var E4=new Set(["string","number","integer","boolean","null"]);function Sj(i,e){return e?i.filter(t=>E4.has(t)||e==="array"&&t==="array"):[]}function xj(i,e,t){let{gen:n,data:r,opts:s}=i,o=n.let("dataType",(0,Ve._)`typeof ${r}`),a=n.let("coerced",(0,Ve._)`undefined`);s.coerceTypes==="array"&&n.if((0,Ve._)`${o} == 'object' && Array.isArray(${r}) && ${r}.length == 1`,()=>n.assign(r,(0,Ve._)`${r}[0]`).assign(o,(0,Ve._)`typeof ${r}`).if(XO(e,r,s.strictNumbers),()=>n.assign(a,r))),n.if((0,Ve._)`${a} !== undefined`);for(let c of t)(E4.has(c)||c==="array"&&s.coerceTypes==="array")&&l(c);n.else(),YO(i),n.endIf(),n.if((0,Ve._)`${a} !== undefined`,()=>{n.assign(r,a),Pj(i,a)});function l(c){switch(c){case"string":n.elseIf((0,Ve._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,Ve._)`"" + ${r}`).elseIf((0,Ve._)`${r} === null`).assign(a,(0,Ve._)`""`);return;case"number":n.elseIf((0,Ve._)`${o} == "boolean" || ${r} === null || (${o} == "string" && ${r} && ${r} == +${r})`).assign(a,(0,Ve._)`+${r}`);return;case"integer":n.elseIf((0,Ve._)`${o} === "boolean" || ${r} === null || (${o} === "string" && ${r} && ${r} == +${r} && !(${r} % 1))`).assign(a,(0,Ve._)`+${r}`);return;case"boolean":n.elseIf((0,Ve._)`${r} === "false" || ${r} === 0 || ${r} === null`).assign(a,!1).elseIf((0,Ve._)`${r} === "true" || ${r} === 1`).assign(a,!0);return;case"null":n.elseIf((0,Ve._)`${r} === "" || ${r} === 0 || ${r} === false`),n.assign(a,null);return;case"array":n.elseIf((0,Ve._)`${o} === "string" || ${o} === "number" || ${o} === "boolean" || ${r} === null`).assign(a,(0,Ve._)`[${r}]`)}}}function Pj({gen:i,parentData:e,parentDataProperty:t},n){i.if((0,Ve._)`${e} !== undefined`,()=>i.assign((0,Ve._)`${e}[${t}]`,n))}function WO(i,e,t,n=cu.Correct){let r=n===cu.Correct?Ve.operators.EQ:Ve.operators.NEQ,s;switch(i){case"null":return(0,Ve._)`${e} ${r} null`;case"array":s=(0,Ve._)`Array.isArray(${e})`;break;case"object":s=(0,Ve._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=o((0,Ve._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=o();break;default:return(0,Ve._)`typeof ${e} ${r} ${i}`}return n===cu.Correct?s:(0,Ve.not)(s);function o(a=Ve.nil){return(0,Ve.and)((0,Ve._)`typeof ${e} == "number"`,a,t?(0,Ve._)`isFinite(${e})`:Ve.nil)}}Qi.checkDataType=WO;function XO(i,e,t,n){if(i.length===1)return WO(i[0],e,t,n);let r,s=(0,P4.toHash)(i);if(s.array&&s.object){let o=(0,Ve._)`typeof ${e} != "object"`;r=s.null?o:(0,Ve._)`!${e} || ${o}`,delete s.null,delete s.array,delete s.object}else r=Ve.nil;s.number&&delete s.integer;for(let o in s)r=(0,Ve.and)(r,WO(o,e,t,n));return r}Qi.checkDataTypes=XO;var Cj={message:({schema:i})=>`must be ${i}`,params:({schema:i,schemaValue:e})=>typeof i=="string"?(0,Ve._)`{type: ${i}}`:(0,Ve._)`{type: ${e}}`};function YO(i){let e=Ej(i);(0,_j.reportError)(e,Cj)}Qi.reportTypeError=YO;function Ej(i){let{gen:e,data:t,schema:n}=i,r=(0,P4.schemaRefOrVal)(i,n,"type");return{gen:e,keyword:"type",data:t,schema:n.type,schemaCode:r,schemaValue:r,parentSchema:n,params:{},it:i}}});var A4=De($h=>{"use strict";Object.defineProperty($h,"__esModule",{value:!0});$h.assignDefaults=void 0;var ul=Je(),Tj=mt();function Aj(i,e){let{properties:t,items:n}=i.schema;if(e==="object"&&t)for(let r in t)T4(i,r,t[r].default);else e==="array"&&Array.isArray(n)&&n.forEach((r,s)=>T4(i,s,r.default))}$h.assignDefaults=Aj;function T4(i,e,t){let{gen:n,compositeRule:r,data:s,opts:o}=i;if(t===void 0)return;let a=(0,ul._)`${s}${(0,ul.getProperty)(e)}`;if(r){(0,Tj.checkStrictMode)(i,`default is ignored for: ${a}`);return}let l=(0,ul._)`${a} === undefined`;o.useDefaults==="empty"&&(l=(0,ul._)`${l} || ${a} === null || ${a} === ""`),n.if(l,(0,ul._)`${a} = ${(0,ul.stringify)(t)}`)}});var Vn=De(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.validateUnion=Et.validateArray=Et.usePattern=Et.callValidateCode=Et.schemaProperties=Et.allSchemaProperties=Et.noPropertyInData=Et.propertyInData=Et.isOwnProperty=Et.hasPropFunc=Et.reportMissingProp=Et.checkMissingProp=Et.checkReportMissingProp=void 0;var Lt=Je(),UO=mt(),so=_s(),Dj=mt();function Qj(i,e){let{gen:t,data:n,it:r}=i;t.if(GO(t,n,e,r.opts.ownProperties),()=>{i.setParams({missingProperty:(0,Lt._)`${e}`},!0),i.error()})}Et.checkReportMissingProp=Qj;function Rj({gen:i,data:e,it:{opts:t}},n,r){return(0,Lt.or)(...n.map(s=>(0,Lt.and)(GO(i,e,s,t.ownProperties),(0,Lt._)`${r} = ${s}`)))}Et.checkMissingProp=Rj;function Mj(i,e){i.setParams({missingProperty:e},!0),i.error()}Et.reportMissingProp=Mj;function D4(i){return i.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Lt._)`Object.prototype.hasOwnProperty`})}Et.hasPropFunc=D4;function HO(i,e,t){return(0,Lt._)`${D4(i)}.call(${e}, ${t})`}Et.isOwnProperty=HO;function Ij(i,e,t,n){let r=(0,Lt._)`${e}${(0,Lt.getProperty)(t)} !== undefined`;return n?(0,Lt._)`${r} && ${HO(i,e,t)}`:r}Et.propertyInData=Ij;function GO(i,e,t,n){let r=(0,Lt._)`${e}${(0,Lt.getProperty)(t)} === undefined`;return n?(0,Lt.or)(r,(0,Lt.not)(HO(i,e,t))):r}Et.noPropertyInData=GO;function Q4(i){return i?Object.keys(i).filter(e=>e!=="__proto__"):[]}Et.allSchemaProperties=Q4;function Nj(i,e){return Q4(e).filter(t=>!(0,UO.alwaysValidSchema)(i,e[t]))}Et.schemaProperties=Nj;function jj({schemaCode:i,data:e,it:{gen:t,topSchemaRef:n,schemaPath:r,errorPath:s},it:o},a,l,c){let u=c?(0,Lt._)`${i}, ${e}, ${n}${r}`:e,f=[[so.default.instancePath,(0,Lt.strConcat)(so.default.instancePath,s)],[so.default.parentData,o.parentData],[so.default.parentDataProperty,o.parentDataProperty],[so.default.rootData,so.default.rootData]];o.opts.dynamicRef&&f.push([so.default.dynamicAnchors,so.default.dynamicAnchors]);let d=(0,Lt._)`${u}, ${t.object(...f)}`;return l!==Lt.nil?(0,Lt._)`${a}.call(${l}, ${d})`:(0,Lt._)`${a}(${d})`}Et.callValidateCode=jj;var Zj=(0,Lt._)`new RegExp`;function zj({gen:i,it:{opts:e}},t){let n=e.unicodeRegExp?"u":"",{regExp:r}=e.code,s=r(t,n);return i.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,Lt._)`${r.code==="new RegExp"?Zj:(0,Dj.useFunc)(i,r)}(${t}, ${n})`})}Et.usePattern=zj;function qj(i){let{gen:e,data:t,keyword:n,it:r}=i,s=e.name("valid");if(r.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(s,!0),o(()=>e.break()),s;function o(a){let l=e.const("len",(0,Lt._)`${t}.length`);e.forRange("i",0,l,c=>{i.subschema({keyword:n,dataProp:c,dataPropType:UO.Type.Num},s),e.if((0,Lt.not)(s),a)})}}Et.validateArray=qj;function Lj(i){let{gen:e,schema:t,keyword:n,it:r}=i;if(!Array.isArray(t))throw new Error("ajv implementation error");if(t.some(l=>(0,UO.alwaysValidSchema)(r,l))&&!r.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>t.forEach((l,c)=>{let u=i.subschema({keyword:n,schemaProp:c,compositeRule:!0},a);e.assign(o,(0,Lt._)`${o} || ${a}`),i.mergeValidEvaluated(u,a)||e.if((0,Lt.not)(o))})),i.result(o,()=>i.reset(),()=>i.error(!0))}Et.validateUnion=Lj});var I4=De(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.validateKeywordUsage=Kr.validSchemaType=Kr.funcKeywordCode=Kr.macroKeywordCode=void 0;var en=Je(),ea=_s(),$j=Vn(),Fj=lu();function Bj(i,e){let{gen:t,keyword:n,schema:r,parentSchema:s,it:o}=i,a=e.macro.call(o.self,r,s,o),l=M4(t,n,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let c=t.name("valid");i.subschema({schema:a,schemaPath:en.nil,errSchemaPath:`${o.errSchemaPath}/${n}`,topSchemaRef:l,compositeRule:!0},c),i.pass(c,()=>i.error(!0))}Kr.macroKeywordCode=Bj;function Vj(i,e){var t;let{gen:n,keyword:r,schema:s,parentSchema:o,$data:a,it:l}=i;Xj(l,e);let c=!a&&e.compile?e.compile.call(l.self,s,o,l):e.validate,u=M4(n,r,c),f=n.let("valid");i.block$data(f,d),i.ok((t=e.valid)!==null&&t!==void 0?t:f);function d(){if(e.errors===!1)m(),e.modifying&&R4(i),g(()=>i.error());else{let O=e.async?h():p();e.modifying&&R4(i),g(()=>Wj(i,O))}}function h(){let O=n.let("ruleErrs",null);return n.try(()=>m((0,en._)`await `),_=>n.assign(f,!1).if((0,en._)`${_} instanceof ${l.ValidationError}`,()=>n.assign(O,(0,en._)`${_}.errors`),()=>n.throw(_))),O}function p(){let O=(0,en._)`${u}.errors`;return n.assign(O,null),m(en.nil),O}function m(O=e.async?(0,en._)`await `:en.nil){let _=l.opts.passContext?ea.default.this:ea.default.self,S=!("compile"in e&&!a||e.schema===!1);n.assign(f,(0,en._)`${O}${(0,$j.callValidateCode)(i,u,_,S)}`,e.modifying)}function g(O){var _;n.if((0,en.not)((_=e.valid)!==null&&_!==void 0?_:f),O)}}Kr.funcKeywordCode=Vj;function R4(i){let{gen:e,data:t,it:n}=i;e.if(n.parentData,()=>e.assign(t,(0,en._)`${n.parentData}[${n.parentDataProperty}]`))}function Wj(i,e){let{gen:t}=i;t.if((0,en._)`Array.isArray(${e})`,()=>{t.assign(ea.default.vErrors,(0,en._)`${ea.default.vErrors} === null ? ${e} : ${ea.default.vErrors}.concat(${e})`).assign(ea.default.errors,(0,en._)`${ea.default.vErrors}.length`),(0,Fj.extendErrors)(i)},()=>i.error())}function Xj({schemaEnv:i},e){if(e.async&&!i.$async)throw new Error("async keyword in sync schema")}function M4(i,e,t){if(t===void 0)throw new Error(`keyword "${e}" failed to compile`);return i.scopeValue("keyword",typeof t=="function"?{ref:t}:{ref:t,code:(0,en.stringify)(t)})}function Yj(i,e,t=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(i):n==="object"?i&&typeof i=="object"&&!Array.isArray(i):typeof i==n||t&&typeof i>"u")}Kr.validSchemaType=Yj;function Uj({schema:i,opts:e,self:t,errSchemaPath:n},r,s){if(Array.isArray(r.keyword)?!r.keyword.includes(s):r.keyword!==s)throw new Error("ajv implementation error");let o=r.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(i,a)))throw new Error(`parent schema must have dependencies of ${s}: ${o.join(",")}`);if(r.validateSchema&&!r.validateSchema(i[s])){let l=`keyword "${s}" value is invalid at path "${n}": `+t.errorsText(r.validateSchema.errors);if(e.validateSchema==="log")t.logger.error(l);else throw new Error(l)}}Kr.validateKeywordUsage=Uj});var j4=De(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.extendSubschemaMode=oo.extendSubschemaData=oo.getSubschema=void 0;var Jr=Je(),N4=mt();function Hj(i,{keyword:e,schemaProp:t,schema:n,schemaPath:r,errSchemaPath:s,topSchemaRef:o}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=i.schema[e];return t===void 0?{schema:a,schemaPath:(0,Jr._)`${i.schemaPath}${(0,Jr.getProperty)(e)}`,errSchemaPath:`${i.errSchemaPath}/${e}`}:{schema:a[t],schemaPath:(0,Jr._)`${i.schemaPath}${(0,Jr.getProperty)(e)}${(0,Jr.getProperty)(t)}`,errSchemaPath:`${i.errSchemaPath}/${e}/${(0,N4.escapeFragment)(t)}`}}if(n!==void 0){if(r===void 0||s===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:r,topSchemaRef:o,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}oo.getSubschema=Hj;function Gj(i,e,{dataProp:t,dataPropType:n,data:r,dataTypes:s,propertyName:o}){if(r!==void 0&&t!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(t!==void 0){let{errorPath:c,dataPathArr:u,opts:f}=e,d=a.let("data",(0,Jr._)`${e.data}${(0,Jr.getProperty)(t)}`,!0);l(d),i.errorPath=(0,Jr.str)`${c}${(0,N4.getErrorPath)(t,n,f.jsPropertySyntax)}`,i.parentDataProperty=(0,Jr._)`${t}`,i.dataPathArr=[...u,i.parentDataProperty]}if(r!==void 0){let c=r instanceof Jr.Name?r:a.let("data",r,!0);l(c),o!==void 0&&(i.propertyName=o)}s&&(i.dataTypes=s);function l(c){i.data=c,i.dataLevel=e.dataLevel+1,i.dataTypes=[],e.definedProperties=new Set,i.parentData=e.data,i.dataNames=[...e.dataNames,c]}}oo.extendSubschemaData=Gj;function Kj(i,{jtdDiscriminator:e,jtdMetadata:t,compositeRule:n,createErrors:r,allErrors:s}){n!==void 0&&(i.compositeRule=n),r!==void 0&&(i.createErrors=r),s!==void 0&&(i.allErrors=s),i.jtdDiscriminator=e,i.jtdMetadata=t}oo.extendSubschemaMode=Kj});var KO=De((Uee,Z4)=>{"use strict";Z4.exports=function i(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var n,r,s;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!i(e[r],t[r]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){var o=s[r];if(!i(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}});var q4=De((Hee,z4)=>{"use strict";var ao=z4.exports=function(i,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var n=typeof t=="function"?t:t.pre||function(){},r=t.post||function(){};Fh(e,n,r,i,"",i)};ao.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};ao.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};ao.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};ao.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Fh(i,e,t,n,r,s,o,a,l,c){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,r,s,o,a,l,c);for(var u in n){var f=n[u];if(Array.isArray(f)){if(u in ao.arrayKeywords)for(var d=0;d{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.getSchemaRefs=vn.resolveUrl=vn.normalizeId=vn._getFullPath=vn.getFullPath=vn.inlineRef=void 0;var eZ=mt(),tZ=KO(),iZ=q4(),nZ=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function rZ(i,e=!0){return typeof i=="boolean"?!0:e===!0?!JO(i):e?L4(i)<=e:!1}vn.inlineRef=rZ;var sZ=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function JO(i){for(let e in i){if(sZ.has(e))return!0;let t=i[e];if(Array.isArray(t)&&t.some(JO)||typeof t=="object"&&JO(t))return!0}return!1}function L4(i){let e=0;for(let t in i){if(t==="$ref")return 1/0;if(e++,!nZ.has(t)&&(typeof i[t]=="object"&&(0,eZ.eachItem)(i[t],n=>e+=L4(n)),e===1/0))return 1/0}return e}function $4(i,e="",t){t!==!1&&(e=fl(e));let n=i.parse(e);return F4(i,n)}vn.getFullPath=$4;function F4(i,e){return i.serialize(e).split("#")[0]+"#"}vn._getFullPath=F4;var oZ=/#\/?$/;function fl(i){return i?i.replace(oZ,""):""}vn.normalizeId=fl;function aZ(i,e,t){return t=fl(t),i.resolve(e,t)}vn.resolveUrl=aZ;var lZ=/^[a-z_][-a-z0-9._]*$/i;function cZ(i,e){if(typeof i=="boolean")return{};let{schemaId:t,uriResolver:n}=this.opts,r=fl(i[t]||e),s={"":r},o=$4(n,r,!1),a={},l=new Set;return iZ(i,{allKeys:!0},(f,d,h,p)=>{if(p===void 0)return;let m=o+d,g=s[p];typeof f[t]=="string"&&(g=O.call(this,f[t])),_.call(this,f.$anchor),_.call(this,f.$dynamicAnchor),s[d]=g;function O(S){let P=this.opts.uriResolver.resolve;if(S=fl(g?P(g,S):S),l.has(S))throw u(S);l.add(S);let k=this.refs[S];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?c(f,k.schema,S):S!==fl(m)&&(S[0]==="#"?(c(f,a[S],S),a[S]=f):this.refs[S]=m),S}function _(S){if(typeof S=="string"){if(!lZ.test(S))throw new Error(`invalid anchor "${S}"`);O.call(this,`#${S}`)}}}),a;function c(f,d,h){if(d!==void 0&&!tZ(f,d))throw u(h)}function u(f){return new Error(`reference "${f}" resolves to more than one schema`)}}vn.getSchemaRefs=cZ});var pu=De(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});lo.getData=lo.KeywordCxt=lo.validateFunctionCode=void 0;var Y4=k4(),B4=uu(),tv=VO(),Bh=uu(),uZ=A4(),hu=I4(),ev=j4(),Me=Je(),Ze=_s(),fZ=fu(),ws=mt(),du=lu();function dZ(i){if(G4(i)&&(K4(i),H4(i))){mZ(i);return}U4(i,()=>(0,Y4.topBoolOrEmptySchema)(i))}lo.validateFunctionCode=dZ;function U4({gen:i,validateName:e,schema:t,schemaEnv:n,opts:r},s){r.code.es5?i.func(e,(0,Me._)`${Ze.default.data}, ${Ze.default.valCxt}`,n.$async,()=>{i.code((0,Me._)`"use strict"; ${V4(t,r)}`),pZ(i,r),i.code(s)}):i.func(e,(0,Me._)`${Ze.default.data}, ${hZ(r)}`,n.$async,()=>i.code(V4(t,r)).code(s))}function hZ(i){return(0,Me._)`{${Ze.default.instancePath}="", ${Ze.default.parentData}, ${Ze.default.parentDataProperty}, ${Ze.default.rootData}=${Ze.default.data}${i.dynamicRef?(0,Me._)`, ${Ze.default.dynamicAnchors}={}`:Me.nil}}={}`}function pZ(i,e){i.if(Ze.default.valCxt,()=>{i.var(Ze.default.instancePath,(0,Me._)`${Ze.default.valCxt}.${Ze.default.instancePath}`),i.var(Ze.default.parentData,(0,Me._)`${Ze.default.valCxt}.${Ze.default.parentData}`),i.var(Ze.default.parentDataProperty,(0,Me._)`${Ze.default.valCxt}.${Ze.default.parentDataProperty}`),i.var(Ze.default.rootData,(0,Me._)`${Ze.default.valCxt}.${Ze.default.rootData}`),e.dynamicRef&&i.var(Ze.default.dynamicAnchors,(0,Me._)`${Ze.default.valCxt}.${Ze.default.dynamicAnchors}`)},()=>{i.var(Ze.default.instancePath,(0,Me._)`""`),i.var(Ze.default.parentData,(0,Me._)`undefined`),i.var(Ze.default.parentDataProperty,(0,Me._)`undefined`),i.var(Ze.default.rootData,Ze.default.data),e.dynamicRef&&i.var(Ze.default.dynamicAnchors,(0,Me._)`{}`)})}function mZ(i){let{schema:e,opts:t,gen:n}=i;U4(i,()=>{t.$comment&&e.$comment&&e3(i),bZ(i),n.let(Ze.default.vErrors,null),n.let(Ze.default.errors,0),t.unevaluated&&gZ(i),J4(i),kZ(i)})}function gZ(i){let{gen:e,validateName:t}=i;i.evaluated=e.const("evaluated",(0,Me._)`${t}.evaluated`),e.if((0,Me._)`${i.evaluated}.dynamicProps`,()=>e.assign((0,Me._)`${i.evaluated}.props`,(0,Me._)`undefined`)),e.if((0,Me._)`${i.evaluated}.dynamicItems`,()=>e.assign((0,Me._)`${i.evaluated}.items`,(0,Me._)`undefined`))}function V4(i,e){let t=typeof i=="object"&&i[e.schemaId];return t&&(e.code.source||e.code.process)?(0,Me._)`/*# sourceURL=${t} */`:Me.nil}function OZ(i,e){if(G4(i)&&(K4(i),H4(i))){vZ(i,e);return}(0,Y4.boolOrEmptySchema)(i,e)}function H4({schema:i,self:e}){if(typeof i=="boolean")return!i;for(let t in i)if(e.RULES.all[t])return!0;return!1}function G4(i){return typeof i.schema!="boolean"}function vZ(i,e){let{schema:t,gen:n,opts:r}=i;r.$comment&&t.$comment&&e3(i),_Z(i),wZ(i);let s=n.const("_errs",Ze.default.errors);J4(i,s),n.var(e,(0,Me._)`${s} === ${Ze.default.errors}`)}function K4(i){(0,ws.checkUnknownRules)(i),yZ(i)}function J4(i,e){if(i.opts.jtd)return W4(i,[],!1,e);let t=(0,B4.getSchemaTypes)(i.schema),n=(0,B4.coerceAndCheckDataType)(i,t);W4(i,t,!n,e)}function yZ(i){let{schema:e,errSchemaPath:t,opts:n,self:r}=i;e.$ref&&n.ignoreKeywordsWithRef&&(0,ws.schemaHasRulesButRef)(e,r.RULES)&&r.logger.warn(`$ref: keywords ignored in schema at path "${t}"`)}function bZ(i){let{schema:e,opts:t}=i;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0,ws.checkStrictMode)(i,"default is ignored in the schema root")}function _Z(i){let e=i.schema[i.opts.schemaId];e&&(i.baseId=(0,fZ.resolveUrl)(i.opts.uriResolver,i.baseId,e))}function wZ(i){if(i.schema.$async&&!i.schemaEnv.$async)throw new Error("async schema in sync schema")}function e3({gen:i,schemaEnv:e,schema:t,errSchemaPath:n,opts:r}){let s=t.$comment;if(r.$comment===!0)i.code((0,Me._)`${Ze.default.self}.logger.log(${s})`);else if(typeof r.$comment=="function"){let o=(0,Me.str)`${n}/$comment`,a=i.scopeValue("root",{ref:e.root});i.code((0,Me._)`${Ze.default.self}.opts.$comment(${s}, ${o}, ${a}.schema)`)}}function kZ(i){let{gen:e,schemaEnv:t,validateName:n,ValidationError:r,opts:s}=i;t.$async?e.if((0,Me._)`${Ze.default.errors} === 0`,()=>e.return(Ze.default.data),()=>e.throw((0,Me._)`new ${r}(${Ze.default.vErrors})`)):(e.assign((0,Me._)`${n}.errors`,Ze.default.vErrors),s.unevaluated&&SZ(i),e.return((0,Me._)`${Ze.default.errors} === 0`))}function SZ({gen:i,evaluated:e,props:t,items:n}){t instanceof Me.Name&&i.assign((0,Me._)`${e}.props`,t),n instanceof Me.Name&&i.assign((0,Me._)`${e}.items`,n)}function W4(i,e,t,n){let{gen:r,schema:s,data:o,allErrors:a,opts:l,self:c}=i,{RULES:u}=c;if(s.$ref&&(l.ignoreKeywordsWithRef||!(0,ws.schemaHasRulesButRef)(s,u))){r.block(()=>i3(i,"$ref",u.all.$ref.definition));return}l.jtd||xZ(i,e),r.block(()=>{for(let d of u.rules)f(d);f(u.post)});function f(d){(0,tv.shouldUseGroup)(s,d)&&(d.type?(r.if((0,Bh.checkDataType)(d.type,o,l.strictNumbers)),X4(i,d),e.length===1&&e[0]===d.type&&t&&(r.else(),(0,Bh.reportTypeError)(i)),r.endIf()):X4(i,d),a||r.if((0,Me._)`${Ze.default.errors} === ${n||0}`))}}function X4(i,e){let{gen:t,schema:n,opts:{useDefaults:r}}=i;r&&(0,uZ.assignDefaults)(i,e.type),t.block(()=>{for(let s of e.rules)(0,tv.shouldUseRule)(n,s)&&i3(i,s.keyword,s.definition,e.type)})}function xZ(i,e){i.schemaEnv.meta||!i.opts.strictTypes||(PZ(i,e),i.opts.allowUnionTypes||CZ(i,e),EZ(i,i.dataTypes))}function PZ(i,e){if(e.length){if(!i.dataTypes.length){i.dataTypes=e;return}e.forEach(t=>{t3(i.dataTypes,t)||iv(i,`type "${t}" not allowed by context "${i.dataTypes.join(",")}"`)}),AZ(i,e)}}function CZ(i,e){e.length>1&&!(e.length===2&&e.includes("null"))&&iv(i,"use allowUnionTypes to allow union type keyword")}function EZ(i,e){let t=i.self.RULES.all;for(let n in t){let r=t[n];if(typeof r=="object"&&(0,tv.shouldUseRule)(i.schema,r)){let{type:s}=r.definition;s.length&&!s.some(o=>TZ(e,o))&&iv(i,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function TZ(i,e){return i.includes(e)||e==="number"&&i.includes("integer")}function t3(i,e){return i.includes(e)||e==="integer"&&i.includes("number")}function AZ(i,e){let t=[];for(let n of i.dataTypes)t3(e,n)?t.push(n):e.includes("integer")&&n==="number"&&t.push("integer");i.dataTypes=t}function iv(i,e){let t=i.schemaEnv.baseId+i.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0,ws.checkStrictMode)(i,e,i.opts.strictTypes)}var Vh=class{constructor(e,t,n){if((0,hu.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,ws.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",n3(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,hu.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const("_errs",Ze.default.errors))}result(e,t,n){this.failResult((0,Me.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,Me.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,Me._)`${t} !== undefined && (${(0,Me.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?du.reportExtraError:du.reportError)(this,this.def.error,t)}$dataError(){(0,du.reportError)(this,this.def.$dataError||du.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,du.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=Me.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=Me.nil,t=Me.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:s,def:o}=this;n.if((0,Me.or)((0,Me._)`${r} === undefined`,t)),e!==Me.nil&&n.assign(e,!0),(s.length||o.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==Me.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:s}=this;return(0,Me.or)(o(),a());function o(){if(n.length){if(!(t instanceof Me.Name))throw new Error("ajv implementation error");let l=Array.isArray(n)?n:[n];return(0,Me._)`${(0,Bh.checkDataTypes)(l,t,s.opts.strictNumbers,Bh.DataType.Wrong)}`}return Me.nil}function a(){if(r.validateSchema){let l=e.scopeValue("validate$data",{ref:r.validateSchema});return(0,Me._)`!${l}(${t})`}return Me.nil}}subschema(e,t){let n=(0,ev.getSubschema)(this.it,e);(0,ev.extendSubschemaData)(n,this.it,e),(0,ev.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return OZ(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=ws.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=ws.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,Me.Name)),!0}};lo.KeywordCxt=Vh;function i3(i,e,t,n){let r=new Vh(i,t,e);"code"in t?t.code(r,n):r.$data&&t.validate?(0,hu.funcKeywordCode)(r,t):"macro"in t?(0,hu.macroKeywordCode)(r,t):(t.compile||t.validate)&&(0,hu.funcKeywordCode)(r,t)}var DZ=/^\/(?:[^~]|~0|~1)*$/,QZ=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function n3(i,{dataLevel:e,dataNames:t,dataPathArr:n}){let r,s;if(i==="")return Ze.default.rootData;if(i[0]==="/"){if(!DZ.test(i))throw new Error(`Invalid JSON-pointer: ${i}`);r=i,s=Ze.default.rootData}else{let c=QZ.exec(i);if(!c)throw new Error(`Invalid JSON-pointer: ${i}`);let u=+c[1];if(r=c[2],r==="#"){if(u>=e)throw new Error(l("property/index",u));return n[e-u]}if(u>e)throw new Error(l("data",u));if(s=t[e-u],!r)return s}let o=s,a=r.split("/");for(let c of a)c&&(s=(0,Me._)`${s}${(0,Me.getProperty)((0,ws.unescapeJsonPointer)(c))}`,o=(0,Me._)`${o} && ${s}`);return o;function l(c,u){return`Cannot access ${c} ${u} levels up, current level is ${e}`}}lo.getData=n3});var Wh=De(rv=>{"use strict";Object.defineProperty(rv,"__esModule",{value:!0});var nv=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};rv.default=nv});var Xh=De(av=>{"use strict";Object.defineProperty(av,"__esModule",{value:!0});var sv=fu(),ov=class extends Error{constructor(e,t,n,r){super(r||`can't resolve reference ${n} from id ${t}`),this.missingRef=(0,sv.resolveUrl)(e,t,n),this.missingSchema=(0,sv.normalizeId)((0,sv.getFullPath)(e,this.missingRef))}};av.default=ov});var Uh=De(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.resolveSchema=Wn.getCompilingSchema=Wn.resolveRef=Wn.compileSchema=Wn.SchemaEnv=void 0;var br=Je(),RZ=Wh(),ta=_s(),_r=fu(),r3=mt(),MZ=pu(),dl=class{constructor(e){var t;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:(0,_r.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Wn.SchemaEnv=dl;function cv(i){let e=s3.call(this,i);if(e)return e;let t=(0,_r.getFullPath)(this.opts.uriResolver,i.root.baseId),{es5:n,lines:r}=this.opts.code,{ownProperties:s}=this.opts,o=new br.CodeGen(this.scope,{es5:n,lines:r,ownProperties:s}),a;i.$async&&(a=o.scopeValue("Error",{ref:RZ.default,code:(0,br._)`require("ajv/dist/runtime/validation_error").default`}));let l=o.scopeName("validate");i.validateName=l;let c={gen:o,allErrors:this.opts.allErrors,data:ta.default.data,parentData:ta.default.parentData,parentDataProperty:ta.default.parentDataProperty,dataNames:[ta.default.data],dataPathArr:[br.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:i.schema,code:(0,br.stringify)(i.schema)}:{ref:i.schema}),validateName:l,ValidationError:a,schema:i.schema,schemaEnv:i,rootId:t,baseId:i.baseId||t,schemaPath:br.nil,errSchemaPath:i.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,br._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(i),(0,MZ.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);let f=o.toString();u=`${o.scopeRefs(ta.default.scope)}return ${f}`,this.opts.code.process&&(u=this.opts.code.process(u,i));let h=new Function(`${ta.default.self}`,`${ta.default.scope}`,u)(this,this.scope.get());if(this.scope.value(l,{ref:h}),h.errors=null,h.schema=i.schema,h.schemaEnv=i,i.$async&&(h.$async=!0),this.opts.code.source===!0&&(h.source={validateName:l,validateCode:f,scopeValues:o._values}),this.opts.unevaluated){let{props:p,items:m}=c;h.evaluated={props:p instanceof br.Name?void 0:p,items:m instanceof br.Name?void 0:m,dynamicProps:p instanceof br.Name,dynamicItems:m instanceof br.Name},h.source&&(h.source.evaluated=(0,br.stringify)(h.evaluated))}return i.validate=h,i}catch(f){throw delete i.validate,delete i.validateName,u&&this.logger.error("Error compiling schema, function code:",u),f}finally{this._compilations.delete(i)}}Wn.compileSchema=cv;function IZ(i,e,t){var n;t=(0,_r.resolveUrl)(this.opts.uriResolver,e,t);let r=i.refs[t];if(r)return r;let s=ZZ.call(this,i,t);if(s===void 0){let o=(n=i.localRefs)===null||n===void 0?void 0:n[t],{schemaId:a}=this.opts;o&&(s=new dl({schema:o,schemaId:a,root:i,baseId:e}))}if(s!==void 0)return i.refs[t]=NZ.call(this,s)}Wn.resolveRef=IZ;function NZ(i){return(0,_r.inlineRef)(i.schema,this.opts.inlineRefs)?i.schema:i.validate?i:cv.call(this,i)}function s3(i){for(let e of this._compilations)if(jZ(e,i))return e}Wn.getCompilingSchema=s3;function jZ(i,e){return i.schema===e.schema&&i.root===e.root&&i.baseId===e.baseId}function ZZ(i,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||Yh.call(this,i,e)}function Yh(i,e){let t=this.opts.uriResolver.parse(e),n=(0,_r._getFullPath)(this.opts.uriResolver,t),r=(0,_r.getFullPath)(this.opts.uriResolver,i.baseId,void 0);if(Object.keys(i.schema).length>0&&n===r)return lv.call(this,t,i);let s=(0,_r.normalizeId)(n),o=this.refs[s]||this.schemas[s];if(typeof o=="string"){let a=Yh.call(this,i,o);return typeof a?.schema!="object"?void 0:lv.call(this,t,a)}if(typeof o?.schema=="object"){if(o.validate||cv.call(this,o),s===(0,_r.normalizeId)(e)){let{schema:a}=o,{schemaId:l}=this.opts,c=a[l];return c&&(r=(0,_r.resolveUrl)(this.opts.uriResolver,r,c)),new dl({schema:a,schemaId:l,root:i,baseId:r})}return lv.call(this,t,o)}}Wn.resolveSchema=Yh;var zZ=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function lv(i,{baseId:e,schema:t,root:n}){var r;if(((r=i.fragment)===null||r===void 0?void 0:r[0])!=="/")return;for(let a of i.fragment.slice(1).split("/")){if(typeof t=="boolean")return;let l=t[(0,r3.unescapeFragment)(a)];if(l===void 0)return;t=l;let c=typeof t=="object"&&t[this.opts.schemaId];!zZ.has(a)&&c&&(e=(0,_r.resolveUrl)(this.opts.uriResolver,e,c))}let s;if(typeof t!="boolean"&&t.$ref&&!(0,r3.schemaHasRulesButRef)(t,this.RULES)){let a=(0,_r.resolveUrl)(this.opts.uriResolver,e,t.$ref);s=Yh.call(this,n,a)}let{schemaId:o}=this.opts;if(s=s||new dl({schema:t,schemaId:o,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var o3=De((ite,qZ)=>{qZ.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var l3=De((Hh,a3)=>{(function(i,e){typeof Hh=="object"&&typeof a3<"u"?e(Hh):typeof define=="function"&&define.amd?define(["exports"],e):e(i.URI=i.URI||{})})(Hh,function(i){"use strict";function e(){for(var F=arguments.length,N=Array(F),W=0;W1){N[0]=N[0].slice(0,-1);for(var K=N.length-1,ee=1;ee= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=h-p,Z=Math.floor,Q=String.fromCharCode;function D(F){throw new RangeError(C[F])}function E(F,N){for(var W=[],K=F.length;K--;)W[K]=N(F[K]);return W}function j(F,N){var W=F.split("@"),K="";W.length>1&&(K=W[0]+"@",F=W[1]),F=F.replace(x,".");var ee=F.split("."),Pe=E(ee,N).join(".");return K+Pe}function z(F){for(var N=[],W=0,K=F.length;W=55296&&ee<=56319&&W>1,N+=Z(N/W);N>M*m>>1;ee+=h)N=Z(N/M);return Z(ee+(M+1)*N/(N+g))},xe=function(N){var W=[],K=N.length,ee=0,Pe=S,Le=_,rt=N.lastIndexOf(P);rt<0&&(rt=0);for(var Ot=0;Ot=128&&D("not-basic"),W.push(N.charCodeAt(Ot));for(var Ut=rt>0?rt+1:0;Ut=K&&D("invalid-input");var Rt=G(N.charCodeAt(Ut++));(Rt>=h||Rt>Z((d-ee)/Zt))&&D("overflow"),ee+=Rt*Zt;var lt=Ht<=Le?p:Ht>=Le+m?m:Ht-Le;if(RtZ(d/zt)&&D("overflow"),Zt*=zt}var _t=W.length+1;Le=le(ee-it,_t,it==0),Z(ee/_t)>d-Pe&&D("overflow"),Pe+=Z(ee/_t),ee%=_t,W.splice(ee++,0,Pe)}return String.fromCodePoint.apply(String,W)},ue=function(N){var W=[];N=z(N);var K=N.length,ee=S,Pe=0,Le=_,rt=!0,Ot=!1,Ut=void 0;try{for(var it=N[Symbol.iterator](),Zt;!(rt=(Zt=it.next()).done);rt=!0){var Ht=Zt.value;Ht<128&&W.push(Q(Ht))}}catch(I){Ot=!0,Ut=I}finally{try{!rt&&it.return&&it.return()}finally{if(Ot)throw Ut}}var Rt=W.length,lt=Rt;for(Rt&&W.push(P);lt=ee&&BiZ((d-Pe)/on)&&D("overflow"),Pe+=(zt-ee)*on,ee=zt;var Qn=!0,rs=!1,Un=void 0;try{for(var yo=N[Symbol.iterator](),aa;!(Qn=(aa=yo.next()).done);Qn=!0){var la=aa.value;if(lad&&D("overflow"),la==ee){for(var xs=Pe,Ps=h;;Ps+=h){var Hn=Ps<=Le?p:Ps>=Le+m?m:Ps-Le;if(xs>6|192).toString(16).toUpperCase()+"%"+(N&63|128).toString(16).toUpperCase():W="%"+(N>>12|224).toString(16).toUpperCase()+"%"+(N>>6&63|128).toString(16).toUpperCase()+"%"+(N&63|128).toString(16).toUpperCase(),W}function we(F){for(var N="",W=0,K=F.length;W=194&&ee<224){if(K-W>=6){var Pe=parseInt(F.substr(W+4,2),16);N+=String.fromCharCode((ee&31)<<6|Pe&63)}else N+=F.substr(W,6);W+=6}else if(ee>=224){if(K-W>=9){var Le=parseInt(F.substr(W+4,2),16),rt=parseInt(F.substr(W+7,2),16);N+=String.fromCharCode((ee&15)<<12|(Le&63)<<6|rt&63)}else N+=F.substr(W,9);W+=9}else N+=F.substr(W,3),W+=3}return N}function yt(F,N){function W(K){var ee=we(K);return ee.match(N.UNRESERVED)?ee:K}return F.scheme&&(F.scheme=String(F.scheme).replace(N.PCT_ENCODED,W).toLowerCase().replace(N.NOT_SCHEME,"")),F.userinfo!==void 0&&(F.userinfo=String(F.userinfo).replace(N.PCT_ENCODED,W).replace(N.NOT_USERINFO,oe).replace(N.PCT_ENCODED,r)),F.host!==void 0&&(F.host=String(F.host).replace(N.PCT_ENCODED,W).toLowerCase().replace(N.NOT_HOST,oe).replace(N.PCT_ENCODED,r)),F.path!==void 0&&(F.path=String(F.path).replace(N.PCT_ENCODED,W).replace(F.scheme?N.NOT_PATH:N.NOT_PATH_NOSCHEME,oe).replace(N.PCT_ENCODED,r)),F.query!==void 0&&(F.query=String(F.query).replace(N.PCT_ENCODED,W).replace(N.NOT_QUERY,oe).replace(N.PCT_ENCODED,r)),F.fragment!==void 0&&(F.fragment=String(F.fragment).replace(N.PCT_ENCODED,W).replace(N.NOT_FRAGMENT,oe).replace(N.PCT_ENCODED,r)),F}function It(F){return F.replace(/^0*(.*)/,"$1")||"0"}function ot(F,N){var W=F.match(N.IPV4ADDRESS)||[],K=u(W,2),ee=K[1];return ee?ee.split(".").map(It).join("."):F}function Nt(F,N){var W=F.match(N.IPV6ADDRESS)||[],K=u(W,3),ee=K[1],Pe=K[2];if(ee){for(var Le=ee.toLowerCase().split("::").reverse(),rt=u(Le,2),Ot=rt[0],Ut=rt[1],it=Ut?Ut.split(":").map(It):[],Zt=Ot.split(":").map(It),Ht=N.IPV4ADDRESS.test(Zt[Zt.length-1]),Rt=Ht?7:8,lt=Zt.length-Rt,zt=Array(Rt),_t=0;_t1){var wt=zt.slice(0,Fi.index),Bi=zt.slice(Fi.index+Fi.length);sn=wt.join(":")+"::"+Bi.join(":")}else sn=zt.join(":");return Pe&&(sn+="%"+Pe),sn}else return F}var Sr=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,nn="".match(/(){0}/)[1]===void 0;function $t(F){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},W={},K=N.iri!==!1?c:l;N.reference==="suffix"&&(F=(N.scheme?N.scheme+":":"")+"//"+F);var ee=F.match(Sr);if(ee){nn?(W.scheme=ee[1],W.userinfo=ee[3],W.host=ee[4],W.port=parseInt(ee[5],10),W.path=ee[6]||"",W.query=ee[7],W.fragment=ee[8],isNaN(W.port)&&(W.port=ee[5])):(W.scheme=ee[1]||void 0,W.userinfo=F.indexOf("@")!==-1?ee[3]:void 0,W.host=F.indexOf("//")!==-1?ee[4]:void 0,W.port=parseInt(ee[5],10),W.path=ee[6]||"",W.query=F.indexOf("?")!==-1?ee[7]:void 0,W.fragment=F.indexOf("#")!==-1?ee[8]:void 0,isNaN(W.port)&&(W.port=F.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?ee[4]:void 0)),W.host&&(W.host=Nt(ot(W.host,K),K)),W.scheme===void 0&&W.userinfo===void 0&&W.host===void 0&&W.port===void 0&&!W.path&&W.query===void 0?W.reference="same-document":W.scheme===void 0?W.reference="relative":W.fragment===void 0?W.reference="absolute":W.reference="uri",N.reference&&N.reference!=="suffix"&&N.reference!==W.reference&&(W.error=W.error||"URI is not a "+N.reference+" reference.");var Pe=Re[(N.scheme||W.scheme||"").toLowerCase()];if(!N.unicodeSupport&&(!Pe||!Pe.unicodeSupport)){if(W.host&&(N.domainHost||Pe&&Pe.domainHost))try{W.host=pe.toASCII(W.host.replace(K.PCT_ENCODED,we).toLowerCase())}catch(Le){W.error=W.error||"Host's domain name can not be converted to ASCII via punycode: "+Le}yt(W,l)}else yt(W,K);Pe&&Pe.parse&&Pe.parse(W,N)}else W.error=W.error||"URI can not be parsed.";return W}function Tt(F,N){var W=N.iri!==!1?c:l,K=[];return F.userinfo!==void 0&&(K.push(F.userinfo),K.push("@")),F.host!==void 0&&K.push(Nt(ot(String(F.host),W),W).replace(W.IPV6ADDRESS,function(ee,Pe,Le){return"["+Pe+(Le?"%25"+Le:"")+"]"})),(typeof F.port=="number"||typeof F.port=="string")&&(K.push(":"),K.push(String(F.port))),K.length?K.join(""):void 0}var at=/^\.\.?\//,dt=/^\/\.(\/|$)/,gt=/^\/\.\.(\/|$)/,jt=/^\/?(?:.|\n)*?(?=\/|$)/;function xr(F){for(var N=[];F.length;)if(F.match(at))F=F.replace(at,"");else if(F.match(dt))F=F.replace(dt,"/");else if(F.match(gt))F=F.replace(gt,"/"),N.pop();else if(F==="."||F==="..")F="";else{var W=F.match(jt);if(W){var K=W[0];F=F.slice(K.length),N.push(K)}else throw new Error("Unexpected dot segment condition")}return N.join("")}function bt(F){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},W=N.iri?c:l,K=[],ee=Re[(N.scheme||F.scheme||"").toLowerCase()];if(ee&&ee.serialize&&ee.serialize(F,N),F.host&&!W.IPV6ADDRESS.test(F.host)){if(N.domainHost||ee&&ee.domainHost)try{F.host=N.iri?pe.toUnicode(F.host):pe.toASCII(F.host.replace(W.PCT_ENCODED,we).toLowerCase())}catch(rt){F.error=F.error||"Host's domain name can not be converted to "+(N.iri?"Unicode":"ASCII")+" via punycode: "+rt}}yt(F,W),N.reference!=="suffix"&&F.scheme&&(K.push(F.scheme),K.push(":"));var Pe=Tt(F,N);if(Pe!==void 0&&(N.reference!=="suffix"&&K.push("//"),K.push(Pe),F.path&&F.path.charAt(0)!=="/"&&K.push("/")),F.path!==void 0){var Le=F.path;!N.absolutePath&&(!ee||!ee.absolutePath)&&(Le=xr(Le)),Pe===void 0&&(Le=Le.replace(/^\/\//,"/%2F")),K.push(Le)}return F.query!==void 0&&(K.push("?"),K.push(F.query)),F.fragment!==void 0&&(K.push("#"),K.push(F.fragment)),K.join("")}function et(F,N){var W=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},K=arguments[3],ee={};return K||(F=$t(bt(F,W),W),N=$t(bt(N,W),W)),W=W||{},!W.tolerant&&N.scheme?(ee.scheme=N.scheme,ee.userinfo=N.userinfo,ee.host=N.host,ee.port=N.port,ee.path=xr(N.path||""),ee.query=N.query):(N.userinfo!==void 0||N.host!==void 0||N.port!==void 0?(ee.userinfo=N.userinfo,ee.host=N.host,ee.port=N.port,ee.path=xr(N.path||""),ee.query=N.query):(N.path?(N.path.charAt(0)==="/"?ee.path=xr(N.path):((F.userinfo!==void 0||F.host!==void 0||F.port!==void 0)&&!F.path?ee.path="/"+N.path:F.path?ee.path=F.path.slice(0,F.path.lastIndexOf("/")+1)+N.path:ee.path=N.path,ee.path=xr(ee.path)),ee.query=N.query):(ee.path=F.path,N.query!==void 0?ee.query=N.query:ee.query=F.query),ee.userinfo=F.userinfo,ee.host=F.host,ee.port=F.port),ee.scheme=F.scheme),ee.fragment=N.fragment,ee}function is(F,N,W){var K=o({scheme:"null"},W);return bt(et($t(F,K),$t(N,K),K,!0),K)}function yl(F,N){return typeof F=="string"?F=bt($t(F,N),N):n(F)==="object"&&(F=$t(bt(F,N),N)),F}function Du(F,N,W){return typeof F=="string"?F=bt($t(F,W),W):n(F)==="object"&&(F=bt(F,W)),typeof N=="string"?N=bt($t(N,W),W):n(N)==="object"&&(N=bt(N,W)),F===N}function Qu(F,N){return F&&F.toString().replace(!N||!N.iri?l.ESCAPE:c.ESCAPE,oe)}function Dn(F,N){return F&&F.toString().replace(!N||!N.iri?l.PCT_ENCODED:c.PCT_ENCODED,we)}var ks={scheme:"http",domainHost:!0,parse:function(N,W){return N.host||(N.error=N.error||"HTTP URIs must have a host."),N},serialize:function(N,W){var K=String(N.scheme).toLowerCase()==="https";return(N.port===(K?443:80)||N.port==="")&&(N.port=void 0),N.path||(N.path="/"),N}},bl={scheme:"https",domainHost:ks.domainHost,parse:ks.parse,serialize:ks.serialize};function po(F){return typeof F.secure=="boolean"?F.secure:String(F.scheme).toLowerCase()==="wss"}var mo={scheme:"ws",domainHost:!0,parse:function(N,W){var K=N;return K.secure=po(K),K.resourceName=(K.path||"/")+(K.query?"?"+K.query:""),K.path=void 0,K.query=void 0,K},serialize:function(N,W){if((N.port===(po(N)?443:80)||N.port==="")&&(N.port=void 0),typeof N.secure=="boolean"&&(N.scheme=N.secure?"wss":"ws",N.secure=void 0),N.resourceName){var K=N.resourceName.split("?"),ee=u(K,2),Pe=ee[0],Le=ee[1];N.path=Pe&&Pe!=="/"?Pe:void 0,N.query=Le,N.resourceName=void 0}return N.fragment=void 0,N}},Ru={scheme:"wss",domainHost:mo.domainHost,parse:mo.parse,serialize:mo.serialize},sa={},Yn=!0,Pr="[A-Za-z0-9\\-\\.\\_\\~"+(Yn?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",rn="[0-9A-Fa-f]",go=t(t("%[EFef]"+rn+"%"+rn+rn+"%"+rn+rn)+"|"+t("%[89A-Fa-f]"+rn+"%"+rn+rn)+"|"+t("%"+rn+rn)),Oo="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Mu="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",_l=e(Mu,'[\\"\\\\]'),vp="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",yp=new RegExp(Pr,"g"),Ss=new RegExp(go,"g"),bp=new RegExp(e("[^]",Oo,"[\\.]",'[\\"]',_l),"g"),oa=new RegExp(e("[^]",Pr,vp),"g"),_p=oa;function wl(F){var N=we(F);return N.match(yp)?N:F}var vo={scheme:"mailto",parse:function(N,W){var K=N,ee=K.to=K.path?K.path.split(","):[];if(K.path=void 0,K.query){for(var Pe=!1,Le={},rt=K.query.split("&"),Ot=0,Ut=rt.length;Ot{"use strict";Object.defineProperty(uv,"__esModule",{value:!0});var c3=l3();c3.code='require("ajv/dist/runtime/uri").default';uv.default=c3});var v3=De(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});Ri.CodeGen=Ri.Name=Ri.nil=Ri.stringify=Ri.str=Ri._=Ri.KeywordCxt=void 0;var LZ=pu();Object.defineProperty(Ri,"KeywordCxt",{enumerable:!0,get:function(){return LZ.KeywordCxt}});var hl=Je();Object.defineProperty(Ri,"_",{enumerable:!0,get:function(){return hl._}});Object.defineProperty(Ri,"str",{enumerable:!0,get:function(){return hl.str}});Object.defineProperty(Ri,"stringify",{enumerable:!0,get:function(){return hl.stringify}});Object.defineProperty(Ri,"nil",{enumerable:!0,get:function(){return hl.nil}});Object.defineProperty(Ri,"Name",{enumerable:!0,get:function(){return hl.Name}});Object.defineProperty(Ri,"CodeGen",{enumerable:!0,get:function(){return hl.CodeGen}});var $Z=Wh(),m3=Xh(),FZ=BO(),mu=Uh(),BZ=Je(),gu=fu(),Gh=uu(),dv=mt(),f3=o3(),VZ=u3(),g3=(i,e)=>new RegExp(i,e);g3.code="new RegExp";var WZ=["removeAdditional","useDefaults","coerceTypes"],XZ=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),YZ={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},UZ={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},d3=200;function HZ(i){var e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P,k,w,x,C,M;let Z=i.strict,Q=(e=i.code)===null||e===void 0?void 0:e.optimize,D=Q===!0||Q===void 0?1:Q||0,E=(n=(t=i.code)===null||t===void 0?void 0:t.regExp)!==null&&n!==void 0?n:g3,j=(r=i.uriResolver)!==null&&r!==void 0?r:VZ.default;return{strictSchema:(o=(s=i.strictSchema)!==null&&s!==void 0?s:Z)!==null&&o!==void 0?o:!0,strictNumbers:(l=(a=i.strictNumbers)!==null&&a!==void 0?a:Z)!==null&&l!==void 0?l:!0,strictTypes:(u=(c=i.strictTypes)!==null&&c!==void 0?c:Z)!==null&&u!==void 0?u:"log",strictTuples:(d=(f=i.strictTuples)!==null&&f!==void 0?f:Z)!==null&&d!==void 0?d:"log",strictRequired:(p=(h=i.strictRequired)!==null&&h!==void 0?h:Z)!==null&&p!==void 0?p:!1,code:i.code?{...i.code,optimize:D,regExp:E}:{optimize:D,regExp:E},loopRequired:(m=i.loopRequired)!==null&&m!==void 0?m:d3,loopEnum:(g=i.loopEnum)!==null&&g!==void 0?g:d3,meta:(O=i.meta)!==null&&O!==void 0?O:!0,messages:(_=i.messages)!==null&&_!==void 0?_:!0,inlineRefs:(S=i.inlineRefs)!==null&&S!==void 0?S:!0,schemaId:(P=i.schemaId)!==null&&P!==void 0?P:"$id",addUsedSchema:(k=i.addUsedSchema)!==null&&k!==void 0?k:!0,validateSchema:(w=i.validateSchema)!==null&&w!==void 0?w:!0,validateFormats:(x=i.validateFormats)!==null&&x!==void 0?x:!0,unicodeRegExp:(C=i.unicodeRegExp)!==null&&C!==void 0?C:!0,int32range:(M=i.int32range)!==null&&M!==void 0?M:!0,uriResolver:j}}var Ou=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...HZ(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new BZ.ValueScope({scope:{},prefixes:XZ,es5:t,lines:n}),this.logger=iz(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,FZ.getRules)(),h3.call(this,YZ,e,"NOT SUPPORTED"),h3.call(this,UZ,e,"DEPRECATED","warn"),this._metaOpts=ez.call(this),e.formats&&KZ.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&JZ.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),GZ.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=f3;n==="id"&&(r={...f3},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[t]||e:void 0}validate(e,t){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return"$async"in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(u,f){await s.call(this,u.$schema);let d=this._addSchema(u,f);return d.validate||o.call(this,d)}async function s(u){u&&!this.getSchema(u)&&await r.call(this,{$ref:u},!0)}async function o(u){try{return this._compileSchemaEnv(u)}catch(f){if(!(f instanceof m3.default))throw f;return a.call(this,f),await l.call(this,f.missingSchema),o.call(this,u)}}function a({missingSchema:u,missingRef:f}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${f} cannot be resolved`)}async function l(u){let f=await c.call(this,u);this.refs[u]||await s.call(this,f.$schema),this.refs[u]||this.addSchema(f,u,t)}async function c(u){let f=this._loading[u];if(f)return f;try{return await(this._loading[u]=n(u))}finally{delete this._loading[u]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,n,r);return this}let s;if(typeof e=="object"){let{schemaId:o}=this.opts;if(s=e[o],s!==void 0&&typeof s!="string")throw new Error(`schema ${o} must be string`)}return t=(0,gu.normalizeId)(t||s),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return r}getSchema(e){let t;for(;typeof(t=p3.call(this,e))=="string";)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new mu.SchemaEnv({schema:{},schemaId:n});if(t=mu.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let t=p3.call(this,e);return typeof t=="object"&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,gu.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e=="string")n=e,typeof t=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=n);else if(typeof e=="object"&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(rz.call(this,n,t),!t)return(0,dv.eachItem)(n,s=>fv.call(this,s)),this;oz.call(this,t);let r={...t,type:(0,Gh.getJSONTypes)(t.type),schemaType:(0,Gh.getJSONTypes)(t.schemaType)};return(0,dv.eachItem)(n,r.type.length===0?s=>fv.call(this,s,r):s=>r.type.forEach(o=>fv.call(this,s,r,o))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t=="object"?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let r=n.rules.findIndex(s=>s.keyword===e);r>=0&&n.rules.splice(r,1)}return this}addFormat(e,t){return typeof t=="string"&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(r=>`${n}${r.instancePath} ${r.message}`).reduce((r,s)=>r+t+s)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let s=r.split("/").slice(1),o=e;for(let a of s)o=o[a];for(let a in n){let l=n[a];if(typeof l!="object")continue;let{$data:c}=l.definition,u=o[a];c&&u&&(o[a]=O3(u))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r=="string"?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,s=this.opts.addUsedSchema){let o,{schemaId:a}=this.opts;if(typeof e=="object")o=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let l=this._cache.get(e);if(l!==void 0)return l;n=(0,gu.normalizeId)(o||n);let c=gu.getSchemaRefs.call(this,e,n);return l=new mu.SchemaEnv({schema:e,schemaId:a,meta:t,baseId:n,localRefs:c}),this._cache.set(l.schema,l),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):mu.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{mu.compileSchema.call(this,e)}finally{this.opts=t}}};Ri.default=Ou;Ou.ValidationError=$Z.default;Ou.MissingRefError=m3.default;function h3(i,e,t,n="error"){for(let r in i){let s=r;s in e&&this.logger[n](`${t}: option ${r}. ${i[s]}`)}}function p3(i){return i=(0,gu.normalizeId)(i),this.schemas[i]||this.refs[i]}function GZ(){let i=this.opts.schemas;if(i)if(Array.isArray(i))this.addSchema(i);else for(let e in i)this.addSchema(i[e],e)}function KZ(){for(let i in this.opts.formats){let e=this.opts.formats[i];e&&this.addFormat(i,e)}}function JZ(i){if(Array.isArray(i)){this.addVocabulary(i);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in i){let t=i[e];t.keyword||(t.keyword=e),this.addKeyword(t)}}function ez(){let i={...this.opts};for(let e of WZ)delete i[e];return i}var tz={log(){},warn(){},error(){}};function iz(i){if(i===!1)return tz;if(i===void 0)return console;if(i.log&&i.warn&&i.error)return i;throw new Error("logger must implement log, warn and error methods")}var nz=/^[a-z_$][a-z0-9_$:-]*$/i;function rz(i,e){let{RULES:t}=this;if((0,dv.eachItem)(i,n=>{if(t.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!nz.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function fv(i,e,t){var n;let r=e?.post;if(t&&r)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,o=r?s.post:s.rules.find(({type:l})=>l===t);if(o||(o={type:t,rules:[]},s.rules.push(o)),s.keywords[i]=!0,!e)return;let a={keyword:i,definition:{...e,type:(0,Gh.getJSONTypes)(e.type),schemaType:(0,Gh.getJSONTypes)(e.schemaType)}};e.before?sz.call(this,o,a,e.before):o.rules.push(a),s.all[i]=a,(n=e.implements)===null||n===void 0||n.forEach(l=>this.addKeyword(l))}function sz(i,e,t){let n=i.rules.findIndex(r=>r.keyword===t);n>=0?i.rules.splice(n,0,e):(i.rules.push(e),this.logger.warn(`rule ${t} is not defined`))}function oz(i){let{metaSchema:e}=i;e!==void 0&&(i.$data&&this.opts.$data&&(e=O3(e)),i.validateSchema=this.compile(e,!0))}var az={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function O3(i){return{anyOf:[i,az]}}});var y3=De(hv=>{"use strict";Object.defineProperty(hv,"__esModule",{value:!0});var lz={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};hv.default=lz});var k3=De(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.callRef=ia.getValidate=void 0;var cz=Xh(),b3=Vn(),yn=Je(),pl=_s(),_3=Uh(),Kh=mt(),uz={keyword:"$ref",schemaType:"string",code(i){let{gen:e,schema:t,it:n}=i,{baseId:r,schemaEnv:s,validateName:o,opts:a,self:l}=n,{root:c}=s;if((t==="#"||t==="#/")&&r===c.baseId)return f();let u=_3.resolveRef.call(l,c,r,t);if(u===void 0)throw new cz.default(n.opts.uriResolver,r,t);if(u instanceof _3.SchemaEnv)return d(u);return h(u);function f(){if(s===c)return Jh(i,o,s,s.$async);let p=e.scopeValue("root",{ref:c});return Jh(i,(0,yn._)`${p}.validate`,c,c.$async)}function d(p){let m=w3(i,p);Jh(i,m,p,p.$async)}function h(p){let m=e.scopeValue("schema",a.code.source===!0?{ref:p,code:(0,yn.stringify)(p)}:{ref:p}),g=e.name("valid"),O=i.subschema({schema:p,dataTypes:[],schemaPath:yn.nil,topSchemaRef:m,errSchemaPath:t},g);i.mergeEvaluated(O),i.ok(g)}}};function w3(i,e){let{gen:t}=i;return e.validate?t.scopeValue("validate",{ref:e.validate}):(0,yn._)`${t.scopeValue("wrapper",{ref:e})}.validate`}ia.getValidate=w3;function Jh(i,e,t,n){let{gen:r,it:s}=i,{allErrors:o,schemaEnv:a,opts:l}=s,c=l.passContext?pl.default.this:yn.nil;n?u():f();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let p=r.let("valid");r.try(()=>{r.code((0,yn._)`await ${(0,b3.callValidateCode)(i,e,c)}`),h(e),o||r.assign(p,!0)},m=>{r.if((0,yn._)`!(${m} instanceof ${s.ValidationError})`,()=>r.throw(m)),d(m),o||r.assign(p,!1)}),i.ok(p)}function f(){i.result((0,b3.callValidateCode)(i,e,c),()=>h(e),()=>d(e))}function d(p){let m=(0,yn._)`${p}.errors`;r.assign(pl.default.vErrors,(0,yn._)`${pl.default.vErrors} === null ? ${m} : ${pl.default.vErrors}.concat(${m})`),r.assign(pl.default.errors,(0,yn._)`${pl.default.vErrors}.length`)}function h(p){var m;if(!s.opts.unevaluated)return;let g=(m=t?.validate)===null||m===void 0?void 0:m.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=Kh.mergeEvaluated.props(r,g.props,s.props));else{let O=r.var("props",(0,yn._)`${p}.evaluated.props`);s.props=Kh.mergeEvaluated.props(r,O,s.props,yn.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=Kh.mergeEvaluated.items(r,g.items,s.items));else{let O=r.var("items",(0,yn._)`${p}.evaluated.items`);s.items=Kh.mergeEvaluated.items(r,O,s.items,yn.Name)}}}ia.callRef=Jh;ia.default=uz});var S3=De(pv=>{"use strict";Object.defineProperty(pv,"__esModule",{value:!0});var fz=y3(),dz=k3(),hz=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",fz.default,dz.default];pv.default=hz});var x3=De(mv=>{"use strict";Object.defineProperty(mv,"__esModule",{value:!0});var ep=Je(),co=ep.operators,tp={maximum:{okStr:"<=",ok:co.LTE,fail:co.GT},minimum:{okStr:">=",ok:co.GTE,fail:co.LT},exclusiveMaximum:{okStr:"<",ok:co.LT,fail:co.GTE},exclusiveMinimum:{okStr:">",ok:co.GT,fail:co.LTE}},pz={message:({keyword:i,schemaCode:e})=>(0,ep.str)`must be ${tp[i].okStr} ${e}`,params:({keyword:i,schemaCode:e})=>(0,ep._)`{comparison: ${tp[i].okStr}, limit: ${e}}`},mz={keyword:Object.keys(tp),type:"number",schemaType:"number",$data:!0,error:pz,code(i){let{keyword:e,data:t,schemaCode:n}=i;i.fail$data((0,ep._)`${t} ${tp[e].fail} ${n} || isNaN(${t})`)}};mv.default=mz});var P3=De(gv=>{"use strict";Object.defineProperty(gv,"__esModule",{value:!0});var vu=Je(),gz={message:({schemaCode:i})=>(0,vu.str)`must be multiple of ${i}`,params:({schemaCode:i})=>(0,vu._)`{multipleOf: ${i}}`},Oz={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:gz,code(i){let{gen:e,data:t,schemaCode:n,it:r}=i,s=r.opts.multipleOfPrecision,o=e.let("res"),a=s?(0,vu._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${s}`:(0,vu._)`${o} !== parseInt(${o})`;i.fail$data((0,vu._)`(${n} === 0 || (${o} = ${t}/${n}, ${a}))`)}};gv.default=Oz});var E3=De(Ov=>{"use strict";Object.defineProperty(Ov,"__esModule",{value:!0});function C3(i){let e=i.length,t=0,n=0,r;for(;n=55296&&r<=56319&&n{"use strict";Object.defineProperty(vv,"__esModule",{value:!0});var na=Je(),vz=mt(),yz=E3(),bz={message({keyword:i,schemaCode:e}){let t=i==="maxLength"?"more":"fewer";return(0,na.str)`must NOT have ${t} than ${e} characters`},params:({schemaCode:i})=>(0,na._)`{limit: ${i}}`},_z={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:bz,code(i){let{keyword:e,data:t,schemaCode:n,it:r}=i,s=e==="maxLength"?na.operators.GT:na.operators.LT,o=r.opts.unicode===!1?(0,na._)`${t}.length`:(0,na._)`${(0,vz.useFunc)(i.gen,yz.default)}(${t})`;i.fail$data((0,na._)`${o} ${s} ${n}`)}};vv.default=_z});var A3=De(yv=>{"use strict";Object.defineProperty(yv,"__esModule",{value:!0});var wz=Vn(),ip=Je(),kz={message:({schemaCode:i})=>(0,ip.str)`must match pattern "${i}"`,params:({schemaCode:i})=>(0,ip._)`{pattern: ${i}}`},Sz={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:kz,code(i){let{data:e,$data:t,schema:n,schemaCode:r,it:s}=i,o=s.opts.unicodeRegExp?"u":"",a=t?(0,ip._)`(new RegExp(${r}, ${o}))`:(0,wz.usePattern)(i,n);i.fail$data((0,ip._)`!${a}.test(${e})`)}};yv.default=Sz});var D3=De(bv=>{"use strict";Object.defineProperty(bv,"__esModule",{value:!0});var yu=Je(),xz={message({keyword:i,schemaCode:e}){let t=i==="maxProperties"?"more":"fewer";return(0,yu.str)`must NOT have ${t} than ${e} properties`},params:({schemaCode:i})=>(0,yu._)`{limit: ${i}}`},Pz={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:xz,code(i){let{keyword:e,data:t,schemaCode:n}=i,r=e==="maxProperties"?yu.operators.GT:yu.operators.LT;i.fail$data((0,yu._)`Object.keys(${t}).length ${r} ${n}`)}};bv.default=Pz});var Q3=De(_v=>{"use strict";Object.defineProperty(_v,"__esModule",{value:!0});var bu=Vn(),_u=Je(),Cz=mt(),Ez={message:({params:{missingProperty:i}})=>(0,_u.str)`must have required property '${i}'`,params:({params:{missingProperty:i}})=>(0,_u._)`{missingProperty: ${i}}`},Tz={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Ez,code(i){let{gen:e,schema:t,schemaCode:n,data:r,$data:s,it:o}=i,{opts:a}=o;if(!s&&t.length===0)return;let l=t.length>=a.loopRequired;if(o.allErrors?c():u(),a.strictRequired){let h=i.parentSchema.properties,{definedProperties:p}=i.it;for(let m of t)if(h?.[m]===void 0&&!p.has(m)){let g=o.schemaEnv.baseId+o.errSchemaPath,O=`required property "${m}" is not defined at "${g}" (strictRequired)`;(0,Cz.checkStrictMode)(o,O,o.opts.strictRequired)}}function c(){if(l||s)i.block$data(_u.nil,f);else for(let h of t)(0,bu.checkReportMissingProp)(i,h)}function u(){let h=e.let("missing");if(l||s){let p=e.let("valid",!0);i.block$data(p,()=>d(h,p)),i.ok(p)}else e.if((0,bu.checkMissingProp)(i,t,h)),(0,bu.reportMissingProp)(i,h),e.else()}function f(){e.forOf("prop",n,h=>{i.setParams({missingProperty:h}),e.if((0,bu.noPropertyInData)(e,r,h,a.ownProperties),()=>i.error())})}function d(h,p){i.setParams({missingProperty:h}),e.forOf(h,n,()=>{e.assign(p,(0,bu.propertyInData)(e,r,h,a.ownProperties)),e.if((0,_u.not)(p),()=>{i.error(),e.break()})},_u.nil)}}};_v.default=Tz});var R3=De(wv=>{"use strict";Object.defineProperty(wv,"__esModule",{value:!0});var wu=Je(),Az={message({keyword:i,schemaCode:e}){let t=i==="maxItems"?"more":"fewer";return(0,wu.str)`must NOT have ${t} than ${e} items`},params:({schemaCode:i})=>(0,wu._)`{limit: ${i}}`},Dz={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Az,code(i){let{keyword:e,data:t,schemaCode:n}=i,r=e==="maxItems"?wu.operators.GT:wu.operators.LT;i.fail$data((0,wu._)`${t}.length ${r} ${n}`)}};wv.default=Dz});var np=De(kv=>{"use strict";Object.defineProperty(kv,"__esModule",{value:!0});var M3=KO();M3.code='require("ajv/dist/runtime/equal").default';kv.default=M3});var I3=De(xv=>{"use strict";Object.defineProperty(xv,"__esModule",{value:!0});var Sv=uu(),Mi=Je(),Qz=mt(),Rz=np(),Mz={message:({params:{i,j:e}})=>(0,Mi.str)`must NOT have duplicate items (items ## ${e} and ${i} are identical)`,params:({params:{i,j:e}})=>(0,Mi._)`{i: ${i}, j: ${e}}`},Iz={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Mz,code(i){let{gen:e,data:t,$data:n,schema:r,parentSchema:s,schemaCode:o,it:a}=i;if(!n&&!r)return;let l=e.let("valid"),c=s.items?(0,Sv.getSchemaTypes)(s.items):[];i.block$data(l,u,(0,Mi._)`${o} === false`),i.ok(l);function u(){let p=e.let("i",(0,Mi._)`${t}.length`),m=e.let("j");i.setParams({i:p,j:m}),e.assign(l,!0),e.if((0,Mi._)`${p} > 1`,()=>(f()?d:h)(p,m))}function f(){return c.length>0&&!c.some(p=>p==="object"||p==="array")}function d(p,m){let g=e.name("item"),O=(0,Sv.checkDataTypes)(c,g,a.opts.strictNumbers,Sv.DataType.Wrong),_=e.const("indices",(0,Mi._)`{}`);e.for((0,Mi._)`;${p}--;`,()=>{e.let(g,(0,Mi._)`${t}[${p}]`),e.if(O,(0,Mi._)`continue`),c.length>1&&e.if((0,Mi._)`typeof ${g} == "string"`,(0,Mi._)`${g} += "_"`),e.if((0,Mi._)`typeof ${_}[${g}] == "number"`,()=>{e.assign(m,(0,Mi._)`${_}[${g}]`),i.error(),e.assign(l,!1).break()}).code((0,Mi._)`${_}[${g}] = ${p}`)})}function h(p,m){let g=(0,Qz.useFunc)(e,Rz.default),O=e.name("outer");e.label(O).for((0,Mi._)`;${p}--;`,()=>e.for((0,Mi._)`${m} = ${p}; ${m}--;`,()=>e.if((0,Mi._)`${g}(${t}[${p}], ${t}[${m}])`,()=>{i.error(),e.assign(l,!1).break(O)})))}}};xv.default=Iz});var N3=De(Cv=>{"use strict";Object.defineProperty(Cv,"__esModule",{value:!0});var Pv=Je(),Nz=mt(),jz=np(),Zz={message:"must be equal to constant",params:({schemaCode:i})=>(0,Pv._)`{allowedValue: ${i}}`},zz={keyword:"const",$data:!0,error:Zz,code(i){let{gen:e,data:t,$data:n,schemaCode:r,schema:s}=i;n||s&&typeof s=="object"?i.fail$data((0,Pv._)`!${(0,Nz.useFunc)(e,jz.default)}(${t}, ${r})`):i.fail((0,Pv._)`${s} !== ${t}`)}};Cv.default=zz});var j3=De(Ev=>{"use strict";Object.defineProperty(Ev,"__esModule",{value:!0});var ku=Je(),qz=mt(),Lz=np(),$z={message:"must be equal to one of the allowed values",params:({schemaCode:i})=>(0,ku._)`{allowedValues: ${i}}`},Fz={keyword:"enum",schemaType:"array",$data:!0,error:$z,code(i){let{gen:e,data:t,$data:n,schema:r,schemaCode:s,it:o}=i;if(!n&&r.length===0)throw new Error("enum must have non-empty array");let a=r.length>=o.opts.loopEnum,l,c=()=>l??(l=(0,qz.useFunc)(e,Lz.default)),u;if(a||n)u=e.let("valid"),i.block$data(u,f);else{if(!Array.isArray(r))throw new Error("ajv implementation error");let h=e.const("vSchema",s);u=(0,ku.or)(...r.map((p,m)=>d(h,m)))}i.pass(u);function f(){e.assign(u,!1),e.forOf("v",s,h=>e.if((0,ku._)`${c()}(${t}, ${h})`,()=>e.assign(u,!0).break()))}function d(h,p){let m=r[p];return typeof m=="object"&&m!==null?(0,ku._)`${c()}(${t}, ${h}[${p}])`:(0,ku._)`${t} === ${m}`}}};Ev.default=Fz});var Z3=De(Tv=>{"use strict";Object.defineProperty(Tv,"__esModule",{value:!0});var Bz=x3(),Vz=P3(),Wz=T3(),Xz=A3(),Yz=D3(),Uz=Q3(),Hz=R3(),Gz=I3(),Kz=N3(),Jz=j3(),eq=[Bz.default,Vz.default,Wz.default,Xz.default,Yz.default,Uz.default,Hz.default,Gz.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Kz.default,Jz.default];Tv.default=eq});var Dv=De(Su=>{"use strict";Object.defineProperty(Su,"__esModule",{value:!0});Su.validateAdditionalItems=void 0;var ra=Je(),Av=mt(),tq={message:({params:{len:i}})=>(0,ra.str)`must NOT have more than ${i} items`,params:({params:{len:i}})=>(0,ra._)`{limit: ${i}}`},iq={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:tq,code(i){let{parentSchema:e,it:t}=i,{items:n}=e;if(!Array.isArray(n)){(0,Av.checkStrictMode)(t,'"additionalItems" is ignored when "items" is not an array of schemas');return}z3(i,n)}};function z3(i,e){let{gen:t,schema:n,data:r,keyword:s,it:o}=i;o.items=!0;let a=t.const("len",(0,ra._)`${r}.length`);if(n===!1)i.setParams({len:e.length}),i.pass((0,ra._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Av.alwaysValidSchema)(o,n)){let c=t.var("valid",(0,ra._)`${a} <= ${e.length}`);t.if((0,ra.not)(c),()=>l(c)),i.ok(c)}function l(c){t.forRange("i",e.length,a,u=>{i.subschema({keyword:s,dataProp:u,dataPropType:Av.Type.Num},c),o.allErrors||t.if((0,ra.not)(c),()=>t.break())})}}Su.validateAdditionalItems=z3;Su.default=iq});var Qv=De(xu=>{"use strict";Object.defineProperty(xu,"__esModule",{value:!0});xu.validateTuple=void 0;var q3=Je(),rp=mt(),nq=Vn(),rq={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(i){let{schema:e,it:t}=i;if(Array.isArray(e))return L3(i,"additionalItems",e);t.items=!0,!(0,rp.alwaysValidSchema)(t,e)&&i.ok((0,nq.validateArray)(i))}};function L3(i,e,t=i.schema){let{gen:n,parentSchema:r,data:s,keyword:o,it:a}=i;u(r),a.opts.unevaluated&&t.length&&a.items!==!0&&(a.items=rp.mergeEvaluated.items(n,t.length,a.items));let l=n.name("valid"),c=n.const("len",(0,q3._)`${s}.length`);t.forEach((f,d)=>{(0,rp.alwaysValidSchema)(a,f)||(n.if((0,q3._)`${c} > ${d}`,()=>i.subschema({keyword:o,schemaProp:d,dataProp:d},l)),i.ok(l))});function u(f){let{opts:d,errSchemaPath:h}=a,p=t.length,m=p===f.minItems&&(p===f.maxItems||f[e]===!1);if(d.strictTuples&&!m){let g=`"${o}" is ${p}-tuple, but minItems or maxItems/${e} are not specified or different at path "${h}"`;(0,rp.checkStrictMode)(a,g,d.strictTuples)}}}xu.validateTuple=L3;xu.default=rq});var $3=De(Rv=>{"use strict";Object.defineProperty(Rv,"__esModule",{value:!0});var sq=Qv(),oq={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:i=>(0,sq.validateTuple)(i,"items")};Rv.default=oq});var B3=De(Mv=>{"use strict";Object.defineProperty(Mv,"__esModule",{value:!0});var F3=Je(),aq=mt(),lq=Vn(),cq=Dv(),uq={message:({params:{len:i}})=>(0,F3.str)`must NOT have more than ${i} items`,params:({params:{len:i}})=>(0,F3._)`{limit: ${i}}`},fq={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:uq,code(i){let{schema:e,parentSchema:t,it:n}=i,{prefixItems:r}=t;n.items=!0,!(0,aq.alwaysValidSchema)(n,e)&&(r?(0,cq.validateAdditionalItems)(i,r):i.ok((0,lq.validateArray)(i)))}};Mv.default=fq});var V3=De(Iv=>{"use strict";Object.defineProperty(Iv,"__esModule",{value:!0});var Xn=Je(),sp=mt(),dq={message:({params:{min:i,max:e}})=>e===void 0?(0,Xn.str)`must contain at least ${i} valid item(s)`:(0,Xn.str)`must contain at least ${i} and no more than ${e} valid item(s)`,params:({params:{min:i,max:e}})=>e===void 0?(0,Xn._)`{minContains: ${i}}`:(0,Xn._)`{minContains: ${i}, maxContains: ${e}}`},hq={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:dq,code(i){let{gen:e,schema:t,parentSchema:n,data:r,it:s}=i,o,a,{minContains:l,maxContains:c}=n;s.opts.next?(o=l===void 0?1:l,a=c):o=1;let u=e.const("len",(0,Xn._)`${r}.length`);if(i.setParams({min:o,max:a}),a===void 0&&o===0){(0,sp.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,sp.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),i.fail();return}if((0,sp.alwaysValidSchema)(s,t)){let m=(0,Xn._)`${u} >= ${o}`;a!==void 0&&(m=(0,Xn._)`${m} && ${u} <= ${a}`),i.pass(m);return}s.items=!0;let f=e.name("valid");a===void 0&&o===1?h(f,()=>e.if(f,()=>e.break())):o===0?(e.let(f,!0),a!==void 0&&e.if((0,Xn._)`${r}.length > 0`,d)):(e.let(f,!1),d()),i.result(f,()=>i.reset());function d(){let m=e.name("_valid"),g=e.let("count",0);h(m,()=>e.if(m,()=>p(g)))}function h(m,g){e.forRange("i",0,u,O=>{i.subschema({keyword:"contains",dataProp:O,dataPropType:sp.Type.Num,compositeRule:!0},m),g()})}function p(m){e.code((0,Xn._)`${m}++`),a===void 0?e.if((0,Xn._)`${m} >= ${o}`,()=>e.assign(f,!0).break()):(e.if((0,Xn._)`${m} > ${a}`,()=>e.assign(f,!1).break()),o===1?e.assign(f,!0):e.if((0,Xn._)`${m} >= ${o}`,()=>e.assign(f,!0)))}}};Iv.default=hq});var Y3=De(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.validateSchemaDeps=es.validatePropertyDeps=es.error=void 0;var Nv=Je(),pq=mt(),Pu=Vn();es.error={message:({params:{property:i,depsCount:e,deps:t}})=>{let n=e===1?"property":"properties";return(0,Nv.str)`must have ${n} ${t} when property ${i} is present`},params:({params:{property:i,depsCount:e,deps:t,missingProperty:n}})=>(0,Nv._)`{property: ${i}, missingProperty: ${n}, depsCount: ${e}, deps: ${t}}`};var mq={keyword:"dependencies",type:"object",schemaType:"object",error:es.error,code(i){let[e,t]=gq(i);W3(i,e),X3(i,t)}};function gq({schema:i}){let e={},t={};for(let n in i){if(n==="__proto__")continue;let r=Array.isArray(i[n])?e:t;r[n]=i[n]}return[e,t]}function W3(i,e=i.schema){let{gen:t,data:n,it:r}=i;if(Object.keys(e).length===0)return;let s=t.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let l=(0,Pu.propertyInData)(t,n,o,r.opts.ownProperties);i.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),r.allErrors?t.if(l,()=>{for(let c of a)(0,Pu.checkReportMissingProp)(i,c)}):(t.if((0,Nv._)`${l} && (${(0,Pu.checkMissingProp)(i,a,s)})`),(0,Pu.reportMissingProp)(i,s),t.else())}}es.validatePropertyDeps=W3;function X3(i,e=i.schema){let{gen:t,data:n,keyword:r,it:s}=i,o=t.name("valid");for(let a in e)(0,pq.alwaysValidSchema)(s,e[a])||(t.if((0,Pu.propertyInData)(t,n,a,s.opts.ownProperties),()=>{let l=i.subschema({keyword:r,schemaProp:a},o);i.mergeValidEvaluated(l,o)},()=>t.var(o,!0)),i.ok(o))}es.validateSchemaDeps=X3;es.default=mq});var H3=De(jv=>{"use strict";Object.defineProperty(jv,"__esModule",{value:!0});var U3=Je(),Oq=mt(),vq={message:"property name must be valid",params:({params:i})=>(0,U3._)`{propertyName: ${i.propertyName}}`},yq={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:vq,code(i){let{gen:e,schema:t,data:n,it:r}=i;if((0,Oq.alwaysValidSchema)(r,t))return;let s=e.name("valid");e.forIn("key",n,o=>{i.setParams({propertyName:o}),i.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),e.if((0,U3.not)(s),()=>{i.error(!0),r.allErrors||e.break()})}),i.ok(s)}};jv.default=yq});var zv=De(Zv=>{"use strict";Object.defineProperty(Zv,"__esModule",{value:!0});var op=Vn(),wr=Je(),bq=_s(),ap=mt(),_q={message:"must NOT have additional properties",params:({params:i})=>(0,wr._)`{additionalProperty: ${i.additionalProperty}}`},wq={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:_q,code(i){let{gen:e,schema:t,parentSchema:n,data:r,errsCount:s,it:o}=i;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,ap.alwaysValidSchema)(o,t))return;let c=(0,op.allSchemaProperties)(n.properties),u=(0,op.allSchemaProperties)(n.patternProperties);f(),i.ok((0,wr._)`${s} === ${bq.default.errors}`);function f(){e.forIn("key",r,g=>{!c.length&&!u.length?p(g):e.if(d(g),()=>p(g))})}function d(g){let O;if(c.length>8){let _=(0,ap.schemaRefOrVal)(o,n.properties,"properties");O=(0,op.isOwnProperty)(e,_,g)}else c.length?O=(0,wr.or)(...c.map(_=>(0,wr._)`${g} === ${_}`)):O=wr.nil;return u.length&&(O=(0,wr.or)(O,...u.map(_=>(0,wr._)`${(0,op.usePattern)(i,_)}.test(${g})`))),(0,wr.not)(O)}function h(g){e.code((0,wr._)`delete ${r}[${g}]`)}function p(g){if(l.removeAdditional==="all"||l.removeAdditional&&t===!1){h(g);return}if(t===!1){i.setParams({additionalProperty:g}),i.error(),a||e.break();return}if(typeof t=="object"&&!(0,ap.alwaysValidSchema)(o,t)){let O=e.name("valid");l.removeAdditional==="failing"?(m(g,O,!1),e.if((0,wr.not)(O),()=>{i.reset(),h(g)})):(m(g,O),a||e.if((0,wr.not)(O),()=>e.break()))}}function m(g,O,_){let S={keyword:"additionalProperties",dataProp:g,dataPropType:ap.Type.Str};_===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),i.subschema(S,O)}}};Zv.default=wq});var J3=De(Lv=>{"use strict";Object.defineProperty(Lv,"__esModule",{value:!0});var kq=pu(),G3=Vn(),qv=mt(),K3=zv(),Sq={keyword:"properties",type:"object",schemaType:"object",code(i){let{gen:e,schema:t,parentSchema:n,data:r,it:s}=i;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&K3.default.code(new kq.KeywordCxt(s,K3.default,"additionalProperties"));let o=(0,G3.allSchemaProperties)(t);for(let f of o)s.definedProperties.add(f);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=qv.mergeEvaluated.props(e,(0,qv.toHash)(o),s.props));let a=o.filter(f=>!(0,qv.alwaysValidSchema)(s,t[f]));if(a.length===0)return;let l=e.name("valid");for(let f of a)c(f)?u(f):(e.if((0,G3.propertyInData)(e,r,f,s.opts.ownProperties)),u(f),s.allErrors||e.else().var(l,!0),e.endIf()),i.it.definedProperties.add(f),i.ok(l);function c(f){return s.opts.useDefaults&&!s.compositeRule&&t[f].default!==void 0}function u(f){i.subschema({keyword:"properties",schemaProp:f,dataProp:f},l)}}};Lv.default=Sq});var n5=De($v=>{"use strict";Object.defineProperty($v,"__esModule",{value:!0});var e5=Vn(),lp=Je(),t5=mt(),i5=mt(),xq={keyword:"patternProperties",type:"object",schemaType:"object",code(i){let{gen:e,schema:t,data:n,parentSchema:r,it:s}=i,{opts:o}=s,a=(0,e5.allSchemaProperties)(t),l=a.filter(m=>(0,t5.alwaysValidSchema)(s,t[m]));if(a.length===0||l.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let c=o.strictSchema&&!o.allowMatchingProperties&&r.properties,u=e.name("valid");s.props!==!0&&!(s.props instanceof lp.Name)&&(s.props=(0,i5.evaluatedPropsToName)(e,s.props));let{props:f}=s;d();function d(){for(let m of a)c&&h(m),s.allErrors?p(m):(e.var(u,!0),p(m),e.if(u))}function h(m){for(let g in c)new RegExp(m).test(g)&&(0,t5.checkStrictMode)(s,`property ${g} matches pattern ${m} (use allowMatchingProperties)`)}function p(m){e.forIn("key",n,g=>{e.if((0,lp._)`${(0,e5.usePattern)(i,m)}.test(${g})`,()=>{let O=l.includes(m);O||i.subschema({keyword:"patternProperties",schemaProp:m,dataProp:g,dataPropType:i5.Type.Str},u),s.opts.unevaluated&&f!==!0?e.assign((0,lp._)`${f}[${g}]`,!0):!O&&!s.allErrors&&e.if((0,lp.not)(u),()=>e.break())})})}}};$v.default=xq});var r5=De(Fv=>{"use strict";Object.defineProperty(Fv,"__esModule",{value:!0});var Pq=mt(),Cq={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(i){let{gen:e,schema:t,it:n}=i;if((0,Pq.alwaysValidSchema)(n,t)){i.fail();return}let r=e.name("valid");i.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),i.failResult(r,()=>i.reset(),()=>i.error())},error:{message:"must NOT be valid"}};Fv.default=Cq});var s5=De(Bv=>{"use strict";Object.defineProperty(Bv,"__esModule",{value:!0});var Eq=Vn(),Tq={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Eq.validateUnion,error:{message:"must match a schema in anyOf"}};Bv.default=Tq});var o5=De(Vv=>{"use strict";Object.defineProperty(Vv,"__esModule",{value:!0});var cp=Je(),Aq=mt(),Dq={message:"must match exactly one schema in oneOf",params:({params:i})=>(0,cp._)`{passingSchemas: ${i.passing}}`},Qq={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Dq,code(i){let{gen:e,schema:t,parentSchema:n,it:r}=i;if(!Array.isArray(t))throw new Error("ajv implementation error");if(r.opts.discriminator&&n.discriminator)return;let s=t,o=e.let("valid",!1),a=e.let("passing",null),l=e.name("_valid");i.setParams({passing:a}),e.block(c),i.result(o,()=>i.reset(),()=>i.error(!0));function c(){s.forEach((u,f)=>{let d;(0,Aq.alwaysValidSchema)(r,u)?e.var(l,!0):d=i.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},l),f>0&&e.if((0,cp._)`${l} && ${o}`).assign(o,!1).assign(a,(0,cp._)`[${a}, ${f}]`).else(),e.if(l,()=>{e.assign(o,!0),e.assign(a,f),d&&i.mergeEvaluated(d,cp.Name)})})}}};Vv.default=Qq});var a5=De(Wv=>{"use strict";Object.defineProperty(Wv,"__esModule",{value:!0});var Rq=mt(),Mq={keyword:"allOf",schemaType:"array",code(i){let{gen:e,schema:t,it:n}=i;if(!Array.isArray(t))throw new Error("ajv implementation error");let r=e.name("valid");t.forEach((s,o)=>{if((0,Rq.alwaysValidSchema)(n,s))return;let a=i.subschema({keyword:"allOf",schemaProp:o},r);i.ok(r),i.mergeEvaluated(a)})}};Wv.default=Mq});var u5=De(Xv=>{"use strict";Object.defineProperty(Xv,"__esModule",{value:!0});var up=Je(),c5=mt(),Iq={message:({params:i})=>(0,up.str)`must match "${i.ifClause}" schema`,params:({params:i})=>(0,up._)`{failingKeyword: ${i.ifClause}}`},Nq={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Iq,code(i){let{gen:e,parentSchema:t,it:n}=i;t.then===void 0&&t.else===void 0&&(0,c5.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let r=l5(n,"then"),s=l5(n,"else");if(!r&&!s)return;let o=e.let("valid",!0),a=e.name("_valid");if(l(),i.reset(),r&&s){let u=e.let("ifClause");i.setParams({ifClause:u}),e.if(a,c("then",u),c("else",u))}else r?e.if(a,c("then")):e.if((0,up.not)(a),c("else"));i.pass(o,()=>i.error(!0));function l(){let u=i.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);i.mergeEvaluated(u)}function c(u,f){return()=>{let d=i.subschema({keyword:u},a);e.assign(o,a),i.mergeValidEvaluated(d,o),f?e.assign(f,(0,up._)`${u}`):i.setParams({ifClause:u})}}}};function l5(i,e){let t=i.schema[e];return t!==void 0&&!(0,c5.alwaysValidSchema)(i,t)}Xv.default=Nq});var f5=De(Yv=>{"use strict";Object.defineProperty(Yv,"__esModule",{value:!0});var jq=mt(),Zq={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:i,parentSchema:e,it:t}){e.if===void 0&&(0,jq.checkStrictMode)(t,`"${i}" without "if" is ignored`)}};Yv.default=Zq});var d5=De(Uv=>{"use strict";Object.defineProperty(Uv,"__esModule",{value:!0});var zq=Dv(),qq=$3(),Lq=Qv(),$q=B3(),Fq=V3(),Bq=Y3(),Vq=H3(),Wq=zv(),Xq=J3(),Yq=n5(),Uq=r5(),Hq=s5(),Gq=o5(),Kq=a5(),Jq=u5(),eL=f5();function tL(i=!1){let e=[Uq.default,Hq.default,Gq.default,Kq.default,Jq.default,eL.default,Vq.default,Wq.default,Bq.default,Xq.default,Yq.default];return i?e.push(qq.default,$q.default):e.push(zq.default,Lq.default),e.push(Fq.default),e}Uv.default=tL});var h5=De(Hv=>{"use strict";Object.defineProperty(Hv,"__esModule",{value:!0});var si=Je(),iL={message:({schemaCode:i})=>(0,si.str)`must match format "${i}"`,params:({schemaCode:i})=>(0,si._)`{format: ${i}}`},nL={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:iL,code(i,e){let{gen:t,data:n,$data:r,schema:s,schemaCode:o,it:a}=i,{opts:l,errSchemaPath:c,schemaEnv:u,self:f}=a;if(!l.validateFormats)return;r?d():h();function d(){let p=t.scopeValue("formats",{ref:f.formats,code:l.code.formats}),m=t.const("fDef",(0,si._)`${p}[${o}]`),g=t.let("fType"),O=t.let("format");t.if((0,si._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>t.assign(g,(0,si._)`${m}.type || "string"`).assign(O,(0,si._)`${m}.validate`),()=>t.assign(g,(0,si._)`"string"`).assign(O,m)),i.fail$data((0,si.or)(_(),S()));function _(){return l.strictSchema===!1?si.nil:(0,si._)`${o} && !${O}`}function S(){let P=u.$async?(0,si._)`(${m}.async ? await ${O}(${n}) : ${O}(${n}))`:(0,si._)`${O}(${n})`,k=(0,si._)`(typeof ${O} == "function" ? ${P} : ${O}.test(${n}))`;return(0,si._)`${O} && ${O} !== true && ${g} === ${e} && !${k}`}}function h(){let p=f.formats[s];if(!p){_();return}if(p===!0)return;let[m,g,O]=S(p);m===e&&i.pass(P());function _(){if(l.strictSchema===!1){f.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${s}" ignored in schema at path "${c}"`}}function S(k){let w=k instanceof RegExp?(0,si.regexpCode)(k):l.code.formats?(0,si._)`${l.code.formats}${(0,si.getProperty)(s)}`:void 0,x=t.scopeValue("formats",{key:s,ref:k,code:w});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,si._)`${x}.validate`]:["string",k,x]}function P(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!u.$async)throw new Error("async format in sync schema");return(0,si._)`await ${O}(${n})`}return typeof g=="function"?(0,si._)`${O}(${n})`:(0,si._)`${O}.test(${n})`}}}};Hv.default=nL});var p5=De(Gv=>{"use strict";Object.defineProperty(Gv,"__esModule",{value:!0});var rL=h5(),sL=[rL.default];Gv.default=sL});var m5=De(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});ml.contentVocabulary=ml.metadataVocabulary=void 0;ml.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ml.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var O5=De(Kv=>{"use strict";Object.defineProperty(Kv,"__esModule",{value:!0});var oL=S3(),aL=Z3(),lL=d5(),cL=p5(),g5=m5(),uL=[oL.default,aL.default,(0,lL.default)(),cL.default,g5.metadataVocabulary,g5.contentVocabulary];Kv.default=uL});var v5=De(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});Cu.DiscrError=void 0;var fL;(function(i){i.Tag="tag",i.Mapping="mapping"})(fL=Cu.DiscrError||(Cu.DiscrError={}))});var b5=De(ey=>{"use strict";Object.defineProperty(ey,"__esModule",{value:!0});var gl=Je(),Jv=v5(),y5=Uh(),dL=mt(),hL={message:({params:{discrError:i,tagName:e}})=>i===Jv.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:i,tag:e,tagName:t}})=>(0,gl._)`{error: ${i}, tag: ${t}, tagValue: ${e}}`},pL={keyword:"discriminator",type:"object",schemaType:"object",error:hL,code(i){let{gen:e,data:t,schema:n,parentSchema:r,it:s}=i,{oneOf:o}=r;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let l=e.let("valid",!1),c=e.const("tag",(0,gl._)`${t}${(0,gl.getProperty)(a)}`);e.if((0,gl._)`typeof ${c} == "string"`,()=>u(),()=>i.error(!1,{discrError:Jv.DiscrError.Tag,tag:c,tagName:a})),i.ok(l);function u(){let h=d();e.if(!1);for(let p in h)e.elseIf((0,gl._)`${c} === ${p}`),e.assign(l,f(h[p]));e.else(),i.error(!1,{discrError:Jv.DiscrError.Mapping,tag:c,tagName:a}),e.endIf()}function f(h){let p=e.name("valid"),m=i.subschema({keyword:"oneOf",schemaProp:h},p);return i.mergeEvaluated(m,gl.Name),p}function d(){var h;let p={},m=O(r),g=!0;for(let P=0;P{mL.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var S5=De((Yt,k5)=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.MissingRefError=Yt.ValidationError=Yt.CodeGen=Yt.Name=Yt.nil=Yt.stringify=Yt.str=Yt._=Yt.KeywordCxt=void 0;var gL=v3(),OL=O5(),vL=b5(),w5=_5(),yL=["/properties"],fp="http://json-schema.org/draft-07/schema",dp=class extends gL.default{_addVocabularies(){super._addVocabularies(),OL.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(vL.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(w5,yL):w5;this.addMetaSchema(e,fp,!1),this.refs["http://json-schema.org/schema"]=fp}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(fp)?fp:void 0)}};k5.exports=Yt=dp;Object.defineProperty(Yt,"__esModule",{value:!0});Yt.default=dp;var bL=pu();Object.defineProperty(Yt,"KeywordCxt",{enumerable:!0,get:function(){return bL.KeywordCxt}});var Ol=Je();Object.defineProperty(Yt,"_",{enumerable:!0,get:function(){return Ol._}});Object.defineProperty(Yt,"str",{enumerable:!0,get:function(){return Ol.str}});Object.defineProperty(Yt,"stringify",{enumerable:!0,get:function(){return Ol.stringify}});Object.defineProperty(Yt,"nil",{enumerable:!0,get:function(){return Ol.nil}});Object.defineProperty(Yt,"Name",{enumerable:!0,get:function(){return Ol.Name}});Object.defineProperty(Yt,"CodeGen",{enumerable:!0,get:function(){return Ol.CodeGen}});var _L=Wh();Object.defineProperty(Yt,"ValidationError",{enumerable:!0,get:function(){return _L.default}});var wL=Xh();Object.defineProperty(Yt,"MissingRefError",{enumerable:!0,get:function(){return wL.default}})});var m$={};SC(m$,{default:()=>Op});module.exports=xC(m$);var tn=require("obsidian");var py=require("obsidian");var os=[{name:"Blinded",id:"Blinded",description:`A blinded creature can\u2019t see and automatically fails any ability check that requires sight. Attack rolls against the creature have advantage, and the creature\u2019s Attack rolls have disadvantage.`},{name:"Charmed",id:"Charmed",description:`A charmed creature can\u2019t Attack the charmer or target the charmer with harmful Abilities or magical Effects. The charmer has advantage on any ability check to interact socially with the creature.`},{name:"Concentrating",id:"Concentrating",description:`Some spells require you to maintain concentration in order to keep their magic active. If you lose concentration, such a spell ends. A creature loses concentration when: it casts another spell that requires concentration, is incapacitated, or dies. When a creature takes damage, it must make a constitution saving throw with a DC of 10 or half the damage it took, whichever is higher. On a failure, concentration is lost.`},{name:"Deafened",id:"Deafened",description:"A deafened creature can\u2019t hear and automatically fails any ability check that requires hearing."},{name:"Frightened",id:"Frightened",description:`A frightened creature has disadvantage on Ability Checks and Attack rolls while the source of its fear is within Line of Sight. The creature can\u2019t willingly move closer to the source of its fear.`},{name:"Grappled",id:"Grappled",description:`A grappled creature\u2019s speed becomes 0, and it can\u2019t benefit from any bonus to its speed. The condition ends if the Grappler is incapacitated. The condition also ends if an Effect removes the grappled creature from the reach of the Grappler or Grappling Effect, such as when a creature is hurled away by the Thunderwave spell.`},{name:"Incapacitated",id:"Incapacitated",description:"An incapacitated creature can\u2019t take Actions or Reactions."},{name:"Invisible",id:"Invisible",description:`An invisible creature is impossible to see without the aid of magic or a Special sense. For the Purpose of Hiding, the creature is heavily obscured. The creature\u2019s Location can be detected by any noise it makes or any tracks it leaves. Attack rolls against the creature have disadvantage, and the creature\u2019s Attack rolls have advantage.`},{name:"Paralyzed",id:"Paralyzed",description:`A paralyzed creature is incapacitated and can\u2019t move or speak. The creature automatically fails Strength and Dexterity Saving Throws. Attack rolls against the creature have advantage. Any Attack that hits the creature is a critical hit if the attacker is within 5 feet of the creature.`},{name:"Petrified",id:"Petrified",description:`A petrified creature is transformed, along with any nonmagical object it is wearing or carrying, into a solid inanimate substance (usually stone). Its weight increases by a factor of ten, and it ceases aging. The creature is incapacitated, can\u2019t move or speak, and is unaware of its surroundings. Attack rolls against the creature have advantage. The creature automatically fails Strength and Dexterity Saving Throws. The creature has Resistance to all damage. The creature is immune to poison and disease, although a poison or disease already in its system is suspended, not neutralized.`},{name:"Poisoned",id:"Poisoned",description:"A poisoned creature has disadvantage on Attack rolls and Ability Checks."},{name:"Prone",id:"Prone",description:`A prone creature\u2019s only Movement option is to crawl, unless it stands up and thereby ends the condition. The creature has disadvantage on Attack rolls. An Attack roll against the creature has advantage if the attacker is within 5 feet of the creature. Otherwise, the Attack roll has disadvantage.`},{name:"Reacted",id:"Reacted",description:`A creature, unless otherwise specified, gets one reaction per round of combat. A reaction is an instant response to a trigger of some kind, which can occur on your turn or on someone else\u2019s. A reaction can be spent to make an opportunity attack, do a readied action, or use an ability that requires a reaction. A creature that has already reacted cannot use a reaction until the start of its turn.`},{name:"Restrained",id:"Restrained",description:`A restrained creature\u2019s speed becomes 0, and it can\u2019t benefit from any bonus to its speed. Attack rolls against the creature have advantage, and the creature\u2019s Attack rolls have disadvantage. The creature has disadvantage on Dexterity Saving Throws.`},{name:"Stunned",id:"Stunned",description:`A stunned creature is incapacitated, can\u2019t move, and can speak only falteringly. The creature automatically fails Strength and Dexterity Saving Throws. Attack rolls against the creature have advantage.`},{name:"Unconscious",id:"Unconscious",description:`An unconscious creature is incapacitated, can\u2019t move or speak, and is unaware of its surroundings. The creature drops whatever it\u2019s holding and falls prone. The creature automatically fails Strength and Dexterity Saving Throws. Attack rolls against the creature have advantage. Any Attack that hits the creature is a critical hit if the attacker is within 5 feet of the creature.`}];var bo="initiative-tracker-view",_o="initiative-tracker-player-view",pa="initiative-tracker-creature-view";var We="\u2013",C$=py.Platform.isMacOS?"Meta":"Control";var Mn={ignore:"ignore",current:"current",temp:"temp"},Kn={playerFirst:"playerFirst",npcFirst:"npcFirst",random:"random"},my={players:[],parties:[],defaultParty:null,statuses:[...os],unconsciousId:"Unconscious",version:[],canUseDiceRoll:!1,preferStatblockLink:!1,initiative:"1d20 + %mod%",modifier:null,sync:!1,playerMarker:"default",monsterMarker:"default",state:{creatures:[],state:!1,name:null,round:null,logFile:null},condense:!1,clamp:!0,autoStatus:!0,beginnerTips:!0,displayDifficulty:!0,encounters:{},warnedAboutImports:!1,openState:{battle:!0,party:!0,status:!0,plugin:!0,player:!0,builder:!0},hpOverflow:Mn.ignore,additiveTemp:!1,rpgSystem:"dnd5e",logging:!1,logFolder:"/",resolveTies:Kn.playerFirst,useLegacy:!1,diplayPlayerHPValues:!0,rollHP:!1,descending:!0,builder:{showParty:!0,showXP:!0,sidebarIcon:!0},rollPlayerInitiatives:0},Cp={.125:"\u215B",.25:"\xBC",.375:"\u215C",.5:"\xBD",.625:"\u215D",.75:"\xBE",.875:"\u215E"};var cE=require("obsidian");var vt=require("obsidian"),as="RANDOM_HP";function gy(){(0,vt.addIcon)(as,` `),(0,vt.addIcon)(Qp,CC),(0,vt.addIcon)(Cl,TC),(0,vt.addIcon)(Rp,AC),(0,vt.addIcon)(DC,QC),(0,vt.addIcon)(Mp,RC),(0,vt.addIcon)(Ip,MC),(0,vt.addIcon)(Np,IC),(0,vt.addIcon)(jp,NC),(0,vt.addIcon)(jC,ZC),(0,vt.addIcon)(an,zC),(0,vt.addIcon)(tr,qC),(0,vt.addIcon)(LC,$C),(0,vt.addIcon)(Tl,BC),(0,vt.addIcon)(El,FC),(0,vt.addIcon)(Zp,XC),(0,vt.addIcon)(VC,WC),(0,vt.addIcon)(wo,YC),(0,vt.addIcon)(zp,UC),(0,vt.addIcon)(Lu,HC),(0,vt.addIcon)(Ts,GC),(0,vt.addIcon)(ls,EC),(0,vt.addIcon)(qp,KC),(0,vt.addIcon)(zu,''),(0,vt.addIcon)(Ep,''),(0,vt.addIcon)(PC,''),(0,vt.addIcon)(Tp,''),(0,vt.addIcon)(JC,eE),(0,vt.addIcon)(Er,tE),(0,vt.addIcon)(Dp,''),(0,vt.addIcon)(Ap,'')}var Ep="expand-creatures",zu="group-creatures",PC="initiative-tracker-active",Tp="initiative-tracker-creature-view",Jn="eye-off",er="heart-handshake",Ap="ARROW_DOWN_A-Z",Dp="ARROW_DOWN_0-1",Qp="initiative-tracker",CC='',ls="crossed-swords",EC='',Cl="initiative-tracker-save",TC='',Rp="initiative-tracker-add",AC='',qu="trash";var DC="initiative-tracker-restart",QC='',Mp="initiative-tracker-play",RC='',Ip="initiative-tracker-forward",MC='',Np="initiative-tracker-backward",IC='',jp="initiative-tracker-stop",NC='',jC="initiative-tracker-grip",ZC='',an="initiative-tracker-hp",zC='',tr="initiative-tracker-ac",qC='',LC="initiative-tracker-hamburger",$C='',El="initiative-tracker-disable",FC='',Tl="initiative-tracker-enable",BC='',VC="initiative-tracker-edit",WC='',Zp="initiative-tracker-tags",XC='',wo="initiative-tracker-initiative",YC='',zp="initiative-tracker-redo",UC='',Lu="initiative-tracker-new",HC='',Ts="initiative-tracker-dice",GC='',qp="initiative-tracker-copy",KC='',JC="initiative-tracker-player-view",eE='',Er="intiative-tracker-encounter-builder",tE='';var ln=class{constructor(){te(this,"displayName",We);te(this,"valueUnit","XP")}getCreatureDifficulty(e,t){return 0}getAdditionalCreatureDifficultyStats(e,t){return[]}getEncounterDifficulty(e,t){return{displayName:We,cssClass:"",value:0,title:"Total XP",summary:We,intermediateValues:[]}}getDifficultyThresholds(e){return[]}formatDifficultyValue(e,t){return isNaN(e)?We:t?`${e.toLocaleString()} ${this.valueUnit}`:e.toLocaleString()}getAdditionalDifficultyBudgets(e){return[]}};var Oy={1:{daily:300,easy:25,medium:50,hard:75,deadly:100},2:{daily:600,easy:50,medium:100,hard:150,deadly:200},3:{daily:1200,easy:75,medium:150,hard:225,deadly:400},4:{daily:1700,easy:125,medium:250,hard:375,deadly:500},5:{daily:3500,easy:250,medium:500,hard:750,deadly:1100},6:{daily:4e3,easy:300,medium:600,hard:900,deadly:1400},7:{daily:5e3,easy:350,medium:750,hard:1100,deadly:1700},8:{daily:6e3,easy:450,medium:900,hard:1400,deadly:2100},9:{daily:7500,easy:550,medium:1100,hard:1600,deadly:2400},10:{daily:9e3,easy:600,medium:1200,hard:1900,deadly:2800},11:{daily:10500,easy:800,medium:1600,hard:2400,deadly:3600},12:{daily:11500,easy:1e3,medium:2e3,hard:3e3,deadly:4500},13:{daily:13500,easy:1100,medium:2200,hard:3400,deadly:5100},14:{daily:15e3,easy:1250,medium:2500,hard:3800,deadly:5700},15:{daily:18e3,easy:1400,medium:2800,hard:4300,deadly:6400},16:{daily:2e4,easy:1600,medium:3200,hard:4800,deadly:7200},17:{daily:25e3,easy:2e3,medium:3900,hard:5900,deadly:8800},18:{daily:27e3,easy:2100,medium:4200,hard:6300,deadly:9500},19:{daily:3e4,easy:2400,medium:4900,hard:7300,deadly:10900},20:{daily:4e4,easy:2800,medium:5700,hard:8500,deadly:12700}},iE={0:0,"0.125":25,"1/8":25,"0.25":50,"1/4":50,"0.5":100,"1/2":100,1:200,2:450,3:700,4:1100,5:1800,6:2300,7:2900,8:3900,9:5e3,10:5900,11:7200,12:8400,13:1e4,14:11500,15:13e3,16:15e3,17:18e3,18:2e4,19:22e3,20:25e3,21:33e3,22:41e3,23:5e4,24:62e3,25:75e3,26:9e4,27:105e3,28:12e4,29:135e3,30:155e3},$u,vy,ma=class extends ln{constructor(t){super();Pl(this,$u);te(this,"plugin");te(this,"systemDifficulties",["Easy","Medium","Hard","Deadly"]);this.plugin=t,this.displayName="DnD 5e"}getCreatureDifficulty(t,n){let r=cn(this.plugin,t,o=>o?.xp??0);if(r)return r;let s=cn(this.plugin,t,o=>o?.cr??"0");return iE[s]??0}getAdditionalCreatureDifficultyStats(t,n){let r=cn(this.plugin,t,s=>s?.cr??0);return[`${cs(r)} CR`]}getEncounterDifficulty(t,n){let r=[...t].reduce((d,[h,p])=>d+this.getCreatureDifficulty(h)*p,0),s=[...t.values()].reduce((d,h)=>d+h,0),o=Pp(this,$u,vy).call(this,s,n.length),a=n.length==0||s==0?0:r*o,l=this.getDifficultyThresholds(n),c=l.reverse().find(d=>a>=d.minValue)?.displayName??"Trivial",u=l.map(d=>`${d.displayName}: ${d.minValue}`).join(` `),f=`Encounter is ${c} Total XP: ${r} Adjusted XP: ${a} (x${o}) Threshold ${u}`;return{displayName:c,summary:f,cssClass:c.toLowerCase(),value:a,title:"Adjusted XP",intermediateValues:[{label:"Total XP",value:r}]}}getDifficultyThresholds(t){let n={easy:0,medium:0,hard:0,deadly:0},r=t.filter(s=>s&&s>0).map(s=>Math.max(1,Math.min(s,20)));return Object.keys(n).forEach(s=>{n[s]+=r.reduce((o,a)=>o+(Oy[a]?.[s]??0),0)}),Object.entries(n).map(([s,o])=>({displayName:s.charAt(0).toUpperCase()+s.slice(1),minValue:o})).sort((s,o)=>s.minValue-o.minValue)}getAdditionalDifficultyBudgets(t){return[{displayName:"Daily Budget",minValue:t.filter(n=>n&&n>0).reduce((n,r)=>n+Oy[Math.max(1,Math.min(r,20))].daily,0)}]}};$u=new WeakSet,vy=function(t,n){let r=[.5,1,1.5,2,2.5,3,4,5],s=1;switch(n<3?s++:n>5&&s--,!0){case t>=15:{s+=5;break}case t>=11:{s+=4;break}case t>=7:{s+=3;break}case t>=3:{s+=2;break}case t>=2:{s+=1;break}}return r[Math.min(s,r.length-1)]};var Fu=class extends ln{constructor(t){super();te(this,"plugin");te(this,"dnd5eRpgSystem");te(this,"systemDifficulties",["Not Deadly","Deadly"]);this.plugin=t,this.valueUnit="CR",this.displayName="DnD 5e Lazy GM",this.dnd5eRpgSystem=new ma(t)}getCreatureDifficulty(t,n){return hi(cn(this.plugin,t,r=>r?.cr??0))}getAdditionalCreatureDifficultyStats(t,n){let r=this.dnd5eRpgSystem.getCreatureDifficulty(t);return[this.dnd5eRpgSystem.formatDifficultyValue(r,!0)]}getDifficultyThresholds(t){let n=t.reduce((s,o)=>s+o,0),r=t.length>0?n/t.length:0;return[{displayName:"Deadly",minValue:n/(r>4?2:4)}]}getEncounterDifficulty(t,n){let r=[...t].reduce((c,[u,f])=>c+this.getCreatureDifficulty(u)*f,0),s=this.getDifficultyThresholds(n).first()?.minValue??0,o=r>s?"Deadly":"Not Deadly",a=[...t].reduce((c,[u,f])=>c+this.dnd5eRpgSystem.getCreatureDifficulty(u)*f,0),l=`Encounter is ${o} Total XP: ${a} Total CR: ${r} Total levels: ${n.reduce((c,u)=>c+u,0)} Deadly Threshold: ${s}`;return{displayName:o,summary:l,cssClass:o=="Deadly"?"deadly":"easy",value:r,title:"Total CR",intermediateValues:[{label:"Total XP",value:a}]}}formatDifficultyValue(t,n){return t?cs(t)+(n?" CR":""):We}};var nE={1:11,2:14,3:18,4:23,5:32,6:35,7:41,8:44,9:49,10:53,11:62,12:68,13:71,14:74,15:82,16:84,17:103,18:119,19:131,20:141},rE={0:1,"1/8":5,"0.25":5,"1/4":10,"0.5":10,"1/2":16,1:22,2:28,3:37,4:48,5:60,6:65,7:70,8:85,9:85,10:95,11:106,12:115,13:120,14:125,15:130,16:140,17:150,18:160,19:165,20:180,21:200,22:225,23:250,24:275,25:300,26:325,27:350,28:375,29:400,30:425},sE={Mild:"easy",Bruising:"medium",Bloddy:"medium",Brutal:"hard",Oppressive:"deadly"},Bu=class extends ln{constructor(t){super();te(this,"plugin");te(this,"valueUnit","Power");te(this,"systemDifficulties",["Mild","Bruising","Bloody","Brutal","Oppressive"]);this.plugin=t,this.displayName="DnD 5e CR2.0 Simple"}getCreatureDifficulty(t,n){let r=cn(this.plugin,t,s=>s?.cr??"0");return rE[r]??0}getAdditionalCreatureDifficultyStats(t,n){let r=cn(this.plugin,t,s=>s?.cr??0);return[`${cs(r)} CR`]}getEncounterDifficulty(t,n){let r=[...t].reduce((c,[u,f])=>c+this.getCreatureDifficulty(u)*f,0),s=this.getDifficultyThresholds(n),o=s.reverse().find(c=>r>=c.minValue)?.displayName??"Mild",a=s.map(c=>`${c.displayName}: ${c.minValue}`).join(` `),l=`Encounter is ${o} Total Power: ${r} Threshold ${a}`;return{displayName:o,summary:l,cssClass:sE[o],value:r,title:"Total Creature Power",intermediateValues:[]}}getDifficultyThresholds(t){let n={mild:.4,bruising:.6,bloddy:.75,brutal:.9,Oppressive:1},r=t.map(s=>nE[s]).reduce((s,o)=>s+o);return Object.entries(n).map(([s,o])=>({displayName:s.charAt(0).toUpperCase()+s.slice(1),minValue:Math.round(o*r)})).sort((s,o)=>s.minValue-o.minValue)}};var Vu={1:{easy:.125,standard:.125,hard:.25,cap:1},2:{easy:.125,standard:.25,hard:.5,cap:3},3:{easy:.25,standard:.5,hard:.75,cap:4},4:{easy:.5,standard:.75,hard:1,cap:6},5:{easy:1,standard:1.5,hard:2.5,cap:8},6:{easy:1.5,standard:2,hard:3,cap:9},7:{easy:2,standard:2.5,hard:3.5,cap:10},8:{easy:2.5,standard:3,hard:4,cap:12},9:{easy:3,standard:3.5,hard:4.5,cap:13},10:{easy:3.5,standard:4,hard:5,cap:15},11:{easy:4,standard:4.5,hard:5.5,cap:16},12:{easy:4.5,standard:5,hard:6,cap:17},13:{easy:5,standard:5.5,hard:6.5,cap:19},14:{easy:5.5,standard:6,hard:7,cap:20},15:{easy:6,standard:6.5,hard:7.5,cap:22},16:{easy:6.5,standard:7,hard:8,cap:24},17:{easy:7,standard:7.5,hard:8.5,cap:25},18:{easy:7.5,standard:8,hard:9,cap:26},19:{easy:8,standard:8.5,hard:9.5,cap:28},20:{easy:8.5,standard:9,hard:10,cap:30}},oE={0:{xp:2,minionsPerStandard:5},"1/8":{xp:5,minionsPerStandard:5},"1/4":{xp:10,minionsPerStandard:5},"1/2":{xp:20,minionsPerStandard:5},1:{xp:40,minionsPerStandard:5},2:{xp:90,minionsPerStandard:5},3:{xp:140,minionsPerStandard:5},4:{xp:220,minionsPerStandard:5},5:{xp:225,minionsPerStandard:8},6:{xp:285,minionsPerStandard:8},7:{xp:360,minionsPerStandard:8},8:{xp:485,minionsPerStandard:8},9:{xp:500,minionsPerStandard:10},10:{xp:590,minionsPerStandard:10},11:{xp:720,minionsPerStandard:10},12:{xp:840,minionsPerStandard:10},13:{xp:1e3,minionsPerStandard:10},14:{xp:1150,minionsPerStandard:10},15:{xp:1300,minionsPerStandard:10},16:{xp:1500,minionsPerStandard:10},17:{xp:1800,minionsPerStandard:10},18:{xp:2e3,minionsPerStandard:10},19:{xp:2200,minionsPerStandard:10},20:{xp:2500,minionsPerStandard:10},21:{xp:3300,minionsPerStandard:10},22:{xp:4100,minionsPerStandard:10},23:{xp:5e3,minionsPerStandard:10},24:{xp:6200,minionsPerStandard:10},25:{xp:7500,minionsPerStandard:10},26:{xp:9e3,minionsPerStandard:10},27:{xp:10500,minionsPerStandard:10},28:{xp:12e3,minionsPerStandard:10},29:{xp:13500,minionsPerStandard:10},30:{xp:15500,minionsPerStandard:10}},Wu={Trivial:{encounterPoints:0,cssClass:"trivial"},Easy:{encounterPoints:1,cssClass:"easy"},Standard:{encounterPoints:2,cssClass:"medium"},Hard:{encounterPoints:4,cssClass:"hard"},Extreme:{encounterPoints:8,cssClass:"deadly"}},Xu=class extends ln{constructor(t){super();te(this,"plugin");te(this,"systemDifficulties",["Trivial","Easy","Standard","Hard","Extreme"]);this.plugin=t,this.displayName="DnD 5e Flee, Mortals!",this.valueUnit="CR"}isMinion(t){return"traits"in t&&t.traits?.find(n=>n.name==="Minion")}getAveragePlayerLevel(t){let n=t.filter(r=>r&&r>0).map(r=>Math.max(1,Math.min(r,20))).reduce((r,s)=>r+s,0);return Math.floor(n/t.length)}getCreatureStatistics(t){let n=0,r=0;return t.forEach((s,o)=>{let a=cn(this.plugin,o,c=>c?.cr??0),l=hi(o.cr);if(this.isMinion(o)){let c=oE[a].minionsPerStandard;a=l*Math.floor(s/c)}else a=l*s;rs?.cr??"0");return hi(r)}getEncounterDifficulty(t,n){let r=this.getAveragePlayerLevel(n),s=Vu[r]?.cap,{totalCreatureCr:o,maxCreatureCr:a}=this.getCreatureStatistics(t),l=this.getDifficultyThresholds(n),c=l.reverse().find(p=>o>=p.minValue)?.displayName,u=Wu[c].encounterPoints,f=Wu[c].cssClass;a>s&&(c="Extreme (Exceeds CR cap)",u=Wu.Extreme.encounterPoints,f=Wu.Extreme.cssClass);let d=l.map(p=>`${p.displayName}: ${p.minValue}`).join(` `),h=`Encounter is ${c} Total Creature CR: ${o} Daily Encounter Points: ${u} Party's CR Cap: ${s} Threshold ${d}`;return{displayName:c,summary:h,cssClass:f,value:o,title:"Total Creature CR",intermediateValues:[{label:"Daily Encounter Points",value:u},{label:"Creature CR Cap",value:s}]}}getDifficultyThresholds(t){let n=this.getAveragePlayerLevel(t),r=Vu[n]?.standard*t.length,s=Vu[n]?.hard*t.length,o=s+(s-r);return[{displayName:"Trivial",minValue:0},{displayName:"Easy",minValue:Vu[n]?.easy*t.length},{displayName:"Standard",minValue:r},{displayName:"Hard",minValue:s},{displayName:"Extreme",minValue:o}]}getAdditionalDifficultyBudgets(t){return[{displayName:"Encounter Points per Day",minValue:8}]}formatDifficultyValue(t,n){return isNaN(t)?We:n?`${cs(t)} ${this.valueUnit}`:cs(t)}};var aE={"-4":10,"-3":15,"-2":20,"-1":30,0:40,1:60,2:80,3:120,4:160};var lE={trivial:"trivial",low:"easy",moderate:"medium",severe:"hard",extreme:"deadly"},Yu=class extends ln{constructor(t){super();te(this,"plugin");te(this,"systemDifficulties",["Trivial","Low","Moderate","Severe","Extreme"]);this.plugin=t,this.displayName="Pathfinder 2e"}getCreatureDifficulty(t,n){let r=cn(this.plugin,t,a=>a?.level)?.toString().split(" ").slice(-1);if(r==null||r==null)return 0;let s=Math.round(n?.length??0>0?n.reduce((a,l)=>a+l)/n.length:0),o=String(r-s);return aE[o]??0}getDifficultyThresholds(t){let n=t.length*20,r={trivial:Math.floor(n*.5),low:Math.floor(n*.75),moderate:n,severe:Math.floor(n*1.5),extreme:Math.floor(n*2)};return Object.entries(r).map(([s,o])=>({displayName:s.charAt(0).toUpperCase()+s.slice(1),minValue:o})).sort((s,o)=>s.minValue-o.minValue)}getEncounterDifficulty(t,n){let r=[...t].reduce((c,[u,f])=>c+this.getCreatureDifficulty(u,n)*f,0),s=this.getDifficultyThresholds(n),o=s.findLast(c=>r>=c.minValue)?.displayName??"Trivial",a=s.map(c=>`${c.displayName}: ${c.minValue}`).join(` `),l=`Encounter is ${o} Total XP: ${r} Threshold ${a}`;return{displayName:o,summary:l,cssClass:lE[o.toLowerCase()]??"trivial",value:r,title:"Total XP",intermediateValues:[{label:"Total XP",value:r}]}}};var Al=(s=>(s.Dnd5e="dnd5e",s.Dnd5eLazyGm="dnd5e-lazygm",s.Dnd5eCR2Simple="dnd5e-cr2-simple",s.Dnd5eFleeMortals="dnd5e-flee-mortals",s.Pathfinder2e="pathfinder2e",s))(Al||{}),Lp=class extends ln{constructor(){super(...arguments);te(this,"systemDifficulties",[We,We])}};function Si(i,e){switch(e||i.data.rpgSystem){case"dnd5e":return new ma(i);case"dnd5e-lazygm":return new Fu(i);case"dnd5e-cr2-simple":return new Bu(i);case"dnd5e-flee-mortals":return new Xu(i);case"pathfinder2e":return new Yu(i)}return new Lp}function hi(i){if(typeof i=="number")return i;if(typeof i!="string")return null;if(!i||i=="undefined"||!i.length)return 0;let e=i.split("/");return e.length==1?isNaN(Number(i))?0:Number(i):Number(e[0])/Number(e[1])}function cs(i){if(typeof i=="string"&&(i=hi(i)),i==0)return"0";let e=i%1,t=Math.floor(i);if(e==0)return t.toString();let n=t==0?"":t.toString();return e in Cp?n+=Cp[e]:n+=e.toString().slice(1),n}function cn(i,e,t){let n=t(e);return n||t(i.getCreatureFromBestiary(e.name))}var be=require("obsidian");var Gu=xp(Vp()),Dl=class extends Gu.FuzzyInputSuggest{renderNote(e,t){e.setText([t.item.source].flat().join(", "))}renderTitle(e,t){this.renderMatches(e,t.item.name,t.match.matches)}getItemText(e){return e.name}},Uu=class extends Gu.FuzzyInputSuggest{renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item,t.match.matches)}getItemText(e){return e}},Hu=class extends Gu.FuzzyInputSuggest{renderNote(e,t){}renderTitle(e,t){this.renderMatches(e,t.item.name,t.match.matches)}getItemText(e){return e.name}};var gf=xp(Vp());var Po=require("obsidian");function xt(){return"ID_xyxyxyxyxyxy".replace(/[xy]/g,function(i){var e=Math.random()*16|0,t=i=="x"?e:e&3|8;return t.toString(16)})}var Ne=class i{constructor(e,t=0){this.creature=e;te(this,"active");te(this,"name");te(this,"modifier");te(this,"hp");te(this,"hit_dice");te(this,"rollHP");te(this,"temp");te(this,"ac");te(this,"current_ac");te(this,"dirty_ac");te(this,"note");te(this,"enabled",!0);te(this,"hidden",!1);te(this,"max");te(this,"current_max");te(this,"level");te(this,"player");te(this,"status",new Set);te(this,"marker");te(this,"initiative");te(this,"manualOrder");te(this,"static",!1);te(this,"source");te(this,"id");te(this,"xp");te(this,"viewing",!1);te(this,"number",0);te(this,"display");te(this,"friendly",!1);te(this,"statblock-link");te(this,"cr");te(this,"path");this.name=e.name,this.display=e.display,this.initiative="initiative"in e?e.initiative:Number(t??0),this.static=e.static??!1,this.setModifier(e.modifier),this.current_ac=this.ac=e.ac??void 0,this.dirty_ac=!1,this.max=this.current_max=e.hp?Number(e.hp):0,this.note=e.note,this.level=e.level,this.player=e.player,this.rollHP=e.rollHP,this.marker=e.marker,this.hp=this.max,this.temp=0,this.source=e.source,this.friendly=e.friendly??this.friendly,this.active=e.active,this.hidden=e.hidden??!1,this.note=e.note,this.path=e.path,this.xp=e.xp,this.cr=e.cr,this.id=e.id??xt(),"statblock-link"in e&&(this["statblock-link"]=e["statblock-link"]),"hit_dice"in e&&typeof e.hit_dice=="string"&&(this.hit_dice=e.hit_dice)}setModifier(e){e&&(Array.isArray(e)&&(this.modifier=[...e]),isNaN(Number(e))||(this.modifier=Number(e))),this.modifier=this.modifier??0}addCondition(e){[...this.status].find(t=>t.name===e.name&&t.amount===e.amount)||this.status.add(e)}removeCondition(e){this.status=new Set([...this.status].filter(t=>t.id!=e.id))}get hpDisplay(){return this.current_max?` 0?`aria-label="Temp HP: ${this.temp}" style="font-weight:bold"`:""}>${this.hp+this.temp}/${this.current_max} `:We}getName(){let e=[this.display??this.name];return this.number>0&&e.push(`${this.number}`),e.join(" ")}getStatblockLink(){if("statblock-link"in this){let e=this["statblock-link"];return e.startsWith("#")?`[${this.name}](${this.note}${e})`:e}}*[Symbol.iterator](){yield this.name,yield this.initiative,yield this.static,yield this.modifier,yield this.max,yield this.ac,yield this.note,yield this.path,yield this.id,yield this.marker,yield this.xp,yield this.hidden,yield this.hit_dice,yield this.current_ac,yield this.rollHP}static new(e){return new i({...e,id:xt()},e.initiative)}static from(e){let t="modifier"in e?e.modifier:Math.floor((("stats"in e&&e.stats.length>1?e.stats[1]:10)-10)/2);return new i({...e,modifier:t})}update(e){this.name=e.name,this.setModifier(e.modifier),this.current_max=this.max=e.hp?Number(e.hp):0,this.hp>this.max&&(this.hp=this.max),this.current_ac=this.ac=e.ac??void 0,this.note=e.note,this.level=e.level,this.player=e.player,this["statblock-link"]=e["statblock-link"],this.marker=e.marker,this.source=e.source}toProperties(){return{...this}}toJSON(){return{name:this.name,display:this.display,initiative:this.initiative,static:this.static,modifier:this.modifier,hp:this.max,currentMaxHP:this.current_max,cr:this.cr,ac:this.ac,currentAC:this.current_ac,note:this.note,path:this.path,id:this.id,marker:this.marker,currentHP:this.hp,tempHP:this.temp,status:Array.from(this.status).map(e=>e.name),enabled:this.enabled,level:this.level,player:this.player,xp:this.xp,active:this.active,hidden:this.hidden,friendly:this.friendly,"statblock-link":this["statblock-link"],hit_dice:this.hit_dice,rollHP:this.rollHP}}static fromJSON(e,t){let n;e.player?(n=t.getPlayerByName(e.name)??new i(e,e.initiative),n.initiative=e.initiative):n=new i(e,e.initiative),n.enabled=e.enabled,n.temp=e.tempHP?e.tempHP:0,n.current_max=e.currentMaxHP,n.hp=e.currentHP,n.current_ac=e.currentAC;let r=[];for(let s of e.status){let o=os.find(({name:a})=>s==a);o?r.push(o):r.push({name:s,description:null,id:xt()})}return n.status=new Set(r),n.active=e.active,n}};function X(){}var In=i=>i;function ti(i,e){for(let t in e)i[t]=e[t];return i}function Wp(i){return i()}function Ku(){return Object.create(null)}function de(i){i.forEach(Wp)}function Ge(i){return typeof i=="function"}function ie(i,e){return i!=i?e==e:i!==e||i&&typeof i=="object"||typeof i=="function"}function ky(i){return Object.keys(i).length===0}function Ii(i,...e){if(i==null){for(let n of e)n(void 0);return X}let t=i.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function ct(i){let e;return Ii(i,t=>e=t)(),e}function ke(i,e,t){i.$$.on_destroy.push(Ii(e,t))}function Gt(i,e,t,n){if(i){let r=Sy(i,e,t,n);return i[0](r)}}function Sy(i,e,t,n){return i[1]&&n?ti(t.ctx.slice(),i[1](n(e))):t.ctx}function Kt(i,e,t,n){if(i[2]&&n){let r=i[2](n(t));if(e.dirty===void 0)return r;if(typeof r=="object"){let s=[],o=Math.max(e.dirty.length,r.length);for(let a=0;a32){let e=[],t=i.ctx.length/32;for(let n=0;nwindow.performance.now():()=>Date.now(),Ql=xy?i=>requestAnimationFrame(i):X;var ga=new Set;function Py(i){ga.forEach(e=>{e.c(i)||(ga.delete(e),e.f())}),ga.size!==0&&Ql(Py)}function As(i){let e;return ga.size===0&&Ql(Py),{promise:new Promise(t=>{ga.add(e={c:i,f:t})}),abort(){ga.delete(e)}}}var Rl=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;var Ju=class i{constructor(e){te(this,"_listeners","WeakMap"in Rl?new WeakMap:void 0);te(this,"_observer");te(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)i.entries.set(t.target,t),this._listeners.get(t.target)?.(t)}))}};Ju.entries="WeakMap"in Rl?new WeakMap:void 0;var Cy=!1;function Ey(){Cy=!0}function Ty(){Cy=!1}function y(i,e){i.appendChild(e)}function se(i,e,t){let n=ef(i);if(!n.getElementById(e)){let r=b("style");r.id=e,r.textContent=t,Dy(n,r)}}function ef(i){if(!i)return document;let e=i.getRootNode?i.getRootNode():i.ownerDocument;return e&&e.host?e:i.ownerDocument}function Ay(i){let e=b("style");return e.textContent="/* empty */",Dy(ef(i),e),e.sheet}function Dy(i,e){return y(i.head||i,e),e.sheet}function A(i,e,t){i.insertBefore(e,t||null)}function T(i){i.parentNode&&i.parentNode.removeChild(i)}function Ie(i,e){for(let t=0;ti.removeEventListener(e,t,n)}function Xp(i){return function(e){return e.preventDefault(),i.call(this,e)}}function Vt(i){return function(e){return e.stopPropagation(),i.call(this,e)}}function Qy(i){return function(e){e.target===this&&i.call(this,e)}}function v(i,e,t){t==null?i.removeAttribute(e):i.getAttribute(e)!==t&&i.setAttribute(e,t)}function Tr(i,e){for(let t in e)v(i,t,e[t])}function pi(i){return i===""?null:+i}function Ry(i){return Array.from(i.childNodes)}function me(i,e){e=""+e,i.data!==e&&(i.data=e)}function Xe(i,e){i.value=e??""}function Ce(i,e,t,n){t==null?i.style.removeProperty(e):i.style.setProperty(e,t,n?"important":"")}function ge(i,e,t){i.classList.toggle(e,!!t)}function Il(i,e,{bubbles:t=!1,cancelable:n=!1}={}){return new CustomEvent(i,{detail:e,bubbles:t,cancelable:n})}var Ml=class{constructor(e=!1){te(this,"is_svg",!1);te(this,"e");te(this,"n");te(this,"t");te(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,n=null){this.e||(this.is_svg?this.e=nr(t.nodeName):this.e=b(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(n)}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}var tf=new Map,nf=0;function wE(i){let e=5381,t=i.length;for(;t--;)e=(e<<5)-e^i.charCodeAt(t);return e>>>0}function kE(i,e){let t={stylesheet:Ay(e),rules:{}};return tf.set(i,t),t}function Nl(i,e,t,n,r,s,o,a=0){let l=16.666/n,c=`{ `;for(let g=0;g<=1;g+=l){let O=e+(t-e)*s(g);c+=g*100+`%{${o(O,1-O)}} `}let u=c+`100% {${o(t,1-t)}} }`,f=`__svelte_${wE(u)}_${a}`,d=ef(i),{stylesheet:h,rules:p}=tf.get(d)||kE(d,i);p[f]||(p[f]=!0,h.insertRule(`@keyframes ${f} ${u}`,h.cssRules.length));let m=i.style.animation||"";return i.style.animation=`${m?`${m}, `:""}${f} ${n}ms linear ${r}ms 1 both`,nf+=1,f}function rf(i,e){let t=(i.style.animation||"").split(", "),n=t.filter(e?s=>s.indexOf(e)<0:s=>s.indexOf("__svelte")===-1),r=t.length-n.length;r&&(i.style.animation=n.join(", "),nf-=r,nf||SE())}function SE(){Ql(()=>{nf||(tf.forEach(i=>{let{ownerNode:e}=i.stylesheet;e&&T(e)}),tf.clear())})}function Ar(i,e,t,n){if(!e)return X;let r=i.getBoundingClientRect();if(e.left===r.left&&e.right===r.right&&e.top===r.top&&e.bottom===r.bottom)return X;let{delay:s=0,duration:o=300,easing:a=In,start:l=us()+s,end:c=l+o,tick:u=X,css:f}=t(i,{from:e,to:r},n),d=!0,h=!1,p;function m(){f&&(p=Nl(i,0,1,o,s,a,f)),s||(h=!0)}function g(){f&&rf(i,p),d=!1}return As(O=>{if(!h&&O>=l&&(h=!0),h&&O>=c&&(u(1,0),g()),!d)return!1;if(h){let _=O-l,S=0+1*a(_/o);u(S,1-S)}return!0}),m(),u(0,1),g}function Dr(i){let e=getComputedStyle(i);if(e.position!=="absolute"&&e.position!=="fixed"){let{width:t,height:n}=e,r=i.getBoundingClientRect();i.style.position="absolute",i.style.width=t,i.style.height=n,xE(i,r)}}function xE(i,e){let t=i.getBoundingClientRect();if(e.left!==t.left||e.top!==t.top){let n=getComputedStyle(i),r=n.transform==="none"?"":n.transform;i.style.transform=`${r} translate(${e.left-t.left}px, ${e.top-t.top}px)`}}var Ds;function fs(i){Ds=i}function Oa(){if(!Ds)throw new Error("Function called outside component initialization");return Ds}function sf(i){Oa().$$.on_mount.push(i)}function of(i){Oa().$$.on_destroy.push(i)}function Fe(){let i=Oa();return(e,t,{cancelable:n=!1}={})=>{let r=i.$$.callbacks[e];if(r){let s=Il(e,t,{cancelable:n});return r.slice().forEach(o=>{o.call(i,s)}),!s.defaultPrevented}return!0}}function Vi(i,e){return Oa().$$.context.set(i,e),e}function Ye(i){return Oa().$$.context.get(i)}function ht(i,e){let t=i.$$.callbacks[e.type];t&&t.slice().forEach(n=>n.call(this,e))}var ko=[];var mi=[],ya=[],Up=[],Iy=Promise.resolve(),Hp=!1;function Gp(){Hp||(Hp=!0,Iy.then(lf))}function af(){return Gp(),Iy}function _n(i){ya.push(i)}function Qr(i){Up.push(i)}var Yp=new Set,va=0;function lf(){if(va!==0)return;let i=Ds;do{try{for(;vai.indexOf(n)===-1?e.push(n):t.push(n)),t.forEach(n=>n()),ya=e}var jl;function CE(){return jl||(jl=Promise.resolve(),jl.then(()=>{jl=null})),jl}function Kp(i,e,t){i.dispatchEvent(Il(`${e?"intro":"outro"}${t}`))}var cf=new Set,ds;function Ee(){ds={r:0,c:[],p:ds}}function Te(){ds.r||de(ds.c),ds=ds.p}function $(i,e){i&&i.i&&(cf.delete(i),i.i(e))}function V(i,e,t,n){if(i&&i.o){if(cf.has(i))return;cf.add(i),ds.c.push(()=>{cf.delete(i),n&&(t&&i.d(1),n())}),i.o(e)}else n&&n()}var EE={duration:0};function So(i,e,t,n){let s=e(i,t,{direction:"both"}),o=n?0:1,a=null,l=null,c=null,u;function f(){c&&rf(i,c)}function d(p,m){let g=p.b-o;return m*=Math.abs(g),{a:o,b:p.b,d:g,duration:m,start:p.start,end:p.start+m,group:p.group}}function h(p){let{delay:m=0,duration:g=300,easing:O=In,tick:_=X,css:S}=s||EE,P={start:us()+m,b:p};p||(P.group=ds,ds.r+=1),"inert"in i&&(p?u!==void 0&&(i.inert=u):(u=i.inert,i.inert=!0)),a||l?l=P:(S&&(f(),c=Nl(i,o,p,g,m,O,S)),p&&_(0,1),a=d(P,g),_n(()=>Kp(i,p,"start")),As(k=>{if(l&&k>l.start&&(a=d(l,g),l=null,Kp(i,a.b,"start"),S&&(f(),c=Nl(i,o,a.b,a.duration,0,O,s.css))),a){if(k>=a.end)_(o=a.b,1-o),Kp(i,a.b,"end"),l||(a.b?f():--a.group.r||de(a.group.c)),a=null;else if(k>=a.start){let w=k-a.start;o=a.a+a.d*O(w/a.duration),_(o,1-o)}}return!!(a||l)}))}return{run(p){Ge(s)?CE().then(()=>{s=s({direction:p?"in":"out"}),h(p)}):h(p)},end(){f(),a=l=null}}}function fe(i){return i?.length!==void 0?i:Array.from(i)}function hs(i,e){i.d(1),e.delete(i.key)}function TE(i,e){V(i,1,1,()=>{e.delete(i.key)})}function uf(i,e){i.f(),hs(i,e)}function ba(i,e){i.f(),TE(i,e)}function bi(i,e,t,n,r,s,o,a,l,c,u,f){let d=i.length,h=s.length,p=d,m={};for(;p--;)m[i[p].key]=p;let g=[],O=new Map,_=new Map,S=[];for(p=h;p--;){let x=f(r,s,p),C=t(x),M=o.get(C);M?n&&S.push(()=>M.p(x,e)):(M=c(C,x),M.c()),O.set(C,g[p]=M),C in m&&_.set(C,Math.abs(p-m[C]))}let P=new Set,k=new Set;function w(x){$(x,1),x.m(a,u),o.set(x.key,x),u=x.first,h--}for(;d&&h;){let x=g[h-1],C=i[d-1],M=x.key,Z=C.key;x===C?(u=x.first,d--,h--):O.has(Z)?!o.has(M)||P.has(M)?w(x):k.has(Z)?d--:_.get(M)>_.get(Z)?(k.add(M),w(x)):(P.add(Z),d--):(l(C,o),d--)}for(;d--;){let x=i[d];O.has(x.key)||l(x,o)}for(;h;)w(g[h-1]);return de(S),g}function Rr(i,e){let t={},n={},r={$$scope:1},s=i.length;for(;s--;){let o=i[s],a=e[s];if(a){for(let l in o)l in a||(n[l]=1);for(let l in a)r[l]||(t[l]=a[l],r[l]=1);i[s]=a}else for(let l in o)r[l]=1}for(let o in n)o in t||(t[o]=void 0);return t}function Jp(i){return typeof i=="object"&&i!==null?i:{}}var AE=["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"],DE=new Set([...AE]);function Mr(i,e,t){let n=i.$$.props[e];n!==void 0&&(i.$$.bound[n]=t,t(i.$$.ctx[n]))}function ye(i){i&&i.c()}function Oe(i,e,t){let{fragment:n,after_update:r}=i.$$;n&&n.m(e,t),_n(()=>{let s=i.$$.on_mount.map(Wp).filter(Ge);i.$$.on_destroy?i.$$.on_destroy.push(...s):de(s),i.$$.on_mount=[]}),r.forEach(_n)}function ve(i,e){let t=i.$$;t.fragment!==null&&(Ny(t.after_update),de(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function RE(i,e){i.$$.dirty[0]===-1&&(ko.push(i),Gp(),i.$$.dirty.fill(0)),i.$$.dirty[e/31|0]|=1<{let p=h.length?h[0]:d;return c.ctx&&r(c.ctx[f],c.ctx[f]=p)&&(!c.skip_bound&&c.bound[f]&&c.bound[f](p),u&&RE(i,f)),d}):[],c.update(),u=!0,de(c.before_update),c.fragment=n?n(c.ctx):!1,e.target){if(e.hydrate){Ey();let f=Ry(e.target);c.fragment&&c.fragment.l(f),f.forEach(T)}else c.fragment&&c.fragment.c();e.intro&&$(i.$$.fragment),Oe(i,e.target,e.anchor),Ty(),lf()}fs(l)}var ME;typeof HTMLElement=="function"&&(ME=class extends HTMLElement{constructor(e,t,n){super();te(this,"$$ctor");te(this,"$$s");te(this,"$$c");te(this,"$$cn",!1);te(this,"$$d",{});te(this,"$$r",!1);te(this,"$$p_d",{});te(this,"$$l",{});te(this,"$$l_u",new Map);this.$$ctor=e,this.$$s=t,n&&this.attachShadow({mode:"open"})}addEventListener(e,t,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){let r=this.$$c.$on(e,t);this.$$l_u.set(t,r)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){let r=this.$$l_u.get(t);r&&(r(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(s){return()=>{let o;return{c:function(){o=b("slot"),s!=="default"&&v(o,"name",s)},m:function(c,u){A(c,o,u)},d:function(c){c&&T(o)}}}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;let t={},n=My(this);for(let s of this.$$s)s in n&&(t[s]=[e(s)]);for(let s of this.attributes){let o=this.$$g_p(s.name);o in this.$$d||(this.$$d[o]=em(o,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 r=()=>{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 o=em(s,this.$$d[s],this.$$p_d,"toAttribute");o==null?this.removeAttribute(this.$$p_d[s].attribute||s):this.setAttribute(this.$$p_d[s].attribute||s,o)}this.$$r=!1};this.$$c.$$.after_update.push(r),r();for(let s in this.$$l)for(let o of this.$$l[s]){let a=this.$$c.$on(s,o);this.$$l_u.set(o,a)}this.$$l={}}}attributeChangedCallback(e,t,n){this.$$r||(e=this.$$g_p(e),this.$$d[e]=em(e,n,this.$$p_d,"toProp"),this.$$c?.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{this.$$cn||(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 em(i,e,t,n){let r=t[i]?.type;if(e=r==="Boolean"&&typeof e!="boolean"?e!=null:e,!n||!t[i])return e;if(n==="toAttribute")switch(r){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(r){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}var ne=class{constructor(){te(this,"$$");te(this,"$$set")}$destroy(){ve(this,1),this.$destroy=X}$on(e,t){if(!Ge(t))return X;let n=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return n.push(t),()=>{let r=n.indexOf(t);r!==-1&&n.splice(r,1)}}$set(e){this.$$set&&!ky(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}};var jy="4";var _a=[];function IE(i,e){return{subscribe:$e(i,e).subscribe}}function $e(i,e=X){let t,n=new Set;function r(a){if(ie(i,a)&&(i=a,t)){let l=!_a.length;for(let c of n)c[1](),_a.push(c,i);if(l){for(let c=0;c<_a.length;c+=2)_a[c][0](_a[c+1]);_a.length=0}}}function s(a){r(a(i))}function o(a,l=X){let c=[a,l];return n.add(c),n.size===1&&(t=e(r,s)||X),a(i),()=>{n.delete(c),n.size===0&&t&&(t(),t=null)}}return{set:r,update:s,subscribe:o}}function oi(i,e,t){let n=!Array.isArray(i),r=n?[i]:i;if(!r.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");let s=e.length<2;return IE(t,(o,a)=>{let l=!1,c=[],u=0,f=X,d=()=>{if(u)return;f();let p=e(n?c[0]:c,o,a);s?o(p):f=Ge(p)?p:X},h=r.map((p,m)=>Ii(p,g=>{c[m]=g,u&=~(1<{u|=1<{(0,ff.setIcon)(m,as)},d=m=>{(0,ff.setIcon)(m,er)},h=m=>{(0,ff.setIcon)(m,Jn)},p=()=>s.openCombatant(a);return i.$$set=m=>{"creature"in m&&t(0,a=m.creature),"count"in m&&t(1,l=m.count),"xp"in m&&t(2,c=m.xp),"shouldShowRoll"in m&&t(3,u=m.shouldShowRoll),"$$scope"in m&&t(9,r=m.$$scope)},[a,l,c,u,s,o,f,d,h,r,n,p]}var tm=class extends ne{constructor(e){super(),re(this,e,qE,zE,ie,{creature:0,count:1,xp:2,shouldShowRoll:3},NE)}},df=tm;function LE(i){se(i,"svelte-s37km9",".encounter-name.svelte-s37km9.svelte-s37km9{display:flex;justify-content:flex-start;align-items:center}.encounter-name.svelte-s37km9 .initiative-tracker-name.svelte-s37km9{margin:0}.encounter-instance.svelte-s37km9>.creatures-container>.encounter-creatures:first-of-type h4.svelte-s37km9,.encounter-creatures.svelte-s37km9>ul.svelte-s37km9{margin-top:0}.creature-li.svelte-s37km9.svelte-s37km9{width:fit-content}.xp-parent.svelte-s37km9.svelte-s37km9{display:inline-flex}.difficulty.svelte-s37km9.svelte-s37km9{width:fit-content}.deadly.svelte-s37km9 .difficulty-label.svelte-s37km9{color:red}.hard.svelte-s37km9 .difficulty-label.svelte-s37km9{color:orange}.medium.svelte-s37km9 .difficulty-label.svelte-s37km9{color:yellow}.easy.svelte-s37km9 .difficulty-label.svelte-s37km9{color:green}.trivial.svelte-s37km9 .difficulty-label.svelte-s37km9{color:#aaaaaa}.icons.svelte-s37km9.svelte-s37km9{display:flex}.icons.svelte-s37km9>div.svelte-s37km9:first-child .clickable-icon{margin-right:0}.creature-name.svelte-s37km9.svelte-s37km9{display:inline-flex;align-items:center;gap:0.25rem}.has-icon.svelte-s37km9.svelte-s37km9{display:flex;align-items:center}")}function $y(i,e,t){let n=i.slice();return n[21]=e[t][0],n[22]=e[t][1],n}function Fy(i,e,t){let n=i.slice();return n[25]=e[t],n}function By(i){let e;function t(s,o){if(s[3]instanceof Array&&s[3].length)return FE;if(!s[3])return $E}let n=t(i,-1),r=n&&n(i);return{c(){r&&r.c(),e=tt()},m(s,o){r&&r.m(s,o),A(s,e,o)},p(s,o){n===(n=t(s,o))&&r?r.p(s,o):(r&&r.d(1),r=n&&n(s),r&&(r.c(),r.m(e.parentNode,e)))},d(s){s&&T(e),r&&r.d(s)}}}function $E(i){let e;return{c(){e=b("div"),e.innerHTML='

No Players

',v(e,"class","encounter-creatures encounter-players")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function FE(i){let e,t,n=(i[4]?i[4]:"Players")+"",r,s,o,a=fe(i[3]),l=[];for(let c=0;c{u[p]=null}),Te(),s=u[r],s?s.p(d,h):(s=u[r]=c[r](d),s.c()),$(s,1),s.m(o.parentNode,o))},i(d){a||($(s),a=!0)},o(d){V(s),a=!1},d(d){d&&(T(e),T(n),T(o)),l&&l.d(),u[r].d(d)}}}function Xy(i){let e,t,n,r;return{c(){e=b("span"),v(e,"class","has-icon svelte-s37km9"),v(e,"aria-label","Rolling for HP")},m(s,o){A(s,e,o),n||(r=H(t=i[17].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function BE(i){let e;return{c(){e=b("strong"),e.textContent="No creatures"},m(t,n){A(t,e,n)},p:X,i:X,o:X,d(t){t&&T(e)}}}function VE(i){let e,t,n=fe([...i[2]]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){e=b("ul");for(let o=0;o0&&Gy(i);return{c(){e=b("span"),t=b("strong"),r=ae(n),s=R(),o=b("span"),a=b("span"),a.textContent="(",l=R(),c=b("span"),p&&p.c(),u=R(),f=b("span"),f.textContent=")",v(t,"class","difficulty-label svelte-s37km9"),v(a,"class","paren left"),v(c,"class","xp-container"),v(f,"class","paren right"),v(o,"class","xp-parent difficulty svelte-s37km9"),v(e,"aria-label",d=i[9].summary),v(e,"class",h=un(i[9].cssClass)+" svelte-s37km9")},m(m,g){A(m,e,g),y(e,t),y(t,r),y(e,s),y(e,o),y(o,a),y(o,l),y(o,c),p&&p.m(c,null),y(o,u),y(o,f)},p(m,g){g&512&&n!==(n=m[9].displayName+"")&&me(r,n),m[9].value>0?p?p.p(m,g):(p=Gy(m),p.c(),p.m(c,null)):p&&(p.d(1),p=null),g&512&&d!==(d=m[9].summary)&&v(e,"aria-label",d),g&512&&h!==(h=un(m[9].cssClass)+" svelte-s37km9")&&v(e,"class",h)},d(m){m&&T(e),p&&p.d()}}}function Gy(i){let e,t=i[10].formatDifficultyValue(i[9].value)+"",n,r,s;return{c(){e=b("span"),n=ae(t),r=R(),s=b("span"),s.textContent=`${i[10].valueUnit}`,v(e,"class","xp number"),v(s,"class","xp text")},m(o,a){A(o,e,a),y(e,n),A(o,r,a),A(o,s,a)},p(o,a){a&512&&t!==(t=o[10].formatDifficultyValue(o[9].value)+"")&&me(n,t)},d(o){o&&(T(e),T(r),T(s))}}}function XE(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p=!i[5].includes("players"),m,g,O=!i[5].includes("creatures"),_,S,P,k,w=p&&By(i),x=O&&Wy(i),C=i[0].data.displayDifficulty&&Uy(i);return{c(){e=b("div"),t=b("div"),n=b("h3"),r=ae(i[1]),s=R(),o=b("div"),a=b("div"),c=R(),u=b("div"),d=R(),h=b("div"),w&&w.c(),m=R(),g=b("div"),x&&x.c(),_=R(),C&&C.c(),v(n,"data-heading",i[1]),v(n,"class","initiative-tracker-name svelte-s37km9"),v(a,"aria-label","Start Encounter"),v(a,"class","svelte-s37km9"),v(u,"aria-label","Add to Encounter"),v(u,"class","svelte-s37km9"),v(o,"class","icons svelte-s37km9"),v(t,"class","encounter-name svelte-s37km9"),v(g,"class","encounter-creatures svelte-s37km9"),v(h,"class","creatures-container"),v(e,"class","encounter-instance svelte-s37km9")},m(M,Z){A(M,e,Z),y(e,t),y(t,n),y(n,r),y(t,s),y(t,o),y(o,a),y(o,c),y(o,u),y(e,d),y(e,h),w&&w.m(h,null),y(h,m),y(h,g),x&&x.m(g,null),y(h,_),C&&C.m(h,null),S=!0,P||(k=[H(l=i[11].call(null,a)),Y(a,"click",i[12]),H(f=i[13].call(null,u)),Y(u,"click",i[14])],P=!0)},p(M,[Z]){(!S||Z&2)&&me(r,M[1]),(!S||Z&2)&&v(n,"data-heading",M[1]),Z&32&&(p=!M[5].includes("players")),p?w?w.p(M,Z):(w=By(M),w.c(),w.m(h,m)):w&&(w.d(1),w=null),Z&32&&(O=!M[5].includes("creatures")),O?x?(x.p(M,Z),Z&32&&$(x,1)):(x=Wy(M),x.c(),$(x,1),x.m(g,null)):x&&(Ee(),V(x,1,1,()=>{x=null}),Te()),M[0].data.displayDifficulty?C?C.p(M,Z):(C=Uy(M),C.c(),C.m(h,null)):C&&(C.d(1),C=null)},i(M){S||($(x),S=!0)},o(M){V(x),S=!1},d(M){M&&T(e),w&&w.d(),x&&x.d(),C&&C.d(),P=!1,de(k)}}}function YE(i,e,t){let n,r,s;ke(i,he,C=>t(19,s=C));let{plugin:o}=e;Vi("plugin",o);let{name:a="Encounter"}=e,{creatures:l=new Map}=e,{players:c}=e,{party:u=null}=e,{hide:f=[]}=e,{rollHP:d=o.data.rollHP}=e,{playerLevels:h}=e,p=new Map,m=new Map,g=Si(o);for(let[C,M]of l){let Z=Number(M);if(o.canUseDiceRoller){let Q=o.getRoller(`${M}`);Q?(Q.on("new-result",()=>{p.set(C,Q.result),t(18,p)}),m.set(C,Q),Q.rollSync()):p.set(C,Z)}else p.set(C,Z)}let O=C=>{new Zl.ExtraButtonComponent(C).setIcon(ls)},_=async()=>{o.view||await o.addTrackerView();let C=o.view,M=[...p].map(([E,j])=>isNaN(Number(j))||j<1?[E]:[...Array(j).keys()].map(z=>Ne.new(E))).flat(),Z=[],Q=[...u?o.getPlayerNamesForParty(u):[],...c],D=[];for(let E of new Set(Q))D.push(o.getPlayerByName(E));for(let E of[...D,...M])Z.push(E.toJSON());he.new(o,{creatures:Z,name:a,round:1,state:!1,logFile:null,roll:!0,rollHP:d,newLog:!0}),o.app.workspace.revealLeaf(C.leaf)},S=C=>{new Zl.ExtraButtonComponent(C).setIcon("plus-with-circle")},P=async C=>{o.view||await o.addTrackerView();let M=[...p].map(([Z,Q])=>isNaN(Number(Q))||Q<1?[Z]:[...Array(Q).keys()].map(D=>Ne.new(Z))).flat();for(let Z of c)s.find(Q=>Q.name===Z)||M.push(o.getPlayerByName(Z));he.add(o,d,...M)},k=(C,M)=>{o.canUseDiceRoller&&m.has(M)&&!m.get(M).isStatic?C.appendChild(m.get(M)?.containerEl??createSpan({text:`${p.get(M)}`})):C.setText(`${p.get(M)}`)},w=C=>{if(!C)return;let M=[];return C.hp&&M.push(`HP: ${C.hp}`),C.ac&&M.push(`AC: ${C.ac}`),C.modifier&&M.push(`MOD: ${C.modifier}`),`${M.join(", ")}`},x=C=>{(0,Zl.setIcon)(C,as)};return i.$$set=C=>{"plugin"in C&&t(0,o=C.plugin),"name"in C&&t(1,a=C.name),"creatures"in C&&t(2,l=C.creatures),"players"in C&&t(3,c=C.players),"party"in C&&t(4,u=C.party),"hide"in C&&t(5,f=C.hide),"rollHP"in C&&t(6,d=C.rollHP),"playerLevels"in C&&t(7,h=C.playerLevels)},i.$$.update=()=>{i.$$.dirty&262272&&t(9,n=g.getEncounterDifficulty(p,h)),i.$$.dirty&68&&t(8,r=d&&[...l.keys()].filter(C=>C.hit_dice?.length).length==l.size)},[o,a,l,c,u,f,d,h,r,n,g,O,_,S,P,k,w,x,p]}var im=class extends ne{constructor(e){super(),re(this,e,YE,XE,ie,{plugin:0,name:1,creatures:2,players:3,party:4,hide:5,rollHP:6,playerLevels:7},LE)}},Ky=im;var zl=require("obsidian");function UE(i){se(i,"svelte-1hp1xp6",".deadly.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:red}.hard.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:orange}.medium.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:yellow}.easy.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:green}.trivial.svelte-1hp1xp6 .difficulty-label.svelte-1hp1xp6{color:#aaaaaa}.icons.svelte-1hp1xp6.svelte-1hp1xp6{display:flex}.icons.svelte-1hp1xp6>div.svelte-1hp1xp6:first-child .clickable-icon{margin-right:0}ul.svelte-1hp1xp6.svelte-1hp1xp6{margin:0}")}function Jy(i,e,t){let n=i.slice();return n[19]=e[t],n}function eb(i,e,t){let n=i.slice();return n[22]=e[t][0],n[23]=e[t][1],n}function tb(i){let e,t,n,r,s,o,a=[GE,HE],l=[];function c(u,f){return f&10&&(n=null),n==null&&(n=!!(!u[3].includes("creatures")&&u[1].size)),n?0:1}return r=c(i,-1),s=l[r]=a[r](i),{c(){e=b("td"),t=b("ul"),s.c(),v(t,"class","encounter-creatures encounter-list svelte-1hp1xp6")},m(u,f){A(u,e,f),y(e,t),l[r].m(t,null),o=!0},p(u,f){let d=r;r=c(u,f),r===d?l[r].p(u,f):(Ee(),V(l[d],1,1,()=>{l[d]=null}),Te(),s=l[r],s?s.p(u,f):(s=l[r]=a[r](u),s.c()),$(s,1),s.m(t,null))},i(u){o||($(s),o=!0)},o(u){V(s),o=!1},d(u){u&&T(e),l[r].d()}}}function HE(i){let e;return{c(){e=ae("-")},m(t,n){A(t,e,n)},p:X,i:X,o:X,d(t){t&&T(e)}}}function GE(i){let e,t,n=fe([...i[1]]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o{P=null}),Te()),C&64&&(a=x[6].includes("players")),a?k?k.p(x,C):(k=nb(x),k.c(),k.m(e,l)):k&&(k.d(1),k=null),x[5].data.displayDifficulty?w?w.p(x,C):(w=sb(x),w.c(),w.m(e,c)):w&&(w.d(1),w=null)},i(x){O||($(P),O=!0)},o(x){V(P),O=!1},d(x){x&&T(e),P&&P.d(),k&&k.d(),w&&w.d(),_=!1,de(S)}}}function rT(i,e,t){let n,{name:r="Encounter"}=e,{creatures:s}=e,{players:o}=e,{hide:a=[]}=e,{playerLevels:l}=e,{plugin:c}=e;Vi("plugin",c);let{headers:u}=e,{rollHP:f=c.data.rollHP}=e,d=new Map,h=new Map,p=Si(c);for(let[w,x]of s){let C=Number(x);if(c.canUseDiceRoller){let M=c.getRoller(`${x}`);M?(M.on("new-result",()=>{d.set(w,M.result),t(15,d)}),h.set(w,M),M.rollSync()):d.set(w,C)}else d.set(w,C)}let m=w=>{new zl.ExtraButtonComponent(w).setIcon(ls).setTooltip("Begin Encounter").onClick(async()=>{c.view||await c.addTrackerView();let x=c.view,C=[...d].map(([Z,Q])=>isNaN(Number(Q))||Q<1?[Z.toJSON()]:[...Array(Q).keys()].map(D=>Ne.new(Z).toJSON())).flat(),M=o.map(Z=>c.getPlayerByName(Z).toJSON());he.new(c,{creatures:[...M,...C],name:r,round:1,state:!1,logFile:null,newLog:!0,roll:!0,rollHP:f}),c.app.workspace.revealLeaf(x.leaf)})},g=w=>{new zl.ExtraButtonComponent(w).setIcon("plus-with-circle")},O=async w=>{c.view||await c.addTrackerView();let x=c.view,C=[...d].map(([M,Z])=>isNaN(Number(Z))||Z<1?[M]:[...Array(Z).keys()].map(Q=>Ne.new(M))).flat();he.add(c,f,...C)},_=(w,x)=>{c.canUseDiceRoller&&h.has(x)&&!h.get(x).isStatic?w.appendChild(h.get(x)?.containerEl??createSpan({text:`${d.get(x)}`})):w.setText(`${d.get(x)}`)},S=(w,x)=>{if(x==1||w==0)return"";let C=x>2?",":"";return w==x-1?`${C} and `:`${C} `},P=w=>{if(!w)return;let x=[];return w.hp&&x.push(`HP: ${w.hp}`),w.ac&&x.push(`AC: ${w.ac}`),w.modifier&&x.push(`MOD: ${w.modifier}`),`${x.join(", ")}`},k=w=>{(0,zl.setIcon)(w,as)};return i.$$set=w=>{"name"in w&&t(0,r=w.name),"creatures"in w&&t(1,s=w.creatures),"players"in w&&t(2,o=w.players),"hide"in w&&t(3,a=w.hide),"playerLevels"in w&&t(4,l=w.playerLevels),"plugin"in w&&t(5,c=w.plugin),"headers"in w&&t(6,u=w.headers),"rollHP"in w&&t(7,f=w.rollHP)},i.$$.update=()=>{i.$$.dirty&32784&&t(8,n=p.getEncounterDifficulty(d,l))},[r,s,o,a,l,c,u,f,n,p,m,g,O,_,P,d]}var nm=class extends ne{constructor(e){super(),re(this,e,rT,nT,ie,{name:0,creatures:1,players:2,hide:3,playerLevels:4,plugin:5,headers:6,rollHP:7},UE)}},ob=nm;function ab(i,e,t){let n=i.slice();return n[3]=e[t],n}function sT(i){let e;return{c(){e=b("th"),e.textContent="Creatures"},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function oT(i){let e;return{c(){e=b("th"),e.textContent="Players"},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function lb(i){let e;return{c(){e=b("th"),e.textContent="Difficulty"},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function cb(i){let e,t,n=[i[3],{headers:i[2]},{plugin:i[1]}],r={};for(let s=0;sV(S[k],1,1,()=>{S[k]=null});return{c(){e=b("table"),t=b("thead"),n=b("tr"),r=b("th"),r.textContent="Name",s=R(),m&&m.c(),a=R(),g&&g.c(),c=R(),O&&O.c(),u=R(),f=b("th"),f.textContent="Launch",d=R(),h=b("tbody");for(let k=0;k!o.hide.includes("players")&&(typeof o.players=="boolean"&&o.players||o.players instanceof Array&&o.players.length))&&s.push("players"),n.some(o=>!o.hide.includes("creatures")&&o.creatures.size)&&s.push("creatures"),i.$$set=o=>{"encounters"in o&&t(0,n=o.encounters),"plugin"in o&&t(1,r=o.plugin)},[n,r,s]}var rm=class extends ne{constructor(e){super(),re(this,e,lT,aT,ie,{encounters:0,plugin:1})}},ub=rm;var Rs=(i,e)=>i.name==e.name&&i.display==e.display&&i.ac==e.ac&&cT(i.modifier,e.modifier)&&i.xp==e.xp&&i.hidden==e.hidden&&i.friendly==e.friendly&&i.static==e.static;function cT(i,e){if(typeof i!=typeof e)return!1;if(typeof i=="number")return i==e;if(Array.isArray(i)&&Array.isArray(e)){for(let t=0;tthis.plugin.getPlayerByName(f)).map(f=>f.level).filter(f=>f&&!isNaN(Number(f)));return{name:t,players:n,party:r,hide:s,creatures:l,xp:c,playerLevels:u,rollHP:a}}parseHide(e){return"hide"in(e??{})?typeof e.hide=="string"?["creatures","players"].filter(t=>e.hide==t):Array.isArray(e.hide)?["creatures","players"].filter(t=>e.hide.includes(t)):[]:[]}parsePlayers(e){let t=[],n=e.players;if(e.party&&this.plugin.data.parties.find(r=>r.name.toLowerCase()==e.party.toLowerCase())){let r=this.plugin.data.parties.find(s=>s.name.toLowerCase()==e.party.toLowerCase());t.push(...r.players)}if(n=="none"||n==!1?t.splice(0,t.length):n==!0?t.push(...[...this.plugin.players.values()].map(r=>r.name)):typeof n=="string"?t.push(n):Array.isArray(n)&&t.push(...[...this.plugin.players.values()??[]].map(r=>r.name).filter(r=>n.map(s=>s.toLowerCase()).includes(r.toLowerCase()))),!t.length){let r=this.plugin.defaultParty?.name;if(r&&this.plugin.data.parties.find(s=>s.name.toLowerCase()==r.toLowerCase())){let s=this.plugin.data.parties.find(o=>o.name.toLowerCase()==r.toLowerCase());t.push(...s.players)}}return Array.from(new Set(t))}async parseRawCreatures(e,t){let n=new Map;if(e&&Array.isArray(e))for(let r of e){let{creature:s,number:o=1}=this.parseRawCreature(r,t)??{};if(!s)continue;let a={name:s.name,display:s.display,ac:s.ac,hp:s.hp,modifier:s.modifier,xp:s.xp,hidden:s.hidden,friendly:s.friendly,rollHP:s.rollHP},l=[...n].find(([c])=>Rs(c,a));if(!l)n.set(s,o);else{let c;!isNaN(Number(o))&&!isNaN(Number(l[1]))?c=Number(o)+l[1]:c=`${o} + ${l[1]}`,n.set(l[0],c)}}return n}parseRawCreature(e,t){if(!e)return{};let n,r=1;if(typeof e=="string"){let g=e.match(/(\d+)?:?\s?(.+)/)??[];r=isNaN(Number(g[1]??null))?r:Number(g[1]),n=g[2]}else if(Array.isArray(e))n=e;else if(typeof e=="object"){let g=Object.entries(e).flat();r=g[0],n=g[1]}if(!n)return{};typeof r=="string"&&!this.plugin.canUseDiceRoller&&/\d+d\d+/.test(r)&&(r=1),isNaN(Number(r))||(r=Number(r)),r!=0&&!r&&(r=1),typeof r=="number"&&r<1&&(r=0);let s,o,a,l,c,u,f=!1,d=!1,h=t;if(typeof n=="string"?(n.match(/,\s+hidden/)&&(f=!0,n=n.replace(/,\s*hidden/,"")),(n.match(/,\s+friend(?:ly)?/)||n.match(/,\s+ally/))&&(d=!0,n=n.replace(/,\s*friend(?:ly)?/,"").replace(/,\s*ally/,"")),s=n.split(/,\s?/)[0],[a,l,c,u]=n.split(/,\s?/).slice(1).map(g=>isNaN(Number(g))?null:Number(g))):Array.isArray(n)?(typeof n[0]=="string"?(s=n[0],o=n[1]):Array.isArray(n[0])&&(s=n[0][0],o=n[0][1]),f=n.slice(1).find(g=>g=="hidden")!=null,d=n.slice(1).find(g=>g=="friend"||g=="friendly"||g=="ally")!=null,[a,l,c,u]=n.slice(1).filter(g=>g!="hidden"&&g!="friend"&&g!="friendly"&&g!="ally").map(g=>isNaN(Number(g))?null:Number(g))):typeof n=="object"&&({creature:s,name:o,hp:a,ac:l,mod:c,xp:u}=n,f=n.hidden||!1,d=n.friend||n.ally||!1),a&&(h=!1),!s||typeof s!="string")return{};let p=this.plugin.getCreatureFromBestiary(s),m=p?Ne.from(p):new Ne({name:s});return m.display=o,m.hp=a??m.hp,m.ac=l??m.ac,m.modifier=c??m.modifier,m.xp=u??m.xp,m.hidden=f??m.hidden,m.friendly=d??m.friendly,m.rollHP=h??t??m.rollHP,{creature:m,number:r}}},sm=class{constructor(e,t,n){this.params=e;this.encounterEl=t;this.plugin=n;te(this,"instance");this.display()}async display(){this.instance=new Ky({target:this.encounterEl,props:{plugin:this.plugin,name:this.params.name,party:this.params.party,players:this.params.players,playerLevels:this.params.playerLevels,creatures:this.params.creatures,hide:this.params.hide,rollHP:this.params.rollHP}})}},xo=class extends Qs.MarkdownRenderChild{constructor(t,n,r,s=!1){super(r);this.plugin=t;this.src=n;this.containerEl=r;this.table=s;te(this,"parser");this.parser=new ql(this.plugin),this.init()}init(){this.table?this.postprocessTable():this.postprocess()}async postprocess(){let t=this.src.split("---")??[],n=this.containerEl.createDiv("encounter-container"),r=n.createSpan({text:"No encounters created. Please check your syntax and try again."});for(let s of t)if(s?.trim().length)try{let o=(0,Qs.parseYaml)(s);new sm(await this.parser.parse(o),n.createDiv("encounter-instance"),this.plugin),r.detach()}catch(o){console.error(o),new Qs.Notice(`Initiative Tracker: here was an issue parsing: `+s)}this.plugin.register(()=>{this.containerEl.empty(),this.containerEl.createEl("pre").createEl("code",{text:`\`\`\`encounter ${this.src}\`\`\``})})}async postprocessTable(){let t=this.src.split("---")??[],r=this.containerEl.createDiv("encounter-container").createSpan({text:"No encounters created. Please check your syntax and try again."}),s=[];for(let o of t)if(o?.trim().length)try{let a=(0,Qs.parseYaml)(o);s.push(await this.parser.parse(a))}catch(a){console.error(a),new Qs.Notice(`Initiative Tracker: here was an issue parsing: `+o)}s.length&&(r.detach(),new ub({target:this.containerEl,props:{encounters:s,plugin:this.plugin}})),this.plugin.register(()=>{this.containerEl.empty(),this.containerEl.createEl("pre").createEl("code",{text:`\`\`\`encounter-table ${this.src}\`\`\``})})}};var om=require("obsidian");var fT=om.Platform.isMacOS?"Meta":"Control";function dT(){let i=$e([]),e=$e(new Map),t=$e(),{subscribe:n,set:r,update:s}=i,o=$e(),a,l=$e(1),c=$e(!1),u=Q=>{c.set(Q),Q?a?.logging?a?.log("Combat re-started"):a?.new({name:ct(f),players:O.filter(D=>D.player),creatures:O.filter(D=>!D.player),round:ct(l)}).then(()=>{o.set(a.getFile())}):a?.log("Combat stopped"),C(D=>(D.length&&!D.find(E=>E.active)&&(O[0].active=!0),D))},f=$e(),d=$e(),h=$e(),p=oi(h,Q=>Q.descending),m,g=oi(i,Q=>(m?.condense&&Q.forEach((D,E,j)=>{let z=j.filter(U=>Rs(U,D)),q=z.map(U=>U.initiative),G=q[Math.floor(Math.random()*q.length)];z.forEach(U=>{U.static||(U.initiative=G)})}),Q)),O=[],_=oi([g,h],([Q,D])=>{let E=[...Q];return E.sort((j,z)=>{if(j.initiative!=z.initiative)return D.descending?z.initiative-j.initiative:j.initiative-z.initiative;if(j.manualOrder!==null&&j.manualOrder!==void 0&&z.manualOrder!==null&&z.manualOrder!==void 0&&j.manualOrder!==z.manualOrder){let q=j.manualOrder||0,G=z.manualOrder||0;return q-G}switch(m.resolveTies){case Kn.random:return Math.random()<.5?1:-1;case Kn.playerFirst:case Kn.npcFirst:let q=j.player?1:0,G=z.player?1:0;return m.resolveTies==Kn.playerFirst?G-q:q-G}}),O=E,E}),S=Q=>{a?.log(`${Q.getName()} initiative changed to ${Q.initiative}`)},P=(Q,...D)=>{for(let{creature:E,change:j}of D){if(j.initiative&&(E.initiative=Number(j.initiative),S(E)),j.name&&(E.name=j.name,E.number=0),j.hp){if(j.hp=Number(j.hp),j.hp<0&&E.temp>0){let z=E.temp+j.hp;E.temp=Math.max(0,z),j.hp=Math.min(0,z)}if(m.clamp&&E.hp+j.hp<0&&(j.hp=-E.hp),j.hp>0&&j.hp+E.hp>E.current_max)switch(m.hpOverflow){case Mn.ignore:j.hp=Math.max(E.current_max-E.hp,0);break;case Mn.temp:j.temp=j.hp-Math.min(E.current_max-E.hp,0),j.hp-=j.temp;break;case Mn.current:break}if(E.hp+=j.hp,m.autoStatus&&E.hp<=0){let z=m.statuses.find(q=>q.id==m.unconsciousId);z&&E.addCondition(z)}}if(j.max&&(E.current_max=Math.max(0,E.current_max+j.max),E.hp>=E.current_max&&m.hpOverflow!==Mn.current&&(E.hp=E.current_max)),j.set_hp&&(E.hp=j.set_hp),j.set_max_hp&&(E.current_max=E.max=j.set_max_hp),j.ac&&(E.current_ac=E.ac=j.ac),j.temp){let z=0;m.additiveTemp&&(z=E.temp),j.temp>0?E.temp=Math.max(E.temp,z+j.temp):E.temp=Math.max(0,E.temp+j.temp)}if(j.marker&&(E.marker=j.marker),j.status?.length)for(let z of j.status)E.addCondition(z);if(j.remove_status?.length)for(let z of j.remove_status)E.removeCondition(z);"hidden"in j&&(E.hidden=j.hidden,a.log(`${E.getName()} ${E.hidden?"hidden":"revealed"}`)),"enabled"in j&&(E.enabled=j.enabled,a.log(`${E.getName()} ${E.enabled?"enabled":"disabled"}`)),Q.includes(E)||Q.push(E)}return Q},k=(...Q)=>C(D=>P(D,...Q)),w=()=>({creatures:ct(i).map(Q=>Q.toJSON()),state:ct(c),name:ct(f),round:ct(l),logFile:a?.getLogFile()??null,rollHP:!1}),x=()=>{app.workspace.trigger("initiative-tracker:save-state",w())};function C(Q){s(Q),x()}let M=Q=>{for(let D=0;Dz.name==E.name).length==1||E.number>0)continue;let j=Q.filter(z=>z.display?z.display==E.display:z.name==E.name).map(z=>z.number);E.number=j?.length?Math.max(...j)+1:1}};function Z(Q,D){for(let E of D)E.static&&E.initiative||(E.active=!1,!(E.player&&Q.data.rollPlayerInitiatives==1)&&(E.player&&Q.data.rollPlayerInitiatives==2?E.initiative=0:E.initiative=Q.getInitiativeValue(E.modifier),E.manualOrder=null));return D}return{subscribe:n,set:r,data:h,setData:Q=>{h.set(Q),m=Q},getLogger:()=>a,setLogger:Q=>{a=Q},updating:e,updateTarget:t,updateCreatures:k,updateCreatureByName:(Q,D)=>C(E=>{let j=E.find(z=>z.name==Q);if(j){if(isNaN(Number(D.hp))||(j.hp=D.hp),D.max&&(j.current_max=Math.max(0,j.current_max+D.max),j.hp>=j.current_max&&m.hpOverflow!==Mn.current&&(j.hp=j.current_max)),D.temp){let z=0;m.additiveTemp&&(z=j.temp),D.temp>0?j.temp=Math.max(j.temp,z+D.temp):j.temp=Math.max(0,j.temp+D.temp)}if(D.marker&&(j.marker=D.marker),(typeof D.ac=="string"||!isNaN(Number(D.ac)))&&(j.ac=j.current_ac=D.ac),(typeof D.current_ac=="string"||!isNaN(Number(D.current_ac)))&&(j.current_ac=D.ac),isNaN(Number(D.initiative))||(j.initiative=D.initiative),typeof D.name=="string"&&(j.name=D.name),"hidden"in D&&(j.hidden=D.hidden),"enabled"in D&&(j.enabled=D.enabled),Array.isArray(D.status)&&D.status?.length)for(let z of D.status)if(typeof z=="string"){let q=m.statuses.find(G=>G.name==z)??{name:z,description:"",id:xt()};j.addCondition(q)}else typeof z=="object"&&z.name?.length&&j.addCondition(z)}return E}),players:oi(_,Q=>Q.filter(D=>D.player)),setUpdate:(Q,D)=>e.update(E=>(E.has(Q)?E.delete(Q):E.set(Q,{saved:D.getModifierState("Shift"),resist:D.getModifierState(fT),customMod:D.getModifierState("Alt")?"2":"1"}),E)),doUpdate:(Q,D,E,j=[])=>e.update(z=>{let q=[],G=[];return z.forEach((U,le)=>{let xe=!Q.includes("."),ue={},B=(U.saved?.5:1)*(U.resist?.5:1)*Number(U.customMod),J=[le.name];le.number>0&&J.push(`${le.number}`);let pe={name:J.join(" "),hp:null,temp:!1,max:!1,status:null,remove_status:null,saved:!1,unc:!1,ac:null,ac_add:!1};if(Q.charAt(0)=="t"){let Re=Number(Q.slice(1));pe.hp=Re,pe.temp=!0,ue.temp=Re}else{let Re=Q.charAt(0)==="m",oe=Number(Q.slice(+Re));oe=-1*Math.sign(oe)*Math.max(Math.abs(oe)*B,1),oe=xe?Math.trunc(oe):oe,pe.hp=oe,Re&&(pe.max=!0,ue.max=oe),ue.hp=oe,le.hp<=0&&(pe.unc=!0)}if(D.length&&(pe.status=D.map(Re=>Re.name),U.saved?pe.saved=!0:ue.status=D),j.length&&(ue.remove_status=j),E){if(E.charAt(0)=="+"||E.charAt(0)=="-"){let Re=parseInt(String(le.current_ac));isNaN(Re)?le.current_ac=le.current_ac+E:le.current_ac=Re+parseInt(E),pe.ac_add=!0}else le.current_ac=E.slice(+(E.charAt(0)=="\\"));pe.ac=E.slice(+(E.charAt(0)=="\\"))}q.push(pe),G.push({creature:le,change:ue})}),a?.logUpdate(q),k(...G),z.clear(),z}),clearUpdate:()=>e.update(Q=>(Q.clear(),Q)),round:l,name:f,sort:p,party:d,setParty:(Q,D)=>C(E=>{let j=D.getPlayersForParty(Q);return d.set(Q),E=[...E.filter(z=>!z.player),...j],E}),state:c,getState:()=>ct(c),toggleState:()=>{u(!ct(c))},setState:u,goToNext:()=>C(Q=>{let D=O.findIndex(E=>E.active);if(D==-1)O[0].active=!0;else{let E,j=D;do if(j=((j+1)%O.length+O.length)%O.length,E=O[j],j==D)break;while(!E.enabled);if(E){if(O[D].active=!1,j!G.resetOnRound));a?.log("###",`Round ${z}`)}a?.log("#####",`${E.getName()}'s turn`),E.active=!0}}return Q}),goToPrevious:()=>C(Q=>{let D=O.findIndex(E=>E.active);if(D==0&&ct(l)==1)return Q;if(D==-1)O[0].active=!0;else{let E,j=D;do if(j=((j-1)%O.length+O.length)%O.length,E=O[j],j==D)break;while(!E.enabled);if(E){if(O[D].active=!1,j>D){let z=ct(l)-1;l.set(z);for(let q of Q)q.status=new Set([...q.status].filter(G=>!G.resetOnRound));a?.log("###",`Round ${z}`)}a?.log("#####",`${E.getName()}'s turn`),E.active=!0}}return Q}),ordered:_,add:async(Q,D=Q.data.rollHP,...E)=>C(j=>{Q.canUseDiceRoller&&D&&fb(E,Q,D),j.push(...E);let z=[];if(!m.condense)z.push(...E);else for(let q of E){let G=O.find(U=>Rs(U,q));G?q.initiative=G.initiative:z.push(q)}return Z(Q,z),a?.log(a?.join(E.map(q=>q.name)),"added to the combat."),M(j),j}),remove:(...Q)=>C(D=>(D=D.filter(E=>!Q.includes(E)),a?.log(a?.join(Q.map(E=>E.name)),"removed from the combat."),D)),replace:(Q,D)=>{C(E=>(E.splice(E.indexOf(Q),1,D),M(E),E))},update:()=>s(Q=>Q),updateAndSave:()=>C(Q=>Q),roll:Q=>C(D=>(Z(Q,D),D)),new:(Q,D)=>C(E=>{if(l.set(D?.round??1),c.set(D?.state??!1),f.set(D?.name??null),!D?.creatures)E=E.filter(j=>j.player);else{let j=[],z=ct(d),q=new Map([...z?Q.getPlayersForParty(z):[],...E.filter(G=>G.player)].map(G=>[G.id,G])).values();for(let G of D.creatures){let U=null;G.player&&(U=E.find(le=>le.player&&le.id===G.id))&&U!=null?j.push(U):j.push(Ne.fromJSON(G,Q))}for(let G of q)j.find(U=>U.player&&U.id==G.id)||j.push(G);E=j}return(!D||D?.roll)&&Z(Q,E),M(E),Q.canUseDiceRoller&&(D?.rollHP??Q.data.rollHP)&&fb(E,Q),D?.logFile&&a?.new(D.logFile).then(()=>{o.set(a.getFile())}),(!D&&a||D?.newLog)&&(a.logging=!1,o.set(null)),E}),reset:()=>C(Q=>{for(let D of Q)D.current_ac=D.ac,D.hp=D.current_max=D.max,D.enabled=!0,D.status.clear();return a?.log("Encounter HP & Statuses reset"),Q}),getOrderedCreatures:()=>ct(_),logUpdate:Q=>{let D=[];for(let E of Q){let j=[];E.hp&&(E.temp?j.push(`${E.name} gained ${E.hp.toString()} temporary HP`):E.max?E.hp<0?j.push(`${E.name} took ${(-1*E.hp).toString()} max HP damage${E.unc?" and died":""}`):j.push(`${E.name} gained ${(-1*E.hp).toString()} max HP`):E.hp<0?j.push(`${E.name} took ${(-1*E.hp).toString()} damage${E.unc?" and was knocked unconscious":""}`):E.hp>0&&j.push(`${E.name} was healed for ${E.hp.toString()} HP`)),E.status&&(j.length?j.push("and"):j.push(E.name),E.saved?j.push(`saved against ${E.status}`):j.push(`took ${E.status} status`)),D.push(j.join(" "))}a?.log(`${D.join(". ")}.`)},logNewInitiative:S,logFile:o,getEncounterState:w,updateState:()=>s(Q=>Q),difficulty:Q=>oi([i,h],([D])=>{let E=[],j=new Map,z=Si(Q);for(let q of D){if(!q.enabled||q.friendly)continue;if(q.player&&q.level){E.push(q.level);continue}let G={name:q.name,display:q.display,ac:q.ac,hp:q.hp,modifier:q.modifier,xp:q.xp,hidden:q.hidden},U=[...j].find(([le])=>Rs(le,G));if(!U){j.set(q,1);continue}j.set(U[0],U[1]+1)}return{difficulty:z.getEncounterDifficulty(j,E),thresholds:z.getDifficultyThresholds(E),labels:z.systemDifficulties}})}}var he=dT();function fb(i,e,t=!1){for(let n of i){if(!n.rollHP&&!t||!n.hit_dice?.length)continue;let r=e.getRoller(n.hit_dice);r&&(n.hp=n.max=n.current_max=r.rollSync())}}var Ll=class extends be.PluginSettingTab{constructor(t){super(t.app,t);this.plugin=t}async display(){try{let{containerEl:t}=this;t.empty(),t.addClass("initiative-tracker-settings"),t.createEl("h2",{text:"Initiative Tracker Settings"}),this._displayBase(t.createDiv()),this.plugin.data.openState||(this.plugin.data.openState={battle:!0,player:!0,party:!0,plugin:!0,status:!0,builder:!0}),this._displayBattle(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.player?{open:!0}:{}}})),this._displayPlayers(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.player?{open:!0}:{}}})),this._displayParties(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.party?{open:!0}:{}}})),this._displayBuilder(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.builder?{open:!0}:{}}})),this._displayStatuses(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.status?{open:!0}:{}}})),this._displayIntegrations(t.createEl("details",{cls:"initiative-tracker-additional-container",attr:{...this.plugin.data.openState.plugin?{open:!0}:{}}})),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 be.Notice("There was an error displaying the settings tab for Obsidian Initiative Tracker.")}}_displayBase(t){t.empty(),new be.Setting(t).setHeading().setName("Basic Settings"),new be.Setting(t).setName("Display Beginner Tips").setDesc("Display instructions in the initiative tracker, helping you get used to the workflow.").addToggle(n=>{n.setValue(this.plugin.data.beginnerTips).onChange(async r=>{this.plugin.data.beginnerTips=r,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Display Encounter Difficulty").setDesc("Display encounter difficulty based on creature CR and player level. Creatures without CR or level will not be considered in the calculation.").addToggle(n=>{n.setValue(this.plugin.data.displayDifficulty).onChange(async r=>{this.plugin.data.displayDifficulty=r,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Roll Equivalent Creatures Together").setDesc("Equivalent creatures (same Name and AC) will roll the same initiative by default.").addToggle(n=>{n.setValue(this.plugin.data.condense).onChange(async r=>{this.plugin.data.condense=r,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Embed statblock-link content in the Creature View").setDesc("Prefer embedded content from a statblock-link attribute when present. Fall back to the TTRPG plugin if the link is missing and the plugin is enabled.").addToggle(n=>{n.setValue(this.plugin.data.preferStatblockLink).onChange(async r=>{this.plugin.data.preferStatblockLink=r,await this.plugin.saveSettings()})})}async _displayBattle(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.battle=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Battle"),n.createDiv("collapser").createDiv("handle"),new be.Setting(t).setName("Clamp Minimum HP").setDesc("When a creature takes damage that would reduce its HP below 0, its HP is set to 0 instead.").addToggle(s=>{s.setValue(this.plugin.data.clamp).onChange(async o=>{this.plugin.data.clamp=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Overflow Healing").setDesc("Set what happens to healing which goes above creatures' max HP threshold.").addDropdown(s=>{s.addOption(Mn.ignore,"Ignore"),s.addOption(Mn.temp,"Add to temp HP"),s.addOption(Mn.current,"Add to current HP"),s.setValue(this.plugin.data.hpOverflow??Mn.ignore),s.onChange(async o=>{this.plugin.data.hpOverflow=o,this.plugin.saveSettings()})}),new be.Setting(t).setName("Automatic Unconscious Status Application").setDesc('When a creature takes damage that would reduce its HP below 0, it gains the "Unconscious" status effect.').addToggle(s=>{s.setValue(this.plugin.data.autoStatus).onChange(async o=>{this.plugin.data.autoStatus=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Additive Temporary HP").setDesc("Any temporary HP added to a creature will be added on top of existing temporary HP.").addToggle(s=>{s.setValue(this.plugin.data.additiveTemp).onChange(async o=>{this.plugin.data.additiveTemp=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Display Player HP in Player View").setDesc("If turned off, player health will display as 'Healthy', 'Hurt', etc.").addToggle(s=>{s.setValue(this.plugin.data.diplayPlayerHPValues).onChange(async o=>{this.plugin.data.diplayPlayerHPValues=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Roll HP for Creatures").setDesc(createFragment(s=>{s.createSpan({text:"Creatures added to encounters will automatically roll for HP if the "}),s.createEl("code",{text:"hit_dice"}),s.createSpan({text:" property is set for the creature."})})).addToggle(s=>{s.setValue(this.plugin.data.rollHP).onChange(async o=>{this.plugin.data.rollHP=o,await this.plugin.saveSettings()})}),new be.Setting(t).setName("Log Battles").setDesc("Actions taken during battle will be logged to the specified log folder.").addToggle(s=>s.setValue(this.plugin.data.logging).onChange(async o=>{this.plugin.data.logging=o,await this.plugin.saveSettings()}));let r=await this.plugin.app.vault.adapter.exists(this.plugin.data.logFolder);new be.Setting(t).setName("Log Folder").setDesc(createFragment(async s=>{if(s.createSpan({text:"A new note will be created in this folder for each battle."}),s.createEl("br"),s.createSpan({text:"Current: "}),s.createEl("code",{text:this.plugin.data.logFolder}),!r){s.createEl("br");let o=s.createDiv("initiative-tracker-warning");(0,be.setIcon)(o,"initiative-tracker-warning"),o.createSpan({text:"This folder does not exist and will be created when a log file is written for the first time."})}})).addText(s=>{s.setValue(this.plugin.data.logFolder);let o=this.app.vault.getAllLoadedFiles().filter(l=>l instanceof be.TFolder);new gf.FolderInputSuggest(this.app,s,o).onSelect(async({item:l})=>{this.plugin.data.logFolder=(0,be.normalizePath)(l.path),await this.plugin.saveSettings(),this.display()})}),new be.Setting(t).setName("Resolve Initiative Ties").setDesc("Define what happens if two creatures have the same initiative.").addDropdown(s=>{s.addOption(Kn.playerFirst,"Player first"),s.addOption(Kn.npcFirst,"NPC first"),s.addOption(Kn.random,"Random"),s.setValue(this.plugin.data.resolveTies??Kn.playerFirst),s.onChange(async o=>{this.plugin.data.resolveTies=o,this.plugin.saveSettings()})})}_displayPlayers(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.player=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Players"),n.createDiv("collapser").createDiv("handle"),new be.Setting(t).setName("Add New Player").setDesc("Players added here will be available to add to a party. If you do not have a party created, all players will be added to a new encounter.").addButton(o=>o.setTooltip("Add Player").setButtonText("+").onClick(async()=>{let l=new hf(this.plugin);l.open(),l.onClose=async()=>{l.saved&&(await this.plugin.savePlayer({...l.player,player:!0}),this._displayPlayers(t))}}));let r=t.createDiv("additional"),s=r.createDiv("initiative-tracker-players");if(!this.plugin.players.size)r.createDiv({attr:{style:"display: flex; justify-content: center; padding-bottom: 18px;"}}).createSpan({text:"No saved players! Create one to see it here."});else{let o=s.createDiv("initiative-tracker-player headers");o.createDiv({text:"Name"}),(0,be.setIcon)(o.createDiv({attr:{"aria-label":"Level"}}),"swords"),(0,be.setIcon)(o.createDiv({attr:{"aria-label":"Max HP"}}),an),(0,be.setIcon)(o.createDiv({attr:{"aria-label":"Armor Class"}}),tr),(0,be.setIcon)(o.createDiv({attr:{"aria-label":"Initiative Modifier"}}),wo),o.createDiv();for(let a of this.plugin.data.players){let l=s.createDiv("initiative-tracker-player");l.createDiv({text:a.name}),l.createDiv({text:`${a.level??We}`}),l.createDiv({text:`${a.hp??We}`}),l.createDiv({text:`${a.ac??We}`}),l.createDiv({text:`${a.modifier??We}`});let c=l.createDiv("initiative-tracker-player-icon");new be.ExtraButtonComponent(c.createDiv()).setIcon("pencil").setTooltip("Edit").onClick(()=>{let u=new hf(this.plugin,a);u.open(),u.onClose=async()=>{u.saved&&(await this.plugin.updatePlayer(a,u.player),this._displayPlayers(t))}}),new be.ExtraButtonComponent(c.createDiv()).setIcon("trash").setTooltip("Delete").onClick(async()=>{this.plugin.deletePlayer(a),await this.plugin.saveSettings(),this._displayPlayers(t)})}for(let[a,l]of this.plugin.statblock_players){let c=s.createDiv("initiative-tracker-player");c.createDiv({text:a}),c.createDiv({text:`${l.level??We}`}),c.createDiv({text:`${l.hp??We}`}),c.createDiv({text:`${l.ac??We}`}),c.createDiv({text:`${l.modifier??We}`});let u=c.createDiv({cls:"initiative-tracker-player-icon imported",attr:{"aria-label":"Imported from Fantasy Statblocks"}});(0,be.setIcon)(u,"heart-handshake")}}}_displayBuilder(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.player=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Encounters"),n.createDiv("collapser").createDiv("handle");let r=t.createDiv("initiative-tracker-explanation");r.createEl("span",{text:"The encounter builder allows you to quickly create encounters that can be saved for later use or immediately launched into a battle."}),r.createEl("br"),r.createEl("br"),r.createEl("span",{text:"It can be opened using the sidebar shortcut (if enabled) or by using the Open Encounter Builder command."}),new be.Setting(t).setName("Add Sidebar Shortcut").setDesc("A sidebar shortcut will be added to open the Encounter Builder.").addToggle(o=>{o.setValue(this.plugin.data.builder.sidebarIcon).onChange(a=>{this.plugin.data.builder.sidebarIcon=a,this.plugin.setBuilderIcon()})}),new be.Setting(t).setName("XP System").setDesc("XP system to use for encounters").addDropdown(o=>{Object.values(Al).forEach(a=>o.addOption(a,Si(this.plugin,a).displayName)),o.setValue(this.plugin.data.rpgSystem??"dnd5e"),o.onChange(async a=>{this.plugin.data.rpgSystem=a,this.plugin.saveSettings()})});let s=t.createDiv("additional");if(new be.Setting(s).setHeading().setName("Saved Encounters"),!Object.keys(this.plugin.data.encounters).length)s.createDiv({attr:{style:"display: flex; justify-content: center; padding-bottom: 18px;"}}).createSpan({text:"No saved encounters! Create one to see it here."});else for(let[o,a]of Object.entries(this.plugin.data.encounters))new be.Setting(s).setName(o).setDesc(createFragment(l=>{let c=[],u=[];for(let f of a.creatures)f.player?c.push(f.name):u.push(f.name);c.length&&(l.createSpan({text:`Players: ${c.join(", ")}`}),l.createEl("br")),u.length&&(l.createSpan({text:`Creatures: ${u.join(", ")}`}),l.createEl("br")),a.timestamp&&l.createSpan({text:`${new Date(a.timestamp).toLocaleString()}`})})).addExtraButton(l=>{l.setIcon("trash").onClick(async()=>{this.plugin.removeEncounter(o),await this.plugin.saveSettings(),this._displayBuilder(t)})})}_displayParties(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.party=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Parties"),n.createDiv("collapser").createDiv("handle");let r=t.createDiv("initiative-tracker-explanation");r.createEl("span",{text:"Parties allow you to create different groups of your players. Each player can be a member of multiple parties."}),r.createEl("br"),r.createEl("br"),r.createEl("span",{text:"You can set a default party for encounters to use, or specify the party for the encounter in the encounter block. While running an encounter in the tracker, you can change the active party, allowing you to quickly switch which players are in combat."}),new be.Setting(t).setName("Default Party").setDesc("The tracker will load this party to encounters by default.").addDropdown(o=>{o.addOption("none","None");for(let a of this.plugin.data.parties)o.addOption(a.name,a.name);o.setValue(this.plugin.data.defaultParty??"none"),o.onChange(async a=>{this.plugin.data.defaultParty=a=="none"?null:a,this.plugin.saveSettings()})}),new be.Setting(t).setName("Add New Party").addButton(o=>o.setTooltip("Add Party").setButtonText("+").onClick(async()=>{let l=new mf(this.plugin);l.open(),l.onClose=async()=>{if(!l.canceled&&!(!l.party.name||!l.party.name.length)){if(this.plugin.data.parties.filter(c=>c.name==l.party.name)){let c=new Map([...this.plugin.data.parties].map(u=>[u.name,u]));c.set(l.party.name,l.party),this.plugin.data.parties=Array.from(c.values())}else this.plugin.data.parties.push(l.party);await this.plugin.saveSettings(),this._displayParties(t)}}}));let s=t.createDiv("additional");if(!this.plugin.data.parties.length)s.createDiv({attr:{style:"display: flex; justify-content: center; padding-bottom: 18px;"}}).createSpan({text:"No saved parties! Create one to see it here."});else for(let o of this.plugin.data.parties)new be.Setting(s).setName(o.name).setDesc(o.players.join(", ")).addExtraButton(a=>{a.setIcon("pencil").onClick(()=>{let l=new mf(this.plugin,o);l.open(),l.onClose=async()=>{if(!l.canceled&&!(!l.party.name||!l.party.name.length)){if(this.plugin.data.parties.splice(this.plugin.data.parties.indexOf(o),1,l.party),this.plugin.data.parties.filter(c=>c.name==l.party.name).length>1&&this.plugin.data.parties.filter(c=>c.name==l.party.name)){let c=new Map(this.plugin.data.parties.map(u=>[u.name,u]));c.set(l.party.name,l.party),this.plugin.data.parties=Array.from(c.values())}await this.plugin.saveSettings(),this._displayParties(t)}}})}).addExtraButton(a=>{a.setIcon("trash").onClick(async()=>{this.plugin.data.parties=this.plugin.data.parties.filter(l=>l.name!=o.name),this.plugin.data.defaultParty==o.name&&(this.plugin.data.defaultParty=this.plugin.data.parties[0]?.name??null),await this.plugin.saveSettings(),this._displayParties(t)})})}_displayStatuses(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.status=t.open};let n=t.createEl("summary");new be.Setting(n).setHeading().setName("Statuses"),new be.Setting(t).setName("Unconscious Status").setDesc("Choose a different status to be used as the default Unconscious status.").addDropdown(o=>{for(let a of this.plugin.data.statuses)o.addOption(a.id,a.name);o.setValue(this.plugin.data.unconsciousId),o.onChange(a=>this.plugin.data.unconsciousId=a)}),n.createDiv("collapser").createDiv("handle");let r=new be.Setting(t).setName("Add New Status").setDesc("These statuses will be available to apply to creatures.").addButton(o=>o.setTooltip("Add Status").setButtonText("+").onClick(async()=>{let l=new pf(this.plugin);l.onClose=async()=>{if(!l.canceled&&l.status.name){if(this.plugin.data.statuses.filter(c=>c.name==l.status.name)){let c=new Map([...this.plugin.data.statuses].map(u=>[u.name,u]));c.set(l.status.name,l.status),this.plugin.data.statuses=Array.from(c.values())}else this.plugin.data.statuses.push(l.status);await this.plugin.saveSettings(),this._displayStatuses(t)}},l.open()}));os.every(o=>this.plugin.data.statuses.includes(o))||r.addExtraButton(o=>o.setIcon("reset").setTooltip("Re-add Default Statuses").onClick(async()=>{this.plugin.data.statuses=Array.from(new Map([...this.plugin.data.statuses,...os].map(a=>[a.name,a])).values()),await this.plugin.saveSettings(),this._displayStatuses(t)}));let s=t.createDiv("additional");for(let o of this.plugin.data.statuses)new be.Setting(s).setName(createFragment(a=>{let l=a.createDiv("status-name-container");l.createSpan({text:o.name}),l.createDiv("status-metadata-container"),o.resetOnRound&&(0,be.setIcon)(l.createDiv({attr:{"aria-label":"Reset Each Round"}}),"timer-reset"),o.hasAmount&&(0,be.setIcon)(l.createDiv({attr:{"aria-label":"Has Amount"}}),"hash")})).setDesc(o.description??"").addExtraButton(a=>a.setIcon("pencil").onClick(()=>{let l=new pf(this.plugin,o);l.onClose=async()=>{if(!l.canceled&&l.status.name){if(this.plugin.data.statuses.splice(this.plugin.data.statuses.indexOf(o),1,l.status),this.plugin.data.statuses.filter(c=>c.name==l.status.name).length>1&&this.plugin.data.statuses.filter(c=>c.name==l.status.name)){let c=new Map(this.plugin.data.statuses.map(u=>[u.name,u]));c.set(l.status.name,l.status),this.plugin.data.statuses=Array.from(c.values())}await this.plugin.saveSettings(),this._displayStatuses(t)}},l.open()})).addExtraButton(a=>a.setIcon("trash").onClick(async()=>{this.plugin.data.statuses=this.plugin.data.statuses.filter(l=>l.name!=o.name),this.plugin.data.unconsciousId==o.id&&(this.plugin.data.unconsciousId="Unconscious"),await this.plugin.saveSettings(),this._displayStatuses(t)})).setClass("initiative-status-item")}async _displayIntegrations(t){t.empty(),t.ontoggle=()=>{this.plugin.data.openState.plugin=t.open};let n=t.createEl("summary");if(new be.Setting(n).setHeading().setName("Plugin Integrations"),n.createDiv("collapser").createDiv("handle"),this.plugin.canUseStatBlocks||(this.plugin.data.sync=!1,await this.plugin.saveSettings()),new be.Setting(t).setName("Sync Monsters from TTRPG Statblocks").setDesc(createFragment(r=>{r.createSpan({text:"Homebrew creatures saved to the TTRPG Statblocks plugin will be available to use."}),this.plugin.canUseStatBlocks||(r.createEl("br"),r.createEl("br"),r.createSpan({text:"Install and enable the "}),r.createEl("a",{text:"TTRPG Statblocks",href:"obsidian://show-plugin?id=obsidian-5e-statblocks"}),r.createSpan({text:" plugin to use homebrew creatures."}))})).addToggle(r=>{r.setDisabled(!this.plugin.canUseStatBlocks).setValue(this.plugin.data.sync),r.onChange(async s=>{this.plugin.data.sync=s,await this.plugin.saveSettings(),this._displayIntegrations(t)})}),this.plugin.data.sync){let r=new be.Setting(t).setDesc(`${this.plugin.bestiary.length} creatures synced.`);r.settingEl.addClass("initiative-synced"),(0,be.setIcon)(r.nameEl,"check-in-circle"),r.nameEl.appendChild(createSpan({text:"Synced"}))}new be.Setting(t).setName("Initiative Formula").setDesc(createFragment(r=>{r.createSpan({text:"Initiative formula to use when calculating initiative. Use "}),r.createEl("code",{text:"%mod%"}),r.createSpan({text:" for the modifier placeholder."}),this.plugin.canUseDiceRoller||(r.createEl("br"),r.createEl("br"),r.createSpan({attr:{style:"color: var(--text-error);"},text:"Requires the "}),r.createEl("a",{text:"Dice Roller",href:"https://github.com/valentine195/obsidian-dice-roller",cls:"external-link"}),r.createSpan({attr:{style:"color: var(--text-error);"},text:" plugin to modify."}))})).addText(r=>{this.plugin.canUseDiceRoller||(r.setDisabled(!0),this.plugin.data.initiative="1d20 + %mod%"),r.setValue(this.plugin.data.initiative),r.onChange(s=>{this.plugin.data.initiative=s}),r.inputEl.onblur=async()=>{he.roll(this.plugin),await this.plugin.saveSettings()}})}},hf=class extends Po.Modal{constructor(t,n={}){super(t.app);this.plugin=t;this.original=n;te(this,"player");te(this,"saved");this.player={...n??{}}}async display(t){let{contentEl:n}=this;n.addClass("initiative-tracker-add-player-modal"),n.empty();let r=!1;n.createEl("h2",{text:this.original?"Edit Player":"New Player"}),new be.Setting(n).setName("Link to Note").setDesc("Link player to a note in your vault.").addText(f=>{f.setValue(this.player.note??"");let d=this.app.vault.getFiles();new gf.FileInputSuggest(this.app,f,d).onSelect(async({item:p})=>{if(!p)return;let m=this.app.metadataCache.getFileCache(p);if(this.player.note=p.basename,this.player.path=p.path,this.player.name=p.basename,!m||!m.frontmatter)return;let{ac:g,hp:O,modifier:_,level:S,name:P}=m.frontmatter;this.player.name=P??this.player.name,this.player.ac=parseInt(g??this.player.ac,10),this.player.hp=parseInt(O??this.player.hp,10),this.player.level=parseInt(S??this.player.level,10),this.player.modifier=parseInt(_??this.player.modifier,10),this.player["statblock-link"]=m.frontmatter["statblock-link"],this.display()})});let s,o,a,l;new be.Setting(n).setName("Name").setDesc("Player name. Must be unique!").addText(f=>{s={input:f.inputEl,validate:d=>{let h=!1;return(!d.value.length&&!t||this.plugin.players.has(d.value)&&this.player.name!=this.original.name)&&(d.addClass("has-error"),h=!0),h}},f.setValue(this.player.name??""),f.onChange(d=>{f.inputEl.removeClass("has-error"),this.player.name=d})}),new be.Setting(n).setName("Level").setDesc("Player level.").addText(f=>{o={input:f.inputEl,validate:d=>{let h=!1;return(isNaN(Number(d.value))||Number(d.value)<=0)&&(d.addClass("has-error"),h=!0),h}},f.setValue(`${this.player.level??""}`),f.onChange(d=>{f.inputEl.removeClass("has-error"),this.player.level=Number(d)})}),new be.Setting(n).setName("Max Hit Points").addText(f=>{a={input:f.inputEl,validate:d=>{let h=!1;return isNaN(Number(d.value))&&(d.addClass("has-error"),h=!0),h}},f.setValue(`${this.player.hp??""}`),f.onChange(d=>{f.inputEl.removeClass("has-error"),this.player.hp=Number(d)})}),new be.Setting(n).setName("Armor Class").addText(f=>{f.setValue(`${this.player.ac??""}`),f.onChange(d=>{this.player.ac=d})}),new be.Setting(n).setName("Initiative Modifier").setDesc("This will be added to randomly-rolled initiatives.").addText(f=>{l={input:f.inputEl,validate:d=>{let h=!1;return isNaN(Number(d.value))&&(f.inputEl.addClass("has-error"),h=!0),h}},f.setValue(`${this.player.modifier??""}`),f.onChange(d=>{this.player.modifier=Number(d)})});let c=n.createDiv(),u=new be.Setting(c);u.addButton(f=>(f.setTooltip("Save").setIcon("checkmark").onClick(async()=>{if(this.validateInputs(s,a,l)){new be.Notice("Fix errors before saving.");return}this.saved=!0,this.close()}),f)),u.addExtraButton(f=>(f.setIcon("cross").setTooltip("Cancel").onClick(()=>{this.saved=!1,this.close()}),f)),this.validateInputs(s,a,l)}validateInputs(...t){let n=!1;for(let r of t)r.validate(r.input)?n=!0:r.input.removeClass("has-error");return n}onOpen(){this.display(!0)}};(0,be.addIcon)("initiative-tracker-warning",'');var pf=class extends Po.Modal{constructor(t,n){super(t.app);this.plugin=t;te(this,"status",{name:null,description:null,id:xt()});te(this,"canceled",!1);te(this,"editing",!1);te(this,"original");te(this,"warned",!1);n&&(this.editing=!0,this.original=n.name,this.status={name:n.name,description:n.description,id:n.id??xt()})}onOpen(){this.titleEl.setText(this.editing?"Edit Status":"New Status"),this.contentEl.empty();let t=new be.Setting(this.contentEl).setName("Name").addText(n=>{n.setValue(this.status.name).onChange(r=>{this.status.name=r,this.plugin.data.statuses.find(s=>s.name==this.status.name)&&!this.warned&&this.original!=this.status.name?(this.warned=!0,t.setDesc(createFragment(s=>{let o=s.createDiv("initiative-tracker-warning");(0,be.setIcon)(o,"initiative-tracker-warning"),o.createSpan({text:"A status by this name already exists and will be overwritten."})}))):this.warned&&(this.warned=!1,t.setDesc(""))})});new be.Setting(this.contentEl).setName("Description").addTextArea(n=>{n.setValue(this.status.description).onChange(r=>this.status.description=r)}),new be.Setting(this.contentEl).setName("Remove Each Round").setDesc("This status will be removed from all creatures at the start of a new round.").addToggle(n=>n.setValue(this.status.resetOnRound).onChange(r=>this.status.resetOnRound=r)),new be.Setting(this.contentEl).setName("Has Amount").setDesc("This status has an amount that can be increased or decreased during combat.").addToggle(n=>n.setValue(this.status.hasAmount).onChange(r=>{this.status.hasAmount=r,this.onOpen()})),this.status.hasAmount&&new be.Setting(this.contentEl).setName("Starting Amount").setDesc("The status will default to this amount when added.").addText(n=>n.setValue(`${this.status.startingAmount}`).onChange(r=>{this.status.amount=this.status.startingAmount=Number(r)}).inputEl.type="number"),new Po.ButtonComponent(this.contentEl.createDiv("initiative-tracker-cancel")).setButtonText("Cancel").onClick(()=>{this.canceled=!0,this.close()})}},mf=class extends Po.Modal{constructor(t,n){super(t.app);this.plugin=t;te(this,"party",{name:null,players:[]});te(this,"canceled",!1);te(this,"editing",!1);te(this,"warned",!1);te(this,"original");n&&(this.editing=!0,this.original=n.name,this.party={name:n.name,players:[...n.players??[]]})}onOpen(){this.titleEl.setText(this.editing?`Edit ${this.party.name??"Party"}`:"New Party");let t=new be.Setting(this.contentEl).setName("Name").addText(o=>{o.setValue(this.party.name).onChange(a=>{this.party.name=a,this.plugin.data.parties.find(l=>l.name==this.party.name)&&!this.warned&&this.original!=this.party.name?(this.warned=!0,t.setDesc(createFragment(l=>{let c=l.createDiv("initiative-tracker-warning");(0,be.setIcon)(c,"initiative-tracker-warning"),c.createSpan({text:"A party by this name already exists and will be overwritten."})}))):this.warned&&(this.warned=!1,t.setDesc(""))})}),n=this.contentEl.createDiv("initiative-tracker-additional-container"),r;new be.Setting(n).setName("Add Player to Party").addText(o=>{r=o;let a=new Hu(this.plugin.app,o,[...this.plugin.players.values()]).onSelect(({item:l})=>{o.setValue(l.name),a.close()})}).addExtraButton(o=>o.setIcon("plus-with-circle").onClick(()=>{if(!(!r.getValue()||!r.getValue().length)){if(this.party.players.includes(r.getValue())){new be.Notice("That player is already in this party!");return}if(!this.plugin.players.has(r.getValue())){new be.Notice("That player doesn't exist! You should make them first.");return}this.party.players.push(r.getValue()),this.displayPlayers(s),r.setValue("")}}));let s=n.createDiv("additional");this.displayPlayers(s),new Po.ButtonComponent(this.contentEl.createDiv("initiative-tracker-cancel")).setButtonText("Cancel").onClick(()=>{this.canceled=!0,this.close()})}displayPlayers(t){if(t.empty(),this.party.players.length)for(let n of this.party.players)new be.Setting(t).setName(n).addExtraButton(r=>{r.setIcon("trash").onClick(()=>{this.party.players.splice(this.party.players.indexOf(n),1),this.displayPlayers(t)})});else t.createDiv({attr:{style:"display: flex; justify-content: center; padding-bottom: 18px;"}}).createSpan({text:"Add a player to the party to see it here."})}};var am=require("obsidian");function hT(i){se(i,"svelte-10ii9u0",".creature-name.svelte-10ii9u0.svelte-10ii9u0{cursor:pointer}.encounter-line.svelte-10ii9u0.svelte-10ii9u0{display:flex;gap:1rem}.icons.svelte-10ii9u0.svelte-10ii9u0{display:flex}.icons.svelte-10ii9u0>span.svelte-10ii9u0 .clickable-icon{margin-right:0}")}function db(i,e,t){let n=i.slice();return n[13]=e[t][0],n[14]=e[t][1],n[16]=t,n}function pT(i){let e;return{c(){e=ae("-")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function mT(i){let e,t=fe([...i[0]]),n=[];for(let r=0;r{o.set(g,S.result)}),a.set(g,S),S.rollSync()):o.set(g,_)}else o.set(g,_)}let l=g=>{new am.ExtraButtonComponent(g).setIcon(ls)},c=async()=>{r.view||await r.addTrackerView();let g=r.view,O=[...o].map(([_,S])=>isNaN(Number(S))||S<1?[_]:[...Array(S).keys()].map(P=>Ne.new(_))).flat();he.new(r,{creatures:O.map(_=>_.toJSON()),name:null,state:!1,round:1,logFile:null,newLog:!0,roll:!0}),r.app.workspace.revealLeaf(g.leaf)},u=g=>{new am.ExtraButtonComponent(g).setIcon("plus-with-circle")},f=async g=>{r.view||await r.addTrackerView();let O=[...o].map(([_,S])=>isNaN(Number(S))||S<1?[_]:[...Array(S).keys()].map(P=>Ne.new(_))).flat();he.add(r,s,...O)},d=(g,O)=>{r.canUseDiceRoller&&a.has(O)&&!a.get(O).isStatic?g.appendChild(a.get(O)?.containerEl??createSpan({text:`${o.get(O)}`})):g.setText(`${o.get(O)}`)},h=(g,O)=>{if(O==1||g==0)return"";let _=O>2?",":"";return g==O-1?`${_} and `:`${_} `},p=g=>{if(!g)return;let O=[];return g.hp&&O.push(`HP: ${g.hp}`),g.ac&&O.push(`AC: ${g.ac}`),g.modifier&&O.push(`MOD: ${g.modifier}`),`${O.join(", ")}`},m=g=>r.openCombatant(g);return i.$$set=g=>{"creatures"in g&&t(0,n=g.creatures),"plugin"in g&&t(1,r=g.plugin),"rollHP"in g&&t(9,s=g.rollHP)},[n,r,l,c,u,f,d,h,p,s,m]}var lm=class extends ne{constructor(e){super(),re(this,e,yT,vT,ie,{creatures:0,plugin:1,rollHP:9},hT)}},pb=lm;var kn=require("obsidian");var Wi=require("obsidian");function bT(i){se(i,"svelte-g63m31",".buttons.svelte-g63m31.svelte-g63m31{display:flex;justify-content:space-between;padding:0 0 0.5rem 0}.state.svelte-g63m31.svelte-g63m31{display:flex;justify-content:flex-start;align-items:center}.clean.svelte-g63m31.svelte-g63m31{display:flex;justify-content:flex-end;align-items:center}.state.svelte-g63m31>.svelte-g63m31:not(:last-child),.clean.svelte-g63m31>.svelte-g63m31:not(:last-child){margin-right:0.25rem}")}function _T(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","svelte-g63m31")},m(s,o){A(s,e,o),n||(r=H(t=i[8].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function wT(i){let e,t,n,r,s,o,a,l,c,u;return{c(){e=b("div"),n=R(),r=b("div"),o=R(),a=b("div"),v(e,"class","svelte-g63m31"),v(r,"class","svelte-g63m31"),v(a,"class","svelte-g63m31")},m(f,d){A(f,e,d),A(f,n,d),A(f,r,d),A(f,o,d),A(f,a,d),c||(u=[H(t=i[9].call(null,e)),H(s=i[11].call(null,r)),H(l=i[10].call(null,a))],c=!0)},d(f){f&&(T(e),T(n),T(r),T(o),T(a)),c=!1,de(u)}}}function mb(i){let e,t,n,r;return{c(){e=b("div"),v(e,"aria-label","Open Log File"),v(e,"class","svelte-g63m31")},m(s,o){A(s,e,o),n||(r=[H(t=i[16].call(null,e)),Y(e,"click",i[17])],n=!0)},p:X,d(s){s&&T(e),n=!1,de(r)}}}function kT(i){let e,t,n,r;return{c(){e=b("div"),v(e,"aria-label","Open Player View"),v(e,"class","svelte-g63m31")},m(s,o){A(s,e,o),n||(r=[H(t=i[15].call(null,e)),Y(e,"click",i[18])],n=!0)},p:X,d(s){s&&T(e),n=!1,de(r)}}}function ST(i){let e,t,n,r,s,o,a,l,c,u;function f(g,O){return g[1]?wT:_T}let d=f(i,-1),h=d(i),p=i[0]&&mb(i),m=i[7]&&kT(i);return{c(){e=b("div"),t=b("div"),h.c(),n=R(),r=b("div"),p&&p.c(),s=R(),m&&m.c(),o=R(),a=b("div"),v(t,"class","state svelte-g63m31"),v(a,"class","svelte-g63m31"),v(r,"class","clean svelte-g63m31"),v(e,"class","buttons svelte-g63m31")},m(g,O){A(g,e,O),y(e,t),h.m(t,null),y(e,n),y(e,r),p&&p.m(r,null),y(r,s),m&&m.m(r,null),y(r,o),y(r,a),c||(u=[H(l=i[14].call(null,a)),Y(a,"click",i[19])],c=!0)},p(g,[O]){d!==(d=f(g,O))&&(h.d(1),h=d(g),h&&(h.c(),h.m(t,null))),g[0]?p?p.p(g,O):(p=mb(g),p.c(),p.m(r,s)):p&&(p.d(1),p=null),g[7]&&m.p(g,O)},i:X,o:X,d(g){g&&T(e),h.d(),p&&p.d(),m&&m.d(),c=!1,de(u)}}}function xT(i,e,t){let n,r,s,o,a,{state:l,data:c,logFile:u,sort:f,party:d}=he;ke(i,l,Q=>t(1,a=Q)),ke(i,c,Q=>t(22,s=Q)),ke(i,u,Q=>t(0,n=Q)),ke(i,f,Q=>t(23,o=Q)),ke(i,d,Q=>t(21,r=Q));let h=Wi.Platform.isDesktop,p=Q=>{new Wi.ExtraButtonComponent(Q).setIcon(Mp).setTooltip("Play").onClick(()=>he.setState(!0))},m=Q=>{new Wi.ExtraButtonComponent(Q).setIcon(jp).setTooltip("Stop").onClick(()=>he.setState(!1))},g=Q=>{new Wi.ExtraButtonComponent(Q).setIcon(Ip).setTooltip("Next").onClick(()=>he.goToNext())},O=Q=>{new Wi.ExtraButtonComponent(Q).setIcon(Np).setTooltip("Previous").onClick(()=>he.goToPrevious())},_=Ye("plugin"),S=Fe(),P=Q=>{let D=new Wi.Menu;if(D.addItem(E=>{E.setIcon(Lu).setTitle("New Encounter").onClick(()=>he.new(_))}),D.addItem(E=>{E.setIcon(Lu).setTitle("Add Creatures").onClick(()=>S("add-creatures"))}),D.addItem(E=>{E.setIcon(zp).setTitle("Reset HP / Status").onClick(()=>he.reset())}),D.addItem(E=>{E.setIcon(Ts).setTitle("Re-roll Initiatives").onClick(()=>he.roll(_))}),D.addItem(E=>{E.setIcon(zu).setTitle(_.data.condense?"Expand Creatures":"Group Creatures").onClick(async()=>{_.data.condense=!_.data.condense,await _.saveSettings(),E.setIcon(_.data.condense?Ep:zu),E.setTitle(_.data.condense?"Expand Creatures":"Group Creatures")})}),D.addItem(E=>{E.setTitle(o?"Sort Ascending":"Sort Descending").onClick(async()=>{_.data.descending=!_.data.descending,await _.saveSettings(),E.setTitle(_.data.descending?"Sort Ascending":"Sort Descending")})}),D.addSeparator(),s.parties&&s.parties.length)if(Wi.Platform.isMobile){D.addItem(E=>{E.setIcon("switch").setTitle("Switch Party").setIsLabel(!0)}),D.addItem(E=>{E.setTitle("None").onClick(()=>{he.setParty("",_)}).setChecked(!r||r=="")});for(let E of s.parties)D.addItem(j=>{j.setTitle(E.name).onClick(()=>{he.setParty(E.name,_)}).setChecked(r==E.name)})}else D.addItem(E=>{let j=E.setIcon("switch").setTitle("Switch Party").setSubmenu();j.addItem(z=>{z.setTitle("None").onClick(()=>{he.setParty("",_)}).setChecked(!r||r=="")});for(let z of s.parties)j.addItem(q=>{q.setTitle(z.name).onClick(()=>{he.setParty(z.name,_)}).setChecked(r==z.name)})});if(Wi.Platform.isMobile?(D.addItem(E=>{E.setIcon("dice").setTitle("Party Rolling Behavior").setIsLabel(!0)}),D.addItem(E=>{E.setTitle("Always Roll").onClick(async()=>{_.data.rollPlayerInitiatives=0,await _.saveSettings()}).setChecked(_.data.rollPlayerInitiatives==0)}),D.addItem(E=>{E.setTitle("Never Roll").onClick(async()=>{_.data.rollPlayerInitiatives=1,await _.saveSettings()}).setChecked(_.data.rollPlayerInitiatives==1)}),D.addItem(E=>{E.setTitle("Set to Zero").onClick(async()=>{_.data.rollPlayerInitiatives=2,await _.saveSettings()}).setChecked(_.data.rollPlayerInitiatives==2)})):D.addItem(E=>{let j=E.setIcon("dice").setTitle("Party Rolling Behavior").setSubmenu();j.addItem(z=>{z.setTitle("Always Roll").onClick(async()=>{_.data.rollPlayerInitiatives=0,await _.saveSettings()}).setChecked(_.data.rollPlayerInitiatives==0)}),j.addItem(z=>{z.setTitle("Never Roll").onClick(async()=>{_.data.rollPlayerInitiatives=1,await _.saveSettings()}).setChecked(_.data.rollPlayerInitiatives==1)}),j.addItem(z=>{z.setTitle("Set to Zero").onClick(async()=>{_.data.rollPlayerInitiatives=2,await _.saveSettings()}).setChecked(_.data.rollPlayerInitiatives==2)})}),D.addSeparator(),!Wi.Platform.isMobile)D.addItem(E=>{let j=E.setIcon("open-elsewhere-glyph").setTitle("Load Encounter").setDisabled(Object.keys(_.data.encounters).length==0).setSubmenu().setNoIcon();for(let z of Object.keys(_.data.encounters))j.addItem(q=>{q.setTitle(z).onClick(()=>{he.new(_,_.data.encounters[z])})})});else{D.addItem(E=>{E.setIcon("open-elsewhere-glyph").setTitle("Load Encounter").setIsLabel(!0)});for(let E of Object.keys(_.data.encounters))D.addItem(j=>{j.setTitle(E).onClick(()=>{he.new(_,_.data.encounters[E])})})}D.addItem(E=>{E.setIcon(Cl).setTitle("Save Encounter").onClick(()=>{S("save")})}),D.showAtMouseEvent(Q)};return[n,a,l,c,u,f,d,h,p,m,g,O,S,P,Q=>{new Wi.ExtraButtonComponent(Q).setIcon("vertical-three-dots")},Q=>{new Wi.ExtraButtonComponent(Q).setIcon("view")},Q=>{new Wi.ExtraButtonComponent(Q).setIcon("file-signature")},async()=>{n&&_.app.workspace.getLeaf().openFile(n)},Q=>S("player-view"),Q=>P(Q)]}var cm=class extends ne{constructor(e){super(),re(this,e,xT,ST,ie,{},bT)}},gb=cm;var Jl=require("obsidian");var vb=require("obsidian");function PT(i){se(i,"svelte-1kp13ds",'.tree-item-flair-outer.svelte-1kp13ds::after{content:""}.initiative.svelte-1kp13ds{display:block;padding:0;width:20px;text-align:center;white-space:nowrap;user-select:all;border:0;color:inherit}')}function Ob(i){let e,t,n,r;return{c(){e=b("input"),v(e,"class","editable initiative tree-item-flair svelte-1kp13ds"),v(e,"aria-label",t=`${i[0]-i[1]} + ${i[1]}`),e.value=i[0]},m(s,o){A(s,e,o),n||(r=[Y(e,"click",ET),Y(e,"blur",i[3]),Y(e,"keydown",TT)],n=!0)},p(s,o){o&3&&t!==(t=`${s[0]-s[1]} + ${s[1]}`)&&v(e,"aria-label",t),o&1&&e.value!==s[0]&&(e.value=s[0])},d(s){s&&T(e),n=!1,de(r)}}}function CT(i){let e,t=i[0],n=Ob(i);return{c(){e=b("div"),n.c(),v(e,"class","tree-item-flair-outer svelte-1kp13ds")},m(r,s){A(r,e,s),n.m(e,null)},p(r,[s]){s&1&&ie(t,t=r[0])?(n.d(1),n=Ob(r),n.c(),n.m(e,null)):n.p(r,s)},i:X,o:X,d(r){r&&T(e),n.d(r)}}}var ET=function(i){this.select()},TT=function(i){if(i.key==="Enter"||i.key==="Tab"){i.preventDefault(),this.blur();return}if(!/^(-?\d*\.?\d*|Backspace|Delete|Arrow\w+)$/.test(i.key))return i.preventDefault(),!1};function AT(i,e,t){let n=Fe(),{initiative:r}=e,{modifier:s}=e,o=function(a){let l=this.value;if(isNaN(Number(l))){new vb.Notice("Enter a valid initiative."),this.value=`${r}`;return}r!=Number(l)&&n("initiative",Number(l))};return i.$$set=a=>{"initiative"in a&&t(0,r=a.initiative),"modifier"in a&&t(1,s=a.modifier)},[r,s,n,o]}var um=class extends ne{constructor(e){super(),re(this,e,AT,CT,ie,{initiative:0,modifier:1},PT)}},yb=um;var Of=require("obsidian");function DT(i){se(i,"svelte-ptr4mi",".controls.svelte-ptr4mi{display:flex;justify-content:flex-end}.icon.svelte-ptr4mi .clickable-icon{margin-right:0}")}function QT(i){let e,t,n,r,s;return{c(){e=b("div"),t=b("div"),v(t,"class","add-button icon svelte-ptr4mi"),v(e,"class","controls svelte-ptr4mi")},m(o,a){A(o,e,a),y(e,t),r||(s=H(n=i[0].call(null,t)),r=!0)},p:X,i:X,o:X,d(o){o&&T(e),r=!1,s()}}}function RT(i,e,t){let n=Fe(),{creature:r}=e,s=Ye("plugin"),o=a=>{let l=new Of.ExtraButtonComponent(a).setIcon("vertical-three-dots").setTooltip("Actions");l.extraSettingsEl.onclick=c=>{c.stopPropagation();let u=new Of.Menu;u.addItem(f=>{f.setIcon(an).setTitle("Set Health/Status").onClick(d=>{he.updateTarget.set("hp"),he.setUpdate(r,d)})}),r.current_ac!=r.ac&&u.addItem(f=>{f.setIcon(an).setTitle("Reset AC").onClick(d=>{t(1,r.current_ac=r.ac,r),he.updateAndSave()})}),u.addItem(f=>{f.setIcon("pencil").setTitle("Edit").onClick(()=>{n("edit",r)})}),r.hidden?u.addItem(f=>{f.setIcon("eye").setTitle("Show").onClick(()=>{he.updateCreatures({creature:r,change:{hidden:!1}})})}):u.addItem(f=>{f.setIcon(Jn).setTitle("Hide").onClick(()=>{he.updateCreatures({creature:r,change:{hidden:!0}})})}),r.enabled?u.addItem(f=>{f.setIcon(El).setTitle("Disable").onClick(()=>{he.updateCreatures({creature:r,change:{enabled:!1}})})}):u.addItem(f=>{f.setIcon(Tl).setTitle("Enable").onClick(()=>{he.updateCreatures({creature:r,change:{enabled:!0}})})}),u.addItem(f=>{f.setIcon(qu).setTitle("Remove").onClick(()=>{he.remove(r)})}),u.showAtPosition(c)}};return i.$$set=a=>{"creature"in a&&t(1,r=a.creature)},[o,r]}var fm=class extends ne{constructor(e){super(),re(this,e,RT,QT,ie,{creature:1},DT)}},bb=fm;var $l=require("obsidian");function MT(i){se(i,"svelte-i278pw",".amount.svelte-i278pw,.tag.svelte-i278pw{display:flex;align-items:center;gap:0.125rem}.tag.svelte-i278pw{color:var(--text-muted);font-size:small;width:fit-content;border-color:var(--border-color);border-radius:0.25rem}.tag.svelte-i278pw .clickable-icon{margin:0}.icon.svelte-i278pw{display:flex;align-items:center}")}function _b(i){let e,t,n,r,s,o=i[0].amount+"",a,l,c,u,f,d;return{c(){e=b("div"),t=b("div"),r=R(),s=b("span"),a=ae(o),l=R(),c=b("div"),v(t,"class","icon svelte-i278pw"),v(c,"class","icon svelte-i278pw"),v(e,"class","amount svelte-i278pw")},m(h,p){A(h,e,p),y(e,t),y(e,r),y(e,s),y(s,a),y(e,l),y(e,c),f||(d=[H(n=i[3].call(null,t)),Y(t,"click",i[5]),H(u=i[4].call(null,c)),Y(c,"click",i[6])],f=!0)},p(h,p){p&1&&o!==(o=h[0].amount+"")&&me(a,o)},d(h){h&&T(e),f=!1,de(d)}}}function IT(i){let e,t,n=i[0].name+"",r,s,o,a,l,c,u,f,d=i[0].hasAmount&&_b(i);return{c(){e=b("div"),t=b("span"),r=ae(n),o=R(),d&&d.c(),a=R(),l=b("div"),v(t,"aria-label-classes","initiative-tracker-condition-tooltip"),v(t,"aria-label",s=i[0].description?.length?i[0].description:null),v(e,"class","tag svelte-i278pw")},m(h,p){A(h,e,p),y(e,t),y(t,r),y(e,o),d&&d.m(e,null),y(e,a),y(e,l),u||(f=[H(c=i[2].call(null,l)),Y(l,"click",i[7])],u=!0)},p(h,[p]){p&1&&n!==(n=h[0].name+"")&&me(r,n),p&1&&s!==(s=h[0].description?.length?h[0].description:null)&&v(t,"aria-label",s),h[0].hasAmount?d?d.p(h,p):(d=_b(h),d.c(),d.m(e,a)):d&&(d.d(1),d=null)},i:X,o:X,d(h){h&&T(e),d&&d.d(),u=!1,de(f)}}}function NT(i,e,t){let n=Fe(),{status:r}=e;(isNaN(r.amount)||r.amount<0)&&(r.amount=r.startingAmount);let s=f=>{new $l.ExtraButtonComponent(f).setIcon("cross-in-box")},o=f=>{(0,$l.setIcon)(f,"minus")},a=f=>{(0,$l.setIcon)(f,"plus")},l=()=>{t(0,r.amount--,r),r.amount<=0&&n("remove")},c=()=>t(0,r.amount++,r),u=()=>n("remove");return i.$$set=f=>{"status"in f&&t(0,r=f.status)},[r,n,s,o,a,l,c,u]}var dm=class extends ne{constructor(e){super(),re(this,e,NT,IT,ie,{status:0},MT)}},vf=dm;var wa=require("obsidian");function jT(i){se(i,"svelte-nkq4jj",".name-holder.svelte-nkq4jj{display:flex;align-items:center;gap:0.25rem;font-size:small}.centered-icon.svelte-nkq4jj{display:flex;align-items:center}.name.svelte-nkq4jj{display:block;text-align:left;background-color:inherit;border:0;padding:0;height:unset;word-break:keep-all}.center.svelte-nkq4jj{text-align:center}.creature-adder.svelte-nkq4jj{cursor:pointer}.statuses.svelte-nkq4jj{display:flex;flex-flow:row wrap;column-gap:0.25rem}.initiative-container.svelte-nkq4jj{border-top-left-radius:0.25rem;border-bottom-left-radius:0.25rem}.controls-container.svelte-nkq4jj{border-top-right-radius:0.25rem;border-bottom-right-radius:0.25rem}.dirty-ac.svelte-nkq4jj{font-weight:var(--font-bold)}.mobile.svelte-nkq4jj{font-size:smaller}")}function wb(i,e,t){let n=i.slice();return n[20]=e[t],n}function kb(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","centered-icon svelte-nkq4jj")},m(s,o){A(s,e,o),n||(r=H(t=i[6].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function Sb(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","centered-icon svelte-nkq4jj")},m(s,o){A(s,e,o),n||(r=H(t=i[7].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function ZT(i){let e;return{c(){e=b("span"),e.textContent=`${i[5]()}`,v(e,"class","name svelte-nkq4jj")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function zT(i){let e,t=i[0].name+"",n;return{c(){e=b("strong"),n=ae(t),v(e,"class","name player svelte-nkq4jj")},m(r,s){A(r,e,s),y(e,n)},p(r,s){s&1&&t!==(t=r[0].name+"")&&me(n,t)},d(r){r&&T(e)}}}function xb(i){let e,t,n=fe([...i[1]]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;o{z=null}),Te()),(!x||G&1)&&h!==(h=q[0].hpDisplay+"")&&(d.innerHTML=h),(!x||G&1)&&O!==(O=(q[0].current_ac?q[0].current_ac:We)+"")&&me(_,O),(!x||G&1&&S!==(S=q[0].current_ac!=q[0].ac?`${q[0].ac}`:""))&&v(g,"aria-label",S),(!x||G&1)&&ge(g,"dirty-ac",q[0].current_ac!=q[0].ac);let le={};G&1&&(le.creature=q[0]),w.$set(le)},i(q){x||($(t.$$.fragment,q),$(z),$(w.$$.fragment,q),x=!0)},o(q){V(t.$$.fragment,q),V(z),V(w.$$.fragment,q),x=!1},d(q){q&&(T(e),T(n),T(r),T(u),T(f),T(p),T(m),T(P),T(k)),ve(t),Z&&Z.d(),Q&&Q.d(),j.d(),z&&z.d(),ve(w),C=!1,de(M)}}}var Cb=(i,e)=>i+e,LT=i=>i.stopPropagation(),$T=i=>i.stopPropagation(),FT=i=>i.stopPropagation(),BT=i=>i.stopPropagation();function VT(i,e,t){let n,r,s=Fe(),{updateTarget:o}=he;ke(i,o,x=>t(2,r=x));let{creature:a}=e,l=()=>a.getName(),c=()=>a.getStatblockLink(),u=x=>{(0,wa.setIcon)(x,Jn)},f=x=>{(0,wa.setIcon)(x,er)},d=null,h=x=>{d=setTimeout(()=>{if(a["statblock-link"]){let C=c();/\[.+\]\(.+\)/.test(C)?[,C]=C.match(/\[.+?\]\((.+?)\)/):/\[\[.+\]\]/.test(C)&&([,C]=C.match(/\[\[(.+?)(?:\|.+?)?\]\]/)),app.workspace.trigger("link-hover",{},x.target,C,"initiative-tracker ")}},1e3)},p=x=>{clearTimeout(d)},m=x=>{he.updateCreatures({creature:a,change:{initiative:Number(x.detail)}})},g=x=>{s("open-combatant",a)},O=x=>{he.updateCreatures({creature:a,change:{remove_status:[x]}})},_=x=>{let C=r;Ke(o,r="hp",r),C!="ac"&&he.setUpdate(a,x)},S=x=>{let C=r;Ke(o,r="ac",r),C!="hp"&&he.setUpdate(a,x)};function P(x){ht.call(this,i,x)}function k(x){ht.call(this,i,x)}function w(x){ht.call(this,i,x)}return i.$$set=x=>{"creature"in x&&t(0,a=x.creature)},i.$$.update=()=>{i.$$.dirty&1&&t(1,n=a.status)},[a,n,r,s,o,l,u,f,h,p,m,g,O,_,S,P,k,w]}var hm=class extends ne{constructor(e){super(),re(this,e,VT,qT,ie,{creature:0},jT)}},Eb=hm;function Tb(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function _f(i){for(var e=1;e=0)&&(t[r]=i[r]);return t}function XT(i,e){if(i==null)return{};var t=WT(i,e),n,r;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(i,n)&&(t[n]=i[n])}return t}function YT(i,e){return HT(i)||KT(i,e)||km(i,e)||e6()}function jn(i){return UT(i)||GT(i)||km(i)||JT()}function UT(i){if(Array.isArray(i))return mm(i)}function HT(i){if(Array.isArray(i))return i}function GT(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function KT(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n=[],r=!0,s=!1,o,a;try{for(t=t.call(i);!(r=(o=t.next()).done)&&(n.push(o.value),!(e&&n.length===e));r=!0);}catch(l){s=!0,a=l}finally{try{!r&&t.return!=null&&t.return()}finally{if(s)throw a}}return n}}function km(i,e){if(i){if(typeof i=="string")return mm(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return mm(i,e)}}function mm(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(l){throw l},f:r}}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,o=!1,a;return{s:function(){t=t.call(i)},n:function(){var l=t.next();return s=l.done,l},e:function(l){o=!0,a=l},f:function(){try{!s&&t.return!=null&&t.return()}finally{if(o)throw a}}}}var t6="finalize",i6="consider";function Pa(i,e,t){i.dispatchEvent(new CustomEvent(t6,{detail:{items:e,info:t}}))}function js(i,e,t){i.dispatchEvent(new CustomEvent(i6,{detail:{items:e,info:t}}))}var Ef="draggedEntered",Hl="draggedLeft",Tf="draggedOverIndex",Sm="draggedLeftDocument",wf={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function n6(i,e,t){i.dispatchEvent(new CustomEvent(Ef,{detail:{indexObj:e,draggedEl:t}}))}function r6(i,e,t){i.dispatchEvent(new CustomEvent(Hl,{detail:{draggedEl:e,type:wf.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function s6(i,e){i.dispatchEvent(new CustomEvent(Hl,{detail:{draggedEl:e,type:wf.OUTSIDE_OF_ANY}}))}function o6(i,e,t){i.dispatchEvent(new CustomEvent(Tf,{detail:{indexObj:e,draggedEl:t}}))}function a6(i){window.dispatchEvent(new CustomEvent(Sm,{detail:{draggedEl:i}}))}var Xi={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:Ef,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:Tf,DRAGGED_LEFT:Hl,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},dn={POINTER:"pointer",KEYBOARD:"keyboard"},Af="isDndShadowItem",xm="data-is-dnd-shadow-item-internal",l6="data-is-dnd-shadow-item-hint",Gl="id:dnd-shadow-placeholder-0000",c6="dnd-action-dragged-el",_i="id",gm=0;function $b(){gm++}function Fb(){if(gm===0)throw new Error("Bug! trying to decrement when there are no dropzones");gm--}var Pm=typeof window>"u",Be=function(){};function Om(i){var e,t=i.getBoundingClientRect(),n=getComputedStyle(i),r=n.transform;if(r){var s,o,a,l;if(r.startsWith("matrix3d("))e=r.slice(9,-1).split(/, /),s=+e[0],o=+e[5],a=+e[12],l=+e[13];else if(r.startsWith("matrix("))e=r.slice(7,-1).split(/, /),s=+e[0],o=+e[3],a=+e[4],l=+e[5];else return t;var c=n.transformOrigin,u=t.x-a-(1-s)*parseFloat(c),f=t.y-l-(1-o)*parseFloat(c.slice(c.indexOf(" ")+1)),d=s?t.width/s:i.offsetWidth,h=o?t.height/o:i.offsetHeight;return{x:u,y:f,width:d,height:h,top:f,right:u+d,bottom:f+h,left:u}}else return t}function Bb(i){var e=Om(i);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function Vb(i){var e=i.getBoundingClientRect();return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function Wb(i){return{x:(i.left+i.right)/2,y:(i.top+i.bottom)/2}}function u6(i,e){return Math.sqrt(Math.pow(i.x-e.x,2)+Math.pow(i.y-e.y,2))}function Df(i,e){return i.y<=e.bottom&&i.y>=e.top&&i.x>=e.left&&i.x<=e.right}function Wl(i){return Wb(Vb(i))}function Ab(i,e){var t=Wl(i),n=Bb(e);return Df(t,n)}function f6(i,e){var t=Wl(i),n=Wl(e);return u6(t,n)}function d6(i){var e=Vb(i);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}var ka;function Cm(){Be(function(){return"resetting indexes cache"}),ka=new Map}Cm();function h6(i){var e=Array.from(i.children).findIndex(function(t){return t.getAttribute(xm)});if(e>=0)return ka.has(i)||ka.set(i,new Map),ka.get(i).set(e,Bb(i.children[e])),e}function p6(i,e){if(!Ab(i,e))return null;var t=e.children;if(t.length===0)return{index:0,isProximityBased:!0};for(var n=h6(e),r=0;r1&&arguments[1]!==void 0?arguments[1]:0;return i.parentElement?Xb(i.parentElement,e+1):e-1}function m6(i,e){if(Object.keys(i).length!==Object.keys(e).length)return!1;for(var t in i)if(!{}.hasOwnProperty.call(e,t)||e[t]!==i[t])return!1;return!0}function g6(i,e){if(i.length!==e.length)return!1;for(var t=0;t2&&arguments[2]!==void 0?arguments[2]:O6,n=arguments.length>3?arguments[3]:void 0,r,s,o=!1,a,l=Array.from(e).sort(function(u,f){return kf(f)-kf(u)});function c(){var u=Wl(i),f=n.multiScrollIfNeeded();if(!f&&a&&Math.abs(a.x-u.x)o.clientHeight&&(a.bottomo.clientWidth&&(a.right0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0;Be(function(){return"creating multi-scroller"});var t=S6(i),n=Array.from(t).sort(function(a,l){return kf(l)-kf(a)}),r=b6(),s=r.scrollIfNeeded;function o(){var a=e();if(!a||!n)return!1;for(var l=n.filter(function(f){return Df(a,f.getBoundingClientRect())||f===document.scrollingElement}),c=0;c0?o:function(){return!1}}}function k6(i){if(!i)return[];for(var e=[],t=i;t;){var n=window.getComputedStyle(t),r=n.overflow;r.split(" ").some(function(s){return s.includes("auto")||s.includes("scroll")})&&e.push(t),t=t.parentElement}return e}function S6(i){var e=new Set,t=Ul(i),n;try{for(t.s();!(n=t.n()).done;){var r=n.value;k6(r).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 x6(i){var e=i.cloneNode(!0),t=[],n=i.tagName==="SELECT",r=n?[i]:jn(i.querySelectorAll("select")),s=Ul(r),o;try{for(s.s();!(o=s.n()).done;){var a=o.value;t.push(a.value)}}catch(S){s.e(S)}finally{s.f()}if(r.length>0)for(var l=n?[e]:jn(e.querySelectorAll("select")),c=0;c0)for(var m=h?[e]:jn(e.querySelectorAll("canvas")),g=0;g1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};i.forEach(function(n){var r=e(n);Object.keys(r).forEach(function(s){n.style[s]=r[s]}),t(n).forEach(function(s){return n.classList.add(s)})})}function Sf(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};i.forEach(function(n){var r=e(n);Object.keys(r).forEach(function(s){n.style[s]=""}),t(n).forEach(function(s){return n.classList.contains(s)&&n.classList.remove(s)})})}function M6(i){var e=i.style.minHeight;i.style.minHeight=window.getComputedStyle(i).getPropertyValue("height");var t=i.style.minWidth;return i.style.minWidth=window.getComputedStyle(i).getPropertyValue("width"),function(){i.style.minHeight=e,i.style.minWidth=t}}var I6="--any--",N6=100,j6=20,Qb=3,Rb={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Mb="data-is-dnd-original-dragged-item",rr,Ci,fn,Qf,Wt,Rf,Ns,Pi,Ms,wn,To=!1,Em=!1,Tm,Kl=!1,Bl=[],ar=new Map,li=new Map,pm=new WeakMap;function Z6(i,e){Be(function(){return"registering drop-zone if absent"}),ar.has(e)||ar.set(e,new Set),ar.get(e).has(i)||(ar.get(e).add(i),$b())}function Ib(i,e){ar.get(e).delete(i),Fb(),ar.get(e).size===0&&ar.delete(e)}function z6(){Be(function(){return"watching dragged element"});var i=ar.get(Qf),e=Ul(i),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.addEventListener(Ef,Gb),n.addEventListener(Hl,Kb),n.addEventListener(Tf,Jb)}}catch(a){e.e(a)}finally{e.f()}window.addEventListener(Sm,Ca);var r=Math.max.apply(Math,jn(Array.from(i.keys()).map(function(a){return li.get(a).dropAnimationDurationMs}))),s=r===0?j6:Math.max(r,N6),o=w6(i,function(){return wn});v6(Ci,i,s*1.07,o)}function q6(){Be(function(){return"unwatching dragged element"});var i=ar.get(Qf),e=Ul(i),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.removeEventListener(Ef,Gb),n.removeEventListener(Hl,Kb),n.removeEventListener(Tf,Jb)}}catch(r){e.e(r)}finally{e.f()}window.removeEventListener(Sm,Ca),y6()}function Mf(i){return i.findIndex(function(e){return!!e[Af]})}function L6(i){var e;return _f(_f({},i),{},(e={},xa(e,Af,!0),xa(e,_i,Gl),e))}function Gb(i){Be(function(){return["dragged entered",i.currentTarget,i.detail]});var e=li.get(i.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&i.currentTarget!==Wt){Be(function(){return"ignoring dragged entered because drop is currently disabled"});return}if(Kl=!1,t=t.filter(function(u){return u[_i]!==Ns[_i]}),Be(function(){return"dragged entered items ".concat(Ir(t))}),Wt!==i.currentTarget){var r=li.get(Wt).items,s=r.filter(function(u){return!u[Af]});js(Wt,s,{trigger:Xi.DRAGGED_ENTERED_ANOTHER,id:fn[_i],source:dn.POINTER})}var o=i.detail.indexObj,a=o.index,l=o.isProximityBased,c=l&&a===i.currentTarget.children.length-1?a+1:a;Pi=i.currentTarget,t.splice(c,0,Ns),js(i.currentTarget,t,{trigger:Xi.DRAGGED_ENTERED,id:fn[_i],source:dn.POINTER})}function Kb(i){if(To){Be(function(){return["dragged left",i.currentTarget,i.detail]});var e=li.get(i.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&i.currentTarget!==Wt&&i.currentTarget!==Pi){Be(function(){return"drop is currently disabled"});return}var r=jn(t),s=Mf(r);s!==-1&&r.splice(s,1);var o=Pi;Pi=void 0;var a=i.detail,l=a.type,c=a.theOtherDz;if(l===wf.OUTSIDE_OF_ANY||l===wf.LEFT_FOR_ANOTHER&&c!==Wt&&li.get(c).dropFromOthersDisabled){Be(function(){return"dragged left all, putting shadow element back in the origin dz"}),Kl=!0,Pi=Wt;var u=o===Wt?r:jn(li.get(Wt).items);u.splice(Rf,0,Ns),js(Wt,u,{trigger:Xi.DRAGGED_LEFT_ALL,id:fn[_i],source:dn.POINTER})}js(i.currentTarget,r,{trigger:Xi.DRAGGED_LEFT,id:fn[_i],source:dn.POINTER})}}function Jb(i){Be(function(){return["dragged is over index",i.currentTarget,i.detail]});var e=li.get(i.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&i.currentTarget!==Wt){Be(function(){return"drop is currently disabled"});return}var r=jn(t);Kl=!1;var s=i.detail.indexObj.index,o=Mf(r);o!==-1&&r.splice(o,1),r.splice(s,0,Ns),js(i.currentTarget,r,{trigger:Xi.DRAGGED_OVER_INDEX,id:fn[_i],source:dn.POINTER})}function xf(i){i.preventDefault();var e=i.touches?i.touches[0]:i;wn={x:e.clientX,y:e.clientY},Ci.style.transform="translate3d(".concat(wn.x-Ms.x,"px, ").concat(wn.y-Ms.y,"px, 0)")}function Ca(){Be(function(){return"dropped"}),Em=!0,window.removeEventListener("mousemove",xf),window.removeEventListener("touchmove",xf),window.removeEventListener("mouseup",Ca),window.removeEventListener("touchend",Ca),q6(),T6(Ci),Pi||(Be(function(){return"element was dropped right after it left origin but before entering somewhere else"}),Pi=Wt),Be(function(){return["dropped in dz",Pi]});var i=li.get(Pi),e=i.items,t=i.type;Sf(ar.get(t),function(s){return li.get(s).dropTargetStyle},function(s){return li.get(s).dropTargetClasses});var n=Mf(e);n===-1&&Pi===Wt&&(n=Rf),e=e.map(function(s){return s[Af]?fn:s});function r(){Tm(),Pa(Pi,e,{trigger:Kl?Xi.DROPPED_OUTSIDE_OF_ANY:Xi.DROPPED_INTO_ZONE,id:fn[_i],source:dn.POINTER}),Pi!==Wt&&Pa(Wt,li.get(Wt).items,{trigger:Xi.DROPPED_INTO_ANOTHER,id:fn[_i],source:dn.POINTER}),n!==-1&&R6(Pi.children[n]),B6()}$6(n,r)}function $6(i,e){var t=i>-1?Om(Pi.children[i]):Om(Pi),n={x:t.left-parseFloat(Ci.style.left),y:t.top-parseFloat(Ci.style.top)},r=li.get(Pi),s=r.dropAnimationDurationMs,o="transform ".concat(s,"ms ease");Ci.style.transition=Ci.style.transition?Ci.style.transition+","+o:o,Ci.style.transform="translate3d(".concat(n.x,"px, ").concat(n.y,"px, 0)"),window.setTimeout(e,s)}function F6(i,e){Bl.push({dz:i,destroy:e}),window.requestAnimationFrame(function(){Hb(i),document.body.appendChild(i)})}function B6(){Ci.remove(),rr.remove(),Bl.length&&(Be(function(){return["will destroy zones that were removed during drag",Bl]}),Bl.forEach(function(i){var e=i.dz,t=i.destroy;t(),e.remove()}),Bl=[]),Ci=void 0,rr=void 0,fn=void 0,Qf=void 0,Wt=void 0,Rf=void 0,Ns=void 0,Pi=void 0,Ms=void 0,wn=void 0,To=!1,Em=!1,Tm=void 0,Kl=!1}function V6(i,e){var t=!1,n={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:Rb,dropTargetClasses:[],transformDraggedElement:function(){},centreDraggedOnCursor:!1};Be(function(){return["dndzone good to go options: ".concat(Ir(e),", config: ").concat(Ir(n)),{node:i}]});var r=new Map;function s(){window.addEventListener("mousemove",l,{passive:!1}),window.addEventListener("touchmove",l,{passive:!1,capture:!1}),window.addEventListener("mouseup",a,{passive:!1}),window.addEventListener("touchend",a,{passive:!1})}function o(){window.removeEventListener("mousemove",l),window.removeEventListener("touchmove",l),window.removeEventListener("mouseup",a),window.removeEventListener("touchend",a)}function a(d){o(),rr=void 0,Ms=void 0,wn=void 0,d.type==="touchend"&&d.target.click()}function l(d){d.preventDefault();var h=d.touches?d.touches[0]:d;wn={x:h.clientX,y:h.clientY},(Math.abs(wn.x-Ms.x)>=Qb||Math.abs(wn.y-Ms.y)>=Qb)&&(o(),u())}function c(d){if(d.target!==d.currentTarget&&(d.target.value!==void 0||d.target.isContentEditable)){Be(function(){return"won't initiate drag on a nested input element"});return}if(d.button){Be(function(){return"ignoring none left click button: ".concat(d.button)});return}if(To){Be(function(){return"cannot start a new drag before finalizing previous one"});return}d.preventDefault(),d.stopPropagation();var h=d.touches?d.touches[0]:d;Ms={x:h.clientX,y:h.clientY},wn=_f({},Ms),rr=d.currentTarget,s()}function u(){Be(function(){return["drag start config: ".concat(Ir(n)),rr]}),To=!0;var d=r.get(rr);Rf=d,Wt=rr.parentElement;var h=Wt.closest("dialog")||Wt.getRootNode(),p=h.body||h,m=n.items,g=n.type,O=n.centreDraggedOnCursor,_=jn(m);fn=_[d],Qf=g,Ns=L6(fn),Ci=E6(rr,O&&wn),rr.setAttribute(Mb,!0);function S(){Ci.parentElement?window.requestAnimationFrame(S):(p.appendChild(Ci),Ci.focus(),z6(),Hb(rr),p.appendChild(rr),Ns[_i]=fn[_i])}window.requestAnimationFrame(S),bf(Array.from(ar.get(n.type)).filter(function(P){return P===Wt||!li.get(P).dropFromOthersDisabled}),function(P){return li.get(P).dropTargetStyle},function(P){return li.get(P).dropTargetClasses}),_.splice(d,1,Ns),Tm=M6(Wt),js(Wt,_,{trigger:Xi.DRAG_STARTED,id:fn[_i],source:dn.POINTER}),window.addEventListener("mousemove",xf,{passive:!1}),window.addEventListener("touchmove",xf,{passive:!1,capture:!1}),window.addEventListener("mouseup",Ca,{passive:!1}),window.addEventListener("touchend",Ca,{passive:!1})}function f(d){var h=d.items,p=h===void 0?void 0:h,m=d.flipDurationMs,g=m===void 0?0:m,O=d.type,_=O===void 0?I6:O,S=d.dragDisabled,P=S===void 0?!1:S,k=d.morphDisabled,w=k===void 0?!1:k,x=d.dropFromOthersDisabled,C=x===void 0?!1:x,M=d.dropTargetStyle,Z=M===void 0?Rb:M,Q=d.dropTargetClasses,D=Q===void 0?[]:Q,E=d.transformDraggedElement,j=E===void 0?function(){}:E,z=d.centreDraggedOnCursor,q=z===void 0?!1:z;n.dropAnimationDurationMs=g,n.type&&_!==n.type&&Ib(i,n.type),n.type=_,n.items=jn(p),n.dragDisabled=P,n.morphDisabled=w,n.transformDraggedElement=j,n.centreDraggedOnCursor=q,t&&To&&!Em&&(!m6(Z,n.dropTargetStyle)||!g6(D,n.dropTargetClasses))&&(Sf([i],function(){return n.dropTargetStyle},function(){return D}),bf([i],function(){return Z},function(){return D})),n.dropTargetStyle=Z,n.dropTargetClasses=jn(D);function G(ue,B){return li.get(ue)?li.get(ue)[B]:n[B]}t&&To&&n.dropFromOthersDisabled!==C&&(C?Sf([i],function(ue){return G(ue,"dropTargetStyle")},function(ue){return G(ue,"dropTargetClasses")}):bf([i],function(ue){return G(ue,"dropTargetStyle")},function(ue){return G(ue,"dropTargetClasses")})),n.dropFromOthersDisabled=C,li.set(i,n),Z6(i,_);for(var U=Mf(n.items),le=0;le".concat(e,"

"),t.style.display="none",t.style.position="fixed",t.style.zIndex="-5",t}function Sa(i){if(!Pm){ai||bm(),ai.innerHTML="";var e=document.createTextNode(i);ai.appendChild(e),ai.style.display="none",ai.style.display="inline"}}var H6="--any--",Nb={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Nn=!1,_m,Ni,Ao="",Eo,sr,Is="",Pf=new WeakSet,jb=new WeakMap,Zb=new WeakMap,wm=new Map,xi=new Map,or=new Map,Cf;function G6(i,e){Be(function(){return"registering drop-zone if absent"}),or.size===0&&(Be(function(){return"adding global keydown and click handlers"}),Cf=X6(),window.addEventListener("keydown",t_),window.addEventListener("click",i_)),or.has(e)||or.set(e,new Set),or.get(e).has(i)||(or.get(e).add(i),$b())}function zb(i,e){Be(function(){return"unregistering drop-zone"}),Ni===i&&Yl(),or.get(e).delete(i),Fb(),or.get(e).size===0&&or.delete(e),or.size===0&&(Be(function(){return"removing global keydown and click handlers"}),window.removeEventListener("keydown",t_),window.removeEventListener("click",i_),Cf=void 0,Y6())}function t_(i){if(Nn)switch(i.key){case"Escape":{Yl();break}}}function i_(){Nn&&(Pf.has(document.activeElement)||(Be(function(){return"clicked outside of any draggable"}),Yl()))}function K6(i){if(Be(function(){return"zone focus"}),!!Nn){var e=i.currentTarget;if(e!==Ni){Ao=e.getAttribute("aria-label")||"";var t=xi.get(Ni),n=t.items,r=n.find(function(f){return f[_i]===sr}),s=n.indexOf(r),o=n.splice(s,1)[0],a=xi.get(e),l=a.items,c=a.autoAriaDisabled;e.getBoundingClientRect().top0&&arguments[0]!==void 0?arguments[0]:!0;Be(function(){return"drop"}),xi.get(Ni).autoAriaDisabled||Sa("Stopped dragging item ".concat(Is)),Pf.has(document.activeElement)&&document.activeElement.blur(),i&&js(Ni,xi.get(Ni).items,{trigger:Xi.DRAG_STOPPED,id:sr,source:dn.KEYBOARD}),Sf(or.get(_m),function(e){return xi.get(e).dropTargetStyle},function(e){return xi.get(e).dropTargetClasses}),Eo=null,sr=null,Is="",_m=null,Ni=null,Ao="",Nn=!1,n_()}function J6(i,e){var t={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Nb,dropTargetClasses:[],autoAriaDisabled:!1};function n(u,f,d){u.length<=1||u.splice(d,1,u.splice(f,1,u[d])[0])}function r(u){switch(Be(function(){return["handling key down",u.key]}),u.key){case"Enter":case" ":{if((u.target.disabled!==void 0||u.target.href||u.target.isContentEditable)&&!Pf.has(u.target))return;u.preventDefault(),u.stopPropagation(),Nn?Yl():s(u);break}case"ArrowDown":case"ArrowRight":{if(!Nn)return;u.preventDefault(),u.stopPropagation();var f=xi.get(i),d=f.items,h=Array.from(i.children),p=h.indexOf(u.currentTarget);Be(function(){return["arrow down",p]}),p0&&(t.autoAriaDisabled||Sa("Moved item ".concat(Is," to position ").concat(_," in the list ").concat(Ao)),n(g,_,_-1),Pa(i,g,{trigger:Xi.DROPPED_INTO_ZONE,id:sr,source:dn.KEYBOARD}));break}}}function s(u){Be(function(){return"drag start"}),a(u.currentTarget),Ni=i,_m=t.type,Nn=!0;var f=Array.from(or.get(t.type)).filter(function(h){return h===Ni||!xi.get(h).dropFromOthersDisabled});if(bf(f,function(h){return xi.get(h).dropTargetStyle},function(h){return xi.get(h).dropTargetClasses}),!t.autoAriaDisabled){var d="Started dragging item ".concat(Is,". Use the arrow keys to move it within its list ").concat(Ao);f.length>1&&(d+=", or tab to another list in order to move the item into it"),Sa(d)}js(i,xi.get(i).items,{trigger:Xi.DRAG_STARTED,id:sr,source:dn.KEYBOARD}),n_()}function o(u){Nn&&u.currentTarget!==Eo&&(u.stopPropagation(),Yl(!1),s(u))}function a(u){var f=xi.get(i),d=f.items,h=Array.from(i.children),p=h.indexOf(u);Eo=u,Eo.tabIndex=t.zoneItemTabIndex,sr=d[p][_i],Is=h[p].getAttribute("aria-label")||""}function l(u){var f=u.items,d=f===void 0?[]:f,h=u.type,p=h===void 0?H6:h,m=u.dragDisabled,g=m===void 0?!1:m,O=u.zoneTabIndex,_=O===void 0?0:O,S=u.zoneItemTabIndex,P=S===void 0?0:S,k=u.dropFromOthersDisabled,w=k===void 0?!1:k,x=u.dropTargetStyle,C=x===void 0?Nb:x,M=u.dropTargetClasses,Z=M===void 0?[]:M,Q=u.autoAriaDisabled,D=Q===void 0?!1:Q;t.items=jn(d),t.dragDisabled=g,t.dropFromOthersDisabled=w,t.zoneTabIndex=_,t.zoneItemTabIndex=P,t.dropTargetStyle=C,t.dropTargetClasses=Z,t.autoAriaDisabled=D,t.type&&p!==t.type&&zb(i,t.type),t.type=p,G6(i,p),D||(i.setAttribute("aria-disabled",g),i.setAttribute("role","list"),i.setAttribute("aria-describedby",g?Cf.DND_ZONE_DRAG_DISABLED:Cf.DND_ZONE_ACTIVE)),xi.set(i,t),Nn?i.tabIndex=i===Ni||Eo.contains(i)||t.dropFromOthersDisabled||Ni&&t.type!==xi.get(Ni).type?-1:0:i.tabIndex=t.zoneTabIndex,i.addEventListener("focus",K6);for(var E=function(q){var G=i.children[q];Pf.add(G),G.tabIndex=Nn?-1:t.zoneItemTabIndex,D||G.setAttribute("role","listitem"),G.removeEventListener("keydown",jb.get(G)),G.removeEventListener("click",Zb.get(G)),g||(G.addEventListener("keydown",r),jb.set(G,r),G.addEventListener("click",o),Zb.set(G,o)),Nn&&t.items[q][_i]===sr&&(Be(function(){return["focusing on",{i:q,focusedItemId:sr}]}),Eo=G,Eo.tabIndex=t.zoneItemTabIndex,G.focus())},j=0;j0&&console.warn("dndzone will ignore unknown options",p),!e)throw new Error("no 'items' key provided to dndzone");var m=e.find(function(g){return!{}.hasOwnProperty.call(g,_i)});if(m)throw new Error("missing '".concat(_i,"' property for item ").concat(Ir(m)));if(u&&!Array.isArray(u))throw new Error("dropTargetClasses should be an array but instead it is a ".concat(Vl(u),", ").concat(Ir(u)));if(a&&!Lb(a))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(Vl(a),", ").concat(Ir(a)));if(l&&!Lb(l))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(Vl(l),", ").concat(Ir(l)))}function Lb(i){return!isNaN(i)&&function(e){return(e|0)===e}(parseFloat(i))}function Ea(i){let e=i-1;return e*e*e+1}function Nr(i,{from:e,to:t},n={}){let r=getComputedStyle(i),s=r.transform==="none"?"":r.transform,[o,a]=r.transformOrigin.split(" ").map(parseFloat),l=e.left+e.width*o/t.width-(t.left+o),c=e.top+e.height*a/t.height-(t.top+a),{delay:u=0,duration:f=h=>Math.sqrt(h)*120,easing:d=Ea}=n;return{delay:u,duration:Ge(f)?f(Math.sqrt(l*l+c*c)):f,easing:d,css:(h,p)=>{let m=p*l,g=p*c,O=h+p*e.width/t.width,_=h+p*e.height/t.height;return`transform: ${s} translate(${m}px, ${g}px) scale(${O}, ${_});`}}}function i7(i){se(i,"svelte-mzbbdu",".no-creatures.svelte-mzbbdu{margin:1rem;text-align:center}.initiative-tracker-table.svelte-mzbbdu{padding:0.5rem;align-items:center;gap:0.25rem 0.5rem;width:100%;margin-left:0rem;table-layout:fixed;border-collapse:separate;border-spacing:0 2px}.left.svelte-mzbbdu{text-align:left}.center.svelte-mzbbdu{text-align:center}.tracker-table-header.svelte-mzbbdu{font-weight:bolder;display:contents}.initiative-tracker-creature.svelte-mzbbdu{position:relative}.initiative-tracker-creature.active.svelte-mzbbdu{background-color:rgba(0, 0, 0, 0.1)}.theme-dark .initiative-tracker-creature.active.svelte-mzbbdu{background-color:rgba(255, 255, 255, 0.1)}.initiative-tracker-creature.disabled.svelte-mzbbdu *{color:var(--text-faint)}.initiative-tracker-creature.svelte-mzbbdu td{border-top:1px solid transparent;border-bottom:1px solid transparent}.initiative-tracker-creature.svelte-mzbbdu td:first-child{border-left:1px solid transparent}.initiative-tracker-creature.svelte-mzbbdu td:last-child{border-right:1px solid transparent}.initiative-tracker-creature.svelte-mzbbdu:hover td,.initiative-tracker-creature.viewing.svelte-mzbbdu td{border-top:1px solid var(--background-modifier-border);border-bottom:1px solid var(--background-modifier-border)}.initiative-tracker-creature.svelte-mzbbdu:hover td:first-child,.initiative-tracker-creature.viewing.svelte-mzbbdu td:first-child{border-left:1px solid var(--background-modifier-border)}.initiative-tracker-creature.svelte-mzbbdu:hover td:last-child,.initiative-tracker-creature.viewing.svelte-mzbbdu td:last-child{border-right:1px solid var(--background-modifier-border)}")}function r_(i,e,t){let n=i.slice();return n[19]=e[t].creature,n[20]=e[t].id,n}function n7(i){let e;return{c(){e=b("div"),e.innerHTML="

Add a creature to get started!

Players may be created in settings.",v(e,"class","no-creatures svelte-mzbbdu")},m(t,n){A(t,e,n)},p:X,i:X,o:X,d(t){t&&T(e)}}}function r7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=[],O=new Map,_,S,P,k,w=fe(i[1]),x=C=>C[20];for(let C=0;C{o[u]=null}),Te(),n=o[t],n?n.p(l,c):(n=o[t]=s[t](l),n.c()),$(n,1),n.m(e,null))},i(l){r||($(n),r=!0)},o(l){V(n),r=!1},d(l){l&&T(e),o[t].d()}}}var Am=300;function o7(i,e,t){let n,r,s,o;ke(i,he,w=>t(18,r=w));let a=Ye("plugin"),{state:l,ordered:c}=he;ke(i,l,w=>t(2,o=w)),ke(i,c,w=>t(0,s=w));let u=Fe(),f=w=>{(0,Jl.setIcon)(w,an)},d=w=>{(0,Jl.setIcon)(w,tr)};function h(w){t(1,n=w.detail.items)}function p(w){if(w.detail.items.length>1){let x=w.detail.items.find(({id:M})=>M==w.detail.info.id),C=w.detail.items.findIndex(M=>M.id==w.detail.info.id);C==w.detail.items.length-1?x.creature.initiative=w.detail.items[C-1].creature.initiative:x.creature.initiative=w.detail.items[C+1].creature.initiative,he.logNewInitiative(x.creature)}t(1,n=w.detail.items),Ke(he,r=[...n.map(({creature:x},C)=>(x.manualOrder=C,x))],r)}let m=w=>{new Jl.ExtraButtonComponent(w).setIcon(Ts)},g=w=>he.roll(a);function O(w){ht.call(this,i,w)}function _(w){ht.call(this,i,w)}function S(w){ht.call(this,i,w)}function P(w){ht.call(this,i,w)}let k=(w,x)=>{u("open-combatant",w),x.stopPropagation()};return i.$$.update=()=>{i.$$.dirty&1&&t(1,n=[...s].map(w=>({creature:w,id:xt()})))},[s,n,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P,k]}var Dm=class extends ne{constructor(e){super(),re(this,e,o7,s7,ie,{},i7)}},o_=Dm;function Ta(i){return Object.prototype.toString.call(i)==="[object Date]"}function Qm(i,e,t,n){if(typeof t=="number"||Ta(t)){let r=n-t,s=(t-e)/(i.dt||1/60),o=i.opts.stiffness*r,a=i.opts.damping*s,l=(o-a)*i.inv_mass,c=(s+l)*i.dt;return Math.abs(c)Qm(i,e[s],t[s],n[s]));if(typeof t=="object"){let r={};for(let s in t)r[s]=Qm(i,e[s],t[s],n[s]);return r}else throw new Error(`Cannot spring ${typeof t} values`)}}function a_(i,e={}){let t=$e(i),{stiffness:n=.15,damping:r=.8,precision:s=.01}=e,o,a,l,c=i,u=i,f=1,d=0,h=!1;function p(g,O={}){u=g;let _=l={};return i==null||O.hard||m.stiffness>=1&&m.damping>=1?(h=!0,o=us(),c=g,t.set(i=u),Promise.resolve()):(O.soft&&(d=1/((O.soft===!0?.5:+O.soft)*60),f=0),a||(o=us(),h=!1,a=As(S=>{if(h)return h=!1,a=null,!1;f=Math.min(f+d,1);let P={inv_mass:f,opts:m,settled:!0,dt:(S-o)*60/1e3},k=Qm(P,c,i,u);return o=S,c=i,t.set(i=k),P.settled&&(a=null),!P.settled})),new Promise(S=>{a.promise.then(()=>{_===l&&S()})}))}let m={set:p,update:(g,O)=>p(g(u,i),O),subscribe:t.subscribe,stiffness:n,damping:r,precision:s};return m}function Rm(i,e){if(i===e||i!==i)return()=>i;let t=typeof i;if(t!==typeof e||Array.isArray(i)!==Array.isArray(e))throw new Error("Cannot interpolate values of different type");if(Array.isArray(i)){let n=e.map((r,s)=>Rm(i[s],r));return r=>n.map(s=>s(r))}if(t==="object"){if(!i||!e)throw new Error("Object cannot be null");if(Ta(i)&&Ta(e)){i=i.getTime(),e=e.getTime();let s=e-i;return o=>new Date(i+o*s)}let n=Object.keys(e),r={};return n.forEach(s=>{r[s]=Rm(i[s],e[s])}),s=>{let o={};return n.forEach(a=>{o[a]=r[a](s)}),o}}if(t==="number"){let n=e-i;return r=>i+r*n}throw new Error(`Cannot interpolate ${t} values`)}function l_(i,e={}){let t=$e(i),n,r=i;function s(o,a){if(i==null)return t.set(i=o),Promise.resolve();r=o;let l=n,c=!1,{delay:u=0,duration:f=400,easing:d=In,interpolate:h=Rm}=ti(ti({},e),a);if(f===0)return l&&(l.abort(),l=null),t.set(i=r),Promise.resolve();let p=us()+u,m;return n=As(g=>{if(gf?(t.set(i=o),!1):(t.set(i=m(d(O/f))),!0)}),n.promise}return{set:s,update:(o,a)=>s(o(r,i),a),subscribe:t.subscribe}}function a7(i){se(i,"svelte-137y560",".difficulty-bar-container.svelte-137y560{display:grid;grid-template-columns:auto 1fr auto;gap:0.5rem;align-items:center;padding:0 0.5rem;margin-bottom:0.5rem;width:100%}.difficulty-bar.svelte-137y560{width:100%;border:1px solid #ccc;border-radius:3px}")}function l7(i){let e,t,n=(i[0].labels?.[0]??"")+"",r,s,o,a,l,c,u=(i[0].labels?.last()??"")+"",f;return{c(){e=b("div"),t=b("span"),r=ae(n),s=R(),o=b("span"),a=b("meter"),l=R(),c=b("span"),f=ae(u),v(a,"class","difficulty-bar svelte-137y560"),v(a,"min","0"),v(a,"low","0.33"),v(a,"high","0.66"),v(a,"optimum","0"),a.value=i[2],v(e,"class","difficulty-bar-container svelte-137y560"),v(e,"aria-label",i[1])},m(d,h){A(d,e,h),y(e,t),y(t,r),y(e,s),y(e,o),y(o,a),y(e,l),y(e,c),y(c,f)},p(d,[h]){h&1&&n!==(n=(d[0].labels?.[0]??"")+"")&&me(r,n),h&4&&(a.value=d[2]),h&1&&u!==(u=(d[0].labels?.last()??"")+"")&&me(f,u),h&2&&v(e,"aria-label",d[1])},i:X,o:X,d(d){d&&T(e)}}}function c7(i,e,t){let n,r,s,{difficulty:o}=he,a=Ye("plugin"),l=o(a);ke(i,l,u=>t(0,r=u));let c=l_(0,{duration:400,easing:Ea});return ke(i,c,u=>t(2,s=u)),i.$$.update=()=>{i.$$.dirty&1&&r.thresholds.last().minValue>0&&c.set(Math.min(r.difficulty.value/r.thresholds.last().minValue,1)),i.$$.dirty&1&&t(1,n=r.difficulty.summary)},[r,n,s,l,c]}var Mm=class extends ne{constructor(e){super(),re(this,e,c7,l7,ie,{},a7)}},c_=Mm;function u7(i){se(i,"svelte-1uuf6mm",".initiave-tracker-party.svelte-1uuf6mm{padding:0 0.5rem;margin:0}.initiative-tracker-name-container.svelte-1uuf6mm{display:flex;justify-content:space-between;align-items:center;padding:0 0.5rem;margin:0;margin-bottom:0.5rem}.initiative-tracker-name.svelte-1uuf6mm{margin:0}.initiative-tracker-round-container.svelte-1uuf6mm{padding:0 0.5rem}")}function u_(i){let e,t;return{c(){e=b("h2"),t=ae(i[0]),v(e,"class","initiative-tracker-name svelte-1uuf6mm")},m(n,r){A(n,e,r),y(e,t)},p(n,r){r&1&&me(t,n[0])},d(n){n&&T(e)}}}function f_(i){let e,t=i[9].formatDifficultyValue(i[1]?.difficulty?.value,!0)+"",n;return{c(){e=b("span"),n=ae(t),v(e,"class","initiative-tracker-xp encounter-xp")},m(r,s){A(r,e,s),y(e,n)},p(r,s){s&2&&t!==(t=r[9].formatDifficultyValue(r[1]?.difficulty?.value,!0)+"")&&me(n,t)},d(r){r&&T(e)}}}function d_(i){let e,t;return e=new c_({}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function h_(i){let e,t;return{c(){e=b("h4"),t=ae(i[2]),v(e,"class","initiave-tracker-party svelte-1uuf6mm")},m(n,r){A(n,e,r),y(e,t)},p(n,r){r&4&&me(t,n[2])},d(n){n&&T(e)}}}function p_(i){let e,t,n,r,s;return{c(){e=b("div"),t=b("small"),n=b("em"),r=ae("Round "),s=ae(i[4]),v(e,"class","initiative-tracker-round-container svelte-1uuf6mm")},m(o,a){A(o,e,a),y(e,t),y(t,n),y(n,r),y(n,s)},p(o,a){a&16&&me(s,o[4])},d(o){o&&T(e)}}}function f7(i){let e,t,n,r,s,o,a,l=i[0]&&i[0].length&&u_(i),c=i[1]?.difficulty?.value>0&&f_(i),u=i[1]&&d_(i),f=i[2]&&h_(i),d=i[3]&&p_(i);return{c(){e=b("div"),t=b("div"),l&&l.c(),n=R(),c&&c.c(),r=R(),u&&u.c(),s=R(),f&&f.c(),o=R(),d&&d.c(),v(t,"class","initiative-tracker-name-container svelte-1uuf6mm"),v(e,"class","initiatie-tracker-metadata")},m(h,p){A(h,e,p),y(e,t),l&&l.m(t,null),y(t,n),c&&c.m(t,null),y(e,r),u&&u.m(e,null),y(e,s),f&&f.m(e,null),y(e,o),d&&d.m(e,null),a=!0},p(h,[p]){h[0]&&h[0].length?l?l.p(h,p):(l=u_(h),l.c(),l.m(t,n)):l&&(l.d(1),l=null),h[1]?.difficulty?.value>0?c?c.p(h,p):(c=f_(h),c.c(),c.m(t,null)):c&&(c.d(1),c=null),h[1]?u?p&2&&$(u,1):(u=d_(h),u.c(),$(u,1),u.m(e,s)):u&&(Ee(),V(u,1,1,()=>{u=null}),Te()),h[2]?f?f.p(h,p):(f=h_(h),f.c(),f.m(e,o)):f&&(f.d(1),f=null),h[3]?d?d.p(h,p):(d=p_(h),d.c(),d.m(e,null)):d&&(d.d(1),d=null)},i(h){a||($(u),a=!0)},o(h){V(u),a=!1},d(h){h&&T(e),l&&l.d(),c&&c.d(),u&&u.d(),f&&f.d(),d&&d.d()}}}function d7(i,e,t){let n,r,s,o,a,{state:l,name:c,round:u,party:f,difficulty:d}=he;ke(i,l,g=>t(3,o=g)),ke(i,c,g=>t(0,n=g)),ke(i,u,g=>t(4,a=g)),ke(i,f,g=>t(2,s=g));let h=Ye("plugin"),p=Si(h),m=d(h);return ke(i,m,g=>t(1,r=g)),[n,r,s,o,a,l,c,u,f,p,m]}var Im=class extends ne{constructor(e){super(),re(this,e,d7,f7,ie,{},u7)}},m_=Im;var Nm=require("obsidian");function h7(i){se(i,"svelte-1ud8n4x",".saving-container.svelte-1ud8n4x.svelte-1ud8n4x{padding:0.5rem}.saving-encounter.svelte-1ud8n4x.svelte-1ud8n4x{display:flex;align-items:center;justify-content:space-between}.save-buttons.svelte-1ud8n4x.svelte-1ud8n4x{margin-top:1rem;display:flex;justify-content:flex-end;gap:1rem}.save-buttons.svelte-1ud8n4x>div.svelte-1ud8n4x{display:flex;align-items:center}.save-buttons.svelte-1ud8n4x .clickable-icon{margin:0}.save-buttons.svelte-1ud8n4x>.save.svelte-1ud8n4x .clickable-icon.is-disabled{cursor:not-allowed;color:var(--text-faint)}")}function g_(i){let e;return{c(){e=b("span"),e.innerHTML="An encounter by that name already exists. Are you sure?",v(e,"class","checking")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function p7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=i[1]&&g_(i);return{c(){e=b("div"),t=b("div"),n=b("span"),n.textContent="Save encounter as:",r=R(),s=b("input"),o=R(),a=b("div"),g&&g.c(),l=R(),c=b("div"),f=R(),d=b("div"),v(s,"type","text"),v(t,"class","saving-encounter svelte-1ud8n4x"),v(c,"class","save svelte-1ud8n4x"),v(d,"class","cancel svelte-1ud8n4x"),v(a,"class","save-buttons svelte-1ud8n4x"),v(e,"class","saving-container svelte-1ud8n4x")},m(O,_){A(O,e,_),y(e,t),y(t,n),y(t,r),y(t,s),Xe(s,i[0]),y(e,o),y(e,a),g&&g.m(a,null),y(a,l),y(a,c),y(a,f),y(a,d),p||(m=[Y(s,"input",i[6]),Y(s,"input",i[3]),H(u=i[4].call(null,c)),H(h=i[5].call(null,d))],p=!0)},p(O,[_]){_&1&&s.value!==O[0]&&Xe(s,O[0]),O[1]?g||(g=g_(O),g.c(),g.m(a,l)):g&&(g.d(1),g=null)},i:X,o:X,d(O){O&&T(e),g&&g.d(),p=!1,de(m)}}}function m7(i,e,t){let n,{name:r}=he;ke(i,r,p=>t(8,n=p));let s=n,o=Ye("plugin"),a,l=()=>{s?.length&&a.disabled?a.setDisabled(!1):!s?.length&&!a.disabled&&a.setDisabled(!0)},c=!1,u=p=>{a=new Nm.ExtraButtonComponent(p).setIcon(Cl).setDisabled(!(s!=null&&s?.length>0)).onClick(async()=>{s&&s in o.data.encounters&&!c?t(1,c=!0):(o.addEncounter(s,{...he.getEncounterState(),name:s,rollHP:o.data.rollHP,timestamp:Date.now()}),await o.saveSettings(),f("cancel"))})},f=Fe(),d=p=>{new Nm.ExtraButtonComponent(p).setIcon("cross").onClick(()=>{f("cancel")})};function h(){s=this.value,t(0,s)}return[s,c,r,l,u,d,h]}var jm=class extends ne{constructor(e){super(),re(this,e,m7,p7,ie,{},h7)}},O_=jm;var If=require("obsidian");function g7(i){se(i,"svelte-vsvyan",".controls.svelte-vsvyan.svelte-vsvyan{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid var(--background-modifier-border)}.controls.svelte-vsvyan h4.svelte-vsvyan{margin:0}.loading-container.svelte-vsvyan.svelte-vsvyan{display:flex;flex-flow:column nowrap;gap:0.5rem;padding:0.5rem;height:100%}.loading-container.svelte-vsvyan .clickable-icon{margin:0}.encounter-container.svelte-vsvyan.svelte-vsvyan{height:100%;display:flex;flex-flow:column nowrap;gap:1rem;overflow-y:auto}.no-encounters.svelte-vsvyan.svelte-vsvyan{color:var(--text-muted);display:flex;justify-content:center}.encounter.svelte-vsvyan.svelte-vsvyan{display:flex;justify-content:space-between;align-items:center}.encounter-controls.svelte-vsvyan.svelte-vsvyan{display:flex;align-items:center;gap:1rem}")}function v_(i,e,t){let n=i.slice();return n[7]=e[t],n}function y_(i){let e;return{c(){e=b("span"),e.innerHTML="There are no saved encounters.",v(e,"class","no-encounters svelte-vsvyan")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function b_(i,e){let t,n,r=e[7]+"",s,o,a,l,c,u,f,d,h,p,m;return{key:i,first:null,c(){t=b("div"),n=b("span"),s=ae(r),o=R(),a=b("div"),l=b("div"),u=R(),f=b("div"),h=R(),v(a,"class","encounter-controls svelte-vsvyan"),v(t,"class","encounter svelte-vsvyan"),this.first=t},m(g,O){A(g,t,O),y(t,n),y(n,s),y(t,o),y(t,a),y(a,l),y(a,u),y(a,f),y(t,h),p||(m=[H(c=e[3].call(null,l,e[7])),H(d=e[4].call(null,f,e[7]))],p=!0)},p(g,O){e=g,O&1&&r!==(r=e[7]+"")&&me(s,r),c&&Ge(c.update)&&O&1&&c.update.call(null,e[7]),d&&Ge(d.update)&&O&1&&d.update.call(null,e[7])},d(g){g&&T(t),p=!1,de(m)}}}function O7(i){let e,t,n,r,s,o,a,l,c=!i[0]||!Object.keys(i[0])?.length,u,f=[],d=new Map,h,p,m=c&&y_(i),g=fe(Object.keys(i[0])),O=_=>_[7];for(let _=0;_{new If.ExtraButtonComponent(u).setIcon("cross").setTooltip("Cancel")},a=(u,f)=>{new If.ExtraButtonComponent(u).setIcon("open-elsewhere-glyph").setTooltip("Load Encounter").onClick(()=>{he.new(s,n[f]),r("cancel")})},l=(u,f)=>{new If.ExtraButtonComponent(u).setIcon("trash").setTooltip("Delete Encounter").onClick(()=>{s.removeEncounter(f),t(0,n=s.data.encounters)})},c=()=>r("cancel");return t(0,n=s.data.encounters),[n,r,o,a,l,c]}var Zm=class extends ne{constructor(e){super(),re(this,e,v7,O7,ie,{},g7)}},__=Zm;var Qa=require("obsidian");var lr=require("obsidian");function y7(i){se(i,"svelte-1u2coj9",".input.svelte-1u2coj9.svelte-1u2coj9{display:flex;align-items:center;gap:0.5rem}.is-disabled{cursor:not-allowed}.input-status.svelte-1u2coj9.svelte-1u2coj9{display:flex;justify-content:space-between}.input.svelte-1u2coj9>div.svelte-1u2coj9,.input-status.svelte-1u2coj9>div.svelte-1u2coj9,td.svelte-1u2coj9.svelte-1u2coj9:has(> svg),th.svelte-1u2coj9.svelte-1u2coj9:has(> svg){display:flex;align-items:center}.status-list.svelte-1u2coj9.svelte-1u2coj9{display:flex;margin:0.5rem 0 0.1rem 0}.status-list-entries.svelte-1u2coj9.svelte-1u2coj9{display:flex;flex-flow:row wrap;column-gap:0.25rem;margin:0 2rem 0 0.5rem}.left.svelte-1u2coj9.svelte-1u2coj9{text-align:left}.center.svelte-1u2coj9.svelte-1u2coj9{text-align:center}.updating-hp.svelte-1u2coj9.svelte-1u2coj9{display:flex;flex-flow:column;gap:0.5rem}.updating-container.svelte-1u2coj9.svelte-1u2coj9{display:flex;flex-flow:column nowrap;gap:0.5rem}.hp-status.svelte-1u2coj9.svelte-1u2coj9{display:flex;flex-flow:column}.updating-buttons.svelte-1u2coj9.svelte-1u2coj9{display:flex;justify-content:flex-end;gap:1rem;margin-right:0.7rem}td.svelte-1u2coj9>input.svelte-1u2coj9{margin:0}")}function w_(i,e,t){let n=i.slice();return n[39]=e[t][0],n[40]=e[t][1],n[41]=e,n[42]=t,n}function k_(i,e,t){let n=i.slice();return n[0]=e[t],n}function b7(i){let e,t,n;return{c(){e=b("div")},m(r,s){A(r,e,s),t||(n=Y(e,"load",i[36]),t=!0)},p:X,i:X,o:X,d(r){r&&T(e),t=!1,n()}}}function _7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P,k,w=[k7,w7],x=[];function C(D,E){return D[4]=="hp"?0:1}t=C(i,[-1,-1]),n=x[t]=w[t](i);let M=i[4]=="hp"&&P_(i),Z=fe([...i[6].entries()]),Q=[];for(let D=0;D{x[j]=null}),Te(),n=x[t],n?n.p(D,E):(n=x[t]=w[t](D),n.c()),$(n,1),n.m(e,null)),D[4]=="hp"?M||(M=P_(D),M.c(),M.m(a,null)):M&&(M.d(1),M=null),E[0]&120){Z=fe([...D[6].entries()]);let z;for(z=0;z{E=null}),Te())},i(j){C||($(E),C=!0)},o(j){V(E),C=!1},d(j){j&&T(e),Q&&Q.d(),D&&D.d(),E&&E.d(),M=!1,de(Z)}}}function S7(i){let e;return{c(){e=b("small"),e.textContent="Set AC",v(e,"class","label")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function x7(i){let e;return{c(){e=b("small"),e.textContent="Apply damage, (-)healing, (t)temp HP, or (m)max HP",v(e,"class","label")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function P7(i){let e;return{c(){e=b("small"),e.textContent=`Apply status effect to creatures that fail their saving throw`,v(e,"class","label")},m(t,n){A(t,e,n)},d(t){t&&T(e)}}}function S_(i){let e,t,n,r,s,o,a,l,c=fe(i[5]),u=[];for(let d=0;dV(u[d],1,1,()=>{u[d]=null});return{c(){e=b("div"),t=b("div"),r=R(),s=b("div");for(let d=0;d{o[u]=null}),Te(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),$(t,1),t.m(n.parentNode,n))},i(l){r||($(t),r=!0)},o(l){V(t),r=!1},d(l){l&&T(n),o[e].d(l)}}}var E7=function(i){if(i.key==="Escape"){this.value="1";return}if(i.key==="Enter"){i.preventDefault();return}};function T7(i,e,t){let n,r,s,{updating:o,updateTarget:a}=he;ke(i,o,oe=>t(6,s=oe)),ke(i,a,oe=>t(4,n=oe));let l=Ye("plugin"),c=oe=>{(0,lr.setIcon)(oe,an)},u=oe=>{(0,lr.setIcon)(oe,tr)},f=oe=>{(0,lr.setIcon)(oe,Zp)},d,h=oe=>{t(22,d=new lr.ExtraButtonComponent(oe).setIcon("plus-circle"))},p=oe=>{(0,lr.setIcon)(oe,qu)},m=oe=>{(0,lr.setIcon)(oe,"check")},g=oe=>{(0,lr.setIcon)(oe,"cross-in-box")},O="",_="",S=null,P=$e([]);ke(i,P,oe=>t(5,r=oe));let k=()=>{S&&(Ke(P,r=[...r,{...l.data.statuses.find(oe=>oe.name==S)??{name:S,id:xt(),description:""}}],r),t(0,S=null),t(3,w.items=l.data.statuses.filter(oe=>!r.find(we=>we.id==oe.id)).map(oe=>oe.name),w),x.setValue(""))},w,x,C=oe=>{x=new lr.TextComponent(oe),x.onChange(we=>t(0,S=we)),oe.onkeydown=we=>{we.key==="Enter"&&(S?k():Q(!0))},M()},M=()=>{t(3,w=new Uu(l.app,x,l.data.statuses.filter(oe=>!r.find(we=>we.id==oe.id)).map(oe=>oe.name))),w.onSelect(async({item:oe})=>{t(0,S=oe),x.setValue(oe),w.close(),k()})};function Z(oe,we){n==we&&oe.focus()}let Q=oe=>{oe?he.doUpdate(O??"",r,_):he.clearUpdate(),t(1,O=null),t(0,S=null),t(2,_=null),Ke(P,r=[],r),t(3,w=null),Ke(a,n=null,n)};function D(){O=this.value,t(1,O)}let E=function(oe){if(oe.key=="Tab")return!0;if(oe.key=="Enter"||oe.key=="Escape"){Q(oe.key=="Enter");return}if(!/^((t|m)?-?\d*\.?\d*(Backspace|Delete|Arrow\w+)?)$/.test(this.value+oe.key))return oe.preventDefault(),!1},j=function(oe){Ke(P,r=[],r)},z=function(oe,we){r.remove(oe),P.set(r)};function q(){_=this.value,t(2,_)}let G=function(){t(3,w=null)},U=function(oe){if(oe.key=="Tab")return!0;if(oe.key=="Enter"||oe.key=="Escape"){Q(oe.key=="Enter");return}},le=function(oe,we,yt,It){Ke(o,we[yt][1].saved=!oe.saved,s)},xe=function(oe,we,yt,It){Ke(o,we[yt][1].resist=!oe.resist,s)};function ue(oe,we){oe[we][1].customMod=pi(this.value)}let B=function(oe,we){he.setUpdate(oe,we),s.size||(Ke(P,r=[],r),t(3,w=null))},J=()=>Q(!0),pe=()=>Q(!1),Re=()=>Q(!1);return i.$$.update=()=>{i.$$.dirty[0]&4194305&&d&&d.setDisabled(!S)},[S,O,_,w,n,r,s,o,a,l,c,u,f,h,p,m,g,P,k,C,Z,Q,d,D,E,j,z,q,G,U,le,xe,ue,B,J,pe,Re]}var zm=class extends ne{constructor(e){super(),re(this,e,T7,C7,ie,{},y7,[-1,-1])}},T_=zm;var Aa=require("obsidian");var ec=class{constructor(e){this.plugin=e;te(this,"logFile");te(this,"file");te(this,"logging",!1)}async setLogFile(e){this.logFile=e,this.logging=!0,await this.setFile()}getLogFile(){return this.logFile?(0,Aa.normalizePath)(this.logFile):""}async setFile(){let e=await this.adapter.exists((0,Aa.normalizePath)(this.logFile))?await this.vault.getAbstractFileByPath((0,Aa.normalizePath)(this.logFile)):await this.vault.create(this.logFile,"");e instanceof Aa.TFile&&(this.file=e)}getFile(){return this.file}get enabled(){return this.plugin.data.logging}get folder(){return this.plugin.data.logFolder}get vault(){return this.plugin.app.vault}get adapter(){return this.plugin.app.vault.adapter}async new(e){if(this.enabled)if(typeof e=="string")await this.setLogFile(e);else{await this.setLogFile(`${this.folder}/${Date.now()} - ${e.name??"Combat"}.md`),await this.log(`**Combat started ${new Date().toLocaleString()}** `),await this.log("## Players"),await this.log("| Player | Initiative | HP | Statuses |"),await this.log("| --- | :-: | :-: | :-: |");for(let t of e.players.sort((n,r)=>r.initiative-n.initiative))await this.log("|",t.getName().replace("|","\\|"),"|",t.initiative.toString(),"|",t.hp?`${t.hp}/${t.max}`:"-","|",[...t.status.size?[...t.status].map(n=>n.name):["-"]].join(", ").replace("|","\\|"),"|");await this.log("## Creatures"),await this.log("| Creature | Initiative | HP | Statuses |"),await this.log("| --- | :-: | :-: | :-: |");for(let t of e.creatures.sort((n,r)=>r.initiative-n.initiative))await this.log("|",t.getName().replace("|","\\|"),"|",t.initiative.toString(),"|",t.hp?`${t.hp}/${t.max}`:"-","|",[...t.status.size?[...t.status].map(n=>n.name):["-"]].join(", ").replace("|","\\|"),"|");await this.log(` ## Combat Log`),await this.log(` ### Round 1`),await this.log(` ##### ${he.getOrderedCreatures()[0].getName()}'s turn`)}}async log(...e){this.enabled&&this.file&&(await this.adapter.exists(this.logFile)||await this.setLogFile(this.logFile),await this.vault.append(this.file,`${e.join(" ")} `))}join(e,t="and"){return e.length==1?e[0]:`${e.slice(0,-1).join(", ")} ${t} ${e.slice(-1)}`}logUpdate(e){let t=[];for(let n of e){let r=[];if(n.hp&&(n.temp?r.push(`${n.name} gained ${(-1*n.hp).toString()} temporary HP`):n.max?n.hp<0?r.push(`${n.name} took ${(-1*n.hp).toString()} max HP damage${n.unc?" and died":""}`):r.push(`${n.name} gained ${n.hp.toString()} max HP`):n.hp<0?r.push(`${n.name} took ${(-1*n.hp).toString()} damage${n.unc?" and was knocked unconscious":""}`):n.hp>0&&r.push(`${n.name} was healed for ${n.hp.toString()} HP`)),n.ac&&(r.length&&!n.status?r.push("and"):r.length&&r.push(","),n.ac_add?r.push(`${n.name} added ${n.ac} to AC`):r.push(`${n.name} AC set to ${n.ac?n.ac:"be blank"}`)),n.status){r.length?r.push("and"):r.push(n.name);let s;n.status.length>1?(s=[n.status.slice(0,n.status.length-1).join(", ")],s.push(n.status[n.status.length-1])):s=[n.status[0]],n.saved?r.push(`saved against ${s.join(" and ")}`):r.push(`took ${s.join(" and ")} status`)}if(n.remove_status){r.length?r.push("and"):r.push(n.name);let s;n.remove_status.length>1?(s=[n.remove_status.slice(0,n.remove_status.length-1).join(", ")],s.push(n.remove_status[n.remove_status.length-1])):s=[n.remove_status[0]],r.push(`relieved of ${s.join(" and ")} status`)}t.push(r.join(" "))}this.log(`${t.join(". ")}.`)}};var Da=require("obsidian");var hn=require("obsidian");var wi=require("obsidian");function A7(i){se(i,"svelte-1rjv45j",".create-new.svelte-1rjv45j>.svelte-1rjv45j{display:grid;grid-template-columns:33% 66%;margin-bottom:0.5rem}.context-buttons.svelte-1rjv45j.svelte-1rjv45j{display:flex;justify-content:flex-end;align-items:center;grid-gap:0.125rem}.cancel-button.svelte-1rjv45j.svelte-1rjv45j{color:var(--text-faint)}.initiative.svelte-1rjv45j.svelte-1rjv45j{position:relative}.initiative.svelte-1rjv45j>.dice.svelte-1rjv45j{position:absolute;right:0.25rem;top:50%;transform:translateY(-50%)}")}function A_(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S;return{c(){e=b("div"),t=b("label"),t.textContent="Static Initiative",n=R(),r=b("div"),o=R(),a=b("div"),l=b("label"),l.textContent="Hidden",c=R(),u=b("div"),d=R(),h=b("div"),p=b("label"),p.textContent="Friendly",m=R(),g=b("div"),v(t,"for","add-mod"),v(e,"class","svelte-1rjv45j"),v(l,"for","add-mod"),v(a,"class","svelte-1rjv45j"),v(p,"for","add-mod"),v(h,"class","svelte-1rjv45j")},m(P,k){A(P,e,k),y(e,t),y(e,n),y(e,r),A(P,o,k),A(P,a,k),y(a,l),y(a,c),y(a,u),A(P,d,k),A(P,h,k),y(h,p),y(h,m),y(h,g),_||(S=[H(s=i[14].call(null,r)),H(f=i[13].call(null,u)),H(O=i[15].call(null,g))],_=!0)},p:X,d(P){P&&(T(e),T(o),T(a),T(d),T(h)),_=!1,de(S)}}}function D_(i){let e,t,n,r,s,o;function a(u,f){return u[7]?Q7:D7}let l=a(i,-1),c=l(i);return{c(){e=b("div"),t=b("div"),r=R(),c.c(),v(t,"class","add-button cancel-button svelte-1rjv45j"),v(e,"class","context-buttons svelte-1rjv45j")},m(u,f){A(u,e,f),y(e,t),y(e,r),c.m(e,null),s||(o=H(n=i[10].call(null,t)),s=!0)},p(u,f){l!==(l=a(u,f))&&(c.d(1),c=l(u),c&&(c.c(),c.m(e,null)))},d(u){u&&T(e),c.d(),s=!1,o()}}}function D7(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","add-button")},m(s,o){A(s,e,o),n||(r=H(t=i[8].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function Q7(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","add-button")},m(s,o){A(s,e,o),n||(r=H(t=i[9].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function R7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P,k,w,x,C,M,Z,Q,D,E,j,z,q,G,U,le,xe,ue,B,J,pe,Re,oe=i[4],we,yt,It,ot,Nt,Sr,nn,$t,Tt=A_(i),at=!i[3]&&!wi.Platform.isMobile&&D_(i);return{c(){e=b("div"),t=b("div"),n=b("div"),r=b("label"),r.textContent="Creature",s=R(),o=b("div"),l=R(),c=b("div"),u=b("label"),u.textContent="Display Name",f=R(),d=b("input"),h=R(),p=b("div"),m=b("label"),m.textContent="HP",g=R(),O=b("input"),_=R(),S=b("div"),P=b("label"),P.textContent="Hit Dice",k=R(),w=b("input"),x=R(),C=b("div"),M=b("label"),M.textContent="AC",Z=R(),Q=b("input"),D=R(),E=b("div"),j=b("label"),j.textContent="Modifier",z=R(),q=b("input"),G=R(),U=b("div"),le=b("label"),le.textContent="Initiative",xe=R(),ue=b("input"),B=R(),J=b("div"),Re=R(),Tt.c(),we=R(),yt=b("div"),It=b("label"),It.textContent="Amount",ot=R(),Nt=b("input"),Sr=R(),at&&at.c(),v(r,"for","add-name"),v(o,"id","add-name"),v(n,"class","svelte-1rjv45j"),v(u,"for","add-display"),v(d,"id","add-display"),v(d,"type","text"),v(d,"name","display"),v(d,"tabindex","0"),v(c,"class","svelte-1rjv45j"),v(m,"for","add-hp"),v(O,"id","add-hp"),v(O,"type","number"),v(O,"name","hp"),v(O,"tabindex","0"),v(p,"class","svelte-1rjv45j"),v(P,"for","hit-dice"),v(w,"id","hit-dice"),v(w,"type","text"),v(w,"name","hitdice"),v(w,"tabindex","0"),v(S,"class","svelte-1rjv45j"),v(M,"for","add-ac"),v(Q,"id","add-ac"),v(Q,"name","ac"),v(Q,"type","text"),v(Q,"tabindex","0"),v(C,"class","svelte-1rjv45j"),v(j,"for","add-mod"),v(q,"id","add-mod"),v(q,"type","text"),v(q,"name","add-mod"),v(q,"tabindex","0"),v(E,"class","svelte-1rjv45j"),v(le,"for","add-init"),v(ue,"id","add-init"),v(ue,"type","number"),v(ue,"name","initiative"),v(ue,"tabindex","0"),v(J,"class","dice svelte-1rjv45j"),v(U,"class","initiative svelte-1rjv45j"),v(It,"for","add-init"),v(Nt,"id","add-init"),v(Nt,"type","number"),v(Nt,"name","initiative"),v(Nt,"tabindex","0"),v(yt,"class","amount svelte-1rjv45j"),v(t,"class","create-new svelte-1rjv45j"),v(e,"class","initiative-tracker-editor")},m(dt,gt){A(dt,e,gt),y(e,t),y(t,n),y(n,r),y(n,s),y(n,o),y(t,l),y(t,c),y(c,u),y(c,f),y(c,d),Xe(d,i[4].display),i[19](d),y(t,h),y(t,p),y(p,m),y(p,g),y(p,O),Xe(O,i[4].hp),y(t,_),y(t,S),y(S,P),y(S,k),y(S,w),Xe(w,i[4].hit_dice),y(t,x),y(t,C),y(C,M),y(C,Z),y(C,Q),Xe(Q,i[4].ac),y(t,D),y(t,E),y(E,j),y(E,z),y(E,q),Xe(q,i[5]),y(t,G),y(t,U),y(U,le),y(U,xe),y(U,ue),Xe(ue,i[4].initiative),y(U,B),y(U,J),y(t,Re),Tt.m(t,null),y(t,we),y(t,yt),y(yt,It),y(yt,ot),y(yt,Nt),Xe(Nt,i[0]),y(e,Sr),at&&at.m(e,null),nn||($t=[H(a=i[12].call(null,o)),Y(d,"input",i[18]),Y(O,"input",i[20]),Y(w,"input",i[21]),Y(Q,"input",i[22]),Y(Q,"change",i[23]),Y(q,"input",i[24]),Y(ue,"input",i[25]),H(pe=i[11].call(null,J)),Y(Nt,"input",i[26])],nn=!0)},p(dt,[gt]){gt&16&&d.value!==dt[4].display&&Xe(d,dt[4].display),gt&16&&pi(O.value)!==dt[4].hp&&Xe(O,dt[4].hp),gt&16&&w.value!==dt[4].hit_dice&&Xe(w,dt[4].hit_dice),gt&16&&Q.value!==dt[4].ac&&Xe(Q,dt[4].ac),gt&32&&q.value!==dt[5]&&Xe(q,dt[5]),gt&16&&pi(ue.value)!==dt[4].initiative&&Xe(ue,dt[4].initiative),gt&16&&ie(oe,oe=dt[4])?(Tt.d(1),Tt=A_(dt),Tt.c(),Tt.m(t,we)):Tt.p(dt,gt),gt&1&&pi(Nt.value)!==dt[0]&&Xe(Nt,dt[0]),!dt[3]&&!wi.Platform.isMobile?at?at.p(dt,gt):(at=D_(dt),at.c(),at.m(e,null)):at&&(at.d(1),at=null)},i:X,o:X,d(dt){dt&&T(e),i[19](null),Tt.d(dt),at&&at.d(),nn=!1,de($t)}}}function M7(i,e,t){let n,r=X,s=()=>(r(),r=Ii(h,B=>t(7,n=B)),h),o,a=X,l=()=>(a(),a=Ii(d,B=>t(17,o=B)),d);i.$$.on_destroy.push(()=>r()),i.$$.on_destroy.push(()=>a());let c=new Ne({}),{amount:u=1}=e,{plugin:f}=e,{adding:d}=e;l();let{editing:h}=e;s();let{isEditing:p}=e;h.subscribe(B=>{B&&t(4,c=B)});let m=JSON.stringify(c.modifier??0),g=m,O=B=>{new wi.ExtraButtonComponent(B).setTooltip("Add Creature").setIcon("plus").onClick(async()=>{if(!c||!c.name||!c.name?.length){new wi.Notice("Enter a name!");return}try{t(4,c.modifier=JSON.parse(`${m}`),c)}catch{console.warn("Initiative Tracker: Non-parseable modifier provided to creature."),t(4,c.modifier=JSON.parse(g),c)}c.modifier||t(4,c.modifier=JSON.parse(g),c),(Array.isArray(c.modifier)&&!c.modifier.every(pe=>!isNaN(Number(pe)))||isNaN(Number(c.modifier)))&&(console.warn("Initiative Tracker: Non-numeric modifier provided to creature."),t(4,c.modifier=0,c)),(c.initiative<=0||c.initiative==null||isNaN(c.initiative))&&t(4,c.initiative=await f.getInitiativeValue(c.modifier),c);let J=o.findIndex(([pe])=>Rs(pe,c));J>-1?Ke(d,o[J][1]+=u,o):o.push([c,u]),d.set(o),Ke(h,n=null,n),t(4,c=new Ne({}))})},_=B=>{new wi.ExtraButtonComponent(B).setTooltip("Add Creature").setIcon("save").onClick(async()=>{if(!c||!c.name||!c.name?.length){new wi.Notice("Enter a name!");return}c.modifier||t(4,c.modifier=0,c),(c.initiative<=0||c.initiative==null||isNaN(c.initiative))&&t(4,c.initiative=await f.getInitiativeValue(c.modifier),c);let J=o.findIndex(([pe])=>pe!=c&&Rs(pe,c));if(J>-1&&await R_(app,`This will merge ${c.name} with ${o[J][0].name}.`)){let pe=o.findIndex(([Re])=>Re==c);Ke(d,o[J][1]+=o[pe][1],o),o.splice(pe,1)}d.set(o),Ke(h,n=null,n),t(4,c=new Ne({}))})},S=B=>{new wi.ExtraButtonComponent(B).setTooltip("Cancel").setIcon("reset").onClick(()=>{t(4,c=new Ne({}))})},P=B=>{new wi.ExtraButtonComponent(B).setIcon(Ts).setTooltip("Roll Initiative").onClick(async()=>{t(4,c.initiative=await f.getInitiativeValue(c.modifier),c)})},k,w,x=B=>{k=new wi.TextComponent(B).setValue(c.name).onChange(J=>t(4,c.name=J,c))},C,M=()=>{C=new Dl(f.app,k,f.bestiary),C.onSelect(async B=>{B.item&&(t(4,c=Ne.from(B.item)),t(4,c.initiative=await f.getInitiativeValue(c.modifier),c),k.setValue(c.name)),C.close()})};sf(()=>{p?setImmediate(()=>{w.focus(),M()}):M()});let Z=B=>{new wi.ToggleComponent(B).setValue(c.hidden).onChange(J=>t(4,c.hidden=J,c))},Q=B=>{new wi.ToggleComponent(B).setValue(c.static).onChange(J=>t(4,c.static=J,c))},D=B=>{new wi.ToggleComponent(B).setValue(c.friendly).onChange(J=>t(4,c.friendly=J,c))};function E(){c.display=this.value,t(4,c)}function j(B){mi[B?"unshift":"push"](()=>{w=B,t(6,w)})}function z(){c.hp=pi(this.value),t(4,c)}function q(){c.hit_dice=this.value,t(4,c)}function G(){c.ac=this.value,t(4,c)}let U=()=>t(4,c.dirty_ac=!0,c);function le(){m=this.value,t(5,m)}function xe(){c.initiative=pi(this.value),t(4,c)}function ue(){u=pi(this.value),t(0,u)}return i.$$set=B=>{"amount"in B&&t(0,u=B.amount),"plugin"in B&&t(16,f=B.plugin),"adding"in B&&l(t(1,d=B.adding)),"editing"in B&&s(t(2,h=B.editing)),"isEditing"in B&&t(3,p=B.isEditing)},i.$$.update=()=>{i.$$.dirty&131089&&wi.Platform.isMobile&&o.splice(0,1,[c,u])},[u,d,h,p,c,m,w,n,O,_,S,P,x,Z,Q,D,f,o,E,j,z,q,G,U,le,xe,ue]}var qm=class extends ne{constructor(e){super(),re(this,e,M7,R7,ie,{amount:0,plugin:16,adding:1,editing:2,isEditing:3},A7)}},Q_=qm;var cr=require("obsidian");function I7(i){se(i,"svelte-uvd81j",".initiative-tracker-list.svelte-uvd81j{display:flex;flex:1 1 auto;flex-flow:column nowrap;height:0px;overflow:scroll}.creature.svelte-uvd81j{border-radius:0.5rem;padding:0.5rem}.creature.svelte-uvd81j:hover{background-color:var(--background-secondary)}.creature-metadata.svelte-uvd81j{display:flex;align-items:center;gap:0.5rem}.creature-amount.svelte-uvd81j{margin-left:auto;display:grid;grid-template-columns:1fr 1fr 1fr 1fr;align-items:center;text-align:center}.creature-data.svelte-uvd81j{--icon-size:10px;display:flex;align-items:center;gap:0.375rem}.list-header.svelte-uvd81j{margin-top:0;margin-bottom:0.5rem}")}function M_(i,e,t){let n=i.slice();return n[21]=e[t][0],n[22]=e[t][1],n[24]=t,n}function N7(i){let e;return{c(){e=b("span"),e.textContent="Add a creature."},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function j7(i){let e,t=fe(i[3]),n=[];for(let r=0;r(r(),r=Ii(c,D=>t(3,n=D)),c),o,a=X,l=()=>(a(),a=Ii(u,D=>t(4,o=D)),u);i.$$.on_destroy.push(()=>r()),i.$$.on_destroy.push(()=>a());let{adding:c}=e;s();let{editing:u}=e;l();let{rollHP:f}=e,d=(D,E)=>{new cr.ExtraButtonComponent(D).setIcon("minus")},h=(D,E)=>{if(n[E][1]-1<1){O(D,E);return}Ke(c,n[E][1]-=1,n),c.set(n)},p=(D,E)=>{new cr.ExtraButtonComponent(D).setIcon("plus")},m=(D,E)=>{Ke(c,n[E][1]+=1,n),c.set(n)},g=(D,E)=>{new cr.ExtraButtonComponent(D).setIcon("trash")},O=(D,E)=>{n.splice(E,1),c.set(n)},_=D=>{(0,cr.setIcon)(D,an)},S=D=>{(0,cr.setIcon)(D,as)},P=D=>{(0,cr.setIcon)(D,tr)},k=D=>{(0,cr.setIcon)(D,wo)},w=D=>{(0,cr.setIcon)(D,Jn)},x=D=>{(0,cr.setIcon)(D,er)},C=(D,E)=>h(E,D),M=(D,E)=>m(E,D),Z=(D,E)=>O(E,D),Q=D=>Ke(u,o=D,o);return i.$$set=D=>{"adding"in D&&s(t(0,c=D.adding)),"editing"in D&&l(t(1,u=D.editing)),"rollHP"in D&&t(2,f=D.rollHP)},[c,u,f,n,o,d,h,p,m,g,O,_,S,P,k,w,x,C,M,Z,Q]}var Lm=class extends ne{constructor(e){super(),re(this,e,L7,q7,ie,{adding:0,editing:1,rollHP:2},I7)}},Z_=Lm;function $7(i){se(i,"svelte-caa9tv",".initiative-tracker-creator.svelte-caa9tv{margin-top:1rem;display:grid;grid-template-columns:1fr 1fr;gap:0.5rem}.initiative-tracker-creator.editing.svelte-caa9tv{grid-template-columns:1fr}.buttons.svelte-caa9tv{display:flex;margin-left:auto;justify-content:flex-end;gap:0.5rem}div.disabled.svelte-caa9tv>button{cursor:not-allowed}.creator-list.svelte-caa9tv{display:flex;justify-content:space-between;flex-flow:column nowrap;gap:0.5rem;margin-bottom:0.5rem}")}function z_(i){let e,t,n,r,s,o,a,l,c,u;return t=new Z_({props:{adding:i[4],editing:i[5],rollHP:i[2]}}),{c(){e=b("div"),ye(t.$$.fragment),n=R(),r=b("div"),s=b("input"),o=R(),a=b("label"),a.textContent="Roll for HP",v(s,"type","checkbox"),v(s,"name","roll-hp"),v(s,"id","roll-hp"),v(a,"for","roll-hp"),v(e,"class","creator-list svelte-caa9tv")},m(f,d){A(f,e,d),Oe(t,e,null),y(e,n),y(e,r),y(r,s),s.checked=i[2],y(r,o),y(r,a),l=!0,c||(u=Y(s,"change",i[9]),c=!0)},p(f,d){let h={};d&4&&(h.rollHP=f[2]),t.$set(h),d&4&&(s.checked=f[2])},i(f){l||($(t.$$.fragment,f),l=!0)},o(f){V(t.$$.fragment,f),l=!1},d(f){f&&T(e),ve(t),c=!1,u()}}}function F7(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p;n=new Q_({props:{plugin:i[0],editing:i[5],adding:i[4],isEditing:i[1]}});let m=!i[1]&&!hn.Platform.isMobile&&z_(i);return{c(){e=b("div"),t=b("div"),ye(n.$$.fragment),r=R(),m&&m.c(),s=R(),o=b("div"),a=b("div"),c=R(),u=b("div"),v(t,"class","initiative-tracker-creator svelte-caa9tv"),ge(t,"editing",i[1]||hn.Platform.isMobile),v(u,"class","svelte-caa9tv"),ge(u,"disabled",!i[3].length&&!i[1]&&!hn.Platform.isMobile),v(o,"class","buttons svelte-caa9tv"),v(e,"class","initiative-tracker-creator-container"),ge(e,"mobile",hn.Platform.isMobileApp)},m(g,O){A(g,e,O),y(e,t),Oe(n,t,null),y(t,r),m&&m.m(t,null),y(e,s),y(e,o),y(o,a),y(o,c),y(o,u),d=!0,h||(p=[H(l=i[6].call(null,a)),H(f=i[7].call(null,u))],h=!0)},p(g,[O]){let _={};O&1&&(_.plugin=g[0]),O&2&&(_.isEditing=g[1]),n.$set(_),!g[1]&&!hn.Platform.isMobile?m?(m.p(g,O),O&2&&$(m,1)):(m=z_(g),m.c(),$(m,1),m.m(t,null)):m&&(Ee(),V(m,1,1,()=>{m=null}),Te()),(!d||O&2)&&ge(t,"editing",g[1]||hn.Platform.isMobile),(!d||O&10)&&ge(u,"disabled",!g[3].length&&!g[1]&&!hn.Platform.isMobile)},i(g){d||($(n.$$.fragment,g),$(m),d=!0)},o(g){V(n.$$.fragment,g),V(m),d=!1},d(g){g&&T(e),ve(n),m&&m.d(),h=!1,de(p)}}}function B7(i,e,t){let n,r,s=Fe(),{plugin:o}=e,{isEditing:a=!1}=e,{creature:l=null}=e,c=o.data.rollHP,u=$e([]);ke(i,u,m=>t(3,n=m));let f=$e(l);ke(i,f,m=>t(10,r=m));let d=m=>{new hn.ButtonComponent(m).setCta().setButtonText("Cancel").onClick(()=>{s("close")})},h=m=>{new hn.ButtonComponent(m).setButtonText(a?"Save":"Add to Encounter").onClick(async()=>{if(!(!n.length&&!a&&!hn.Platform.isMobile)){if(a)r.hp!=l.max&&t(8,l.max=t(8,l.current_max=r.hp,l),l),l.dirty_ac&&(t(8,l.current_ac=r.ac,l),t(8,l.dirty_ac=!1,l)),he.replace(l,r);else{let g=n.flatMap(([O,_])=>[...Array(_).keys()].map(S=>Ne.new(O)));he.add(o,c,...g)}if(l?.player&&l?.path){let g=await o.app.vault.getAbstractFileByPath(l.path);g&&g instanceof hn.TFile&&o.app.fileManager.processFrontMatter(g,O=>{O.ac=l.ac,O.hp=l.max,O.level=l.level,O.modifier=l.modifier})}s("close")}})};function p(){c=this.checked,t(2,c)}return i.$$set=m=>{"plugin"in m&&t(0,o=m.plugin),"isEditing"in m&&t(1,a=m.isEditing),"creature"in m&&t(8,l=m.creature)},[o,a,c,n,u,f,d,h,l,p]}var $m=class extends ne{constructor(e){super(),re(this,e,B7,F7,ie,{plugin:0,isEditing:1,creature:8},$7)}},q_=$m;var Nf=class extends Da.Modal{constructor(t,n){super(t.app);this.plugin=t;this.creature=n}onOpen(){this.containerEl.addClass("initiative-tracker-modal"),new q_({target:this.contentEl,props:{plugin:this.plugin,...this.creature?{creature:this.creature,isEditing:!0}:{}}}).$on("close",()=>this.close())}};async function R_(i,e,t={cta:"Yes",secondary:"No"}){return new Promise((n,r)=>{try{let s=new Fm(i,e,t);s.onClose=()=>{n(s.confirmed)},s.open()}catch{r()}})}var Fm=class extends Da.Modal{constructor(t,n,r){super(t);this.text=n;this.buttons=r;te(this,"confirmed",!1)}async display(){this.containerEl.addClass("initiative-tracker-modal"),this.contentEl.empty(),this.contentEl.addClass("confirm-modal"),this.contentEl.createEl("p",{text:this.text});let t=this.contentEl.createDiv("confirm-buttons");new Da.ButtonComponent(t).setButtonText(this.buttons.cta).setCta().onClick(()=>{this.confirmed=!0,this.close()}),new Da.ButtonComponent(t).setButtonText(this.buttons.secondary).onClick(()=>{this.close()})}onOpen(){this.display()}};var Bm=require("obsidian");function V7(i){se(i,"svelte-1yp1f6q",".obsidian-initiative-tracker.svelte-1yp1f6q{margin:0.5rem;min-width:180px;overflow-y:auto}.add-creature-container.svelte-1yp1f6q{display:flex;flex-flow:column nowrap;justify-content:flex-start;margin-right:0.5rem}.context-container.svelte-1yp1f6q{display:flex;flex-flow:row nowrap;justify-content:space-between}.copy-button.svelte-1yp1f6q{width:min-content;opacity:0.25}.copy-button.svelte-1yp1f6q:hover{opacity:1}.add-button.svelte-1yp1f6q{width:min-content}.add-button.svelte-1yp1f6q .clickable-icon{margin:0}")}function W7(i){let e,t,n,r,s,o,a,l,c;return{c(){e=b("div"),t=b("div"),n=b("div"),s=R(),o=b("div"),v(n,"class","copy-button svelte-1yp1f6q"),v(o,"class","add-button svelte-1yp1f6q"),v(t,"class","context-container svelte-1yp1f6q"),v(e,"class","add-creature-container svelte-1yp1f6q")},m(u,f){A(u,e,f),y(e,t),y(t,n),y(t,s),y(t,o),l||(c=[H(r=i[7].call(null,n)),H(a=i[6].call(null,o)),Y(o,"click",i[18])],l=!0)},p:X,i:X,o:X,d(u){u&&T(e),l=!1,de(c)}}}function X7(i){let e,t;return e=new __({}),e.$on("cancel",i[17]),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function Y7(i){let e,t;return e=new O_({}),e.$on("cancel",i[16]),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function U7(i){let e,t,n,r,s,o,a,l,c,u,f,d;t=new gb({}),t.$on("save",i[9]),t.$on("load",i[10]),t.$on("add-creatures",i[11]),t.$on("player-view",i[12]),t.$on("open-map",i[13]),r=new m_({}),o=new o_({}),o.$on("edit",i[14]),o.$on("open-combatant",i[15]),l=new T_({});let h=[Y7,X7,W7],p=[];function m(g,O){return g[1]?0:g[2]?1:2}return u=m(i,-1),f=p[u]=h[u](i),{c(){e=b("div"),ye(t.$$.fragment),n=R(),ye(r.$$.fragment),s=R(),ye(o.$$.fragment),a=R(),ye(l.$$.fragment),c=R(),f.c(),v(e,"class","obsidian-initiative-tracker svelte-1yp1f6q")},m(g,O){A(g,e,O),Oe(t,e,null),y(e,n),Oe(r,e,null),y(e,s),Oe(o,e,null),y(e,a),Oe(l,e,null),y(e,c),p[u].m(e,null),d=!0},p(g,[O]){let _=u;u=m(g,O),u===_?p[u].p(g,O):(Ee(),V(p[_],1,1,()=>{p[_]=null}),Te(),f=p[u],f?f.p(g,O):(f=p[u]=h[u](g),f.c()),$(f,1),f.m(e,null))},i(g){d||($(t.$$.fragment,g),$(r.$$.fragment,g),$(o.$$.fragment,g),$(l.$$.fragment,g),$(f),d=!0)},o(g){V(t.$$.fragment,g),V(r.$$.fragment,g),V(o.$$.fragment,g),V(l.$$.fragment,g),V(f),d=!1},d(g){g&&T(e),ve(t),ve(r),ve(o),ve(l),p[u].d()}}}function H7(i,e,t){let n,r,s,{plugin:o}=e,{data:a}=he;ke(i,a,C=>t(8,s=C)),he.setData(o.data),he.setLogger(new ec(o)),o.data.state?he.new(o,o.data.state):(he.setParty(o.data.defaultParty,o),he.roll(o));let{ordered:l}=he;ke(i,l,C=>t(20,r=C)),Vi("plugin",o);let c=!1,u=!1,f=C=>{let M=new Nf(o,C);M.onClose=()=>{},M.open()},d=C=>{new Qa.ExtraButtonComponent(C).setTooltip("Add Creature").setIcon(Rp)},h=C=>{new Qa.ExtraButtonComponent(C).setTooltip("Copy Initiative Order").setIcon(qp).onClick(async()=>{let M=r.map(Z=>`${Z.initiative} ${Z.name}`).join(` `);try{await navigator.clipboard.writeText(M),new Qa.Notice("Initiative order copied to clipboard.")}catch{new Qa.Notice("Initiative order could not be copied to clipboard.")}})},p=()=>t(1,c=!0),m=()=>t(2,u=!0),g=()=>f();function O(C){ht.call(this,i,C)}function _(C){ht.call(this,i,C)}let S=C=>f(C.detail),P=C=>o.openCombatant(C.detail),k=()=>t(1,c=!1),w=()=>t(2,u=!1),x=()=>f();return i.$$set=C=>{"plugin"in C&&t(0,o=C.plugin)},i.$$.update=()=>{i.$$.dirty&256&&(n=s.displayDifficulty)},[o,c,u,a,l,f,d,h,s,p,m,g,O,_,S,P,k,w,x]}var Vm=class extends ne{constructor(e){super(),re(this,e,H7,U7,ie,{plugin:0},V7)}},L_=Vm;var Ra=class extends kn.ItemView{constructor(t,n){super(t);this.leaf=t;this.plugin=n;te(this,"ui");te(this,"playerViewOpened",!1);this.plugin.data.state?.creatures?.length}async onOpen(){this.ui=new L_({target:this.contentEl,props:{plugin:this.plugin}}),this.ui.$on("player-view",()=>this.openPlayerView())}getViewType(){return bo}getDisplayText(){return"Initiative Tracker"}getIcon(){return Qp}get pcs(){return[]}get npcs(){return[]}getExistingPlayerView(){let t=this.plugin.app.workspace.getLeavesOfType(_o);if(t.length)return t[0].view}async getPlayerView(){let t=this.getExistingPlayerView();if(t)return this.app.workspace.revealLeaf(t.leaf),t;let n=this.app.workspace.getLeaf("window");return await n.setViewState({type:_o}),await this.app.workspace.setActiveLeaf(n,{focus:!0}),n.view}async openPlayerView(){await this.getPlayerView(),this.playerViewOpened=!0}},tc=class extends kn.ItemView{constructor(t,n){super(t);this.plugin=n;te(this,"buttonEl",this.contentEl.createDiv("creature-view-button"));te(this,"statblockEl",this.contentEl.createDiv("creature-statblock-container"));this.load(),this.containerEl.addClass("creature-view-container"),this.containerEl.on("mouseover","a.internal-link",(0,kn.debounce)(r=>app.workspace.trigger("link-hover",{},r.target,r.target.dataset.href,"initiative-tracker "),10)),this.containerEl.on("click","a.internal-link",r=>app.workspace.openLinkText(r.target.dataset.href,"initiative-tracker"))}onload(){new kn.ExtraButtonComponent(this.buttonEl).setIcon("cross").setTooltip("Close Statblock").onClick(async()=>{await this.render(),this.app.workspace.trigger("initiative-tracker:stop-viewing")})}onunload(){this.app.workspace.trigger("initiative-tracker:stop-viewing")}async render(t){if(this.statblockEl.empty(),!t){this.statblockEl.createEl("em",{text:"Select a creature to view it here."});return}if(t["statblock-link"]&&(this.plugin.data.preferStatblockLink||!this.plugin.canUseStatBlocks))await this.renderEmbed(t.getStatblockLink());else if(this.plugin.canUseStatBlocks){let n=window.FantasyStatblocks.render(t.creature,this.statblockEl,t.display);this.addChild(n)}else this.statblockEl.createEl("em",{text:"Install the TTRPG Statblocks plugin or add a statblock-link to your monster to use this feature!"})}async renderEmbed(t){this.plugin.canUseStatBlocks&&window.FantasyStatblocks.isStatblockLink?.(t)&&(t=window.FantasyStatblocks.parseStatblockLink(t)),/\[.+\]\(.+\)/.test(t)?[,t]=t.match(/\[.+?\]\((.+?)\)/):/\[\[.+\]\]/.test(t)&&([,t]=t.match(/\[\[(.+?)(?:\|.+?)?\]\]/));let{path:n,subpath:r}=(0,kn.parseLinktext)(t),s=this.app.metadataCache.getFirstLinkpathDest(n,"/"),o=`Oops! Something is wrong with your statblock-link:
${t}`;if(s){let a=await this.app.vault.cachedRead(s);if(r&&a){let l=app.metadataCache.getFileCache(s),c=(0,kn.resolveSubpath)(l,r);c&&(o=a.slice(c.start.offset,c.end.offset))}else a&&(o=a)}await kn.MarkdownRenderer.render(this.app,o,this.statblockEl.createDiv("markdown-rendered"),n,this)}getDisplayText(){return"Combatant"}getIcon(){return Tp}getViewType(){return pa}};var aC=require("obsidian");var _U=$e(0);function G7(){let i=$e([]),{subscribe:e,set:t,update:n}=i,r=oi(i,a=>a.filter(l=>l.isPlayer)),s=oi(i,a=>a.filter(l=>l.isPlayer==!1)),o=oi(i,a=>[...a].reduce((l,c)=>l+c.count,0));return{subscribe:e,party:r,generics:s,count:o,modifier:oi(o,a=>a<3?1:a>5?-1:0),average:oi(i,a=>a.length?a.reduce((l,c)=>l+(c.enabled?c.level:0),0)/a.length:0),add:a=>n(l=>((!a.count||a.count<=0)&&(a.count=1),l.push(a),l)),addFromState:a=>n(l=>{let c=a;return c.isPlayer=!0,(!c.count||c.count<=0)&&(c.count=1),l.push(c),l}),remove:a=>n(l=>(l=l.filter(c=>c!=a),l)),delete:a=>n(l=>(l=l.filter(c=>c!=a),l)),set:(a,l)=>n(c=>{let u=c.find(f=>f==a);return u.count=l,c}),setLevel:(a,l)=>n(c=>{let u=c.find(f=>f==a);return u.level=l,c}),switchParty:a=>{n(l=>(l=[...a,...ct(s)],l))},empty:()=>t([]),toggleEnabled:a=>n(l=>{let c=l.find(u=>u==a);return c.enabled=!c.enabled,l})}}var ji=G7();var ic=require("obsidian");function K7(){let i=$e(new Map),{subscribe:e,set:t,update:n}=i;return{players:ji,subscribe:e,add:r=>n(s=>(s.set(r,(s.get(r)??0)+1),s)),remove:r=>n(s=>{let o=s.get(r);return o&&(o==1&&s.delete(r),o>1&&s.set(r,o-1)),s}),delete:r=>n(s=>(s.delete(r),s)),set:(r,s)=>n(o=>(o.set(r,s),o)),setMultiple:r=>n(s=>{for(let[o,a]of r)s.set(o,a);return s}),empty:()=>t(new Map),update:r=>n(s=>(s.set(r,s.get(r)??1),s))}}var ii=K7();function J7(i){let e;return{c(){e=ae(i[0])},m(t,n){A(t,e,n)},p(t,[n]){n&1&&me(e,t[0])},i:X,o:X,d(t){t&&T(e)}}}function eA(i,e,t){let{str:n=We}=e;return i.$$set=r=>{"str"in r&&t(0,n=r.str)},[n]}var Wm=class extends ne{constructor(e){super(),re(this,e,eA,J7,ie,{str:0})}},jf=Wm;function tA(i){se(i,"svelte-ywuffm",`.creature-name-container.svelte-ywuffm{display:grid;grid-template-areas:"add name" ". desc";justify-content:flex-start;align-items:center;grid-template-columns:auto 1fr}.creature-name.svelte-ywuffm{cursor:pointer;display:flex;justify-content:space-between}.setting-item-description.svelte-ywuffm{grid-area:desc}`)}function $_(i,e,t){let n=i.slice();return n[14]=e[t],n}function F_(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon"),v(e,"aria-label",t="This creature is significantly under the average party level and might not contribute much to the fight.")},m(o,a){A(o,e,a),r||(s=H(n=i[8].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function B_(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon"),v(e,"aria-label",t="This creature is significantly over the average party level and might prove a challenge.")},m(o,a){A(o,e,a),r||(s=H(n=i[9].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function V_(i){let e,t=X_(i[0].source)+"",n,r;return{c(){e=b("span"),n=ae(t),v(e,"aria-label",r=Y_(i[0].source))},m(s,o){A(s,e,o),y(e,n)},p(s,o){o&1&&t!==(t=X_(s[0].source)+"")&&me(n,t),o&1&&r!==(r=Y_(s[0].source))&&v(e,"aria-label",r)},d(s){s&&T(e)}}}function W_(i){let e,t,n;return t=new jf({props:{str:i[0][i[14].field]??We}}),{c(){e=b("td"),ye(t.$$.fragment)},m(r,s){A(r,e,s),Oe(t,e,null),n=!0},p(r,s){let o={};s&9&&(o.str=r[0][r[14].field]??We),t.$set(o)},i(r){n||($(t.$$.fragment,r),n=!0)},o(r){V(t.$$.fragment,r),n=!1},d(r){r&&T(e),ve(t)}}}function iA(i){let e,t,n,r,s,o,a,l=i[0].name+"",c,u,f,d,h,p,m,g,O,_=i[2]&&F_(i),S=i[1]&&B_(i),P=i[0].source?.length&&V_(i),k=fe(i[3]),w=[];for(let C=0;CV(w[C],1,1,()=>{w[C]=null});return{c(){e=b("tr"),t=b("td"),n=b("div"),r=b("div"),o=R(),a=b("div"),c=ae(l),u=R(),_&&_.c(),f=R(),S&&S.c(),d=R(),h=b("div"),P&&P.c(),p=R();for(let C=0;CZf(s,e++)).join(t)}${n?")":""}`);else if(typeof i=="object")for(let s of Object.values(i))r.push(Zf(s,e++));return r.join(" ")}function X_(i){if(!Array.isArray(i))return i;let e=i.slice(0,2);return i.length>2&&e.push(`and ${i.length-2} more`),Zf(e,0,", ",!1)}function Y_(i){return Array.isArray(i)?Zf(i,0,", ",!1):""}function nA(i,e,t){let n,r,s,o,{players:a}=ii,{average:l}=a;ke(i,l,O=>t(10,s=O));let c=Ye("plugin"),u=Ye("table");ke(i,u,O=>t(3,o=O));let{creature:f}=e,d=O=>{new ic.ExtraButtonComponent(O).setIcon("plus-with-circle")},h=O=>(0,ic.setIcon)(O,"baby"),p=O=>(0,ic.setIcon)(O,"skull"),m=()=>ii.add(f),g=O=>c.openCombatant(Ne.from(f));return i.$$set=O=>{"creature"in O&&t(0,f=O.creature)},i.$$.update=()=>{i.$$.dirty&1025&&t(2,n="cr"in f&&f.cr&&hi(f.cr)s+3)},[f,r,n,o,l,c,u,d,h,p,s,m,g]}var Xm=class extends ne{constructor(e){super(),re(this,e,nA,iA,ie,{creature:0},tA)}},U_=Xm;var Xf=require("obsidian");function zf(i,{delay:e=0,duration:t=400,easing:n=In}={}){let r=+getComputedStyle(i).opacity;return{delay:e,duration:t,easing:n,css:s=>`opacity: ${s*r}`}}function Ym(i,{delay:e=0,duration:t=400,easing:n=Ea,axis:r="y"}={}){let s=getComputedStyle(i),o=+s.opacity,a=r==="y"?"height":"width",l=parseFloat(s[a]),c=r==="y"?["top","bottom"]:["left","right"],u=c.map(O=>`${O[0].toUpperCase()}${O.slice(1)}`),f=parseFloat(s[`padding${u[0]}`]),d=parseFloat(s[`padding${u[1]}`]),h=parseFloat(s[`margin${u[0]}`]),p=parseFloat(s[`margin${u[1]}`]),m=parseFloat(s[`border${u[0]}Width`]),g=parseFloat(s[`border${u[1]}Width`]);return{delay:e,duration:t,easing:n,css:O=>`overflow: hidden;opacity: ${Math.min(O*20,1)*o};${a}: ${O*l}px;padding-${c[0]}: ${O*f}px;padding-${c[1]}: ${O*d}px;margin-${c[0]}: ${O*h}px;margin-${c[1]}: ${O*p}px;border-${c[0]}-width: ${O*m}px;border-${c[1]}-width: ${O*g}px;`}}var rA=Function.prototype.toString,Um=Object.create,sA=Object.prototype.toString,oA=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 aA(){return new oA}function lA(){return new WeakMap}var cA=typeof WeakMap<"u"?lA:aA;function Gm(i){if(!i)return Um(null);var e=i.constructor;if(e===Object)return i===Object.prototype?{}:Um(i);if(e&&~rA.call(e).indexOf("[native code]"))try{return new e}catch{}return Um(i)}function uA(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 fA(i){return i.flags}var dA=/test/g.flags==="g"?fA:uA;function H_(i){var e=sA.call(i);return e.substring(8,e.length-1)}function hA(i){return i[Symbol.toStringTag]||H_(i)}var pA=typeof Symbol<"u"?hA:H_,mA=Object.defineProperty,gA=Object.getOwnPropertyDescriptor,G_=Object.getOwnPropertyNames,Km=Object.getOwnPropertySymbols,K_=Object.prototype,J_=K_.hasOwnProperty,OA=K_.propertyIsEnumerable,ew=typeof Km=="function";function vA(i){return G_(i).concat(Km(i))}var yA=ew?vA:G_;function Lf(i,e,t){for(var n=yA(i),r=0,s=n.length,o=void 0,a=void 0;r{let e=$e([...i.options]),{update:t,set:n,subscribe:r}=e,s=oi(e,o=>i.options[0]==o[0]&&i.options[1]==o[1]);return{isDefault:s,getIsDefault:()=>ct(s),update:t,set:n,subscribe:r,reset:()=>n([...i.options]),compare:o=>{if(ct(s))return!0;let a=ct(e);return hi(o)>=a[0]&&hi(o)<=a[1]},filter:i,...i}};function $f(i){return typeof i!="string"?i:i.toLowerCase()}var ZA=i=>{let e=$e([]),{subscribe:t,set:n,update:r}=e,s=oi(e,o=>!o.length);return{isDefault:s,getIsDefault:()=>ct(s),subscribe:t,set:n,reset:()=>n([]),compare:o=>{if(ct(s))return!0;if(typeof o=="number")return!1;let a=ct(e);return Array.isArray(o)?o.some(l=>a.includes($f(l))):a.includes($f(o))},update:r,filter:i,...i}},zA=i=>{let e="",t=$e(e),{subscribe:n,set:r,update:s}=t,o=oi(t,l=>!l.length),a=(0,tg.prepareSimpleSearch)("");return t.subscribe(l=>a=(0,tg.prepareSimpleSearch)(l)),{isDefault:o,getIsDefault:()=>ct(o),subscribe:n,set:r,reset:()=>r(e),compare:l=>ct(o)?!0:typeof l=="number"?!1:ct(o)||a(l)!=null,update:s,filter:i,...i}};function ow(i){switch(i.type){case 2:return ZA(i);case 0:return jA(i);case 1:return zA(i)}}function aw(i,e){let t=new Map(e.map(n=>[n,new Set]));for(let n of i)for(let r of e)for(let s of r.fields)if(s in n){switch(r.type){case 0:{let o=hi(n[s]);if(o==null||isNaN(o))continue;let a=[...t.get(r)];a.length||(a[0]=1/0,a[1]=-1/0),a[0]=Math.min(a[0],o),Math.max(a[1],o)!=a[0]&&(a[1]=Math.max(a[1],o)),t.set(r,new Set(a));break}case 2:{if(Array.isArray(n[s]))for(let o of n[s])t.get(r).add($f(o));else typeof n[s]=="string"&&t.get(r).add($f(n[s]));break}case 1:continue}continue}return t}function cw(i,e){let t=k=>{let w=ow(k);return n.set(k.id,w),o.set(k.id,w.subscribe(x=>{r.update(C=>C)})),w},n=new Map,r=$e(n),s=new Map;r.subscribe(k=>{for(let[w,x]of k)s.set(w,x.filter)});let o=new Map;e.data.builder||(e.data.builder={sidebarIcon:!0,showParty:!0,showXP:!0});let a=()=>ci(e.data.builder?.filters?.layout??lw),l=()=>ci(e.data.builder?.filters?.filters??eg);e.data.builder.filters||(e.data.builder.filters={filters:l(),layout:a()});let c=e.data.builder?.filters?.filters??eg,u=e.data.builder?.filters?.layout??a();if(c.filter(k=>k.derive).length){let k=aw(ct(i),c);for(let[w,x]of k)w.options=Array.from(x)}for(let k of c)t(k);let d=oi([i,r],([k,w])=>{let x=[],C=Array.from(w.values());for(let M of k)C.every(Z=>{if(!Z.filter.fields.length)return!0;for(let Q of Z.filter.fields)if(Q in M)return Z.compare(M[Q]);return!0})&&x.push(M);return x}),h=$e(u??a()),p=k=>{h.set(k),e.data.builder.filters.layout=k,e.saveSettings()},m=k=>{p(k?lw:a()),g(w=>{w.clear();let x=k?eg:l();for(let C of x)t(C);return w})};function g(k){r.update(w=>{let x=k(w);return e.data.builder.filters.filters=[...x.values()].map(C=>C.filter),e.saveSettings(),x})}let O=oi(r,k=>{let w=0;for(let x of k.values())x.getIsDefault()||w++;return w}),_=t(qA),S=(k,w)=>{if(k.derive){let C=aw(ct(i),[k]);for(let[M,Z]of C)M.options=Array.from(Z)}let x=ow(k);return w.set(k.id,x),o.set(k.id,x.subscribe(C=>r.update(M=>M))),w},P=(k,w)=>(w.delete(k),o.has(k)&&(o.get(k)(),o.delete(k)),w);return{add:k=>g(w=>S(k,w)),update:(k,w)=>g(x=>(P(k,x),S(w,x))),remove:k=>g(w=>P(k.id,w)),reset:()=>g(k=>{for(let w of k.values())w.reset();return k}),active:O,filtered:d,filters:r,filterMap:s,layout:{subscribe:h.subscribe,set:p},resetLayout:m,getOrDefault(k){return s?.get(k)??ci(ig)},name:_}}var UU=$e(),qA={type:1,text:"Name",fields:["name"],options:"",id:"ID_DEFAULT_NAME_FILTER",derive:!1},eg=[{type:0,text:"CR",fields:["cr"],options:[0,30],id:"ID_DEFAULT_CR_FILTER",derive:!0},{type:2,text:"Size",fields:["size"],options:[],id:"ID_DEFAULT_SIZE_FILTER",derive:!0},{type:2,text:"Type",fields:["type"],options:[],id:"ID_DEFAULT_TYPE_FILTER",derive:!0},{type:2,text:"Alignment",fields:["alignment"],options:[],id:"ID_DEFAULT_ALIGNMENT_FILTER",derive:!0}],lw=[{nested:[{id:"ID_DEFAULT_CR_FILTER",type:"filter"}],id:"ID_DEFAULT_NESTED_CR",type:"nested"},{id:"ID_DEFAULT_NESTED_LAYOUT",type:"nested",nested:[{id:"ID_DEFAULT_SIZE_FILTER",type:"filter"},{id:"ID_DEFAULT_TYPE_FILTER",type:"filter"},{id:"ID_DEFAULT_ALIGNMENT_FILTER",type:"filter"}]}];function LA(i){se(i,"svelte-1dlbj12",'.thumb.svelte-1dlbj12{position:absolute;top:50%;width:0;height:0}.thumb-content.svelte-1dlbj12{position:relative;width:fit-content;height:fit-content;transform:translate(-50%, -50%)}.thumb-content.svelte-1dlbj12::before{content:"";position:absolute;width:200%;height:200%;transform:translate(-25%, -25%) scale(0);border-radius:100vh;background:var(--interactive-hover);opacity:30%;transition:transform 100ms ease-in-out}.thumb-content.active.svelte-1dlbj12::before{transform:translate(-25%, -25%) scale(1)}')}function $A(i){let e,t,n,r,s,o,a,l=i[4].default,c=Gt(l,i,i[3],null);return{c(){e=b("div"),t=b("div"),c&&c.c(),v(t,"class","thumb-content svelte-1dlbj12"),ge(t,"active",i[1]),v(e,"class","thumb svelte-1dlbj12"),v(e,"style",n=`left: ${i[0]*100}%;`)},m(u,f){A(u,e,f),y(e,t),c&&c.m(t,null),s=!0,o||(a=[H(r=FA.call(null,e)),Y(e,"dragstart",i[6]),Y(e,"drag",i[7]),Y(e,"dragend",i[8]),Y(e,"click",Vt(i[5]))],o=!0)},p(u,[f]){c&&c.p&&(!s||f&8)&&Jt(c,l,u,u[3],s?Kt(l,u[3],f,null):ei(u[3]),null),(!s||f&2)&&ge(t,"active",u[1]),(!s||f&1&&n!==(n=`left: ${u[0]*100}%;`))&&v(e,"style",n)},i(u){s||($(c,u),s=!0)},o(u){V(c,u),s=!1},d(u){u&&T(e),c&&c.d(u),o=!1,de(a)}}}function FA(i){let e=BA(i);return i.addEventListener("touchstart",e),i.addEventListener("mousedown",e),{destroy(){i.removeEventListener("touchstart",e),i.removeEventListener("mousedown",e)}}}function BA(i){let e=VA(i);return function(t){t.preventDefault(),i.dispatchEvent(new CustomEvent("dragstart"));let n="touches"in t?"touchmove":"mousemove",r="touches"in t?"touchend":"mouseup";document.addEventListener(n,e),document.addEventListener(r,s);function s(o){o.stopPropagation(),document.removeEventListener(n,e),document.removeEventListener(r,s),i.dispatchEvent(new CustomEvent("dragend"))}}}function VA(i){let e=i.parentElement;return function(t){let{left:n,width:r}=e.getBoundingClientRect(),s="touches"in t?t.touches[0].clientX:t.clientX,o=Math.min(Math.max((s-n)/r,0),1)||0;i.dispatchEvent(new CustomEvent("drag",{detail:o}))}}function WA(i,e,t){let{$$slots:n={},$$scope:r}=e,s=Fe(),o,{pos:a}=e;function l(d){ht.call(this,i,d)}let c=()=>(t(1,o=!0),s("active",!0)),u=({detail:d})=>t(0,a=d),f=()=>(t(1,o=!1),s("active",!1));return i.$$set=d=>{"pos"in d&&t(0,a=d.pos),"$$scope"in d&&t(3,r=d.$$scope)},[a,o,s,r,n,l,c,u,f]}var ng=class extends ne{constructor(e){super(),re(this,e,WA,$A,ie,{pos:0},LA)}},rg=ng;function XA(i){se(i,"svelte-1skvzai","input.svelte-1skvzai{display:none}.track-container.svelte-1skvzai{width:calc(100% - 16px);height:16px;display:flex;align-items:center}.track.svelte-1skvzai{margin:0 8px;position:relative;height:4px;width:calc(100% - 16px);border-radius:100vh;background:var(--background-modifier-form-field)}.progress.svelte-1skvzai{position:absolute;left:0;right:0;top:0;bottom:0;border-radius:100vh;background:var(--interactive-accent)}.thumb.svelte-1skvzai{width:16px;height:16px;border-radius:100vh;background:var(--interactive-accent)}.thumb.svelte-1skvzai:hover,.thumb.svelte-1skvzai:active{background:var(--interactive-hover)}")}function uw(i){let e,t,n;return{c(){e=b("input"),v(e,"type","number"),e.value=t=i[0][1],v(e,"name",n=i[1][1]),v(e,"class","svelte-1skvzai")},m(r,s){A(r,e,s)},p(r,s){s&1&&t!==(t=r[0][1])&&e.value!==t&&(e.value=t),s&2&&n!==(n=r[1][1])&&v(e,"name",n)},d(r){r&&T(e)}}}function YA(i){let e;return{c(){e=b("div"),v(e,"class","thumb svelte-1skvzai")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function fw(i){let e,t,n;function r(o){i[13](o)}let s={$$slots:{default:[UA]},$$scope:{ctx:i}};return i[3][1]!==void 0&&(s.pos=i[3][1]),e=new rg({props:s}),mi.push(()=>Mr(e,"pos",r)),e.$on("active",i[14]),{c(){ye(e.$$.fragment)},m(o,a){Oe(e,o,a),n=!0},p(o,a){let l={};a&524288&&(l.$$scope={dirty:a,ctx:o}),!t&&a&8&&(t=!0,l.pos=o[3][1],Qr(()=>t=!1)),e.$set(l)},i(o){n||($(e.$$.fragment,o),n=!0)},o(o){V(e.$$.fragment,o),n=!1},d(o){ve(e,o)}}}function UA(i){let e;return{c(){e=b("div"),v(e,"class","thumb svelte-1skvzai")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function HA(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=i[2]&&uw(i);function O(P){i[11](P)}let _={$$slots:{default:[YA]},$$scope:{ctx:i}};i[3][0]!==void 0&&(_.pos=i[3][0]),u=new rg({props:_}),mi.push(()=>Mr(u,"pos",O)),u.$on("active",i[12]);let S=i[2]&&fw(i);return{c(){e=b("div"),t=b("input"),s=R(),g&&g.c(),o=R(),a=b("div"),l=b("div"),c=R(),ye(u.$$.fragment),d=R(),S&&S.c(),v(t,"type","number"),t.value=n=i[0][0],v(t,"name",r=i[1][0]),v(t,"class","svelte-1skvzai"),v(l,"class","progress svelte-1skvzai"),v(l,"style",i[5]),v(a,"class","track svelte-1skvzai"),v(e,"class","track-container svelte-1skvzai")},m(P,k){A(P,e,k),y(e,t),y(e,s),g&&g.m(e,null),y(e,o),y(e,a),y(a,l),y(a,c),Oe(u,a,null),y(a,d),S&&S.m(a,null),h=!0,p||(m=Y(e,"click",i[6]),p=!0)},p(P,[k]){(!h||k&1&&n!==(n=P[0][0])&&t.value!==n)&&(t.value=n),(!h||k&2&&r!==(r=P[1][0]))&&v(t,"name",r),P[2]?g?g.p(P,k):(g=uw(P),g.c(),g.m(e,o)):g&&(g.d(1),g=null),(!h||k&32)&&v(l,"style",P[5]);let w={};k&524288&&(w.$$scope={dirty:k,ctx:P}),!f&&k&8&&(f=!0,w.pos=P[3][0],Qr(()=>f=!1)),u.$set(w),P[2]?S?(S.p(P,k),k&4&&$(S,1)):(S=fw(P),S.c(),$(S,1),S.m(a,null)):S&&(Ee(),V(S,1,1,()=>{S=null}),Te())},i(P){h||($(u.$$.fragment,P),$(S),h=!0)},o(P){V(u.$$.fragment,P),V(S),h=!1},d(P){P&&T(e),g&&g.d(),ve(u),S&&S.d(),p=!1,m()}}}function GA(i){return[Math.min(...i),Math.max(...i)]}function KA(i,e,t){let n,r=Fe(),{name:s=[]}=e,{range:o=!1}=e,{min:a=0}=e,{max:l=100}=e,{step:c=1}=e,{value:u=[a,l]}=e,f,d=!1,{order:h=!1}=e;function p(w){let x=a%c,C=l-a;t(0,u=w.map(M=>a+M*C).map(M=>Math.round((M-x)/c)*c+x)),r("input",u)}function m(w){t(3,f=w.map(x=>Math.min(Math.max(x,a),l)).map(x=>(x-a)/(l-a)))}function g(){m(u),p(f)}function O(w){let x=w.target,C=w.offsetX/x.clientWidth,M=f.map(Z=>Math.abs(C-Z));M[1]>M[0]?t(3,f=[C,f[1]]):t(3,f=[f[0],C]),p(f)}function _(w){i.$$.not_equal(f[0],w)&&(f[0]=w,t(3,f),t(2,o),t(10,h),t(4,d))}let S=({detail:w})=>t(4,d=w);function P(w){i.$$.not_equal(f[1],w)&&(f[1]=w,t(3,f),t(2,o),t(10,h),t(4,d))}let k=({detail:w})=>t(4,d=w);return i.$$set=w=>{"name"in w&&t(1,s=w.name),"range"in w&&t(2,o=w.range),"min"in w&&t(7,a=w.min),"max"in w&&t(8,l=w.max),"step"in w&&t(9,c=w.step),"value"in w&&t(0,u=w.value),"order"in w&&t(10,h=w.order)},i.$$.update=()=>{i.$$.dirty&1052&&o&&h&&d&&t(3,f=GA(f)),i.$$.dirty&24&&d&&p(f),i.$$.dirty&17&&(d||m(u)),i.$$.dirty&384&&g(),i.$$.dirty&12&&t(5,n=` left: ${o?Math.min(f[0],f[1])*100:0}%; right: ${100-Math.max(f[0],o?f[1]:f[0])*100}%; `)},[u,s,o,f,d,n,O,a,l,c,h,_,S,P,k]}var sg=class extends ne{constructor(e){super(),re(this,e,KA,HA,ie,{name:1,range:2,min:7,max:8,step:9,value:0,order:10},XA)}},dw=sg;function JA(i){se(i,"svelte-191t5bs",".range-filter.svelte-191t5bs{display:flex;align-items:center;gap:1rem;width:100%;white-space:nowrap}")}function eD(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P;function k(x){i[5](x)}let w={range:!0,order:!0,min:i[0].options[0],max:i[0].options[1]};return i[3]!==void 0&&(w.value=i[3]),c=new dw({props:w}),mi.push(()=>Mr(c,"value",k)),{c(){e=b("div"),t=b("span"),n=ae(i[2]),r=R(),s=b("input"),l=R(),ye(c.$$.fragment),f=R(),d=b("input"),m=R(),g=b("span"),O=ae(i[1]),v(s,"type","number"),v(s,"placeholder",i[2]),v(s,"min",o=i[0].options[0]),v(s,"max",a=i[0].options[1]),v(d,"type","number"),v(d,"placeholder",i[1]),v(d,"min",h=i[0].options[0]),v(d,"max",p=i[0].options[1]),v(e,"class","range-filter svelte-191t5bs")},m(x,C){A(x,e,C),y(e,t),y(t,n),y(e,r),y(e,s),Xe(s,i[3][0]),y(e,l),Oe(c,e,null),y(e,f),y(e,d),Xe(d,i[3][1]),y(e,m),y(e,g),y(g,O),_=!0,S||(P=[Y(s,"input",i[4]),Y(d,"input",i[6])],S=!0)},p(x,[C]){(!_||C&4)&&me(n,x[2]),(!_||C&4)&&v(s,"placeholder",x[2]),(!_||C&1&&o!==(o=x[0].options[0]))&&v(s,"min",o),(!_||C&1&&a!==(a=x[0].options[1]))&&v(s,"max",a),C&8&&pi(s.value)!==x[3][0]&&Xe(s,x[3][0]);let M={};C&1&&(M.min=x[0].options[0]),C&1&&(M.max=x[0].options[1]),!u&&C&8&&(u=!0,M.value=x[3],Qr(()=>u=!1)),c.$set(M),(!_||C&2)&&v(d,"placeholder",x[1]),(!_||C&1&&h!==(h=x[0].options[0]))&&v(d,"min",h),(!_||C&1&&p!==(p=x[0].options[1]))&&v(d,"max",p),C&8&&pi(d.value)!==x[3][1]&&Xe(d,x[3][1]),(!_||C&2)&&me(O,x[1])},i(x){_||($(c.$$.fragment,x),_=!0)},o(x){V(c.$$.fragment,x),_=!1},d(x){x&&T(e),ve(c),S=!1,de(P)}}}function tD(i,e,t){let n,r,s,o=X,a=()=>(o(),o=Ii(l,d=>t(3,s=d)),l);i.$$.on_destroy.push(()=>o());let{filter:l}=e;a();function c(){s[0]=pi(this.value),l.set(s)}function u(d){s=d,l.set(s)}function f(){s[1]=pi(this.value),l.set(s)}return i.$$set=d=>{"filter"in d&&a(t(0,l=d.filter))},i.$$.update=()=>{i.$$.dirty&1&&t(2,n=`Min ${l.filter.text}`),i.$$.dirty&1&&t(1,r=`Max ${l.filter.text}`)},[l,r,n,s,c,u,f]}var og=class extends ne{constructor(e){super(),re(this,e,tD,eD,ie,{filter:0},JA)}},hw=og;function iD(i){se(i,"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 nD(i){let e,t=`${i[0]} transparent ${i[0]} ${i[0]}`;return{c(){e=b("div"),Ce(e,"--duration",i[1]),v(e,"class","svelte-66wdl1"),Ce(e,"border-color",t),Ce(e,"width",i[2]),Ce(e,"height",i[2])},m(n,r){A(n,e,r)},p(n,[r]){r&2&&Ce(e,"--duration",n[1]);let s=r&2;(r&3&&t!==(t=`${n[0]} transparent ${n[0]} ${n[0]}`)||s)&&Ce(e,"border-color",t),(r&6||s)&&Ce(e,"width",n[2]),(r&6||s)&&Ce(e,"height",n[2])},i:X,o:X,d(n){n&&T(e)}}}function rD(i,e,t){let{color:n="cornflowerblue"}=e,{duration:r="1.5s"}=e,{size:s="1em"}=e;return i.$$set=o=>{"color"in o&&t(0,n=o.color),"duration"in o&&t(1,r=o.duration),"size"in o&&t(2,s=o.size)},[n,r,s]}var ag=class extends ne{constructor(e){super(),re(this,e,rD,nD,ie,{color:0,duration:1,size:2},iD)}},lg=ag;function sD(i){let e,t=`rotate(${i[0].angle}deg) scale(${i[0].scale}) translate(${i[0].dx}px, ${i[0].dy}px)`,n,r=i[11].default,s=Gt(r,i,i[10],null);return{c(){e=b("span"),s&&s.c(),Ce(e,"transform",t)},m(o,a){A(o,e,a),s&&s.m(e,null),n=!0},p(o,[a]){s&&s.p&&(!n||a&1024)&&Jt(s,r,o,o[10],n?Kt(r,o[10],a,null):ei(o[10]),null),a&1&&t!==(t=`rotate(${o[0].angle}deg) scale(${o[0].scale}) translate(${o[0].dx}px, ${o[0].dy}px)`)&&Ce(e,"transform",t)},i(o){n||($(s,o),n=!0)},o(o){V(s,o),n=!1},d(o){o&&T(e),s&&s.d(o)}}}function oD(i,e,t){let n,{$$slots:r={},$$scope:s}=e,{wiggle:o=!1}=e,{angle:a=0}=e,{scale:l=1}=e,{dx:c=0}=e,{dy:u=0}=e,{duration:f=200}=e,{stiffness:d=.05}=e,{damping:h=.1}=e,p={angle:0,scale:1,dx:0,dy:0},m=a_(p,{stiffness:d,damping:h});return ke(i,m,g=>t(0,n=g)),i.$$set=g=>{"wiggle"in g&&t(2,o=g.wiggle),"angle"in g&&t(3,a=g.angle),"scale"in g&&t(4,l=g.scale),"dx"in g&&t(5,c=g.dx),"dy"in g&&t(6,u=g.dy),"duration"in g&&t(7,f=g.duration),"stiffness"in g&&t(8,d=g.stiffness),"damping"in g&&t(9,h=g.damping),"$$scope"in g&&t(10,s=g.$$scope)},i.$$.update=()=>{i.$$.dirty&132&&o&&setTimeout(()=>t(2,o=!1),f),i.$$.dirty&124&&m.set(o?{scale:l,angle:a,dx:c,dy:u}:p)},[n,m,o,a,l,c,u,f,d,h,s,r]}var cg=class extends ne{constructor(e){super(),re(this,e,oD,sD,ie,{wiggle:2,angle:3,scale:4,dx:5,dy:6,duration:7,stiffness:8,damping:9})}},ug=cg;function aD(i){let e,t,n=[i[0],{fill:"currentColor"},{viewBox:"0 0 16 16"}],r={};for(let s=0;s{t(0,e=ti(ti({},e),ir(n)))},e=ir(e),[e]}var fg=class extends ne{constructor(e){super(),re(this,e,lD,aD,ie,{})}},dg=fg;function cD(i){let e,t,n=[i[0],{viewBox:"0 0 24 24"},{fill:"currentColor"}],r={};for(let s=0;s{t(0,e=ti(ti({},e),ir(n)))},e=ir(e),[e]}var hg=class extends ne{constructor(e){super(),re(this,e,uD,cD,ie,{})}},Ff=hg;function fD(i){let e,t,n=[i[0],{viewBox:"0 0 24 24"},{fill:"currentColor"}],r={};for(let s=0;s{t(0,e=ti(ti({},e),ir(n)))},e=ir(e),[e]}var pg=class extends ne{constructor(e){super(),re(this,e,dD,fD,ie,{})}},mg=pg;var ki=i=>i instanceof Object?(i.label===void 0&&console.error(`MultiSelect option ${JSON.stringify(i)} is an object but has no label key`),i.label):`${i}`;function nc(i,e=null){let t="";if(["selected","option",null].includes(e)||console.error(`MultiSelect: Invalid key=${e} for get_style`),typeof i=="object"&&i.style&&(typeof i.style=="string"&&(t=i.style),typeof i.style=="object")){if(e&&e in i.style)return i.style[e]??"";console.error(`Invalid style object for option=${JSON.stringify(i)}`)}return t.trim()&&!t.trim().endsWith(";")&&(t+=";"),t}var{Boolean:hD}=Rl;function pD(i){se(i,"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 mD=i=>({searchText:i[0]&16,msgType:i[0]&68660|i[1]&16,msg:i[0]&101428|i[1]&16}),pw=i=>({searchText:i[4],msgType:i[124],msg:i[125]});function gg(i){let e=i.slice(),t={dupe:e[15],create:e[10],"no-match":e[35]}[e[124]];return e[125]=t,e}function Og(i){let e=i.slice(),t=e[5].map(ki).includes(e[4]);e[120]=t;let n=!e[16]&&e[120]&&"dupe";e[121]=n;let r=!!(e[11]&&e[10])&&"create";e[122]=r;let s=!!(e[2]?.length==0&&e[35])&&"no-match";e[123]=s;let o=e[121]||e[122]||e[123];return e[124]=o,e}function mw(i,e,t){let n=i.slice();n[126]=e[t],n[133]=t;let r=n[126]instanceof Object?n[126]:{label:n[126]};n[127]=r.label,n[50]=r.disabled!==void 0?r.disabled:null,n[128]=r.title!==void 0?r.title:null,n[129]=r.selectedTitle!==void 0?r.selectedTitle:null,n[130]=r.disabledTitle!==void 0?r.disabledTitle:n[13];let s=n[0]===n[133];return n[131]=s,n}var gD=i=>({option:i[0]&1073741828}),gw=i=>({option:i[126],idx:i[133]}),OD=i=>({option:i[0]&1073741828}),Ow=i=>({option:i[126],idx:i[133]}),vD=i=>({}),vw=i=>({}),yD=i=>({}),yw=i=>({}),bD=i=>({}),bw=i=>({}),_D=i=>({selected:i[0]&32,disabled:i[1]&524288,invalid:i[0]&128,id:i[0]&262144,placeholder:i[1]&256,open:i[0]&256,required:i[1]&4096}),_w=i=>({selected:i[5],disabled:i[50],invalid:i[7],id:i[18],placeholder:i[39],open:i[8],required:i[43]});function ww(i,e,t){let n=i.slice();return n[126]=e[t],n[133]=t,n}var wD=i=>({}),kw=i=>({}),kD=i=>({option:i[0]&32,idx:i[0]&32}),Sw=i=>({option:i[126],idx:i[133]}),SD=i=>({option:i[0]&32,idx:i[0]&32}),xw=i=>({option:i[126],idx:i[133]}),xD=i=>({open:i[0]&256}),Pw=i=>({open:i[8]});function PD(i){let e,t;return e=new dg({props:{width:"15px",style:"min-width: 1em; padding: 0 1pt; cursor: pointer;"}}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function CD(i){let e=ki(i[126])+"",t;return{c(){t=ae(e)},m(n,r){A(n,t,r)},p(n,r){r[0]&32&&e!==(e=ki(n[126])+"")&&me(t,e)},d(n){n&&T(t)}}}function ED(i){let e,t=ki(i[126])+"",n;return{c(){e=new Ml(!1),n=tt(),e.a=n},m(r,s){e.m(t,r,s),A(r,n,s)},p(r,s){s[0]&32&&t!==(t=ki(r[126])+"")&&e.p(t)},d(r){r&&(T(n),e.d())}}}function TD(i){let e;function t(s,o){return s[37]?ED:CD}let n=t(i,[-1,-1,-1,-1,-1]),r=n(i);return{c(){r.c(),e=tt()},m(s,o){r.m(s,o),A(s,e,o)},p(s,o){n===(n=t(s,o))&&r?r.p(s,o):(r.d(1),r=n(s),r&&(r.c(),r.m(e.parentNode,e)))},d(s){s&&T(e),r.d(s)}}}function AD(i){let e,t=i[77].default,n=Gt(t,i,i[115],Sw),r=n||TD(i);return{c(){r&&r.c()},m(s,o){r&&r.m(s,o),e=!0},p(s,o){n?n.p&&(!e||o[0]&32|o[3]&4194304)&&Jt(n,t,s,s[115],e?Kt(t,s[115],o,kD):ei(s[115]),Sw):r&&r.p&&(!e||o[0]&32|o[1]&64)&&r.p(s,e?o:[-1,-1,-1,-1,-1])},i(s){e||($(r,s),e=!0)},o(s){V(r,s),e=!1},d(s){r&&r.d(s)}}}function Cw(i){let e,t,n,r,s,o=i[77]["remove-icon"],a=Gt(o,i,i[115],kw),l=a||DD(i);function c(){return i[97](i[126])}function u(){return i[98](i[126])}return{c(){e=b("button"),l&&l.c(),v(e,"type","button"),v(e,"title",t=i[41]+" "+ki(i[126])),v(e,"class","remove svelte-1r2hsto")},m(f,d){A(f,e,d),l&&l.m(e,null),n=!0,r||(s=[Y(e,"mouseup",Vt(c)),Y(e,"keydown",function(){Ge(i[62](u))&&i[62](u).apply(this,arguments)})],r=!0)},p(f,d){i=f,a&&a.p&&(!n||d[3]&4194304)&&Jt(a,o,i,i[115],n?Kt(o,i[115],d,wD):ei(i[115]),kw),(!n||d[0]&32|d[1]&1024&&t!==(t=i[41]+" "+ki(i[126])))&&v(e,"title",t)},i(f){n||($(l,f),n=!0)},o(f){V(l,f),n=!1},d(f){f&&T(e),l&&l.d(f),r=!1,de(s)}}}function DD(i){let e,t;return e=new Ff({props:{width:"15px"}}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function Ew(i,e){let t,n,r,s,o,a,l=X,c,u,f,d=e[77].selected,h=Gt(d,e,e[115],xw),p=h||AD(e),m=!e[50]&&(e[42]===null||e[5].length>e[42])&&Cw(e);function g(){return e[99](e[133])}return{key:i,first:null,c(){t=b("li"),p&&p.c(),n=R(),m&&m.c(),v(t,"class",r=un(e[26])+" svelte-1r2hsto"),v(t,"role","option"),v(t,"aria-selected","true"),v(t,"draggable",s=e[44]&&!e[50]&&e[5].length>1),v(t,"style",o=nc(e[126],"selected")+" "+e[27]),ge(t,"active",e[54]===e[133]),this.first=t},m(O,_){A(O,t,_),p&&p.m(t,null),y(t,n),m&&m.m(t,null),c=!0,u||(f=[Y(t,"dragstart",function(){Ge(e[65](e[133]))&&e[65](e[133]).apply(this,arguments)}),Y(t,"drop",Xp(function(){Ge(e[64](e[133]))&&e[64](e[133]).apply(this,arguments)})),Y(t,"dragenter",g),Y(t,"dragover",Xp(e[93]))],u=!0)},p(O,_){e=O,h?h.p&&(!c||_[0]&32|_[3]&4194304)&&Jt(h,d,e,e[115],c?Kt(d,e[115],_,SD):ei(e[115]),xw):p&&p.p&&(!c||_[0]&32|_[1]&64|_[3]&4194304)&&p.p(e,c?_:[-1,-1,-1,-1,-1]),!e[50]&&(e[42]===null||e[5].length>e[42])?m?(m.p(e,_),_[0]&32|_[1]&526336&&$(m,1)):(m=Cw(e),m.c(),$(m,1),m.m(t,null)):m&&(Ee(),V(m,1,1,()=>{m=null}),Te()),(!c||_[0]&67108864&&r!==(r=un(e[26])+" svelte-1r2hsto"))&&v(t,"class",r),(!c||_[0]&32|_[1]&532480&&s!==(s=e[44]&&!e[50]&&e[5].length>1))&&v(t,"draggable",s),(!c||_[0]&134217760&&o!==(o=nc(e[126],"selected")+" "+e[27]))&&v(t,"style",o),(!c||_[0]&67108896|_[1]&8388608)&&ge(t,"active",e[54]===e[133])},r(){a=t.getBoundingClientRect()},f(){Dr(t),l()},a(){l(),l=Ar(t,a,Nr,{duration:100})},i(O){c||($(p,O),$(m),c=!0)},o(O){V(p,O),V(m),c=!1},d(O){O&&T(t),p&&p.d(O),m&&m.d(),u=!1,de(f)}}}function Tw(i){let e,t=i[77].spinner,n=Gt(t,i,i[115],bw),r=n||QD(i);return{c(){r&&r.c()},m(s,o){r&&r.m(s,o),e=!0},p(s,o){n&&n.p&&(!e||o[3]&4194304)&&Jt(n,t,s,s[115],e?Kt(t,s[115],o,bD):ei(s[115]),bw)},i(s){e||($(r,s),e=!0)},o(s){V(r,s),e=!1},d(s){r&&r.d(s)}}}function QD(i){let e,t;return e=new lg({}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function RD(i){let e,t,n,r=i[31]&&(i[31]>1||i[32])&&Aw(i),s=i[31]!==1&&i[5].length>1&&Dw(i);return{c(){r&&r.c(),e=R(),s&&s.c(),t=tt()},m(o,a){r&&r.m(o,a),A(o,e,a),s&&s.m(o,a),A(o,t,a),n=!0},p(o,a){o[31]&&(o[31]>1||o[32])?r?(r.p(o,a),a[1]&3&&$(r,1)):(r=Aw(o),r.c(),$(r,1),r.m(e.parentNode,e)):r&&(Ee(),V(r,1,1,()=>{r=null}),Te()),o[31]!==1&&o[5].length>1?s?(s.p(o,a),a[0]&32|a[1]&1&&$(s,1)):(s=Dw(o),s.c(),$(s,1),s.m(t.parentNode,t)):s&&(Ee(),V(s,1,1,()=>{s=null}),Te())},i(o){n||($(r),$(s),n=!0)},o(o){V(r),V(s),n=!1},d(o){o&&(T(e),T(t)),r&&r.d(o),s&&s.d(o)}}}function MD(i){let e,t=i[77]["disabled-icon"],n=Gt(t,i,i[115],yw),r=n||jD(i);return{c(){r&&r.c()},m(s,o){r&&r.m(s,o),e=!0},p(s,o){n&&n.p&&(!e||o[3]&4194304)&&Jt(n,t,s,s[115],e?Kt(t,s[115],o,yD):ei(s[115]),yw)},i(s){e||($(r,s),e=!0)},o(s){V(r,s),e=!1},d(s){r&&r.d(s)}}}function Aw(i){let e,t,n;function r(o){i[102](o)}let s={angle:20,$$slots:{default:[ID]},$$scope:{ctx:i}};return i[51]!==void 0&&(s.wiggle=i[51]),e=new ug({props:s}),mi.push(()=>Mr(e,"wiggle",r)),{c(){ye(e.$$.fragment)},m(o,a){Oe(e,o,a),n=!0},p(o,a){let l={};a[0]&32|a[1]&7|a[3]&4194304&&(l.$$scope={dirty:a,ctx:o}),!t&&a[1]&1048576&&(t=!0,l.wiggle=o[51],Qr(()=>t=!1)),e.$set(l)},i(o){n||($(e.$$.fragment,o),n=!0)},o(o){V(e.$$.fragment,o),n=!1},d(o){ve(e,o)}}}function ID(i){let e,t=i[32]?.(i[5].length,i[31])+"",n,r;return{c(){e=b("span"),n=ae(t),v(e,"class",r="max-select-msg "+i[33]+" svelte-1r2hsto")},m(s,o){A(s,e,o),y(e,n)},p(s,o){o[0]&32|o[1]&3&&t!==(t=s[32]?.(s[5].length,s[31])+"")&&me(n,t),o[1]&4&&r!==(r="max-select-msg "+s[33]+" svelte-1r2hsto")&&v(e,"class",r)},d(s){s&&T(e)}}}function Dw(i){let e,t,n,r,s=i[77]["remove-icon"],o=Gt(s,i,i[115],vw),a=o||ND(i);return{c(){e=b("button"),a&&a.c(),v(e,"type","button"),v(e,"class","remove remove-all svelte-1r2hsto"),v(e,"title",i[40])},m(l,c){A(l,e,c),a&&a.m(e,null),t=!0,n||(r=[Y(e,"mouseup",Vt(i[61])),Y(e,"keydown",i[62](i[61]))],n=!0)},p(l,c){o&&o.p&&(!t||c[3]&4194304)&&Jt(o,s,l,l[115],t?Kt(s,l[115],c,vD):ei(l[115]),vw),(!t||c[1]&512)&&v(e,"title",l[40])},i(l){t||($(a,l),t=!0)},o(l){V(a,l),t=!1},d(l){l&&T(e),a&&a.d(l),n=!1,de(r)}}}function ND(i){let e,t;return e=new Ff({props:{width:"15px"}}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function jD(i){let e,t;return e=new mg({props:{width:"14pt",style:"margin: 0 2pt;","data-name":"disabled-icon"}}),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p:X,i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function Qw(i){let e,t,n,r,s,o,a=fe(i[2].slice(0,Math.max(0,i[30]??0)||1/0)),l=[];for(let f=0;fV(l[f],1,1,()=>{l[f]=null}),u=i[4]&&Mw(Og(i));return{c(){e=b("ul");for(let f=0;f1),v(e,"aria-expanded",i[8]),v(e,"aria-disabled",s=i[50]?"true":null),v(e,"style",i[49]),ge(e,"hidden",!i[8])},m(f,d){A(f,e,d);for(let h=0;h{u=null}),Te()),(!o||d[1]&32768&&n!==(n="options "+f[46]+" svelte-1r2hsto"))&&v(e,"class",n),(!o||d[1]&1&&r!==(r=f[31]===null||f[31]>1))&&v(e,"aria-multiselectable",r),(!o||d[0]&256)&&v(e,"aria-expanded",f[8]),(!o||d[1]&524288&&s!==(s=f[50]?"true":null))&&v(e,"aria-disabled",s),(!o||d[1]&262144)&&v(e,"style",f[49]),(!o||d[0]&256|d[1]&32768)&&ge(e,"hidden",!f[8])},i(f){if(!o){for(let d=0;d{n=null}),Te())},i(r){t||($(n),t=!0)},o(r){V(n),t=!1},d(r){r&&T(e),n&&n.d(r)}}}function Iw(i){let e,t,n,r,s,o=i[77]["user-msg"],a=Gt(o,i,i[115],pw),l=a||$D(i);return{c(){e=b("li"),l&&l.c(),v(e,"title",i[10]),v(e,"role","option"),v(e,"aria-selected","false"),v(e,"class",t="user-msg "+i[28]+" "+(i[52]?i[23]:"")+" svelte-1r2hsto"),ge(e,"active",i[52]),Ce(e,"cursor",{dupe:"not-allowed",create:"pointer","no-match":"default"}[i[124]])},m(c,u){A(c,e,u),l&&l.m(e,null),n=!0,r||(s=[Y(e,"mousedown",Vt(i[78])),Y(e,"mouseup",Vt(i[108])),Y(e,"mouseover",i[109]),Y(e,"focus",i[110]),Y(e,"mouseout",i[111]),Y(e,"blur",i[112])],r=!0)},p(c,u){a?a.p&&(!n||u[0]&101428|u[1]&16|u[3]&4194304)&&Jt(a,o,c,c[115],n?Kt(o,c[115],u,mD):ei(c[115]),pw):l&&l.p&&(!n||u[0]&101428|u[1]&16)&&l.p(c,n?u:[-1,-1,-1,-1,-1]),(!n||u[0]&1024)&&v(e,"title",c[10]),(!n||u[0]&276824064|u[1]&2097152&&t!==(t="user-msg "+c[28]+" "+(c[52]?c[23]:"")+" svelte-1r2hsto"))&&v(e,"class",t),(!n||u[0]&276824064|u[1]&2097152)&&ge(e,"active",c[52]),u[0]&68660|u[1]&16&&Ce(e,"cursor",{dupe:"not-allowed",create:"pointer","no-match":"default"}[c[124]])},i(c){n||($(l,c),n=!0)},o(c){V(l,c),n=!1},d(c){c&&T(e),l&&l.d(c),r=!1,de(s)}}}function $D(i){let e=i[125]+"",t;return{c(){t=ae(e)},m(n,r){A(n,t,r)},p(n,r){r[0]&101428|r[1]&16&&e!==(e=n[125]+"")&&me(t,e)},d(n){n&&T(t)}}}function FD(i){let e,t,n,r,s,o,a=[],l=new Map,c,u,f,d,h,p,m,g,O,_,S,P,k,w,x,C,M;_n(i[94]);let Z=i[77]["expand-icon"],Q=Gt(Z,i,i[115],Pw),D=Q||PD(i),E=fe(i[5]),j=B=>B[16]?[B[17](B[126]),B[133]]:B[17](B[126]);for(let B=0;B0?1:-1}~(_=xe(i,[-1,-1,-1,-1,-1]))&&(S=le[_]=U[_](i));let ue=(i[4]&&i[35]||i[3]?.length>0)&&Qw(i);return{c(){e=b("div"),t=b("input"),r=R(),D&&D.c(),s=R(),o=b("ul");for(let B=0;B=Number(i[43])?JSON.stringify(i[5]):null,v(t,"tabindex","-1"),v(t,"aria-hidden","true"),v(t,"aria-label","ignore this, used only to prevent form submission if select is required but empty"),v(t,"class","form-control svelte-1r2hsto"),v(u,"class",f=un(i[19])+" svelte-1r2hsto"),v(u,"style",i[20]),v(u,"id",i[18]),u.disabled=i[50],v(u,"autocomplete",i[12]),v(u,"inputmode",i[21]),v(u,"pattern",i[38]),v(u,"placeholder",d=i[5].length==0?i[39]:null),v(u,"aria-invalid",h=i[7]?"true":null),v(u,"ondrop","return false"),v(o,"class",m="selected "+i[47]+" svelte-1r2hsto"),v(o,"aria-label","selected options"),v(o,"style",i[48]),v(e,"class",k="multiselect "+i[36]+" svelte-1r2hsto"),v(e,"title",w=i[50]?i[14]:null),v(e,"data-id",i[18]),v(e,"role","searchbox"),v(e,"tabindex","-1"),v(e,"style",i[45]),ge(e,"disabled",i[50]),ge(e,"single",i[31]===1),ge(e,"open",i[8]),ge(e,"invalid",i[7])},m(B,J){A(B,e,J),y(e,t),i[95](t),y(e,r),D&&D.m(e,null),y(e,s),y(e,o);for(let pe=0;pe=Number(B[43])?JSON.stringify(B[5]):null)&&t.value!==n)&&(t.value=n),Q&&Q.p&&(!x||J[0]&256|J[3]&4194304)&&Jt(Q,Z,B,B[115],x?Kt(Z,B[115],J,xD):ei(B[115]),Pw),J[0]&201523232|J[1]&143141952|J[2]&13|J[3]&4194304){E=fe(B[5]),Ee();for(let Re=0;Re{G=null}),Te());let pe=_;_=xe(B,J),_===pe?~_&&le[_].p(B,J):(S&&(Ee(),V(le[pe],1,1,()=>{le[pe]=null}),Te()),~_?(S=le[_],S?S.p(B,J):(S=le[_]=U[_](B),S.c()),$(S,1),S.m(e,P)):S=null),B[4]&&B[35]||B[3]?.length>0?ue?(ue.p(B,J),J[0]&24|J[1]&16&&$(ue,1)):(ue=Qw(B),ue.c(),$(ue,1),ue.m(e,null)):ue&&(Ee(),V(ue,1,1,()=>{ue=null}),Te()),(!x||J[1]&32&&k!==(k="multiselect "+B[36]+" svelte-1r2hsto"))&&v(e,"class",k),(!x||J[0]&16384|J[1]&524288&&w!==(w=B[50]?B[14]:null))&&v(e,"title",w),(!x||J[0]&262144)&&v(e,"data-id",B[18]),(!x||J[1]&16384)&&v(e,"style",B[45]),(!x||J[1]&524320)&&ge(e,"disabled",B[50]),(!x||J[1]&33)&&ge(e,"single",B[31]===1),(!x||J[0]&256|J[1]&32)&&ge(e,"open",B[8]),(!x||J[0]&128|J[1]&32)&&ge(e,"invalid",B[7])},i(B){if(!x){$(D,B);for(let J=0;J`${ki(I)}`.toLowerCase()}=e,{filterFunc:P=(I,nt)=>nt?`${ki(I)}`.toLowerCase().includes(nt.toLowerCase()):!0}=e,{closeDropdownOnSelect:k="desktop"}=e,{form_input:w=null}=e,{highlightMatches:x=!0}=e,{id:C=null}=e,{input:M=null}=e,{inputClass:Z=""}=e,{inputStyle:Q=null}=e,{inputmode:D=null}=e,{invalid:E=!1}=e,{liActiveOptionClass:j=""}=e,{liActiveUserMsgClass:z=""}=e,{liOptionClass:q=""}=e,{liOptionStyle:G=null}=e,{liSelectedClass:U=""}=e,{liSelectedStyle:le=null}=e,{liUserMsgClass:xe=""}=e,{loading:ue=!1}=e,{matchingOptions:B=[]}=e,{maxOptions:J=void 0}=e,{maxSelect:pe=null}=e,{maxSelectMsg:Re=(I,nt)=>nt>1?`${I}/${nt}`:""}=e,{maxSelectMsgClass:oe=""}=e,{name:we=null}=e,{noMatchingOptionsMsg:yt="No matching options"}=e,{open:It=!1}=e,{options:ot}=e,{outerDiv:Nt=null}=e,{outerDivClass:Sr=""}=e,{parseLabelsAsHtml:nn=!1}=e,{pattern:$t=null}=e,{placeholder:Tt=null}=e,{removeAllTitle:at="Remove all"}=e,{removeBtnTitle:dt="Remove"}=e,{minSelect:gt=null}=e,{required:jt=!1}=e,{resetFilterOnAdd:xr=!0}=e,{searchText:bt=""}=e,{selected:et=ot?.filter(I=>I instanceof Object&&I?.preselected).slice(0,pe??void 0)??[]}=e,{sortSelected:is=!1}=e,{selectedOptionsDraggable:yl=!is}=e,{style:Du=null}=e,{ulOptionsClass:Qu=""}=e,{ulSelectedClass:Dn=""}=e,{ulSelectedStyle:ks=null}=e,{ulOptionsStyle:bl=null}=e,{value:po=null}=e,mo=I=>{t(67,po=pe===1?I[0]??null:I)},Ru=I=>{pe===1?t(5,et=I?[I]:[]):t(5,et=I??[])},sa=!1;ot?.length>0||(c||ue||m||u?ot=[]:console.error("MultiSelect received no options")),pe!==null&&pe<1&&console.error(`MultiSelect's maxSelect must be null or positive integer, got ${pe}`),Array.isArray(et)||console.error(`MultiSelect's selected prop should always be an array, got ${et}`),pe&&typeof jt=="number"&&jt>pe&&console.error(`MultiSelect maxSelect=${pe} < required=${jt}, makes it impossible for users to submit a valid form`),nn&&c&&console.warn("Don't combine parseLabelsAsHtml and allowUserOptions. It's susceptible to XSS attacks!"),is&&yl&&console.warn("MultiSelect's sortSelected and selectedOptionsDraggable should not be combined as any user re-orderings of selected options will be undone by sortSelected on component re-renders."),c&&!l&&l!==null&&console.error(`MultiSelect has allowUserOptions=${c} but createOptionMsg=${l} is falsy. This prevents the "Add option" from showing up, resulting in a confusing user experience.`),J&&(typeof J!="number"||J<0||J%1!=0)&&console.error(`MultiSelect's maxOptions must be undefined or a positive integer, got ${J}`);let Yn=Fe(),Pr=!1,rn;if(o!==null&&!B[o])throw`Run time error, activeIndex=${o} is out of bounds, matchingOptions.length=${B.length}`;function go(I,nt){pe&&pe>1&&et.length>=pe&&t(51,sa=!0),!isNaN(Number(I))&&typeof et.map(ki)[0]=="number"&&(I=Number(I));let Bt=et.map(S).includes(S(I));if((pe===null||pe===1||et.length0&&(typeof ot[0]=="object"?I={label:bt}:(["number","undefined"].includes(typeof ot[0])&&!isNaN(Number(bt))?I=Number(bt):I=bt,Yn("create",{option:I})),c==="append"&&t(3,ot=[...ot,I])),xr&&t(4,bt=""),["",void 0,null].includes(I)){console.error(`MultiSelect: encountered falsy option ${I}`);return}pe===1?t(5,et=[I]):(t(5,et=[...et,I]),is===!0?t(5,et=et.sort((ss,Cr)=>{let[Gn,ca]=[ki(ss),ki(Cr)];return`${Gn}`.localeCompare(`${ca}`)})):typeof is=="function"&&t(5,et=et.sort(is)));let yi=et.length===pe,Rn=k===!0||k==="desktop"&&rnS(yi)===S(I)),[Bt]=et.splice(nt,1);if(Bt===void 0&&c&&(Bt=typeof ot[0]?{label:I}:I),Bt===void 0)return console.error(`Multiselect can't remove selected option ${JSON.stringify(I)}, not found in selected list`);t(5,et=[...et]),t(7,E=!1),w?.setCustomValidity(""),Yn("remove",{option:Bt}),Yn("change",{option:Bt,type:"remove"})}function Mu(I){m||(t(8,It=!0),I instanceof FocusEvent||M?.focus(),Yn("open",{event:I}))}function _l(I){t(8,It=!1),M?.blur(),t(0,o=null),Yn("close",{event:I})}async function vp(I){if(I.key==="Escape"||I.key==="Tab")_l(I),t(4,bt="");else if(I.key==="Enter")I.preventDefault(),a?(et.includes(a)?Oo(a):go(a,I),t(4,bt="")):c&&bt.length>0?go(bt,I):Mu(I);else if(["ArrowDown","ArrowUp"].includes(I.key)){if(o===null&&B.length>0){t(0,o=0);return}else if(c&&!B.length&&bt.length>0){t(52,Pr=!Pr);return}else if(o===null)return;I.preventDefault();let nt=I.key==="ArrowUp"?-1:1;if(t(0,o=(o+nt)%B.length),o<0&&t(0,o=B.length-1),d){await af();let Bt=document.querySelector("ul.options > li.active");Bt&&Bt.scrollIntoViewIfNeeded?.()}}else I.key==="Backspace"&&et.length>0&&!bt?Oo(et.at(-1)):B.length>0&&t(0,o=0)}function yp(){Yn("removeAll",{options:et}),Yn("change",{options:et,type:"removeAll"}),t(5,et=[]),t(4,bt="")}let Ss=I=>nt=>{["Enter","Space"].includes(nt.code)&&(nt.preventDefault(),I())};function bp(I){Nt&&!Nt.contains(I.target)&&_l(I)}let oa=null,_p=I=>nt=>{if(!nt.dataTransfer)return;nt.dataTransfer.dropEffect="move";let Bt=parseInt(nt.dataTransfer.getData("text/plain")),yi=[...et];Btnt=>{nt.dataTransfer&&(nt.dataTransfer.effectAllowed="move",nt.dataTransfer.dropEffect="move",nt.dataTransfer.setData("text/plain",`${I}`))},vo;function wp(I){if(!x||typeof CSS>"u"||!CSS.highlights)return;CSS.highlights.clear();let nt=I?.target?.value.trim().toLowerCase();if(!nt)return;let Bt=document.createTreeWalker(vo,NodeFilter.SHOW_TEXT,{acceptNode:Cr=>Cr?.textContent===yt?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}),yi=[],Rn=Bt.nextNode();for(;Rn;)yi.push(Rn),Rn=Bt.nextNode();let ss=yi.map(Cr=>{let Gn=Cr.textContent?.toLowerCase(),ca=[],ua=0;for(;Gn&&ua{let bn=new Range;return bn.setStart(Cr,Es),bn.setEnd(Cr,Es+nt.length),bn})});CSS.highlights.set("sms-search-matches",new Highlight(...ss.flat()))}function Iu(I){ht.call(this,i,I)}function kp(I){ht.call(this,i,I)}function Nu(I){ht.call(this,i,I)}function F(I){ht.call(this,i,I)}function N(I){ht.call(this,i,I)}function W(I){ht.call(this,i,I)}function K(I){ht.call(this,i,I)}function ee(I){ht.call(this,i,I)}function Pe(I){ht.call(this,i,I)}function Le(I){ht.call(this,i,I)}function rt(I){ht.call(this,i,I)}function Ot(I){ht.call(this,i,I)}function Ut(I){ht.call(this,i,I)}function it(I){ht.call(this,i,I)}function Zt(I){ht.call(this,i,I)}function Ht(I){ht.call(this,i,I)}function Rt(){t(53,rn=window.innerWidth)}function lt(I){mi[I?"unshift":"push"](()=>{w=I,t(1,w)})}let zt=()=>{t(7,E=!0);let I;pe&&pe>1&&Number(jt)>1?I=`Please select between ${jt} and ${pe} options`:Number(jt)>1?I=`Please select at least ${jt} options`:I="Please select an option",w?.setCustomValidity(I)},_t=I=>Oo(I),ns=I=>Oo(I),Fi=I=>t(54,oa=I);function sn(I){mi[I?"unshift":"push"](()=>{M=I,t(6,M)})}function wt(){bt=this.value,t(4,bt)}function Bi(I){sa=I,t(51,sa)}let on=(I,nt,Bt)=>{I||go(nt,Bt)},Qn=(I,nt)=>{I||t(0,o=nt)},rs=(I,nt)=>{I||t(0,o=nt)},Un=()=>t(0,o=null),yo=()=>t(0,o=null),aa=I=>{c&&go(bt,I)},la=()=>t(52,Pr=!0),xs=()=>t(52,Pr=!0),Ps=()=>t(52,Pr=!1),Hn=()=>t(52,Pr=!1);function Cs(I){mi[I?"unshift":"push"](()=>{vo=I,t(55,vo)})}function kl(I){mi[I?"unshift":"push"](()=>{Nt=I,t(9,Nt)})}return i.$$set=I=>{"activeIndex"in I&&t(0,o=I.activeIndex),"activeOption"in I&&t(68,a=I.activeOption),"createOptionMsg"in I&&t(10,l=I.createOptionMsg),"allowUserOptions"in I&&t(11,c=I.allowUserOptions),"allowEmpty"in I&&t(69,u=I.allowEmpty),"autocomplete"in I&&t(12,f=I.autocomplete),"autoScroll"in I&&t(70,d=I.autoScroll),"breakpoint"in I&&t(71,h=I.breakpoint),"defaultDisabledTitle"in I&&t(13,p=I.defaultDisabledTitle),"disabled"in I&&t(50,m=I.disabled),"disabledInputTitle"in I&&t(14,g=I.disabledInputTitle),"duplicateOptionMsg"in I&&t(15,O=I.duplicateOptionMsg),"duplicates"in I&&t(16,_=I.duplicates),"key"in I&&t(17,S=I.key),"filterFunc"in I&&t(72,P=I.filterFunc),"closeDropdownOnSelect"in I&&t(73,k=I.closeDropdownOnSelect),"form_input"in I&&t(1,w=I.form_input),"highlightMatches"in I&&t(74,x=I.highlightMatches),"id"in I&&t(18,C=I.id),"input"in I&&t(6,M=I.input),"inputClass"in I&&t(19,Z=I.inputClass),"inputStyle"in I&&t(20,Q=I.inputStyle),"inputmode"in I&&t(21,D=I.inputmode),"invalid"in I&&t(7,E=I.invalid),"liActiveOptionClass"in I&&t(22,j=I.liActiveOptionClass),"liActiveUserMsgClass"in I&&t(23,z=I.liActiveUserMsgClass),"liOptionClass"in I&&t(24,q=I.liOptionClass),"liOptionStyle"in I&&t(25,G=I.liOptionStyle),"liSelectedClass"in I&&t(26,U=I.liSelectedClass),"liSelectedStyle"in I&&t(27,le=I.liSelectedStyle),"liUserMsgClass"in I&&t(28,xe=I.liUserMsgClass),"loading"in I&&t(29,ue=I.loading),"matchingOptions"in I&&t(2,B=I.matchingOptions),"maxOptions"in I&&t(30,J=I.maxOptions),"maxSelect"in I&&t(31,pe=I.maxSelect),"maxSelectMsg"in I&&t(32,Re=I.maxSelectMsg),"maxSelectMsgClass"in I&&t(33,oe=I.maxSelectMsgClass),"name"in I&&t(34,we=I.name),"noMatchingOptionsMsg"in I&&t(35,yt=I.noMatchingOptionsMsg),"open"in I&&t(8,It=I.open),"options"in I&&t(3,ot=I.options),"outerDiv"in I&&t(9,Nt=I.outerDiv),"outerDivClass"in I&&t(36,Sr=I.outerDivClass),"parseLabelsAsHtml"in I&&t(37,nn=I.parseLabelsAsHtml),"pattern"in I&&t(38,$t=I.pattern),"placeholder"in I&&t(39,Tt=I.placeholder),"removeAllTitle"in I&&t(40,at=I.removeAllTitle),"removeBtnTitle"in I&&t(41,dt=I.removeBtnTitle),"minSelect"in I&&t(42,gt=I.minSelect),"required"in I&&t(43,jt=I.required),"resetFilterOnAdd"in I&&t(75,xr=I.resetFilterOnAdd),"searchText"in I&&t(4,bt=I.searchText),"selected"in I&&t(5,et=I.selected),"sortSelected"in I&&t(76,is=I.sortSelected),"selectedOptionsDraggable"in I&&t(44,yl=I.selectedOptionsDraggable),"style"in I&&t(45,Du=I.style),"ulOptionsClass"in I&&t(46,Qu=I.ulOptionsClass),"ulSelectedClass"in I&&t(47,Dn=I.ulSelectedClass),"ulSelectedStyle"in I&&t(48,ks=I.ulSelectedStyle),"ulOptionsStyle"in I&&t(49,bl=I.ulOptionsStyle),"value"in I&&t(67,po=I.value),"$$scope"in I&&t(115,s=I.$$scope)},i.$$.update=()=>{i.$$.dirty[0]&32&&mo(et),i.$$.dirty[2]&32&&Ru(po),i.$$.dirty[0]&196664|i.$$.dirty[2]&1024&&t(2,B=ot.filter(I=>P(I,bt)&&(!et.map(S).includes(S(I))||_))),i.$$.dirty[0]&5&&t(68,a=B[o??-1]??null),i.$$.dirty[0]&32&&t(56,n=I=>et.map(ki).includes(I)),i.$$.dirty[0]&2|i.$$.dirty[1]&4096&&w?.setCustomValidity("")},[o,w,B,ot,bt,et,M,E,It,Nt,l,c,f,p,g,O,_,S,C,Z,Q,D,j,z,q,G,U,le,xe,ue,J,pe,Re,oe,we,yt,Sr,nn,$t,Tt,at,dt,gt,jt,yl,Du,Qu,Dn,ks,bl,m,sa,Pr,rn,oa,vo,n,go,Oo,Mu,vp,yp,Ss,bp,_p,wl,wp,po,a,u,d,h,P,k,x,xr,is,r,Iu,kp,Nu,F,N,W,K,ee,Pe,Le,rt,Ot,Ut,it,Zt,Ht,Rt,lt,zt,_t,ns,Fi,sn,wt,Bi,on,Qn,rs,Un,yo,aa,la,xs,Ps,Hn,Cs,kl,s]}var vg=class extends ne{constructor(e){super(),re(this,e,BD,FD,ie,{activeIndex:0,activeOption:68,createOptionMsg:10,allowUserOptions:11,allowEmpty:69,autocomplete:12,autoScroll:70,breakpoint:71,defaultDisabledTitle:13,disabled:50,disabledInputTitle:14,duplicateOptionMsg:15,duplicates:16,key:17,filterFunc:72,closeDropdownOnSelect:73,form_input:1,highlightMatches:74,id:18,input:6,inputClass:19,inputStyle:20,inputmode:21,invalid:7,liActiveOptionClass:22,liActiveUserMsgClass:23,liOptionClass:24,liOptionStyle:25,liSelectedClass:26,liSelectedStyle:27,liUserMsgClass:28,loading:29,matchingOptions:2,maxOptions:30,maxSelect:31,maxSelectMsg:32,maxSelectMsgClass:33,name:34,noMatchingOptionsMsg:35,open:8,options:3,outerDiv:9,outerDivClass:36,parseLabelsAsHtml:37,pattern:38,placeholder:39,removeAllTitle:40,removeBtnTitle:41,minSelect:42,required:43,resetFilterOnAdd:75,searchText:4,selected:5,sortSelected:76,selectedOptionsDraggable:44,style:45,ulOptionsClass:46,ulSelectedClass:47,ulSelectedStyle:48,ulOptionsStyle:49,value:67},pD,[-1,-1,-1,-1,-1])}},rc=vg;function VD(i=!0){let e=this,t=new IntersectionObserver(function([n]){let r=n.intersectionRatio;if(r<1){let s=r<=0&&i?"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=VD);function WD(i){se(i,"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 XD(i){let e,t,n,r;function s(a){i[2](a)}let o={options:i[0].options.flat(),outerDivClass:"multiselect-dropdown",placeholder:i[0].text};return i[1]!==void 0&&(o.selected=i[1]),t=new rc({props:o}),mi.push(()=>Mr(t,"selected",s)),{c(){e=b("div"),ye(t.$$.fragment),v(e,"class","multiselect-container svelte-1dl3a9e")},m(a,l){A(a,e,l),Oe(t,e,null),r=!0},p(a,[l]){let c={};l&1&&(c.options=a[0].options.flat()),l&1&&(c.placeholder=a[0].text),!n&&l&2&&(n=!0,c.selected=a[1],Qr(()=>n=!1)),t.$set(c)},i(a){r||($(t.$$.fragment,a),r=!0)},o(a){V(t.$$.fragment,a),r=!1},d(a){a&&T(e),ve(t)}}}function YD(i,e,t){let n,r=X,s=()=>(r(),r=Ii(o,l=>t(1,n=l)),o);i.$$.on_destroy.push(()=>r());let{filter:o}=e;s();function a(l){n=l,o.set(n)}return i.$$set=l=>{"filter"in l&&s(t(0,o=l.filter))},[o,n,a]}var yg=class extends ne{constructor(e){super(),re(this,e,YD,XD,ie,{filter:0},WD)}},Nw=yg;var Bf=require("obsidian");function UD(i){se(i,"svelte-1xutc2s",".search.svelte-1xutc2s,.search.svelte-1xutc2s input{width:100%}")}function HD(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","search svelte-1xutc2s")},m(s,o){A(s,e,o),n||(r=H(t=i[1].call(null,e)),n=!0)},p:X,i:X,o:X,d(s){s&&T(e),n=!1,r()}}}function GD(i,e,t){let n,r=X,s=()=>(r(),r=Ii(o,l=>t(2,n=l)),o);i.$$.on_destroy.push(()=>r());let{filter:o}=e;s();let a=l=>{new Bf.TextComponent(l).setPlaceholder(o.text).onChange((0,Bf.debounce)(c=>{Ke(o,n=c,n)},10))};return i.$$set=l=>{"filter"in l&&s(t(0,o=l.filter))},[o,a]}var bg=class extends ne{constructor(e){super(),re(this,e,GD,HD,ie,{filter:0},UD)}},Vf=bg;function KD(i){se(i,"svelte-hht686",".nested-filter-container{display:flex;flex-flow:row wrap;gap:0.5rem}.filter-container.svelte-hht686{flex-grow:1;flex-basis:0}")}function jw(i,e,t){let n=i.slice();return n[5]=e[t],n}function JD(i){let e,t,n,r,s=i[1].type==0&&Zw(i),o=i[1].type==2&&zw(i),a=i[1].type==1&&qw(i);return{c(){e=b("div"),s&&s.c(),t=R(),o&&o.c(),n=R(),a&&a.c(),v(e,"class","filter-container svelte-hht686")},m(l,c){A(l,e,c),s&&s.m(e,null),y(e,t),o&&o.m(e,null),y(e,n),a&&a.m(e,null),r=!0},p(l,c){l[1].type==0?s?(s.p(l,c),c&2&&$(s,1)):(s=Zw(l),s.c(),$(s,1),s.m(e,t)):s&&(Ee(),V(s,1,1,()=>{s=null}),Te()),l[1].type==2?o?(o.p(l,c),c&2&&$(o,1)):(o=zw(l),o.c(),$(o,1),o.m(e,n)):o&&(Ee(),V(o,1,1,()=>{o=null}),Te()),l[1].type==1?a?(a.p(l,c),c&2&&$(a,1)):(a=qw(l),a.c(),$(a,1),a.m(e,null)):a&&(Ee(),V(a,1,1,()=>{a=null}),Te())},i(l){r||($(s),$(o),$(a),r=!0)},o(l){V(s),V(o),V(a),r=!1},d(l){l&&T(e),s&&s.d(),o&&o.d(),a&&a.d()}}}function e8(i){let e,t,n=fe(i[0].nested),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){e=b("div");for(let o=0;o{o[u]=null}),Te(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),$(t,1),t.m(n.parentNode,n))},i(l){r||($(t),r=!0)},o(l){V(t),r=!1},d(l){l&&T(n),o[e].d(l)}}}function i8(i,e,t){let n,r=Ye("filters"),{filters:s}=r;ke(i,s,l=>t(3,n=l));let{layout:o}=e,a;return i.$$set=l=>{"layout"in l&&t(0,o=l.layout)},i.$$.update=()=>{i.$$.dirty&9&&("nested"in o||t(1,a=n.get(o.id)))},[o,a,s,n]}var Wf=class extends ne{constructor(e){super(),re(this,e,i8,t8,ie,{layout:0},KD)}},Fw=Wf;function n8(i){se(i,"svelte-1teebz7",".filters-container.svelte-1teebz7{display:flex;flex-flow:column nowrap;gap:1rem}.controls.svelte-1teebz7{display:flex;justify-content:space-between;align-items:center;gap:0.5rem}.filter-button.svelte-1teebz7{position:relative}.filter-number.svelte-1teebz7{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}.filters.svelte-1teebz7{display:flex;flex-flow:column nowrap;gap:1rem}")}function Bw(i,e,t){let n=i.slice();return n[10]=e[t],n}function Vw(i){let e,t,n,r=fe(i[2]),s=[];for(let a=0;aV(s[a],1,1,()=>{s[a]=null});return{c(){e=b("div");for(let a=0;a{n&&(t||(t=So(e,Ym,{easing:In},!0)),t.run(1))}),n=!0}},o(a){s=s.filter(Boolean);for(let l=0;l{k=null}),Te())},i(w){_||($(n.$$.fragment,w),$(k),_=!0)},o(w){V(n.$$.fragment,w),V(k),_=!1},d(w){w&&T(e),ve(n),k&&k.d(),S=!1,de(P)}}}function s8(i,e,t){let n,r,s=!1,o=Fe(),a=Ye("filters"),{active:l,name:c,layout:u}=a;return ke(i,l,O=>t(1,n=O)),ke(i,u,O=>t(2,r=O)),[s,n,r,o,a,l,c,O=>{new Xf.ExtraButtonComponent(O).setIcon("reset")},O=>{new Xf.ExtraButtonComponent(O).setIcon("filter")},O=>{new Xf.ExtraButtonComponent(O).setIcon("settings")},u,()=>t(0,s=!s),()=>a.reset(),O=>o("settings",O)]}var _g=class extends ne{constructor(e){super(),re(this,e,s8,r8,ie,{},n8)}},Xw=_g;var uo=require("obsidian");var Do=require("obsidian");function o8(i){se(i,"svelte-zo5pkp",".pagination.svelte-zo5pkp{display:flex;justify-content:space-between;align-items:center;gap:1rem}.paginated-container.svelte-zo5pkp{display:flex;align-items:center;gap:1rem}.paginated.svelte-zo5pkp{display:flex;align-items:center;gap:1rem}.clickable-icon.active.svelte-zo5pkp{background-color:var(--background-modifier-hover)}.slicer.svelte-zo5pkp{display:flex;align-items:center;gap:0.5rem}")}function Yw(i,e,t){let n=i.slice();return n[14]=e[t],n}function a8(i){let e,t=i[14]+"",n,r,s,o;function a(){return i[13](i[14])}return{c(){e=b("span"),n=ae(t),r=R(),v(e,"class","clickable-icon svelte-zo5pkp"),ge(e,"active",i[14]==i[0])},m(l,c){A(l,e,c),y(e,n),y(e,r),s||(o=Y(e,"click",a),s=!0)},p(l,c){i=l,c&2&&t!==(t=i[14]+"")&&me(n,t),c&3&&ge(e,"active",i[14]==i[0])},d(l){l&&T(e),s=!1,o()}}}function l8(i){let e,t,n;return{c(){e=b("span"),e.textContent="..."},m(r,s){A(r,e,s),t||(n=Y(e,"click",i[12]),t=!0)},p:X,d(r){r&&T(e),t=!1,n()}}}function Uw(i){let e;function t(s,o){return s[14]==null?l8:a8}let n=t(i,-1),r=n(i);return{c(){r.c(),e=tt()},m(s,o){r.m(s,o),A(s,e,o)},p(s,o){n===(n=t(s,o))&&r?r.p(s,o):(r.d(1),r=n(s),r&&(r.c(),r.m(e.parentNode,e)))},d(s){s&&T(e),r.d(s)}}}function c8(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_=fe(i[1]),S=[];for(let P=0;P<_.length;P+=1)S[P]=Uw(Yw(i,_,P));return{c(){e=b("div"),t=b("div"),n=b("div"),s=R(),o=b("span"),o.textContent="per page",a=R(),l=b("div"),c=b("div"),f=R(),d=b("div");for(let P=0;P{new Do.DropdownComponent(O).addOptions({10:"10",25:"25",50:"50",100:"100",200:"200"}).setValue(`${s}`).onChange(_=>l("slice",Number(_)))},u,f=O=>{t(9,u=new Do.ExtraButtonComponent(O).setIcon("chevron-left").setDisabled(o==1).onClick(()=>{l("previous")}))},d,h=O=>{t(10,d=new Do.ExtraButtonComponent(O).setIcon("chevron-right").setDisabled(o==a).onClick(()=>{l("next")}))},p=O=>{let _=new Do.Menu;for(let S of n)_.addItem(P=>{P.setTitle(`${S}`).onClick(()=>{l("page",S)})});_.showAtMouseEvent(O)},m=O=>p(O),g=O=>l("page",O);return i.$$set=O=>{"slice"in O&&t(7,s=O.slice),"page"in O&&t(0,o=O.page),"pages"in O&&t(8,a=O.pages)},i.$$.update=()=>{i.$$.dirty&256&&t(11,n=[...Array(a).keys()].map(O=>O+1)),i.$$.dirty&1793&&d&&u&&(d.setDisabled(o==a),u.setDisabled(o==1)),i.$$.dirty&2305&&t(1,r=n.reduce((O,_)=>(_==1||o==1&&(_==2||_==3)||_==a||o==a&&(_==a-1||_==a-2)||_==o-1||_==o||_==o+1?O.push(_):O.length>=1&&O[O.length-1]!=null&&O.push(null),O),[]))},[o,r,l,c,f,h,p,s,a,u,d,n,m,g]}var wg=class extends ne{constructor(e){super(),re(this,e,u8,c8,ie,{slice:7,page:0,pages:8},o8)}},Hw=wg;var WP=require("obsidian");var ZG=require("obsidian");var $G=$e(0),zs=class i{constructor(e,t,n,r){this.text=e;this.field=t;this.type=n;this.func=r;te(this,"active");te(this,"id",xt());te(this,"_func",this.getSortByType())}getSortByType(){switch(this.type){case 0:return(e,t)=>(e[this.field]??"").localeCompare(t[this.field]??"");case 1:return(e,t)=>hi(e[this.field]??0)-hi(t[this.field]??0);case 2:return new Function("a","b",this.func)}}sortAsc(e,t){return this._func(e,t)}sortDesc(e,t){return this._func(t,e)}toState(){return{text:this.text,field:this.field,type:this.type,...this.func&&this.func.length?{func:this.func}:{}}}static fromState(e){return new i(e.text,e.field,e.type,e.func)}static get defaultState(){return{text:"",field:"",type:0}}},Gw=[{text:"CR",field:"cr",type:1},{text:"Type",field:"type",type:0},{text:"Size",field:"size",type:0},{text:"Alignment",field:"alignment",type:0}],sc=zs.fromState({text:"Name",field:"name",type:0});function Jw(i,e){i.data.builder||(i.data.builder={sidebarIcon:!0,showParty:!0,showXP:!0}),i.data.builder.headers||(i.data.builder.headers=ci(Gw),i.saveSettings());let t=$e(i.data.builder.headers.map(f=>zs.fromState(f))),{subscribe:n,set:r,update:s}=t,o=$e(ci(e)),a=$e(!0),l=oi(t,f=>[sc,...f]),c=f=>s(d=>{if(f.active)a.update(h=>!h);else{let h=ct(l).find(p=>p.active);h&&(h.active=!1),f.active=!0,a.set(!0)}return o.update(h=>(h.sort(ct(a)?f.sortAsc.bind(f):f.sortDesc.bind(f)),h)),d});function u(f){s(f),i.saveSettings()}return{allHeaders:l,subscribe:n,set:r,update:s,sort:c,sortDir:a,creatures:o,reset:()=>o.update(()=>ci(e)),setHeadersFromState:f=>u(d=>{i.data.builder.headers=f;let h=f.map(m=>zs.fromState(m)),p=d.findIndex(m=>m.active);return p>=0&&pu(f=>(i.data.builder.headers=ci(Gw),i.data.builder.headers.map(d=>zs.fromState(d))))}}var Gr=require("obsidian");var Hr=require("obsidian");var ut=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,n){[e,t]=za(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Ia.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=za(this,e,t);let n=[];return this.decompose(e,t,n,0),Ia.from(n,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),n=this.length-this.scanIdentical(e,-1),r=new Mo(this),s=new Mo(e);for(let o=t,a=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new Mo(this,e)}iterRange(e,t=this.length){return new Gf(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Kf(n)}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 Sn(e):Ia.from(Sn.split(e,[]))}},Sn=class i extends ut{constructor(e,t=f8(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],a=r+o.length;if((t?n:a)>=e)return new Sg(r,a,n,o);r=a+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new i(ek(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),a=Hf(s.text,o.text.slice(),0,s.length);if(a.length<=32)n.push(new i(a,o.length+s.length));else{let l=a.length>>1;n.push(new i(a.slice(0,l)),new i(a.slice(l)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof i))return super.replace(e,t,n);[e,t]=za(this,e,t);let r=Hf(this.text,Hf(n.text,ek(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new i(r,s):Ia.from(i.split(r,[]),s)}sliceString(e,t=this.length,n=` `){[e,t]=za(this,e,t);let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=n),es&&(r+=a.slice(Math.max(0,e-s),t-s)),s=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new i(n,r)),n=[],r=-1);return r>-1&&t.push(new i(n,r)),t}},Ia=class i extends ut{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],a=r+o.length,l=n+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,n,r);r=a+1,n=l+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s=o){let c=r&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!c?n.push(a):a.decompose(e-o,t-o,n,c)}o=l+1}}replace(e,t,n){if([e,t]=za(this,e,t),n.lines=s&&t<=a){let l=o.replace(e-s,t-s,n),c=this.lines-o.lines+l.lines;if(l.lines>4&&l.lines>c>>6){let u=this.children.slice();return u[r]=l,new i(u,this.length-(t-e)+n.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=` `){[e,t]=za(this,e,t);let r="";for(let s=0,o=0;se&&s&&(r+=n),eo&&(r+=a.sliceString(e-o,t-o,n)),o=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i))return 0;let n=0,[r,s,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==a)return n;let l=this.children[r],c=e.children[s];if(l!=c)return n+l.scanIdentical(c,t);n+=l.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let h of e)n+=h.lines;if(n<32){let h=[];for(let p of e)p.flatten(h);return new Sn(h,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,a=[],l=0,c=-1,u=[];function f(h){let p;if(h.lines>s&&h instanceof i)for(let m of h.children)f(m);else h.lines>o&&(l>o||!l)?(d(),a.push(h)):h instanceof Sn&&l&&(p=u[u.length-1])instanceof Sn&&h.lines+p.lines<=32?(l+=h.lines,c+=h.length+1,u[u.length-1]=new Sn(p.text.concat(h.text),p.length+1+h.length)):(l+h.lines>r&&d(),l+=h.lines,c+=h.length+1,u.push(h))}function d(){l!=0&&(a.push(u.length==1?u[0]:i.from(u,c)),c=-1,l=u.length=0)}for(let h of e)f(h);return d(),a.length==1?a[0]:new i(a,t)}};ut.empty=new Sn([""],0);function f8(i){let e=-1;for(let t of i)e+=t.length+1;return e}function Hf(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s=t&&(l>n&&(a=a.slice(0,n-r)),r0?1:(e instanceof Sn?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,a=r instanceof Sn?r.text.length:r.children.length;if(o==(t>0?a:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(r instanceof Sn){let l=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof Sn?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},Gf=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Mo(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}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 n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),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!=""}},Kf=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(ut.prototype[Symbol.iterator]=function(){return this.iter()},Mo.prototype[Symbol.iterator]=Gf.prototype[Symbol.iterator]=Kf.prototype[Symbol.iterator]=function(){return this});var Sg=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function za(i,e,t){return e=Math.max(0,Math.min(i.length,e)),[e,Math.max(e,Math.min(i.length,t))]}var Na="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 Na[e-1]<=i;return!1}function tk(i){return i>=127462&&i<=127487}var ik=8205;function ui(i,e,t=!0,n=!0){return(t?lk:h8)(i,e,n)}function lk(i,e,t){if(e==i.length)return e;e&&ck(i.charCodeAt(e))&&uk(i.charCodeAt(e-1))&&e--;let n=gi(i,e);for(e+=Yi(n);e=0&&tk(gi(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function h8(i,e,t){for(;e>0;){let n=lk(i,e-2,t);if(n=56320&&i<57344}function uk(i){return i>=55296&&i<56320}function gi(i,e){let t=i.charCodeAt(e);if(!uk(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return ck(n)?(t-55296<<10)+(n-56320)+65536:t}function fc(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Yi(i){return i<65536?1:2}var xg=/\r\n?|\n/,Ei=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(Ei||(Ei={})),ps=class i{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-r);s+=a}else{if(n!=Ei.Simple&&c>=e&&(n==Ei.TrackDel&&re||n==Ei.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!a)return e==r||t<0?s:s+l;s+=l}r=c}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n=0&&r<=t&&a>=e)return rt?"cover":!0;r=a}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}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)}},Ui=class i extends ps{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 Pg(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return Cg(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r=0){t[r]=a,t[r+1]=o;let l=r>>1;for(;n.length0&&qs(n,t,s.text),s.forward(u),a+=u}let c=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],o=0,a=null;function l(u=!1){if(!u&&!r.length)return;od||f<0||d>t)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${t})`);let p=h?typeof h=="string"?ut.of(h.split(n||xg)):h:ut.empty,m=p.length;if(f==d&&m==0)return;fo&&Zi(r,f-o,-1),Zi(r,d-f,m),qs(s,r,p),o=d}}return c(e),l(!a),a}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=[],n=[];for(let r=0;ra&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length=0&&t<=0&&t==i[r+1]?i[r]+=e:e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function qs(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)a=i.sections[o++],l=i.sections[o++];e(r,c,s,u,f),r=c,s=u}}}function Cg(i,e,t,n=!1){let r=[],s=n?[]:null,o=new Io(i),a=new Io(e);for(let l=-1;;)if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);Zi(r,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let c=0,u=o.len;for(;u;)if(a.ins==-1){let f=Math.min(u,a.len);c+=f,u-=f,a.forward(f)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||n.length>c),s.forward2(l),o.forward(l)}}}}var Io=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?ut.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?ut.empty:t[n].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)}},Ma=class i{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}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 n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new i(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return ce.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return ce.range(this.anchor,n)}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 ce.range(e.anchor,e.head)}static create(e,t,n){return new i(e,t,n)}},ce=class i{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:i.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.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=>Ma.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 n=0,r=0;re?8:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(n);for(let r=1;rs.head?i.range(l,a):i.range(a,l))}}return new i(e,t)}};function dk(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}var jg=0,Ae=class i{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=jg++,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,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:Zg),!!e.static,e.enables)}of(e){return new ja([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ja(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ja(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}};function Zg(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}var ja=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=jg++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?c=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||u.push(e[f.id]);return{create(f){return f.values[o]=n(f),1},update(f,d){if(l&&d.docChanged||c&&(d.docChanged||d.selection)||Eg(f,u)){let h=n(f);if(a?!nk(h,f.values[o],r):!r(h,f.values[o]))return f.values[o]=h,1}return 0},reconfigure:(f,d)=>{let h,p=d.config.address[s];if(p!=null){let m=id(d,p);if(this.dependencies.every(g=>g instanceof Ae?d.facet(g)===f.facet(g):g instanceof Xt?d.field(g,!1)==f.field(g,!1):!0)||(a?nk(h=n(f),m,r):r(h=n(f),m)))return f.values[o]=m,0}else h=n(f);return f.values[o]=h,1}}}};function nk(i,e,t){if(i.length!=e.length)return!1;for(let n=0;ni[l.id]),r=t.map(l=>l.type),s=n.filter(l=>!(l&1)),o=i[e.id]>>1;function a(l){let c=[];for(let u=0;un===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(rk).find(n=>n.field==this);return(t?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,r)=>{let s=n.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,r)=>r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,rk.of({field:this,create:e})]}get extension(){return this}},Qo={lowest:4,low:3,default:2,high:1,highest:0};function oc(i){return e=>new Jf(e,i)}var fr={highest:oc(Qo.highest),high:oc(Qo.high),default:oc(Qo.default),low:oc(Qo.low),lowest:oc(Qo.lowest)},Jf=class{constructor(e,t){this.inner=e,this.prec=t}},ed=class i{of(e){return new lc(this,e)}reconfigure(e){return i.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}},lc=class{constructor(e,t){this.compartment=e,this.inner=t}},td=class i{constructor(e,t,n,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,n){let r=[],s=Object.create(null),o=new Map;for(let d of m8(e,t,o))d instanceof Xt?r.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let a=Object.create(null),l=[],c=[];for(let d of r)a[d.id]=c.length<<1,c.push(h=>d.slot(h));let u=n?.config.facets;for(let d in s){let h=s[d],p=h[0].facet,m=u&&u[d]||[];if(h.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,Zg(m,h))l.push(n.facet(p));else{let g=p.combine(h.map(O=>O.value));l.push(n&&p.compare(g,n.facet(p))?n.facet(p):g)}else{for(let g of h)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=c.length<<1,c.push(O=>g.dynamicSlot(O)));a[p.id]=c.length<<1,c.push(g=>p8(g,p,h))}}let f=c.map(d=>d(a));return new i(e,o,f,a,l,s)}};function m8(i,e,t){let n=[[],[],[],[],[]],r=new Map;function s(o,a){let l=r.get(o);if(l!=null){if(l<=a)return;let c=n[l].indexOf(o);c>-1&&n[l].splice(c,1),o instanceof lc&&t.delete(o.compartment)}if(r.set(o,a),Array.isArray(o))for(let c of o)s(c,a);else if(o instanceof lc){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;t.set(o.compartment,c),s(c,a)}else if(o instanceof Jf)s(o.inner,o.prec);else if(o instanceof Xt)n[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof ja)n[a].push(o),o.facet.extensions&&s(o.facet.extensions,Qo.default);else{let c=o.extension;if(!c)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(c,a)}}return s(i,Qo.default),n.reduce((o,a)=>o.concat(a))}function ac(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let r=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|r}function id(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}var hk=Ae.define(),Tg=Ae.define({combine:i=>i.some(e=>e),static:!0}),pk=Ae.define({combine:i=>i.length?i[0]:void 0,static:!0}),mk=Ae.define(),gk=Ae.define(),Ok=Ae.define(),vk=Ae.define({combine:i=>i.length?i[0]:!1}),pn=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Ag}},Ag=class{of(e){return new pn(this,e)}},Dg=class{constructor(e){this.map=e}of(e){return new ze(this,e)}},ze=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 Dg(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}};ze.reconfigure=ze.define();ze.appendConfig=ze.define();var Oi=class i{constructor(e,t,n,r,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&dk(n,t.newLength),s.some(a=>a.type==i.time)||(this.annotations=s.concat(i.time.of(Date.now())))}static create(e,t,n,r,s,o){return new i(e,t,n,r,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]=="."))}};Oi.time=pn.define();Oi.userEvent=pn.define();Oi.addToHistory=pn.define();Oi.remote=pn.define();function g8(i,e){let t=[];for(let n=0,r=0;;){let s,o;if(n=i[n]))s=i[n++],o=i[n++];else if(r=0;r--){let s=n[r](i);s instanceof Oi?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Oi?i=s[0]:i=bk(e,Za(s),!1)}return i}function v8(i){let e=i.startState,t=e.facet(Ok),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=yk(n,Qg(e,s,i.changes.newLength),!0))}return n==i?i:Oi.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}var y8=[];function Za(i){return i==null?y8:Array.isArray(i)?i:[i]}var Pt=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(Pt||(Pt={})),b8=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Rg;try{Rg=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function _8(i){if(Rg)return Rg.test(i);for(let e=0;e"\x80"&&(t.toUpperCase()!=t.toLowerCase()||b8.test(t)))return!0}return!1}function w8(i){return e=>{if(!/\S/.test(e))return Pt.Space;if(_8(e))return Pt.Word;for(let t=0;t-1)return Pt.Word;return Pt.Other}}var At=class i{constructor(e,t,n,r,s,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;ar.set(c,l)),t=null),r.set(a.value.compartment,a.value.extension)):a.is(ze.reconfigure)?(t=null,n=a.value):a.is(ze.appendConfig)&&(t=null,n=Za(n).concat(a.value));let s;t?s=e.startState.values.slice():(t=td.resolve(n,r,this),s=new i(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(Tg)?e.newSelection:e.newSelection.asSingle();new i(t,e.newDoc,o,s,(a,l)=>l.update(a,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:ce.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],o=Za(n.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return i.create({doc:e.doc,selection:ce.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=td.resolve(e.extensions||[],new Map),n=e.doc instanceof ut?e.doc:ut.of((e.doc||"").split(t.staticFacet(i.lineSeparator)||xg)),r=e.selection?e.selection instanceof ce?e.selection:ce.single(e.selection.anchor,e.selection.head):ce.single(0);return dk(r,n.length),t.staticFacet(Tg)||(r=r.asSingle()),new i(t,n,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(i.tabSize)}get lineBreak(){return this.facet(i.lineSeparator)||` `}get readOnly(){return this.facet(vk)}phrase(e,...t){for(let n of this.facet(i.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(hk))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return w8(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,a=e-n;for(;o>0;){let l=ui(t,o,!1);if(s(t.slice(l,o))!=Pt.Word)break;o=l}for(;ai.length?i[0]:4});At.lineSeparator=pk;At.readOnly=vk;At.phrases=Ae.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});At.languageData=hk;At.changeFilter=mk;At.transactionFilter=gk;At.transactionExtender=Ok;ed.reconfigure=ze.define();function mn(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],a=n[s];if(a===void 0)n[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}var ur=class{eq(e){return this==e}range(e,t=e){return cc.create(e,t,this)}};ur.prototype.startSide=ur.prototype.endSide=0;ur.prototype.point=!1;ur.prototype.mapMode=Ei.TrackDel;var cc=class i{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new i(e,t,n)}};function Mg(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}var Ig=class i{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,a=s.length;;){if(o==a)return o;let l=o+a>>1,c=s[l]-e||(n?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return c>=0?o:a;c>=0?a=l:o=l+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);sh||d==h&&c.startSide>0&&c.endSide<=0)continue;(h-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(a=Math.max(a,h-d)),n.push(c),r.push(d-o),s.push(h-o))}return{mapped:n.length?new i(r,s,n,a):null,pos:o}}},kt=class i{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new i(e,t,n,r)}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:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(Mg)),this.isEmpty)return t.length?i.of(t):this;let a=new nd(this,null,-1).goto(0),l=0,c=[],u=new jr;for(;a.value||l=0){let f=t[l++];u.addInner(f.from,f.to,f.value)||c.push(f)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||sa.to||s=s&&e<=s+o.length&&o.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return uc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return uc.from(e).goto(t)}static compare(e,t,n,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=sk(o,a,n),c=new Ro(o,l,s),u=new Ro(a,l,s);n.iterGaps((f,d,h)=>ok(c,f,u,d,h,r)),n.empty&&n.length==0&&ok(c,0,u,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=999999999);let s=e.filter(u=>!u.isEmpty&&t.indexOf(u)<0),o=t.filter(u=>!u.isEmpty&&e.indexOf(u)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=sk(s,o),l=new Ro(s,a,0).goto(n),c=new Ro(o,a,0).goto(n);for(;;){if(l.to!=c.to||!Ng(l.active,c.active)||l.point&&(!c.point||!l.point.eq(c.point)))return!1;if(l.to>r)return!0;l.next(),c.next()}}static spans(e,t,n,r,s=-1){let o=new Ro(e,null,s).goto(t),a=t,l=o.openStart;for(;;){let c=Math.min(o.to,n);if(o.point){let u=o.activeForPoint(o.to),f=o.pointFroma&&(r.span(a,c,o.active,l),l=o.openEnd(c));if(o.to>n)return l+(o.point&&o.to>n?1:0);a=o.to,o.next()}}static of(e,t=!1){let n=new jr;for(let r of e instanceof cc?[e]:t?k8(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(e){if(!e.length)return i.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let r=e[n];r!=i.empty;r=r.nextLayer)t=new i(r.chunkPos,r.chunk,t,Math.max(r.maxPoint,t.maxPoint));return t}};kt.empty=new kt([],[],null,-1);function k8(i){if(i.length>1)for(let e=i[0],t=1;t0)return i.slice().sort(Mg);e=n}return i}kt.empty.nextLayer=kt.empty;var jr=class i{finishChunk(e){this.chunks.push(new Ig(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,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new i)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<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=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.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 n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(kt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=kt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function sk(i,e,t){let n=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=n&&r.push(new nd(o,t,n,s));return r.length==1?r[0]:new i(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)kg(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)kg(this.heap,n);(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(),kg(this.heap,0)}}};function kg(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1=0&&(r=i[n+1],n++),t.compare(r)<0)break;i[n]=t,i[e]=r,e=n}}var Ro=class{constructor(e,t,n){this.minPoint=n,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=uc.from(e,t,n)}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){Yf(this.active,e),Yf(this.activeTo,e),Yf(this.activeRank,e),this.minActive=ak(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t0;)t++;Uf(this.active,t,n),Uf(this.activeTo,t,r),Uf(this.activeRank,t,s),e&&Uf(e,t,this.cursor.from),this.minActive=ak(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Yf(n,r)}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(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[r]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function ok(i,e,t,n,r,s){i.goto(e),t.goto(n);let o=n+r,a=n,l=n-e;for(;;){let c=i.to+l-t.to||i.endSide-t.endSide,u=c<0?i.to+l:t.to,f=Math.min(u,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Ng(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(a,f,i.point,t.point):f>a&&!Ng(i.active,t.active)&&s.compareRange(a,f,i.active,t.active),u>o)break;a=u,c<=0&&i.next(),c>=0&&t.next()}}function Ng(i,e){if(i.length!=e.length)return!1;for(let t=0;t=e;n--)i[n+1]=i[n];i[e]=t}function ak(i,e){let t=-1,n=1e9;for(let r=0;r=e)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?t-s%t:1,r=ui(i,r)}return n===!0?-1:i.length}var zg="\u037C",_k=typeof Symbol>"u"?"__"+zg:Symbol.for(zg),qg=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),wk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Zn=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,a,l,c){let u=[],f=/^@(\w+)\b/.exec(o[0]),d=f&&f[1]=="keyframes";if(f&&a==null)return l.push(o[0]+";");for(let h in a){let p=a[h];if(/&/.test(h))s(h.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,l);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(r(h),p,u,d)}else p!=null&&u.push(h.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(u.length||d)&&l.push((n&&!f&&!c?o.map(n):o).join(", ")+" {"+u.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=wk[_k]||1;return wk[_k]=e+1,zg+e.toString(36)}static mount(e,t,n){let r=e[qg],s=n&&n.nonce;r?s&&r.setNonce(s):r=new Lg(e,s),r.mount(Array.isArray(t)?t:[t],e)}},kk=new Map,Lg=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=kk.get(n);if(s)return e[qg]=s;this.sheet=new r.CSSStyleSheet,kk.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[qg]=this}mount(e,t){let n=this.sheet,r=0,s=0;for(let o=0;o-1&&(this.modules.splice(l,1),s--,l=-1),l==-1){if(this.modules.splice(s++,0,a),n)for(let c=0;c",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},S8=typeof navigator<"u"&&/Mac/.test(navigator.platform),x8=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(fi=0;fi<10;fi++)ms[48+fi]=ms[96+fi]=String(fi);var fi;for(fi=1;fi<=24;fi++)ms[fi+111]="F"+fi;var fi;for(fi=65;fi<=90;fi++)ms[fi]=String.fromCharCode(fi+32),qa[fi]=String.fromCharCode(fi);var fi;for(sd in ms)qa.hasOwnProperty(sd)||(qa[sd]=ms[sd]);var sd;function Sk(i){var e=S8&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||x8&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?qa:ms)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function bd(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function Yg(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function P8(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function md(i,e){if(!e.anchorNode)return!1;try{return Yg(i,e.anchorNode)}catch{return!1}}function kc(i){return i.nodeType==3?jo(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function vc(i,e,t,n){return t?xk(i,e,t,n,-1)||xk(i,e,t,n,1):!1}function No(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function _d(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}function xk(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:gs(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=No(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=r<0?gs(i):0}else return!1}}function gs(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function D0(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function C8(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 l2(i,e){let t=e.width/i.offsetWidth,n=e.height/i.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-i.offsetWidth)<1)&&(t=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-i.offsetHeight)<1)&&(n=1),{scaleX:t,scaleY:n}}function E8(i,e,t,n,r,s,o,a){let l=i.ownerDocument,c=l.defaultView||window;for(let u=i,f=!1;u&&!f;)if(u.nodeType==1){let d,h=u==l.body,p=1,m=1;if(h)d=C8(c);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(f=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let _=u.getBoundingClientRect();({scaleX:p,scaleY:m}=l2(u,_)),d={left:_.left,right:_.left+u.clientWidth*p,top:_.top,bottom:_.top+u.clientHeight*m}}let g=0,O=0;if(r=="nearest")e.top0&&e.bottom>d.bottom+O&&(O=e.bottom-d.bottom+O+o)):e.bottom>d.bottom&&(O=e.bottom-d.bottom+o,t<0&&e.top-O0&&e.right>d.right+g&&(g=e.right-d.right+g+s)):e.right>d.right&&(g=e.right-d.right+s,t<0&&e.leftt.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}var Ug=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:n}=e;this.set(t,Math.min(e.anchorOffset,t?gs(t):0),n,Math.min(e.focusOffset,n?gs(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},La=null;function c2(i){if(i.setActive)return i.setActive();if(La)return i.focus(La);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(La==null?{get preventScroll(){return La={preventScroll:!0},!0}}:void 0),!La){La=!1;for(let t=0;tMath.max(1,i.scrollHeight-i.clientHeight-4)}function d2(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&n>0)return{node:t,offset:n};if(t.nodeType==1&&n>0){if(t.contentEditable=="false")return null;t=t.childNodes[n-1],n=gs(t)}else if(t.parentNode&&!_d(t))n=No(t),t=t.parentNode;else return null}}function h2(i,e){for(let t=i,n=e;;){if(t.nodeType==3&&nt)return f.domBoundsAround(e,t,c);if(d>=e&&r==-1&&(r=l,s=c),c>t&&f.dom.parentNode==this.dom){o=l,a=u;break}u=d,c=d+f.breakAfter}return{from:s,to:a<0?n+this.length:a,startDOM:(r?this.children[r-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,n=Q0){this.markDirty();for(let r=e;rthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}};function p2(i,e,t,n,r,s,o,a,l){let{children:c}=i,u=c.length?c[e]:null,f=s.length?s[s.length-1]:null,d=f?f.breakAfter:o;if(!(e==n&&u&&!o&&!d&&s.length<2&&u.merge(t,r,s.length?f:null,t==0,a,l))){if(n0&&(!o&&s.length&&u.merge(t,u.length,s[0],!1,a,0)?u.breakAfter=s.shift().breakAfter:(t2),Qe={mac:Ak||/Mac/.test(xn.platform),windows:/Win/.test(xn.platform),linux:/Linux|X11/.test(xn.platform),ie:Id,ie_version:g2?Hg.documentMode||6:Kg?+Kg[1]:Gg?+Gg[1]:0,gecko:Ek,gecko_version:Ek?+(/Firefox\/(\d+)/.exec(xn.userAgent)||[0,0])[1]:0,chrome:!!$g,chrome_version:$g?+$g[1]:0,ios:Ak,android:/Android\b/.test(xn.userAgent),webkit:Tk,safari:O2,webkit_version:Tk?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Hg.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"},Q8=256,$r=class i extends Mt{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,n){return this.flags&8||n&&(!(n instanceof i)||this.length-(t-e)+n.length>Q8||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.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 Hi(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return R8(this.dom,e,t)}},Bs=class i extends Mt{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let r of t)r.setParent(this)}setAttrs(e){if(u2(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,n,r,s,o){return n&&(!(n instanceof i&&n.mark.eq(this.mark))||e&&s<=0||te&&t.push(n=e&&(r=s),n=l,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new i(this.mark,t,o)}domAtPos(e){return v2(this,e)}coordsAt(e,t){return b2(this,e,t)}};function R8(i,e,t){let n=i.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;e==0&&t<0||e==n&&t>=0?Qe.chrome||Qe.gecko||(e?(r--,o=1):s=0)?0:a.length-1];return Qe.safari&&!o&&l.width==0&&(l=Array.prototype.find.call(a,c=>c.width)||l),o?D0(l,o<0):l||null}var Sc=class i extends Mt{static create(e,t,n){return new i(e,t,n)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,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,n,r,s,o){return n&&(!(n instanceof i)||!this.widget.compare(n.widget)||e>0&&s<=0||t0)?Hi.before(this.dom):Hi.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let a=o?r.length-1:0;s=r[a],!(e>0?a==0:a==r.length-1||s.top0?Hi.before(this.dom):Hi.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return ut.empty}get isHidden(){return!0}};$r.prototype.children=Sc.prototype.children=xc.prototype.children=Q0;function v2(i,e){let t=i.dom,{children:n}=i,r=0;for(let s=0;rs&&e0;s--){let o=n[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s0&&e instanceof Bs&&r.length&&(n=r[r.length-1])instanceof Bs&&n.mark.eq(e.mark)?y2(n,e.children[0],t-1):(r.push(e),e.setParent(i)),i.length+=e.length}function b2(i,e,t){let n=null,r=-1,s=null,o=-1;function a(c,u){for(let f=0,d=0;f=u&&(h.children.length?a(h,u-d):(!s||s.isHidden&&t>0)&&(p>u||d==p&&h.getSide()>0)?(s=h,o=u-d):(d-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of n)if(s!=t&&(r.indexOf(s)==-1||i[s]!==e[s]))return!1;return!0}function e0(i,e,t){let n=!1;if(e)for(let r in e)t&&r in t||(n=!0,r=="style"?i.style.cssText="":i.removeAttribute(r));if(t)for(let r in t)e&&e[r]==t[r]||(n=!0,r=="style"?i.style.cssText=t[r]:i.setAttribute(r,t[r]));return n}function I8(i){let e=Object.create(null);for(let t=0;t0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,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){R0(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){y2(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Jg(t,this.attrs||{})),n&&(this.attrs=Jg({class:n},this.attrs||{}))}domAtPos(e){return v2(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(u2(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&&(e0(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&Mt.get(r)instanceof Bs;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((n=Mt.get(r))===null||n===void 0?void 0:n.isEditable)==!1&&(!Qe.ios||!this.children.some(s=>s instanceof $r))){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 n of this.children){if(!(n instanceof $r)||/[^ -~]/.test(n.text))return null;let r=kc(n.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=b2(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight=t){if(s instanceof i)return s;if(o>t)break}r=o+s.breakAfter}return null}},Va=class i extends Mt{constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,r,s,o){return n&&(!(n instanceof i)||!this.widget.compare(n.widget)||e>0&&s<=0||t0}},dr=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Gi=function(i){return i[i.Text=0]="Text",i[i.WidgetBefore=1]="WidgetBefore",i[i.WidgetAfter=2]="WidgetAfter",i[i.WidgetRange=3]="WidgetRange",i}(Gi||(Gi={})),je=class extends ur{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Pc(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Vs(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=_2(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Vs(e,n,r,t,e.widget||null,!0)}static line(e){return new Cc(e)}static set(e,t=!1){return kt.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};je.none=kt.empty;var Pc=class i extends je{constructor(e){let{start:t,end:n}=_2(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;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||((n=e.attrs)===null||n===void 0?void 0:n.class))&&R0(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)}};Pc.prototype.point=!1;var Cc=class i extends je{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof i&&this.spec.class==e.spec.class&&R0(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)}};Cc.prototype.mapMode=Ei.TrackBefore;Cc.prototype.point=!0;var Vs=class i extends je{constructor(e,t,n,r,s,o){super(t,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?Ei.TrackBefore:Ei.TrackAfter:Ei.TrackDel}get type(){return this.startSide!=this.endSide?Gi.WidgetRange:this.startSide<=0?Gi.WidgetBefore:Gi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof i&&N8(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)}};Vs.prototype.point=!0;function _2(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function N8(i,e){return i==e||!!(i&&e&&i.compare(e))}function t0(i,e,t,n=0){let r=t.length-1;r>=0&&t[r]+n>=i?t[r]=Math.max(t[r],e):t.push(i,e)}var yc=class i{constructor(e,t,n,r){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=r,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 Va&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new Ti),this.atCursorPos=!0),this.curLine}flushBuffer(e=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(od(new xc(-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 Va)&&this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)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 r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(od(new $r(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=0}}span(e,t,n,r){this.buildText(t-e,n,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,n,r,s,o){if(this.disallowBlockEffectsFor[o]&&n instanceof Vs){if(n.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 a=t-e;if(n instanceof Vs)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Va(n.widget||Ws.block,a,n));else{let l=Sc.create(n.widget||Ws.inline,a,a?0:n.startSide),c=this.atCursorPos&&!l.isEditable&&s<=r.length&&(e0),u=!l.isEditable&&(er.length||n.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!c&&!l.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),c&&(f.append(od(new xc(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(od(l,r),s),this.atCursorPos=u,this.pendingBuffer=u?er.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);a&&(this.textOff+a<=this.text.length?this.textOff+=a:(this.skip+=a-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,n,r,s){let o=new i(e,t,n,s);return o.openEnd=kt.spans(r,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}};function od(i,e){for(let t of e)i=new Bs(t,[i],i.length);return i}var Ws=class extends dr{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}};Ws.inline=new Ws("span");Ws.block=new Ws("div");var Ct=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(Ct||(Ct={})),Zo=Ct.LTR,M0=Ct.RTL;function w2(i){let e=[];for(let t=0;t=t){if(a.level==n)return o;(s<0||(r!=0?r<0?a.fromt:e[s].level>a.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}};function S2(i,e){if(i.length!=e.length)return!1;for(let t=0;t=0;m-=3)if(Zr[m+1]==-h){let g=Zr[m+2],O=g&2?r:g&4?g&1?s:r:0;O&&(Dt[f]=Dt[Zr[m]]=O),a=m;break}}else{if(Zr.length==189)break;Zr[a++]=f,Zr[a++]=d,Zr[a++]=l}else if((p=Dt[f])==2||p==1){let m=p==r;l=m?0:1;for(let g=a-3;g>=0;g-=3){let O=Zr[g+2];if(O&2)break;if(m)Zr[g+2]|=2;else{if(O&4)break;Zr[g+2]|=4}}}}}function $8(i,e,t,n){for(let r=0,s=n;r<=t.length;r++){let o=r?t[r-1].to:i,a=rl;)p==g&&(p=t[--m].from,g=m?t[m-1].to:i),Dt[--p]=h;l=u}else s=c,l++}}}function n0(i,e,t,n,r,s,o){let a=n%2?2:1;if(n%2==r%2)for(let l=e,c=0;ll&&o.push(new qr(l,m.from,h));let g=m.direction==Zo!=!(h%2);r0(i,g?n+1:n,r,m.inner,m.from,m.to,o),l=m.to}p=m.to}else{if(p==t||(u?Dt[p]!=a:Dt[p]==a))break;p++}d?n0(i,l,p,n+1,r,d,o):le;){let u=!0,f=!1;if(!c||l>s[c-1].to){let m=Dt[l-1];m!=a&&(u=!1,f=m==16)}let d=!u&&a==1?[]:null,h=u?n:n+1,p=l;e:for(;;)if(c&&p==s[c-1].to){if(f)break e;let m=s[--c];if(!u)for(let g=m.from,O=c;;){if(g==e)break e;if(O&&s[O-1].to==g)g=s[--O].from;else{if(Dt[g-1]==a)break e;break}}if(d)d.push(m);else{m.toDt.length;)Dt[Dt.length]=256;let n=[],r=e==Zo?0:1;return r0(i,r,r,t,0,i.length,n),n}function x2(i){return[new qr(0,i,0)]}var P2="";function B8(i,e,t,n,r){var s;let o=n.head-i.from,a=qr.find(e,o,(s=n.bidiLevel)!==null&&s!==void 0?s:-1,n.assoc),l=e[a],c=l.side(r,t);if(o==c){let d=a+=r?1:-1;if(d<0||d>=e.length)return null;l=e[a=d],o=l.side(!r,t),c=l.side(r,t)}let u=ui(i.text,o,l.forward(r,t));(ul.to)&&(u=c),P2=i.text.slice(Math.min(o,u),Math.max(o,u));let f=a==(r?e.length-1:0)?null:e[a+(r?1:-1)];return f&&u==c&&f.level+(r?0:1)i.some(e=>e)}),M2=Ae.define({combine:i=>i.some(e=>e)}),I2=Ae.define(),bc=class i{constructor(e,t="nearest",n="nearest",r=5,s=5,o=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,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(ce.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},ad=ze.define({map:(i,e)=>i.map(e)});function Ai(i,e,t){let n=i.facet(A2);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}var Nd=Ae.define({combine:i=>i.length?i[0]:!0}),W8=0,hc=Ae.define(),di=class i{constructor(e,t,n,r,s){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.extension=s(this)}static define(e,t){let{eventHandlers:n,eventObservers:r,provide:s,decorations:o}=t||{};return new i(W8++,e,n,r,a=>{let l=[hc.of(a)];return o&&l.push(Ec.of(c=>{let u=c.plugin(a);return u?o(u):je.none})),s&&l.push(s(a)),l})}static fromClass(e,t){return i.define(n=>new e(n),t)}},_c=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(n){if(Ai(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Ai(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(n){Ai(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},N2=Ae.define(),I0=Ae.define(),Ec=Ae.define(),j2=Ae.define(),N0=Ae.define(),Z2=Ae.define();function Qk(i,e){let t=i.state.facet(Z2);if(!t.length)return t;let n=t.map(s=>s instanceof Function?s(i):s),r=[];return kt.spans(n,e.from,e.to,{point(){},span(s,o,a,l){let c=s-e.from,u=o-e.from,f=r;for(let d=a.length-1;d>=0;d--,l--){let h=a[d].spec.bidiIsolate,p;if(h==null&&(h=V8(e.text,c,u)),l>0&&f.length&&(p=f[f.length-1]).to==c&&p.direction==h)p.to=u,f=p.inner;else{let m={from:c,to:u,direction:h,inner:[]};f.push(m),f=m.inner}}}}),r}var z2=Ae.define();function q2(i){let e=0,t=0,n=0,r=0;for(let s of i.state.facet(z2)){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&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:n,bottom:r}}var pc=Ae.define(),Lr=class i{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}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,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAu)break;s+=2}if(!l)return n;new i(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),o=l.toA,a=l.toB}}},kd=class i{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Ui.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,a,l)=>r.push(new Lr(s,o,a,l))),this.changedRanges=r}static create(e,t,n){return new i(e,t,n)}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}},Sd=class extends Mt{get length(){return this.view.state.doc.length}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,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 Ti],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Lr(0,0,0,e.state.doc.length)],0,null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:c,toA:u})=>uthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let r=-1;this.view.inputState.composing>=0&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!J8(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?Y8(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:c,to:u}=this.hasComposition;n=new Lr(c,u,e.changes.mapPos(c,-1),e.changes.mapPos(u,1)).addToSet(n.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Qe.ie||Qe.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,a=this.updateDeco(),l=G8(o,a,e.changes);return n=Lr.extendWithRanges(n,l),!(this.flags&7)&&n.length==0?!1:(this.updateInner(n,e.startState.doc.length,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=Qe.chrome||Qe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.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?r[o]:null;if(!a)break;let{fromA:l,toA:c,fromB:u,toB:f}=a,d,h,p,m;if(n&&n.range.fromBu){let P=yc.build(this.view.state.doc,u,n.range.fromB,this.decorations,this.dynamicDecorationMap),k=yc.build(this.view.state.doc,n.range.toB,f,this.decorations,this.dynamicDecorationMap);h=P.breakAtStart,p=P.openStart,m=k.openEnd;let w=this.compositionView(n);k.breakAtStart?w.breakAfter=1:k.content.length&&w.merge(w.length,w.length,k.content[0],!1,k.openStart,0)&&(w.breakAfter=k.content[0].breakAfter,k.content.shift()),P.content.length&&w.merge(0,0,P.content[P.content.length-1],!0,0,P.openEnd)&&P.content.pop(),d=P.content.concat(w).concat(k.content)}else({content:d,breakAtStart:h,openStart:p,openEnd:m}=yc.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:g,off:O}=s.findPos(c,1),{i:_,off:S}=s.findPos(l,-1);p2(this,_,S,g,O,d,h,p,m)}n&&this.fixCompositionDOM(n)}compositionView(e){let t=new $r(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Bs(r,[t],t.length);let n=new Ti;return n.append(t,0),n}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8|(o.children.some(l=>l.flags&7)?1:0),this.markedForComposition.add(o);let a=Mt.get(s);a&&a!=o&&(a.dom=null),o.setDOM(s)},n=this.childPos(e.range.fromB,1),r=this.children[n.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)n=r.childPos(n.off,1),r=r.children[n.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,r=n==this.dom,s=!r&&md(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(a.anchor)),c=a.empty?l:this.moveToLine(this.domAtPos(a.head));if(Qe.gecko&&a.empty&&!this.hasComposition&&X8(l)){let f=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(f,l.node.childNodes[l.offset]||null)),l=c=new Hi(f,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!vc(l.node,l.offset,u.anchorNode,u.anchorOffset)||!vc(c.node,c.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,a))&&(this.view.observer.ignore(()=>{Qe.android&&Qe.chrome&&this.dom.contains(u.focusNode)&&K8(u.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=bd(this.view.root);if(f)if(a.empty){if(Qe.gecko){let d=U8(l.node,l.offset);if(d&&d!=3){let h=(d==1?d2:h2)(l.node,l.offset);h&&(l=new Hi(h.node,h.offset))}}f.collapse(l.node,l.offset),a.bidiLevel!=null&&f.caretBidiLevel!==void 0&&(f.caretBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(l.node,l.offset);try{f.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([l,c]=[c,l]),d.setEnd(c.node,c.offset),d.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(d)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(l,c)),this.impreciseAnchor=l.precise?null:new Hi(u.anchorNode,u.anchorOffset),this.impreciseHead=c.precise?null:new Hi(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&vc(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,n=bd(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=Ti.find(this,t.head);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!l||!c||l.bottom>c.top)return;let u=this.domAtPos(t.head+t.assoc);n.collapse(u.node,u.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&n.collapse(r,s)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let r=e.offset;!n&&r=0;r--){let s=Mt.get(t.childNodes[r]);s instanceof Ti&&(n=s.domAtPos(s.length))}return n?new Hi(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let n=Mt.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t=0;o--){let a=this.children[o],l=s-a.breakAfter,c=l-a.length;if(le||a.covers(1))&&(!n||a instanceof Ti&&!(n instanceof Ti&&t>=0))&&(n=a,r=c),s=c}return n?n.coordsAt(e-r,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),r=this.children[t];if(!(r instanceof Ti))return null;for(;r.children.length;){let{i:a,off:l}=r.childPos(n,1);for(;;a++){if(a==r.children.length)return null;if((r=r.children[a]).length)break}n=l}if(!(r instanceof $r))return null;let s=ui(r.text,n);if(s==n)return null;let o=jo(r.dom,n,s).getClientRects();for(let a=0;aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==Ct.LTR;for(let c=0,u=0;ur)break;if(c>=n){let h=f.dom.getBoundingClientRect();if(t.push(h.height),o){let p=f.dom.lastChild,m=p?kc(p):[];if(m.length){let g=m[m.length-1],O=l?g.right-h.left:h.right-g.left;O>a&&(a=O,this.minWidth=s,this.minWidthFrom=c,this.minWidthTo=d)}}}c=d+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?Ct.RTL:Ct.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Ti){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,n,r;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=kc(e.firstChild)[0];t=e.getBoundingClientRect().height,n=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new wd(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>n){let a=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(je.replace({widget:new xd(a),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return je.set(e)}updateDeco(){let e=0,t=this.view.state.facet(Ec).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),n=!1,r=this.view.state.facet(j2).map((s,o)=>{let a=typeof s=="function";return a&&(n=!0),a?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(kt.join(r))),this.decorations=[...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];et.anchor?-1:1),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let s=q2(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:a,offsetHeight:l}=this.view.scrollDOM;E8(this.view.scrollDOM,o,t.head{ne.from&&(t=!0)}),t}function eQ(i,e,t=1){let n=i.charCategorizer(e),r=i.doc.lineAt(e),s=e-r.from;if(r.length==0)return ce.cursor(e);s==0?t=1:s==r.length&&(t=-1);let o=s,a=s;t<0?o=ui(r.text,s,!1):a=ui(r.text,s);let l=n(r.text.slice(o,a));for(;o>0;){let c=ui(r.text,o,!1);if(n(r.text.slice(c,o))!=l)break;o=c}for(;ai?e.left-i:Math.max(0,i-e.right)}function iQ(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function Fg(i,e){return i.tope.top+1}function Rk(i,e){return ei.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function o0(i,e,t){let n,r,s,o,a=!1,l,c,u,f;for(let p=i.firstChild;p;p=p.nextSibling){let m=kc(p);for(let g=0;gS||o==S&&s>_){n=p,r=O,s=_,o=S;let P=S?t0?g0)}_==0?t>O.bottom&&(!u||u.bottomO.top)&&(c=p,f=O):u&&Fg(u,O)?u=Mk(u,O.bottom):f&&Fg(f,O)&&(f=Rk(f,O.top))}}if(u&&u.bottom>=t?(n=l,r=u):f&&f.top<=t&&(n=c,r=f),!n)return{node:i,offset:0};let d=Math.max(r.left,Math.min(r.right,e));if(n.nodeType==3)return Ik(n,d,t);if(a&&n.contentEditable!="false")return o0(n,d,t);let h=Array.prototype.indexOf.call(i.childNodes,n)+(e>=(r.left+r.right)/2?1:0);return{node:i,offset:h}}function Ik(i,e,t){let n=i.nodeValue.length,r=-1,s=1e9,o=0;for(let a=0;at?u.top-t:t-u.bottom)-1;if(u.left-1<=e&&u.right+1>=e&&f=(u.left+u.right)/2,h=d;if((Qe.chrome||Qe.gecko)&&jo(i,a).getBoundingClientRect().left==u.right&&(h=!d),f<=0)return{node:i,offset:a+(h?1:0)};r=a+(h?1:0),s=f}}}return{node:i,offset:r>-1?r:o>0?i.nodeValue.length:0}}function $2(i,e,t,n=-1){var r,s;let o=i.contentDOM.getBoundingClientRect(),a=o.top+i.viewState.paddingTop,l,{docHeight:c}=i.viewState,{x:u,y:f}=e,d=f-a;if(d<0)return 0;if(d>c)return i.state.doc.length;for(let P=i.viewState.heightOracle.textHeight/2,k=!1;l=i.elementAtHeight(d),l.type!=Gi.Text;)for(;d=n>0?l.bottom+P:l.top-P,!(d>=0&&d<=c);){if(k)return t?null:0;k=!0,n=-n}f=a+d;let h=l.from;if(hi.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:Nk(i,o,l,u,f);let p=i.dom.ownerDocument,m=i.root.elementFromPoint?i.root:p,g=m.elementFromPoint(u,f);g&&!i.contentDOM.contains(g)&&(g=null),g||(u=Math.max(o.left+1,Math.min(o.right-1,u)),g=m.elementFromPoint(u,f),g&&!i.contentDOM.contains(g)&&(g=null));let O,_=-1;if(g&&((r=i.docView.nearest(g))===null||r===void 0?void 0:r.isEditable)!=!1){if(p.caretPositionFromPoint){let P=p.caretPositionFromPoint(u,f);P&&({offsetNode:O,offset:_}=P)}else if(p.caretRangeFromPoint){let P=p.caretRangeFromPoint(u,f);P&&({startContainer:O,startOffset:_}=P,(!i.contentDOM.contains(O)||Qe.safari&&nQ(O,_,u)||Qe.chrome&&rQ(O,_,u))&&(O=void 0))}}if(!O||!i.docView.dom.contains(O)){let P=Ti.find(i.docView,h);if(!P)return d>l.top+l.height/2?l.to:l.from;({node:O,offset:_}=o0(P.dom,u,f))}let S=i.docView.nearest(O);if(!S)return null;if(S.isWidget&&((s=S.dom)===null||s===void 0?void 0:s.nodeType)==1){let P=S.dom.getBoundingClientRect();return e.yi.defaultLineHeight*1.5){let a=i.viewState.heightOracle.textHeight,l=Math.floor((r-t.top-(i.defaultLineHeight-a)*.5)/a);s+=l*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+rd(o,s,i.state.tabSize)}function nQ(i,e,t){let n;if(i.nodeType!=3||e!=(n=i.nodeValue.length))return!1;for(let r=i.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return jo(i,n-1,n).getBoundingClientRect().left>t}function rQ(i,e,t){if(e!=0)return!1;for(let r=i;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let n=i.nodeType==1?i.getBoundingClientRect():jo(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function a0(i,e){let t=i.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==Gi.Text))return n}return t}function sQ(i,e,t,n){let r=a0(i,e.head),s=!n||r.type!=Gi.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=i.dom.getBoundingClientRect(),a=i.textDirectionAt(r.from),l=i.posAtCoords({x:t==(a==Ct.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(l!=null)return ce.cursor(l,t?-1:1)}return ce.cursor(t?r.to:r.from,t?-1:1)}function jk(i,e,t,n){let r=i.state.doc.lineAt(e.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let a=e,l=null;;){let c=B8(r,s,o,a,t),u=P2;if(!c){if(r.number==(t?i.state.doc.lines:1))return a;u=` `,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),c=i.visualLineSide(r,!t)}if(l){if(!l(u))return a}else{if(!n)return c;l=n(u)}a=c}}function oQ(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==Pt.Space&&(r=o),r==o}}function aQ(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return ce.cursor(r,e.assoc);let o=e.goalColumn,a,l=i.contentDOM.getBoundingClientRect(),c=i.coordsAtPos(r,e.assoc||-1),u=i.documentTop;if(c)o==null&&(o=c.left-l.left),a=s<0?c.top:c.bottom;else{let h=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(l.right-l.left,i.defaultCharacterWidth*(r-h.from))),a=(s<0?h.top:h.bottom)+u}let f=l.left+o,d=n??i.viewState.heightOracle.textHeight>>1;for(let h=0;;h+=10){let p=a+(d+h)*s,m=$2(i,{x:f,y:p},!1,s);if(pl.bottom||(s<0?mr)){let g=i.docView.coordsForChar(m),O=!g||p{if(e>s&&er(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:ce.cursor(n,nnull),Qe.gecko&&wQ(e.contentDOM.ownerDocument)}handleEvent(e){!pQ(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||this.runHandlers(e.type,e)}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=lQ(e),n=this.handlers,r=this.view.contentDOM;for(let s in t)if(s!="scroll"){let o=!t[s].handlers.length,a=n[s];a&&o!=!a.handlers.length&&(r.removeEventListener(s,this.handleEvent),a=null),a||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in n)s!="scroll"&&!t[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&Date.now()n.keyCode==e.keyCode))&&!e.ctrlKey||cQ.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:Qe.safari&&!Qe.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.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 Zk(i,e){return(t,n)=>{try{return e.call(i,n,t)}catch(r){Ai(t.state,r)}}}function lQ(i){let e=Object.create(null);function t(n){return e[n]||(e[n]={observers:[],handlers:[]})}for(let n of i){let r=n.spec;if(r&&r.domEventHandlers)for(let s in r.domEventHandlers){let o=r.domEventHandlers[s];o&&t(s).handlers.push(Zk(n.value,o))}if(r&&r.domEventObservers)for(let s in r.domEventObservers){let o=r.domEventObservers[s];o&&t(s).observers.push(Zk(n.value,o))}}for(let n in hr)t(n).handlers.push(hr[n]);for(let n in qn)t(n).observers.push(qn[n]);return e}var F2=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],cQ="dthko",B2=[16,17,18,20,91,92,224,225],ld=6;function cd(i){return Math.max(0,i)*.7+8}function uQ(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}var c0=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=T8(e.contentDOM),this.atoms=e.state.facet(N0).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(At.allowMultipleSelections)&&fQ(e,t),this.dragging=hQ(e,t)&&Y2(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&uQ(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=q2(this.view);e.clientX-o.left<=s.left+ld?n=-cd(s.left-e.clientX):e.clientX+o.right>=s.right-ld&&(n=cd(e.clientX-s.right)),e.clientY-o.top<=s.top+ld?r=-cd(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-ld&&(r=cd(e.clientY-s.bottom)),this.setScrollSpeed(n,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(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;nthis.select(this.lastEvent),20)}};function fQ(i,e){let t=i.state.facet(C2);return t.length?t[0](e):Qe.mac?e.metaKey:e.ctrlKey}function dQ(i,e){let t=i.state.facet(E2);return t.length?t[0](e):Qe.mac?!e.altKey:!e.ctrlKey}function hQ(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=bd(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function pQ(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=Mt.get(t))&&n.ignoreEvent(e))return!1;return!0}var hr=Object.create(null),qn=Object.create(null),V2=Qe.ie&&Qe.ie_version<15||Qe.ios&&Qe.webkit_version<604;function mQ(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(),W2(i,t.value)},50)}function W2(i,e){let{state:t}=i,n,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(u0!=null&&t.selection.ranges.every(l=>l.empty)&&u0==s.toString()){let l=-1;n=t.changeByRange(c=>{let u=t.doc.lineAt(c.from);if(u.from==l)return{range:c};l=u.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:u.from,insert:f},range:ce.cursor(c.from+f.length)}})}else o?n=t.changeByRange(l=>{let c=s.line(r++);return{changes:{from:l.from,to:l.to,insert:c.text},range:ce.cursor(l.from+c.length)}}):n=t.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}qn.scroll=i=>{i.inputState.lastScrollTop=i.scrollDOM.scrollTop,i.inputState.lastScrollLeft=i.scrollDOM.scrollLeft};hr.keydown=(i,e)=>(i.inputState.setSelectionOrigin("select"),e.keyCode==27&&(i.inputState.lastEscPress=Date.now()),!1);qn.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};qn.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};hr.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let n of i.state.facet(T2))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=vQ(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new c0(i,e,t,n)),n&&i.observer.ignore(()=>c2(i.contentDOM));let r=i.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}return!1};function zk(i,e,t,n){if(n==1)return ce.cursor(e,t);if(n==2)return eQ(i.state,e,t);{let r=Ti.find(i.docView,e),s=i.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,a=r?r.posAtEnd:s.to;return ai>=e.top&&i<=e.bottom,qk=(i,e,t)=>X2(e,t)&&i>=t.left&&i<=t.right;function gQ(i,e,t,n){let r=Ti.find(i.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&qk(t,n,o))return-1;let a=r.coordsAt(s,1);return a&&qk(t,n,a)?1:o&&X2(n,o)?-1:1}function Lk(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:gQ(i,t,e.clientX,e.clientY)}}var OQ=Qe.ie&&Qe.ie_version<=11,$k=null,Fk=0,Bk=0;function Y2(i){if(!OQ)return i.detail;let e=$k,t=Bk;return $k=i,Bk=Date.now(),Fk=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(Fk+1)%3:1}function vQ(i,e){let t=Lk(i,e),n=Y2(e),r=i.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,a){let l=Lk(i,s),c,u=zk(i,l.pos,l.bias,n);if(t.pos!=l.pos&&!o){let f=zk(i,t.pos,t.bias,n),d=Math.min(f.from,u.from),h=Math.max(f.to,u.to);u=d1&&(c=yQ(r,l.pos))?c:a?r.addRange(u):ce.create([u])}}}function yQ(i,e){for(let t=0;t=e)return ce.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}hr.dragstart=(i,e)=>{let{selection:{main:t}}=i.state;if(e.target.draggable){let r=i.docView.nearest(e.target);if(r&&r.isWidget){let s=r.posAtStart,o=s+r.length;(s>=t.to||o<=t.from)&&(t=ce.range(s,o))}}let{inputState:n}=i;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",i.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove"),!1};hr.dragend=i=>(i.inputState.draggedContent=null,!1);function Vk(i,e,t,n){if(!t)return;let r=i.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=i.inputState,o=n&&s&&dQ(i,e)?{from:s.from,to:s.to}:null,a={from:r,insert:t},l=i.state.changes(o?[o,a]:a);i.focus(),i.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),i.inputState.draggedContent=null}hr.drop=(i,e)=>{if(!e.dataTransfer)return!1;if(i.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let n=Array(t.length),r=0,s=()=>{++r==t.length&&Vk(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(n[o]=a.result),s()},a.readAsText(t[o])}return!0}else{let n=e.dataTransfer.getData("Text");if(n)return Vk(i,e,n,!0),!0}return!1};hr.paste=(i,e)=>{if(i.state.readOnly)return!0;i.observer.flush();let t=V2?null:e.clipboardData;return t?(W2(i,t.getData("text/plain")||t.getData("text/uri-list")),!0):(mQ(i),!1)};function bQ(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function _Q(i){let e=[],t=[],n=!1;for(let r of i.selection.ranges)r.empty||(e.push(i.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:e.join(i.lineBreak),ranges:t,linewise:n}}var u0=null;hr.copy=hr.cut=(i,e)=>{let{text:t,ranges:n,linewise:r}=_Q(i.state);if(!t&&!r)return!1;u0=r?t:null,e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=V2?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",t),!0):(bQ(i,t),!1)};var U2=pn.define();function H2(i,e){let t=[];for(let n of i.facet(Q2)){let r=n(i,e);r&&t.push(r)}return t?i.update({effects:t,annotations:U2.of(!0)}):null}function G2(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=H2(i.state,e);t?i.dispatch(t):i.update([])}},10)}qn.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),G2(i)};qn.blur=i=>{i.observer.clearSelectionRange(),G2(i)};qn.compositionstart=qn.compositionupdate=i=>{i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0)};qn.compositionend=i=>{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,Qe.chrome&&Qe.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50)};qn.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};hr.beforeinput=(i,e)=>{var t;let n;if(Qe.chrome&&Qe.android&&(n=F2.find(r=>r.inputType==e.inputType))&&(i.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}return Qe.ios&&e.inputType=="deleteContentForward"&&i.observer.flushSoon(),Qe.safari&&e.inputType=="insertText"&&i.inputState.composing>=0&&setTimeout(()=>qn.compositionend(i,e),20),!1};var Wk=new Set;function wQ(i){Wk.has(i)||(Wk.add(i),i.addEventListener("copy",()=>{}),i.addEventListener("cut",()=>{}))}var Xk=["pre-wrap","normal","pre-line","break-spaces"],f0=class{constructor(e){this.lineWrapping=e,this.doc=ut.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}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 Xk.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=s,l){this.heightSamples={};for(let c=0;c0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>Od&&(e.heightChanged=!0),this.height=t)}replace(e,t,n){return i.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let s=this,o=n.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:c,fromB:u,toB:f}=r[a],d=s.lineAt(l,qt.ByPosNoHeight,n.setDoc(t),0,0),h=d.to>=c?d:s.lineAt(c,qt.ByPosNoHeight,n,0,0);for(f+=h.to-c,c=h.to;a>0&&d.from<=r[a-1].toA;)l=r[a-1].fromA,u=r[a-1].fromB,a--,ls*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),n+=1+a.break,r-=a.size}else if(s>r*2){let a=e[n];a.break?e.splice(n,1,a.left,null,a.right):e.splice(n,1,a.left,a.right),n+=2+a.break,s-=a.size}else break;else if(r=s&&o(this.blockAt(0,n,r,s))}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}},zn=class i extends Pd{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,r){return new zr(r,this.length,n,this.height,this.breaks)}replace(e,t,n){let r=n[0];return n.length==1&&(r instanceof i||r instanceof Fs&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Fs?r=new i(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Pn.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.index++]):(n||this.outdated)&&this.setHeight(e,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:""})`}},Fs=class i extends Pn{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-n+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:a}}blockAt(e,t,n,r){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let c=r+(e0){let s=n[n.length-1];s instanceof i?n[n.length-1]=new i(s.length+r):n.push(null,new i(r-1))}if(e>0){let s=n[0];s instanceof i?n[0]=new i(e+s.length):n.unshift(new i(e-1),null)}return Pn.of(n)}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,n=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],a=Math.max(t,r.from),l=-1;for(r.from>t&&o.push(new i(r.from-t-1).updateHeight(e,t));a<=s&&r.more;){let u=e.doc.lineAt(a).length;o.length&&o.push(null);let f=r.heights[r.index++];l==-1?l=f:Math.abs(f-l)>=Od&&(l=-2);let d=new zn(u,f);d.outdated=!1,o.push(d),a+=u+1}a<=s&&o.push(null,new i(s-a).updateHeight(e,a));let c=Pn.of(o);return(l<0||Math.abs(c.height-this.height)>=Od||Math.abs(l-this.heightMetrics(e,t).perLine)>=Od)&&(e.heightChanged=!0),c}else(n||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},h0=class extends Pn{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let s=n+this.left.height;return ea))return c;let u=t==qt.ByPosNoHeight?qt.ByPosNoHeight:qt.ByPos;return l?c.join(this.right.lineAt(a,u,n,o,a)):this.left.lineAt(a,u,n,r,s).join(c)}forEachLine(e,t,n,r,s,o){let a=r+this.left.height,l=s+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,n,a,l,o);else{let c=this.lineAt(l,qt.ByPos,n,r,s);e=e&&c.from<=t&&o(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,a,l,o)}}replace(e,t,n){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of n)s.push(a);if(e>0&&Yk(s,o-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?Pn.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=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,n=!1,r){let{left:s,right:o}=this,a=t+s.length+this.break,l=null;return r&&r.from<=t+s.length&&r.more?l=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=a+o.length&&r.more?l=o=o.updateHeight(e,a,n,r):o.updateHeight(e,a,n),l?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 Yk(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof Fs&&(n=i[e+1])instanceof Fs&&i.splice(e-1,3,new Fs(t.length+1+n.length))}var kQ=5,p0=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 n=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof zn?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new zn(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=kQ)&&this.addLineDeco(r,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 zn(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new Fs(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof zn)return e;let t=new zn(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,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof zn)&&!this.isCovered?this.nodes.push(new zn(0,-1)):(this.writtenTou.clientHeight||u.scrollWidth>u.clientWidth)&&f.overflow!="visible"){let d=u.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),a=Math.max(a,d.top),l=c==i.parentNode?d.bottom:Math.min(l,d.bottom)}c=f.position=="absolute"||f.position=="fixed"?u.offsetParent:u.parentNode}else if(c.nodeType==11)c=c.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function PQ(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}var wc=class{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;ntypeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new f0(t),this.stateDeco=e.facet(Ec).filter(n=>typeof n!="function"),this.heightMap=Pn.empty().applyChanges(this.stateDeco,ut.empty,this.heightOracle.setDoc(e.doc),[new Lr(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=je.set(this.lineGaps.map(n=>n.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new $a(s,o))}}this.viewports=e.sort((n,r)=>n.from-r.from),this.scaler=this.heightMap.height<=7e6?Uk:new O0(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:mc(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Ec).filter(u=>typeof u!="function");let r=e.changedRanges,s=Lr.extendWithRanges(r,SQ(n,this.stateDeco,e?e.changes:Ui.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let c=!e.changes.empty||e.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),c&&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(M2)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?Ct.RTL:Ct.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let c=0,u=0;if(a.width&&a.height){let{scaleX:P,scaleY:k}=l2(t,a);(P>.005&&Math.abs(this.scaleX-P)>.005||k>.005&&Math.abs(this.scaleY-k)>.005)&&(this.scaleX=P,this.scaleY=k,c|=8,o=l=!0)}let f=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,c|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=8);let h=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=h&&(this.scrollAnchorHeight=-1,this.scrollTop=h),this.scrolledToBottom=f2(e.scrollDOM);let p=(this.printing?PQ:xQ)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let _=a.width;if((this.contentDOMWidth!=_||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,c|=8),l){let P=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(P)&&(o=!0),o||r.lineWrapping&&Math.abs(_-this.contentDOMWidth)>r.charWidth){let{lineHeight:k,charWidth:w,textHeight:x}=e.docView.measureTextSize();o=k>0&&r.refresh(s,k,w,x,_/w,P),o&&(e.docView.minWidth=0,c|=8)}m>0&&g>0?u=Math.max(m,g):m<0&&g<0&&(u=Math.min(m,g)),r.heightChanged=!1;for(let k of this.viewports){let w=k.from==this.viewport.from?P:e.docView.measureVisibleLineHeights(k);this.heightMap=(o?Pn.empty().applyChanges(this.stateDeco,ut.empty,this.heightOracle,[new Lr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new d0(k.from,w))}r.heightChanged&&(c|=2)}let S=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return S&&(this.viewport=this.getViewport(u,this.scrollTarget)),this.updateForViewport(),(c&2||S)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new $a(r.lineAt(o-n*1e3,qt.ByHeight,s,0,0).from,r.lineAt(a+(1-n)*1e3,qt.ByHeight,s,0,0).to);if(t){let{head:c}=t.range;if(cl.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(c,qt.ByPos,s,0,0),d;t.y=="center"?d=(f.top+f.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&c=a+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=Ct.LTR&&!n)return[];let a=[],l=(c,u,f,d)=>{if(u-cc&&gg.from>=f.from&&g.to<=f.to&&Math.abs(g.from-c)g.fromO));if(!m){if(ug.from<=u&&g.to>=u)){let g=t.moveToLineBoundary(ce.cursor(u),!1,!0).head;g>c&&(u=g)}m=new wc(c,u,this.gapSize(f,c,u,d))}a.push(m)};for(let c of this.viewportLines){if(c.lengthc.from&&l(c.from,d,c,u),ht.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];kt.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||mc(this.heightMap.lineAt(e,qt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return mc(this.heightMap.lineAt(this.scaler.fromDOM(e),qt.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 mc(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}},$a=class{constructor(e,t){this.from=e,this.to=t}};function CQ(i,e,t){let n=[],r=i,s=0;return kt.spans(t,i,e,{span(){},point(o,a){o>r&&(n.push({from:r,to:o}),s+=o-r),r=a}},20),r=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let r=0;;r++){let{from:s,to:o}=e[r],a=o-s;if(n<=a)return s+n;n-=a}}function fd(i,e){let t=0;for(let{from:n,to:r}of i.ranges){if(e<=r){t+=e-n;break}t+=r-n}return t/i.total}function EQ(i,e){for(let t of i)if(e(t))return t}var Uk={toDOM(i){return i},fromDOM(i){return i},scale:1},O0=class{constructor(e,t,n){let r=0,s=0,o=0;this.viewports=n.map(({from:a,to:l})=>{let c=t.lineAt(a,qt.ByPos,e,0,0).top,u=t.lineAt(l,qt.ByPos,e,0,0).bottom;return r+=u-c,{from:a,to:l,top:c,bottom:u,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let s=tmc(r,e)):i._content)}var dd=Ae.define({combine:i=>i.join(" ")}),v0=Ae.define({combine:i=>i.indexOf(!0)>-1}),y0=Zn.newName(),K2=Zn.newName(),J2=Zn.newName(),eS={"&light":"."+K2,"&dark":"."+J2};function b0(i,e,t){return new Zn(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):i+" "+n}})}var TQ=b0("."+y0,{"&":{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},".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},"&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"}},eS),gc="\uFFFF",_0=class{constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(At.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=gc}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let s=this.text.length;this.readNode(r);let o=r.nextSibling;if(o==t)break;let a=Mt.get(r),l=Mt.get(o);(a&&l?a.breakAfter:(a?a.breakAfter:_d(r))||_d(o)&&(r.nodeName!="BR"||r.cmIgnore)&&this.text.length>s)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,a;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(a=r.exec(t))&&(s=a.index,o=a[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);n=s+o}}readNode(e){if(e.cmIgnore)return;let t=Mt.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.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 n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(AQ(e,n.node,n.offset)?t:0))}};function AQ(i,e,t){for(;;){if(!e||t-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let a=s||o?[]:RQ(e),l=new _0(a,e.state);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=MQ(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!Yg(e.contentDOM,a.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Yg(e.contentDOM,a.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),u=e.viewport;if((Qe.ios||Qe.chrome)&&e.state.selection.main.empty&&l!=c&&(u.from>0||u.toDate.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:a}=e.bounds,l=r.from,c=null;(s===8||Qe.android&&e.text.length=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:i.state.doc.slice(r.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,r.to))}:(Qe.mac||Qe.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=ce.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:ut.of([" "])}):Qe.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` `&&i.lineWrapping&&(n&&(n=ce.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:ut.of([" "])}),t){if(Qe.ios&&i.inputState.flushIOSKey(t)||Qe.android&&(t.to==r.to&&(t.from==r.from||t.from==r.from-1&&i.state.sliceDoc(t.from,r.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&Ba(i.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.lengthr.head)&&Ba(i.contentDOM,"Backspace",8)||t.from==r.from&&t.to==r.to+1&&t.insert.length==0&&Ba(i.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();i.inputState.composing>=0&&i.inputState.composing++;let a,l=()=>a||(a=DQ(i,t,n));return i.state.facet(D2).some(c=>c(i,t.from,t.to,o,l))||i.dispatch(l()),!0}else if(n&&!n.main.eq(r)){let o=!1,a="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),a=i.inputState.lastSelectionOrigin),i.dispatch({selection:n,scrollIntoView:o,userEvent:a}),!0}else return!1}function DQ(i,e,t){let n,r=i.state,s=r.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 a=s.frome.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(i.state.toText(a+e.insert.sliceString(0,void 0,i.state.lineBreak)+l))}else{let a=r.changes(e),l=t&&t.main.to<=a.newLength?t.main:void 0;if(r.selection.ranges.length>1&&i.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let c=i.state.sliceDoc(e.from,e.to),u,f=t&&L2(i,t.main.head);if(f){let p=e.insert.length-(e.to-e.from);u={from:f.from,to:f.to-p}}else u=i.state.doc.lineAt(s.head);let d=s.to-e.to,h=s.to-s.from;n=r.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:l||p.map(a)};let m=p.to-d,g=m-c.length;if(p.to-p.from!=h||i.state.sliceDoc(g,m)!=c||p.to>=u.from&&p.from<=u.to)return{range:p};let O=r.changes({from:g,to:m,insert:e.insert}),_=p.to-s.to;return{changes:O,range:l?ce.range(Math.max(0,l.anchor+_),Math.max(0,l.head+_)):p.map(O)}})}else n={changes:a,selection:l&&r.selection.replaceRange(l)}}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)),r.update(n,{userEvent:o,scrollIntoView:!0})}function QQ(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s0&&a>0&&i.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(n=="end"){let l=Math.max(0,s-Math.min(o,a));t-=o+l-s}if(o=o?s-t:0;s-=l,a=s+(a-o),o=s}else if(a=a?s-t:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function RQ(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new Ed(t,n)),(r!=t||s!=n)&&e.push(new Ed(r,s))),e}function MQ(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?ce.single(t+e,n+e):null}var IQ={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Vg=Qe.ie&&Qe.ie_version<=11,k0=class{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Ug,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 n of t)this.queue.push(n);(Qe.ie&&Qe.ie_version<=11||Qe.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),Vg&&(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.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){e.type=="change"&&!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,n)=>t!=e[n]))){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:n}=this,r=this.selectionRange;if(n.state.facet(Nd)?n.root.activeElement!=this.dom:!md(n.dom,r))return;let s=r.anchorNode&&n.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Qe.ie&&Qe.ie_version<=11||Qe.android&&Qe.chrome)&&!n.state.selection.main.empty&&r.focusNode&&vc(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=bd(e.root);if(!t)return!1;let n=Qe.safari&&e.root.nodeType==11&&P8(this.dom.ownerDocument)==this.dom&&NQ(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=md(this.dom,n);return r&&!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&&Ba(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!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,n=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&md(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new w0(this.view,e,t,n);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 n=this.view.state,r=tS(this.view,t);return this.view.state==n&&this.view.update([]),r}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 n=Hk(t,e.previousSibling||e.target.previousSibling,-1),r=Hk(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):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("change",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("change",this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}};function Hk(i,e,t){for(;e;){let n=Mt.get(e);if(n&&n.parent==i)return n;let r=e.parentNode;e=r!=i.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Gk(i,e){let t=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=i.docView.domAtPos(i.state.selection.main.anchor);return vc(o.node,o.offset,r,s)&&([t,n,r,s]=[r,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}}function NQ(i,e){if(e.getComposedRanges){let r=e.getComposedRanges(i.root)[0];if(r)return Gk(i,r)}let t=null;function n(r){r.preventDefault(),r.stopImmediatePropagation(),t=r.getTargetRanges()[0]}return i.contentDOM.addEventListener("beforeinput",n,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",n,!0),t?Gk(i,t):null}var Se=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={}){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:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(n=>n.forEach(r=>t(r,this)))||(n=>this.update(n)),this.dispatch=this.dispatch.bind(this),this._root=e.root||A8(e.parent)||document,this.viewState=new Cd(e.state||At.create(e)),e.scrollTo&&e.scrollTo.is(ad)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(hc).map(n=>new _c(n));for(let n of this.plugins)n.update(this);this.observer=new k0(this),this.inputState=new l0(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Sd(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...e){let t=e.length==1&&e[0]instanceof Oi?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,n=!1,r,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;e.some(d=>d.annotation(U2))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=H2(s,o),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(u=null)):this.observer.clear(),s.facet(At.phrases)!=this.state.facet(At.phrases))return this.setState(s);r=kd.create(this,s,e),r.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(f&&(f=f.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection;f=new bc(h.empty?h:ce.cursor(h.head,h.head>h.anchor?-1:1))}for(let h of d.effects)h.is(ad)&&(f=h.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Td.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(pc)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(dd)!=r.state.facet(dd)&&(this.viewState.mustMeasureContent=!0),(t||n||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let d of this.state.facet(s0))try{d(r)}catch(h){Ai(this.state,h,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!tS(this,u)&&c.force&&Ba(this.contentDOM,c.key,c.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 n of this.plugins)n.destroy(this);this.viewState=new Cd(e),this.plugins=e.facet(hc).map(n=>new _c(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new Sd(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(hc),n=e.state.facet(hc);if(t!=n){let r=[];for(let s of n){let o=t.indexOf(s);if(o<0)r.push(new _c(s));else{let a=this.plugins[o];a.mustUpdate=e,r.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-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,n=this.scrollDOM,r=n.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(f2(n))s=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(r);s=h.from,o=h.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(h=>{try{return h.read(this)}catch(p){return Ai(this.state,p),Kk}}),f=kd.create(this,this.state,[]),d=!1;f.flags|=l,t?t.flags|=l:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let h=0;h1||p<-1){r=r+p,n.scrollTop=r/this.scaleY,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(s0))a(t)}get themeClasses(){return y0+" "+(this.state.facet(v0)?J2:K2)+" "+this.state.facet(dd)}updateAttrs(){let e=Jk(this,N2,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Nd)?"true":"false",class:"cm-content",style:`${Qe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Jk(this,I0,t);let n=this.observer.ignore(()=>{let r=e0(this.contentDOM,this.contentAttrs,t),s=e0(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let r of n.effects)if(r.is(i.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(pc);let e=this.state.facet(i.cspNonce);Zn.mount(this.root,this.styleModules.concat(TQ).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;tn.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,n){return Bg(this,e,jk(this,e,t,n))}moveByGroup(e,t){return Bg(this,e,jk(this,e,t,n=>oQ(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=n[t?n.length-1:0];return ce.cursor(s.side(t,r)+e.from,s.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return sQ(this,e,t,n)}moveVertically(e,t,n){return Bg(this,e,aQ(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),$2(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[qr.find(s,e-r.from,-1,t)];return D0(n,o.dir==Ct.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(R2)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>jQ)return x2(e.length);let t=this.textDirectionAt(e.from),n;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t&&(s.fresh||S2(s.isolates,n=Qk(this,e))))return s.order;n||(n=Qk(this,e));let r=F8(e.text,t,n);return this.bidiCache.push(new Td(e.from,e.to,t,n,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Qe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{c2(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(){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 ad.of(new bc(typeof e=="number"?ce.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return ad.of(new bc(ce.cursor(n.from),"start","start",n.top-e,t,!0))}static domEventHandlers(e){return di.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return di.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Zn.newName(),r=[dd.of(n),pc.of(b0(`.${n}`,e))];return t&&t.dark&&r.push(v0.of(!0)),r}static baseTheme(e){return fr.lowest(pc.of(b0("."+y0,e,eS)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&Mt.get(n)||Mt.get(e);return((t=r?.rootView)===null||t===void 0?void 0:t.view)||null}};Se.styleModule=pc;Se.inputHandler=D2;Se.scrollHandler=I2;Se.focusChangeEffect=Q2;Se.perLineTextDirection=R2;Se.exceptionSink=A2;Se.updateListener=s0;Se.editable=Nd;Se.mouseSelectionStyle=T2;Se.dragMovesSelection=E2;Se.clickAddsSelectionRange=C2;Se.decorations=Ec;Se.outerDecorations=j2;Se.atomicRanges=N0;Se.bidiIsolatedRanges=Z2;Se.scrollMargins=z2;Se.darkTheme=v0;Se.cspNonce=Ae.define({combine:i=>i.length?i[0]:""});Se.contentAttributes=I0;Se.editorAttributes=N2;Se.lineWrapping=Se.contentAttributes.of({class:"cm-lineWrapping"});Se.announce=ze.define();var jQ=4096,Kk={},Td=class i{constructor(e,t,n,r,s,o){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=s,this.order=o}static update(e,t){if(t.empty&&!e.some(s=>s.fresh))return e;let n=[],r=e.length?e[e.length-1].dir:Ct.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&Jg(o,t)}return t}var ZQ=Qe.mac?"mac":Qe.windows?"win":Qe.linux?"linux":"key";function zQ(i,e){let t=i.split(/-(?!$)/),n=t[t.length-1];n=="Space"&&(n=" ");let r,s,o,a;for(let l=0;ln.concat(r),[]))),t}function nS(i,e,t){return rS(iS(i.state),e,i,t)}var $s=null,LQ=4e3;function $Q(i,e=ZQ){let t=Object.create(null),n=Object.create(null),r=(o,a)=>{let l=n[o];if(l==null)n[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,l,c,u)=>{var f,d;let h=t[o]||(t[o]=Object.create(null)),p=a.split(/ (?!$)/).map(O=>zQ(O,e));for(let O=1;O{let P=$s={view:S,prefix:_,scope:o};return setTimeout(()=>{$s==P&&($s=null)},LQ),!0}]})}let m=p.join(" ");r(m,!1);let g=h[m]||(h[m]={preventDefault:!1,stopPropagation:!1,run:((d=(f=h._any)===null||f===void 0?void 0:f.run)===null||d===void 0?void 0:d.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let o of i){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let c of a){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in u)u[f].run.push(o.any)}let l=o[e]||o.key;if(l)for(let c of a)s(c,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(c,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}function rS(i,e,t,n){let r=Sk(e),s=gi(r,0),o=Yi(s)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;$s&&$s.view==t&&$s.scope==n&&(a=$s.prefix+" ",B2.indexOf(e.keyCode)<0&&(c=!0,$s=null));let f=new Set,d=g=>{if(g){for(let O of g.run)if(!f.has(O)&&(f.add(O),O(t,e)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},h=i[n],p,m;return h&&(d(h[a+hd(r,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Qe.windows&&e.ctrlKey&&e.altKey)&&(p=ms[e.keyCode])&&p!=r?(d(h[a+hd(p,e,!0)])||e.shiftKey&&(m=qa[e.keyCode])!=r&&m!=p&&d(h[a+hd(m,e,!1)]))&&(l=!0):o&&e.shiftKey&&d(h[a+hd(r,e,!0)])&&(l=!0),!l&&d(h._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),l}var Tc=class i{constructor(e,t,n,r,s){this.className=e,this.left=t,this.top=n,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=sS(e);return[new i(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return FQ(e,t,n)}};function sS(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==Ct.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function t2(i,e,t){let n=ce.cursor(e);return{from:Math.max(t.from,i.moveToLineBoundary(n,!1,!0).from),to:Math.min(t.to,i.moveToLineBoundary(n,!0,!0).from),type:Gi.Text}}function FQ(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),r=Math.min(t.to,i.viewport.to),s=i.textDirection==Ct.LTR,o=i.contentDOM,a=o.getBoundingClientRect(),l=sS(i),c=o.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),f=a.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),d=a.right-(u?parseInt(u.paddingRight):0),h=a0(i,n),p=a0(i,r),m=h.type==Gi.Text?h:null,g=p.type==Gi.Text?p:null;if(m&&(i.lineWrapping||h.widgetLineBreaks)&&(m=t2(i,n,m)),g&&(i.lineWrapping||p.widgetLineBreaks)&&(g=t2(i,r,g)),m&&g&&m.from==g.from)return _(S(t.from,t.to,m));{let k=m?S(t.from,null,m):P(h,!1),w=g?S(null,t.to,g):P(p,!0),x=[];return(m||h).to<(g||p).from-(m&&g?1:0)||h.widgetLineBreaks>1&&k.bottom+i.defaultLineHeight/2D&&j.from=q)break;xe>z&&Q(Math.max(le,z),k==null&&le<=D,Math.min(xe,q),w==null&&xe>=E,U.dir)}if(z=G.to+1,z>=q)break}return Z.length==0&&Q(D,k==null,E,w==null,i.textDirection),{top:C,bottom:M,horizontal:Z}}function P(k,w){let x=a.top+(w?k.top:k.bottom);return{top:x,bottom:x,horizontal:[]}}}function BQ(i,e){return i.constructor==e.constructor&&i.eq(e)}var S0=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(vd)!=e.state.facet(vd)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(vd);for(;t!BQ(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},vd=Ae.define();function oS(i){return[di.define(e=>new S0(e,i)),vd.of(i)]}var aS=!Qe.ios,Ac=Ae.define({combine(i){return mn(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function lS(i={}){return[Ac.of(i),VQ,WQ,XQ,M2.of(!0)]}function cS(i){return i.startState.facet(Ac)!=i.state.facet(Ac)}var VQ=oS({above:!0,markers(i){let{state:e}=i,t=e.facet(Ac),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||aS:t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=r.empty?r:ce.cursor(r.head,r.head>r.anchor?-1:1);for(let l of Tc.forRange(i,o,a))n.push(l)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=cS(i);return t&&i2(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){i2(e.state,i)},class:"cm-cursorLayer"});function i2(i,e){e.style.animationDuration=i.facet(Ac).cursorBlinkRate+"ms"}var WQ=oS({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:Tc.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||cS(i)},class:"cm-selectionLayer"}),x0={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};aS&&(x0[".cm-line"].caretColor="transparent !important",x0[".cm-content"]={caretColor:"transparent !important"});var XQ=fr.highest(Se.theme(x0)),uS=ze.define({map(i,e){return i==null?null:e.mapPos(i)}}),Oc=Xt.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(uS)?n.value:t,i)}}),YQ=di.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(Oc);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(Oc)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(Oc),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(Oc)!=i&&this.view.dispatch({effects:uS.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function fS(){return[Oc,YQ]}var KG=/x/.unicode!=null?"gu":"g";var P0=2e3;function UQ(i,e,t){let n=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>P0||t.off>P0||e.col<0||t.col<0){let o=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let l=n;l<=r;l++){let c=i.doc.line(l);c.length<=a&&s.push(ce.range(c.from+o,c.to+a))}}else{let o=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let l=n;l<=r;l++){let c=i.doc.line(l),u=rd(c.text,o,i.tabSize,!0);if(u<0)s.push(ce.cursor(c.to));else{let f=rd(c.text,a,i.tabSize);s.push(ce.range(c.from+u,c.from+f))}}}return s}function HQ(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function n2(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),r=t-n.from,s=r>P0?-1:r==n.length?HQ(i,e.clientX):Ls(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:s,off:r}}function GQ(i,e){let t=n2(i,e),n=i.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(r.changes)}},get(r,s,o){let a=n2(i,r);if(!a)return n;let l=UQ(i.state,t,a);return l.length?o?ce.create(l.concat(n.ranges)):ce.create(l):n}}:null}function dS(i){let e=i?.eventFilter||(t=>t.altKey&&t.button==0);return Se.mouseSelectionStyle.of((t,n)=>e(n)?GQ(t,n):null)}var dc="-10000px",Ad=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=n(o,s))}update(e,t){var n;let r=e.state.facet(this.facet),s=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let o=[],a=t?[]:null;for(let l=0;lt[c]=l),t.length=a.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}};function KQ(i){let{win:e}=i;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}var Wg=Ae.define({combine:i=>{var e,t,n;return{position:Qe.ios?"absolute":((e=i.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(r=>r.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||KQ}}}),r2=new WeakMap,j0=di.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(Wg);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Ad(i,Qc,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(Wg);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=dc,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=this.view.dom.getBoundingClientRect(),e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:r}=this.manager.tooltipViews[0];if(Qe.gecko)n=r.offsetParent!=this.container.ownerDocument.body;else if(r.style.top==dc&&r.style.left=="0px"){let s=r.getBoundingClientRect();n=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}}if(n||this.position=="absolute")if(this.parent){let r=this.parent.getBoundingClientRect();r.width&&r.height&&(e=r.width/this.parent.offsetWidth,t=r.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);return{editor:i,parent:this.parent?this.container.getBoundingClientRect():i,pos:this.manager.tooltips.map((r,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(r.pos):this.view.coordsAtPos(r.pos)}),size:this.manager.tooltipViews.map(({dom:r})=>r.getBoundingClientRect()),space:this.view.state.facet(Wg).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{editor:t,space:n,scaleX:r,scaleY:s}=i,o=[];for(let a=0;a=Math.min(t.bottom,n.bottom)||f.rightMath.min(t.right,n.right)+.1){u.style.top=dc;continue}let h=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,m=d.right-d.left,g=(e=r2.get(c))!==null&&e!==void 0?e:d.bottom-d.top,O=c.offset||eR,_=this.view.textDirection==Ct.LTR,S=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.min(f.left-(h?14:0)+O.x,n.right-m):Math.max(n.left,f.left-m+(h?14:0)-O.x),P=this.above[a];!l.strictSide&&(P?f.top-(d.bottom-d.top)-O.yn.bottom)&&P==n.bottom-f.bottom>f.top-n.top&&(P=this.above[a]=!P);let k=(P?f.top-n.top:n.bottom-f.bottom)-p;if(kS&&C.topw&&(w=P?C.top-g-2-p:C.bottom+p+2);if(this.position=="absolute"?(u.style.top=(w-i.parent.top)/s+"px",u.style.left=(S-i.parent.left)/r+"px"):(u.style.top=w/s+"px",u.style.left=S/r+"px"),h){let C=f.left+(_?O.x:-O.x)-(S+14-7);h.style.left=C/r+"px"}c.overlap!==!0&&o.push({left:S,top:w,right:x,bottom:w+g}),u.classList.toggle("cm-tooltip-above",P),u.classList.toggle("cm-tooltip-below",!P),c.positioned&&c.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=dc}},{eventObservers:{scroll(){this.maybeMeasure()}}}),JQ=Se.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"}}}),eR={x:0,y:0},Qc=Ae.define({enables:[j0,JQ]}),Dd=Ae.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])}),Qd=class i{static create(e){return new i(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Ad(e,Dd,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},tR=Qc.compute([Dd],i=>{let e=i.facet(Dd);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:Qd.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),C0=class{constructor(e,t,n,r,s){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(r)).find(u=>u.from<=r&&u.to>=r),c=l&&l.dir==Ct.RTL?-1:1;s=t.x{this.pending==a&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>Ai(e.state,l,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(j0),t=e?e.manager.tooltips.findIndex(n=>n.create==Qd.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&s&&!iR(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,a=(n=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==a?this.view.posAtCoords(this.lastMove)!=o:!nR(this.view,o,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},pd=4;function iR(i,e){let t=i.getBoundingClientRect();return e.clientX>=t.left-pd&&e.clientX<=t.right+pd&&e.clientY>=t.top-pd&&e.clientY<=t.bottom+pd}function nR(i,e,t,n,r,s){let o=i.scrollDOM.getBoundingClientRect(),a=i.documentTop+i.documentPadding.top+i.contentHeight;if(o.left>n||o.rightr||Math.min(o.bottom,a)=e&&l<=t}function hS(i,e={}){let t=ze.define(),n=Xt.define({create(){return[]},update(r,s){if(r.length&&(e.hideOnChange&&(s.docChanged||s.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let a of r){let l=s.changes.mapPos(a.pos,-1,Ei.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),a);c.pos=l,c.end!=null&&(c.end=s.changes.mapPos(c.end)),o.push(c)}}r=o}for(let o of s.effects)o.is(t)&&(r=o.value),o.is(rR)&&(r=[]);return r},provide:r=>Dd.from(r)});return[n,di.define(r=>new C0(r,i,n,t,e.hoverTime||300)),tR]}function Z0(i,e){let t=i.plugin(j0);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}var rR=ze.define();var s2=Ae.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function qo(i,e){let t=i.plugin(pS),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}var pS=di.fromClass(class{constructor(i){this.input=i.state.facet(zo),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(s2);this.top=new Fa(i,!0,e.topContainer),this.bottom=new Fa(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(s2);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Fa(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Fa(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(zo);if(t!=this.input){let n=t.filter(l=>l),r=[],s=[],o=[],a=[];for(let l of n){let c=this.specs.indexOf(l),u;c<0?(u=l(i.view),a.push(u)):(u=this.panels[c],u.update&&u.update(i)),r.push(u),(u.top?s:o).push(u)}this.specs=n,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>Se.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Fa=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=o2(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=o2(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function o2(i){let e=i.nextSibling;return i.remove(),e}var zo=Ae.define({enables:pS}),pr=class extends ur{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};pr.prototype.elementClass="";pr.prototype.toDOM=void 0;pr.prototype.mapMode=Ei.TrackBefore;pr.prototype.startSide=pr.prototype.endSide=-1;pr.prototype.point=!0;var Xg=Ae.define(),sR={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>kt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},yd=Ae.define();function z0(i){return[oR(),yd.of(Object.assign(Object.assign({},sR),i))]}var E0=Ae.define({combine:i=>i.some(e=>e)});function oR(i){let e=[aR];return i&&i.fixed===!1&&e.push(E0.of(!0)),e}var aR=di.fromClass(class{constructor(i){this.view=i,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(yd).map(e=>new Rd(i,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!i.state.facet(E0),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}i.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(E0)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&this.dom.remove();let t=kt.iter(this.view.state.facet(Xg),this.view.viewport.from),n=[],r=this.gutters.map(s=>new A0(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(s.type)){let o=!0;for(let a of s.type)if(a.type==Gi.Text&&o){T0(t,n,a.from);for(let l of r)l.line(this.view,a,n);o=!1}else if(a.widget)for(let l of r)l.widget(this.view,a)}else if(s.type==Gi.Text){T0(t,n,s.from);for(let o of r)o.line(this.view,s,n)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();i&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(i){let e=i.startState.facet(yd),t=i.state.facet(yd),n=i.docChanged||i.heightChanged||i.viewportChanged||!kt.eq(i.startState.facet(Xg),i.state.facet(Xg),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let r of this.gutters)r.update(i)&&(n=!0);else{n=!0;let r=[];for(let s of t){let o=e.indexOf(s);o<0?r.push(new Rd(this.view,s)):(this.gutters[o].update(i),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)this.dom.appendChild(s.dom);this.gutters=r}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove()}},{provide:i=>Se.scrollMargins.of(e=>{let t=e.plugin(i);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==Ct.LTR?{left:t.dom.offsetWidth*e.scaleX}:{right:t.dom.offsetWidth*e.scaleX}})});function a2(i){return Array.isArray(i)?i:[i]}function T0(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}var A0=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=kt.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,s=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let a=new Md(e,o,s,n);r.elements.push(a),r.dom.appendChild(a.dom)}else r.elements[this.i].update(e,o,s,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];T0(this.cursor,r,t.from),n.length&&(r=r.concat(n));let s=this.gutter.config.lineMarker(e,t,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t);n&&this.addElement(e,t,[n])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},Rd=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let l=s.getBoundingClientRect();o=(l.top+l.bottom)/2}else o=r.clientY;let a=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,a,r)&&r.preventDefault()});this.markers=a2(t.markers(e)),t.initialSpacer&&(this.spacer=new Md(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=a2(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let n=e.view.viewport;return!kt.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Md=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),lR(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let a=o,l=s{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=zi.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};qe.closedBy=new qe({deserialize:i=>i.split(" ")});qe.openedBy=new qe({deserialize:i=>i.split(" ")});qe.group=new qe({deserialize:i=>i.split(" ")});qe.isolate=new qe({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});qe.contextHash=new qe({perNode:!0});qe.lookAhead=new qe({perNode:!0});qe.mounted=new qe({perNode:!0});var Wa=class{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[qe.mounted.id]}},uR=Object.create(null),zi=class i{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):uR,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new i(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),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 r}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(qe.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return n=>{for(let r=n.prop(qe.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}};zi.none=new zi("",Object.create(null),0,8);var Mc=class i{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|ni.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=r&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&n&&(a||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;c=!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:W0(zi.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new i(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new i(zi.none,t,n,r)))}static build(e){return dR(e)}};ri.empty=new ri(zi.none,[],[],0);var q0=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)}},Xs=class i{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return zi.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function Ic(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?a.length:-1;e!=c;e+=t){let u=a[e],f=l[e]+o.from;if(vS(r,n,f,f+u.length)){if(u instanceof Xs){if(s&ni.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,t,n-f,r);if(d>-1)return new Nc(new $0(o,u,e,f),null,d)}else if(s&ni.IncludeAnonymous||!u.type.isAnonymous||V0(u)){let d;if(!(s&ni.IgnoreMounts)&&(d=Wa.get(u))&&!d.overlay)return new i(d.tree,f,e,o);let h=new i(u,f,e,o);return s&ni.IncludeAnonymous||!h.type.isAnonymous?h:h.nextChild(t<0?u.children.length-1:0,t,n,r)}}}if(s&ni.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,n=0){let r;if(!(n&ni.IgnoreOverlays)&&(r=Wa.get(this._tree))&&r.overlay){let s=e-this.from;for(let{from:o,to:a}of r.overlay)if((t>0?o<=s:o=s:a>s))return new i(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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 gS(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(let o=!1;!o;)if(o=r.type.is(t),!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function L0(i,e,t=e.length-1){for(let n=i.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}var $0=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Nc=class i extends zd{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,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);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,n=0){if(n&ni.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.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:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new ri(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function yS(i){if(!i.length)return null;let e=0,t=i[0];for(let s=1;st.from||o.to=e){let a=new Fr(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[n])).push(Ic(a,e,t,!1))}}return r?yS(r):n}var jc=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 Fr)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.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:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Fr?(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,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);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,n=this.mode){return this.buffer?n&ni.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ni.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ni.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,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<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,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let a=n._tree.children[s];if(this.mode&ni.IncludeAnonymous||a instanceof Xs||!a.type.isAnonymous||V0(a))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==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r=0;s--){if(s<0)return L0(this.node,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function V0(i){return i.children.some(e=>e instanceof Xs||!e.type.isAnonymous||V0(e))}function dR(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=n.types.length}=i,a=Array.isArray(t)?new q0(t,t.length):t,l=n.types,c=0,u=0;function f(k,w,x,C,M,Z){let{id:Q,start:D,end:E,size:j}=a,z=u;for(;j<0;)if(a.next(),j==-1){let xe=s[Q];x.push(xe),C.push(D-k);return}else if(j==-3){c=Q;return}else if(j==-4){u=Q;return}else throw new RangeError(`Unrecognized record size: ${j}`);let q=l[Q],G,U,le=D-k;if(E-D<=r&&(U=g(a.pos-w,M))){let xe=new Uint16Array(U.size-U.skip),ue=a.pos-U.size,B=xe.length;for(;a.pos>ue;)B=O(U.start,xe,B);G=new Xs(xe,E-U.start,n),le=U.start-k}else{let xe=a.pos-j;a.next();let ue=[],B=[],J=Q>=o?Q:-1,pe=0,Re=E;for(;a.pos>xe;)J>=0&&a.id==J&&a.size>=0?(a.end<=Re-r&&(p(ue,B,D,pe,a.end,Re,J,z),pe=ue.length,Re=a.end),a.next()):Z>2500?d(D,xe,ue,B):f(D,xe,ue,B,J,Z+1);if(J>=0&&pe>0&&pe-1&&pe>0){let oe=h(q);G=W0(q,ue,B,0,ue.length,0,E-D,oe,oe)}else G=m(q,ue,B,E-D,z-E)}x.push(G),C.push(le)}function d(k,w,x,C){let M=[],Z=0,Q=-1;for(;a.pos>w;){let{id:D,start:E,end:j,size:z}=a;if(z>4)a.next();else{if(Q>-1&&E=0;j-=3)D[z++]=M[j],D[z++]=M[j+1]-E,D[z++]=M[j+2]-E,D[z++]=z;x.push(new Xs(D,M[2]-E,n)),C.push(E-k)}}function h(k){return(w,x,C)=>{let M=0,Z=w.length-1,Q,D;if(Z>=0&&(Q=w[Z])instanceof ri){if(!Z&&Q.type==k&&Q.length==C)return Q;(D=Q.prop(qe.lookAhead))&&(M=x[Z]+Q.length+D)}return m(k,w,x,C,M)}}function p(k,w,x,C,M,Z,Q,D){let E=[],j=[];for(;k.length>C;)E.push(k.pop()),j.push(w.pop()+x-M);k.push(m(n.types[Q],E,j,Z-M,D-Z)),w.push(M-x)}function m(k,w,x,C,M=0,Z){if(c){let Q=[qe.contextHash,c];Z=Z?[Q].concat(Z):[Q]}if(M>25){let Q=[qe.lookAhead,M];Z=Z?[Q].concat(Z):[Q]}return new ri(k,w,x,C,Z)}function g(k,w){let x=a.fork(),C=0,M=0,Z=0,Q=x.end-r,D={size:0,start:0,skip:0};e:for(let E=x.pos-k;x.pos>E;){let j=x.size;if(x.id==w&&j>=0){D.size=C,D.start=M,D.skip=Z,Z+=4,C+=4,x.next();continue}let z=x.pos-j;if(j<0||z=o?4:0,G=x.start;for(x.next();x.pos>z;){if(x.size<0)if(x.size==-3)q+=4;else break e;else x.id>=o&&(q+=4);x.next()}M=G,C+=j,Z+=q}return(w<0||C==k)&&(D.size=C,D.start=M,D.skip=Z),D.size>4?D:void 0}function O(k,w,x){let{id:C,start:M,end:Z,size:Q}=a;if(a.next(),Q>=0&&C4){let E=a.pos-(Q-4);for(;a.pos>E;)x=O(k,w,x)}w[--x]=D,w[--x]=Z-k,w[--x]=M-k,w[--x]=C}else Q==-3?c=C:Q==-4&&(u=C);return x}let _=[],S=[];for(;a.pos>0;)f(i.start||0,i.bufferStart||0,_,S,-1,0);let P=(e=i.length)!==null&&e!==void 0?e:_.length?S[0]+_[0].length:0;return new ri(l[i.topID],_.reverse(),S.reverse(),P)}var OS=new WeakMap;function Zd(i,e){if(!i.isAnonymous||e instanceof Xs||e.type!=i)return 1;let t=OS.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof ri)){t=1;break}t+=Zd(i,n)}OS.set(e,t)}return t}function W0(i,e,t,n,r,s,o,a,l){let c=0;for(let p=n;p=u)break;w+=x}if(S==P+1){if(w>u){let x=p[P];h(x.children,x.positions,0,x.children.length,m[P]+_);continue}f.push(p[P])}else{let x=m[S-1]+p[S-1].length-k;f.push(W0(i,p,m,P,S,k,x,null,l))}d.push(k+_-s)}}return h(e,t,n,r,0),(a||l)(f,d,o)}var Lo=class i{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,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=[],n=!1){let r=[new i(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a=n)for(;o&&o.from=d.from||f<=d.to||c){let h=Math.max(d.from,l)-c,p=Math.min(d.to,f)-c;d=h>=p?null:new i(h,p,d.tree,d.offset+c,a>0,!!u)}if(d&&r.push(d),o.to>f)break;o=snew Rc(r.from,r.to)):[new Rc(0,0)]:[new Rc(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}},B0=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 rK=new qe({perNode:!0});var hR=0,Xr=class i{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=hR++}static define(e){if(e?.base)throw new Error("Can not derive from a modified tag");let t=new i([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new Fd;return t=>t.modified.indexOf(e)>-1?t:Fd.get(t.base||t,t.modified.concat(e).sort((n,r)=>n.id-r.id))}},pR=0,Fd=class i{constructor(){this.instances=[],this.id=pR++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(a=>a.base==e&&mR(t,a.modified));if(n)return n;let r=[],s=new Xr(r,e,t);for(let a of t)a.instances.push(s);let o=gR(t);for(let a of e.set)if(!a.modified.length)for(let l of o)r.push(i.get(a,l));return s}};function mR(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function gR(i){let e=[[]];for(let t=0;tn.length-t.length)}function Bd(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!d)throw new RangeError("Invalid path: "+r);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==r.length)break;let h=r[f++];if(f==r.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+r);let u=new Ya(n,o,l>0?s.slice(0,l):null);e[c]=u.sort(e[c])}}return wS.add(e)}var wS=new qe,Ya=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let a of s)for(let l of a.set){let c=t[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:n}}function OR(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function kS(i,e,t,n=0,r=i.length){let s=new Y0(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}var Y0=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,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,n,r,s){let{type:o,from:a,to:l}=e;if(a>=n||l<=t)return;o.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(o)));let c=r,u=vR(e)||Ya.empty,f=OR(s,u.tags);if(f&&(c&&(c+=" "),c+=f,u.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,a),c),u.opaque)return;let d=e.tree&&e.tree.prop(qe.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+a,1),p=this.highlighters.filter(g=>!g.scope||g.scope(d.tree.type)),m=e.firstChild();for(let g=0,O=a;;g++){let _=g=S||!e.nextSibling())););if(!_||S>n)break;O=_.to+a,O>t&&(this.highlightRange(h.cursor(),Math.max(t,_.from+a),Math.min(n,O),"",p),this.startSpan(Math.min(n,O),c))}m&&e.parent()}else if(e.firstChild()){d&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function vR(i){let e=i.type.prop(wS);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}var _e=Xr.define,qd=_e(),Ys=_e(),bS=_e(Ys),_S=_e(Ys),Us=_e(),Ld=_e(Us),X0=_e(Us),Wr=_e(),$o=_e(Wr),Br=_e(),Vr=_e(),U0=_e(),Zc=_e(U0),$d=_e(),L={comment:qd,lineComment:_e(qd),blockComment:_e(qd),docComment:_e(qd),name:Ys,variableName:_e(Ys),typeName:bS,tagName:_e(bS),propertyName:_S,attributeName:_e(_S),className:_e(Ys),labelName:_e(Ys),namespace:_e(Ys),macroName:_e(Ys),literal:Us,string:Ld,docString:_e(Ld),character:_e(Ld),attributeValue:_e(Ld),number:X0,integer:_e(X0),float:_e(X0),bool:_e(Us),regexp:_e(Us),escape:_e(Us),color:_e(Us),url:_e(Us),keyword:Br,self:_e(Br),null:_e(Br),atom:_e(Br),unit:_e(Br),modifier:_e(Br),operatorKeyword:_e(Br),controlKeyword:_e(Br),definitionKeyword:_e(Br),moduleKeyword:_e(Br),operator:Vr,derefOperator:_e(Vr),arithmeticOperator:_e(Vr),logicOperator:_e(Vr),bitwiseOperator:_e(Vr),compareOperator:_e(Vr),updateOperator:_e(Vr),definitionOperator:_e(Vr),typeOperator:_e(Vr),controlOperator:_e(Vr),punctuation:U0,separator:_e(U0),bracket:Zc,angleBracket:_e(Zc),squareBracket:_e(Zc),paren:_e(Zc),brace:_e(Zc),content:Wr,heading:$o,heading1:_e($o),heading2:_e($o),heading3:_e($o),heading4:_e($o),heading5:_e($o),heading6:_e($o),contentSeparator:_e(Wr),list:_e(Wr),quote:_e(Wr),emphasis:_e(Wr),strong:_e(Wr),link:_e(Wr),monospace:_e(Wr),strikethrough:_e(Wr),inserted:_e(),deleted:_e(),changed:_e(),invalid:_e(),meta:$d,documentMeta:_e($d),annotation:_e($d),processingInstruction:_e($d),definition:Xr.defineModifier(),constant:Xr.defineModifier(),function:Xr.defineModifier(),standard:Xr.defineModifier(),local:Xr.defineModifier(),special:Xr.defineModifier()},aK=H0([{tag:L.link,class:"tok-link"},{tag:L.heading,class:"tok-heading"},{tag:L.emphasis,class:"tok-emphasis"},{tag:L.strong,class:"tok-strong"},{tag:L.keyword,class:"tok-keyword"},{tag:L.atom,class:"tok-atom"},{tag:L.bool,class:"tok-bool"},{tag:L.url,class:"tok-url"},{tag:L.labelName,class:"tok-labelName"},{tag:L.inserted,class:"tok-inserted"},{tag:L.deleted,class:"tok-deleted"},{tag:L.literal,class:"tok-literal"},{tag:L.string,class:"tok-string"},{tag:L.number,class:"tok-number"},{tag:[L.regexp,L.escape,L.special(L.string)],class:"tok-string2"},{tag:L.variableName,class:"tok-variableName"},{tag:L.local(L.variableName),class:"tok-variableName tok-local"},{tag:L.definition(L.variableName),class:"tok-variableName tok-definition"},{tag:L.special(L.variableName),class:"tok-variableName2"},{tag:L.definition(L.propertyName),class:"tok-propertyName tok-definition"},{tag:L.typeName,class:"tok-typeName"},{tag:L.namespace,class:"tok-namespace"},{tag:L.className,class:"tok-className"},{tag:L.macroName,class:"tok-macroName"},{tag:L.propertyName,class:"tok-propertyName"},{tag:L.operator,class:"tok-operator"},{tag:L.comment,class:"tok-comment"},{tag:L.meta,class:"tok-meta"},{tag:L.invalid,class:"tok-invalid"},{tag:L.punctuation,class:"tok-punctuation"}]);var G0,Ua=new qe;function AS(i){return Ae.define({combine:i?e=>e.concat(i):void 0})}var DS=new qe,Cn=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,At.prototype.hasOwnProperty("tree")||Object.defineProperty(At.prototype,"tree",{get(){return vi(this)}}),this.parser=t,this.extension=[Hs.of(this),At.languageData.of((s,o,a)=>{let l=SS(s,o,a),c=l.type.prop(Ua);if(!c)return[];let u=s.facet(c),f=l.type.prop(DS);if(f){let d=l.resolve(o-l.from,a);for(let h of f)if(h.test(d,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return SS(e,t,n).type.prop(Ua)==this.data}findRegions(e){let t=e.facet(Hs);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(Ua)==this.data){n.push({from:o,to:o+s.length});return}let a=s.prop(qe.mounted);if(a){if(a.tree.prop(Ua)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+o,to:l.to+o});else n.push({from:o,to:o+s.length});return}else if(a.overlay){let l=n.length;if(r(a.tree,a.overlay[0].from+o),n.length>l)return}}for(let l=0;ln.isTop?t:void 0)]}),e.name)}configure(e,t){return new i(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function vi(i){let e=i.field(Cn.state,!1);return e?e.tree:ri.empty}var t1=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},zc=null,i1=class i{constructor(e,t,n=[],r,s,o,a,l){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new i(e,t,[],ri.empty,0,n,[],null)}startParse(){return this.parser.startParse(new t1(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ri.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}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(Lo.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=zc;zc=this;try{return e()}finally{zc=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=xS(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,f,d)=>l.push({fromA:c,toA:u,fromB:f,toB:d})),n=Lo.applyChanges(n,l),r=ri.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);ue.from&&(this.fragments=xS(this.fragments,r,s),this.skipped.splice(n--,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 Xa{createParse(t,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let l=zc;if(l){for(let c of r)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new ri(zi.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 zc}};function xS(i,e,t){return Lo.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}var Lc=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),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new i(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=i1.create(e.facet(Hs).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new i(n)}};Cn.state=Xt.define({create:Lc.init,update(i,e){for(let t of e.effects)if(t.is(Cn.setState))return t.value;return e.startState.facet(Hs)!=e.state.facet(Hs)?Lc.init(e.state):i.apply(e)}});var QS=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(QS=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var K0=typeof navigator<"u"&&(!((G0=navigator.scheduling)===null||G0===void 0)&&G0.isInputPending)?()=>navigator.scheduling.isInputPending():null,yR=di.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(Cn.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(Cn.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=QS(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,l=s.context.work(()=>K0&&K0()||Date.now()>o,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Cn.setState.of(new Lc(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ai(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()}}}),Hs=Ae.define({combine(i){return i.length?i[0]:null},enables:i=>[Cn.state,yR,Se.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});var bR=Ae.define(),$c=Ae.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Fc(i){let e=i.facet($c);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Ha(i,e){let t="",n=i.tabSize,r=i.facet($c)[0];if(r==" "){for(;e>=n;)t+=" ",e-=n;r=" "}for(let s=0;s=e?_R(i,t,e):null}var Fo=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Fc(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return Ls(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},c1=new qe;function _R(i,e,t){let n=e.resolveStack(t),r=n.node.enterUnfinishedNodesBefore(t);if(r!=n.node){let s=[];for(let o=r;o!=n.node;o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)n={node:s[o],next:n}}return RS(n,i,t)}function RS(i,e,t){for(let n=i;n;n=n.next){let r=kR(n.node);if(r)return r(n1.create(e,t,n))}return 0}function wR(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function kR(i){let e=i.type.prop(c1);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(qe.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>IS(o,!0,1,void 0,s&&!wR(o)?r.from:void 0)}return i.parent==null?SR:null}function SR(){return 0}var n1=class i extends Fo{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new i(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(xR(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return RS(this.context.next,this.base,this.pos)}};function xR(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function PR(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped)return l.fromIS(n,e,t,i)}function IS(i,e,t,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==i.pos+o,l=e?PR(i):null;return l?a?i.column(l.from):i.column(l.to):i.baseIndent+(a?0:i.unit*t)}var NS=i=>i.baseIndent;function Ud({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}var CR=200;function jS(){return At.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,r=t.lineAt(n);if(n>r.from+CR)return i;let s=t.sliceString(r.from,n);if(!e.some(c=>c.test(s)))return i;let{state:o}=i,a=-1,l=[];for(let{head:c}of o.selection.ranges){let u=o.doc.lineAt(c);if(u.from==a)continue;a=u.from;let f=Yd(o,u.from);if(f==null)continue;let d=/^\s*/.exec(u.text)[0],h=Ha(o,f);d!=h&&l.push({from:u.from,to:u.from+d.length,insert:h})}return l.length?[i,{changes:l,sequential:!0}]:i})}var ER=Ae.define(),u1=new qe;function ZS(i){let e=i.firstChild,t=i.lastChild;return e&&e.tot)continue;if(s&&a.from=e&&c.to>t&&(s=c)}}return s}function AR(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Wd(i,e,t){for(let n of i.facet(ER)){let r=n(i,e,t);if(r)return r}return TR(i,e,t)}function zS(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}var Hd=ze.define({map:zS}),Bc=ze.define({map:zS});function qS(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}var Bo=Xt.define({create(){return je.none},update(i,e){i=i.map(e.changes);for(let t of e.effects)if(t.is(Hd)&&!DR(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(f1),r=n?je.replace({widget:new r1(n(e.state,t.value))}):PS;i=i.update({add:[r.range(t.value.from,t.value.to)]})}else t.is(Bc)&&(i=i.update({filter:(n,r)=>t.value.from!=n||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:n}=e.selection.main;i.between(n,n,(r,s)=>{rn&&(t=!0)}),t&&(i=i.update({filterFrom:n,filterTo:n,filter:(r,s)=>s<=n||r>=n}))}return i},provide:i=>Se.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,r)=>{t.push(n,r)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!r||r.from>s)&&(r={from:s,to:o})}),r}function DR(i,e,t){let n=!1;return i.between(e,e,(r,s)=>{r==e&&s==t&&(n=!0)}),n}function LS(i,e){return i.field(Bo,!1)?e:e.concat(ze.appendConfig.of(BS()))}var QR=i=>{for(let e of qS(i)){let t=Wd(i.state,e.from,e.to);if(t)return i.dispatch({effects:LS(i.state,[Hd.of(t),$S(i,t)])}),!0}return!1},RR=i=>{if(!i.state.field(Bo,!1))return!1;let e=[];for(let t of qS(i)){let n=Xd(i.state,t.from,t.to);n&&e.push(Bc.of(n),$S(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function $S(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,r=i.state.doc.lineAt(e.to).number;return Se.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${r}.`)}var MR=i=>{let{state:e}=i,t=[];for(let n=0;n{let e=i.state.field(Bo,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,r)=>{t.push(Bc.of({from:n,to:r}))}),i.dispatch({effects:t}),!0};var FS=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:QR},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:RR},{key:"Ctrl-Alt-[",run:MR},{key:"Ctrl-Alt-]",run:IR}],NR={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},f1=Ae.define({combine(i){return mn(i,NR)}});function BS(i){let e=[Bo,ZR];return i&&e.push(f1.of(i)),e}function VS(i,e){let{state:t}=i,n=t.facet(f1),r=o=>{let a=i.lineBlockAt(i.posAtDOM(o.target)),l=Xd(i.state,a.from,a.to);l&&i.dispatch({effects:Bc.of(l)}),o.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,r,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",t.phrase("folded code")),s.title=t.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}var PS=je.replace({widget:new class extends dr{toDOM(i){return VS(i,null)}}}),r1=class extends dr{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return VS(e,this.value)}},jR={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},qc=class extends pr{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}};function WS(i={}){let e=Object.assign(Object.assign({},jR),i),t=new qc(e,!0),n=new qc(e,!1),r=di.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Hs)!=o.state.facet(Hs)||o.startState.field(Bo,!1)!=o.state.field(Bo,!1)||vi(o.startState)!=vi(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let a=new jr;for(let l of o.viewportLineBlocks){let c=Xd(o.state,l.from,l.to)?n:Wd(o.state,l.from,l.to)?t:null;c&&a.add(l.from,l.from,c)}return a.finish()}}),{domEventHandlers:s}=e;return[r,z0({class:"cm-foldGutter",markers(o){var a;return((a=o.plugin(r))===null||a===void 0?void 0:a.markers)||kt.empty},initialSpacer(){return new qc(e,!1)},domEventHandlers:Object.assign(Object.assign({},s),{click:(o,a,l)=>{if(s.click&&s.click(o,a,l))return!0;let c=Xd(o.state,a.from,a.to);if(c)return o.dispatch({effects:Bc.of(c)}),!0;let u=Wd(o.state,a.from,a.to);return u?(o.dispatch({effects:Hd.of(u)}),!0):!1}})}),BS()]}var ZR=Se.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),Gs=class i{constructor(e,t){this.specs=e;let n;function r(a){let l=Zn.newName();return(n||(n=Object.create(null)))["."+l]=a,l}let s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof Cn?a=>a.prop(Ua)==o.data:o?a=>a==o:void 0,this.style=H0(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=n?new Zn(n):null,this.themeType=t.themeType}static define(e,t){return new i(e,t||{})}},s1=Ae.define(),XS=Ae.define({combine(i){return i.length?[i[0]]:null}});function J0(i){let e=i.facet(s1);return e.length?e:i.facet(XS)}function Ga(i,e){let t=[zR],n;return i instanceof Gs&&(i.module&&t.push(Se.styleModule.of(i.module)),n=i.themeType),e?.fallback?t.push(XS.of(i)):n?t.push(s1.computeN([Se.darkTheme],r=>r.facet(Se.darkTheme)==(n=="dark")?[i]:[])):t.push(s1.of(i)),t}var o1=class{constructor(e){this.markCache=Object.create(null),this.tree=vi(e.state),this.decorations=this.buildDeco(e,J0(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=vi(e.state),n=J0(e.state),r=n!=J0(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||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=s.to)}buildDeco(e,t){if(!t||!this.tree.length)return je.none;let n=new jr;for(let{from:r,to:s}of e.visibleRanges)kS(this.tree,t,(o,a,l)=>{n.add(o,a,this.markCache[l]||(this.markCache[l]=je.mark({class:l})))},r,s);return n.finish()}},zR=fr.high(di.fromClass(o1,{decorations:i=>i.decorations})),YS=Gs.define([{tag:L.meta,color:"#404740"},{tag:L.link,textDecoration:"underline"},{tag:L.heading,textDecoration:"underline",fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.keyword,color:"#708"},{tag:[L.atom,L.bool,L.url,L.contentSeparator,L.labelName],color:"#219"},{tag:[L.literal,L.inserted],color:"#164"},{tag:[L.string,L.deleted],color:"#a11"},{tag:[L.regexp,L.escape,L.special(L.string)],color:"#e40"},{tag:L.definition(L.variableName),color:"#00f"},{tag:L.local(L.variableName),color:"#30a"},{tag:[L.typeName,L.namespace],color:"#085"},{tag:L.className,color:"#167"},{tag:[L.special(L.variableName),L.macroName],color:"#256"},{tag:L.definition(L.propertyName),color:"#00c"},{tag:L.comment,color:"#940"},{tag:L.invalid,color:"#f00"}]),qR=Se.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),US=1e4,HS="()[]{}",GS=Ae.define({combine(i){return mn(i,{afterCursor:!0,brackets:HS,maxScanDistance:US,renderMatch:FR})}}),LR=je.mark({class:"cm-matchingBracket"}),$R=je.mark({class:"cm-nonmatchingBracket"});function FR(i){let e=[],t=i.matched?LR:$R;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}var BR=Xt.define({create(){return je.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(GS);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=mr(e.state,r.head,-1,n)||r.head>0&&mr(e.state,r.head-1,1,n)||n.afterCursor&&(mr(e.state,r.head,1,n)||r.headSe.decorations.from(i)}),VR=[BR,qR];function KS(i={}){return[GS.of(i),VR]}var WR=new qe;function a1(i,e,t){let n=i.prop(e<0?qe.openedBy:qe.closedBy);if(n)return n;if(i.name.length==1){let r=t.indexOf(i.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function l1(i){let e=i.type.prop(WR);return e?e(i.node):i}function mr(i,e,t,n={}){let r=n.maxScanDistance||US,s=n.brackets||HS,o=vi(i),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=a1(l.type,t,s);if(c&&l.from0?e>=u.from&&eu.from&&e<=u.to))return XR(i,e,t,l,u,c,s)}}return YR(i,e,t,o,a.type,r,s)}function XR(i,e,t,n,r,s,o){let a=n.parent,l={from:r.from,to:r.to},c=0,u=a?.cursor();if(u&&(t<0?u.childBefore(n.from):u.childAfter(n.to)))do if(t<0?u.to<=n.from:u.from>=n.to){if(c==0&&s.indexOf(u.type.name)>-1&&u.from0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=i.doc.iterRange(e,t>0?i.doc.length:0),f=0;for(let d=0;!u.next().done&&d<=s;){let h=u.value;t<0&&(d+=h.length);let p=e+d*t;for(let m=t>0?0:h.length-1,g=t>0?h.length:-1;m!=g;m+=t){let O=o.indexOf(h[m]);if(!(O<0||n.resolveInner(p+m,1).type!=r))if(O%2==0==t>0)f++;else{if(f==1)return{start:c,end:{from:p+m,to:p+m+1},matched:O>>1==l>>1};f--}}t>0&&(d+=h.length)}return u.done?{start:c,matched:!1}:null}var UR=Object.create(null),CS=[zi.none];var ES=[],TS=Object.create(null),HR=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"]])HR[i]=GR(UR,e);function e1(i,e){ES.indexOf(i)>-1||(ES.push(i),console.warn(e))}function GR(i,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=i[c]||L[c];u?typeof u=="function"?l.length?l=l.map(u):e1(c,`Modifier ${c} used at start of tag`):l.length?e1(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:e1(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+t.map(a=>a.id),s=TS[r];if(s)return s.id;let o=TS[r]=zi.define({id:CS.length,name:n,props:[Bd({[n]:t})]});return CS.push(o),o.id}var mK={rtl:je.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:Ct.RTL}),ltr:je.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:Ct.LTR}),auto:je.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var KR=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=O1(i.state,t.from);return n.line?JR(i):n.block?tM(i):!1};function g1(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=i(e,t);return r?(n(t.update(r)),!0):!1}}var JR=g1(rM,0);var eM=g1(ax,0);var tM=g1((i,e)=>ax(i,e,nM(e)),0);function O1(i,e){let t=i.languageDataAt("commentTokens",e);return t.length?t[0]:{}}var Vc=50;function iM(i,{open:e,close:t},n,r){let s=i.sliceDoc(n-Vc,n),o=i.sliceDoc(r,r+Vc),a=/\s*$/.exec(s)[0].length,l=/^\s*/.exec(o)[0].length,c=s.length-a;if(s.slice(c-e.length,c)==e&&o.slice(l,l+t.length)==t)return{open:{pos:n-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let u,f;r-n<=2*Vc?u=f=i.sliceDoc(n,r):(u=i.sliceDoc(n,n+Vc),f=i.sliceDoc(r-Vc,r));let d=/^\s*/.exec(u)[0].length,h=/\s*$/.exec(f)[0].length,p=f.length-h-t.length;return u.slice(d,d+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:n+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:r-h-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function nM(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),r=t.to<=n.to?n:i.doc.lineAt(t.to),s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}function ax(i,e,t=e.selection.ranges){let n=t.map(s=>O1(e,s.from).block);if(!n.every(s=>s))return null;let r=t.map((s,o)=>iM(e,n[o],s.from,s.to));if(i!=2&&!r.every(s=>s))return{changes:e.changes(t.map((s,o)=>r[o]?[]:[{from:s.from,insert:n[o].open+" "},{from:s.to,insert:" "+n[o].close}]))};if(i!=1&&r.some(s=>s)){let s=[];for(let o=0,a;or&&(s==o||o>f.from)){r=f.from;let d=/^\s*/.exec(f.text)[0].length,h=d==f.length,p=f.text.slice(d,d+c.length)==c?d:-1;ds.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of n)(f||!u)&&s.push({from:a.from+c,insert:l+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(i!=1&&n.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:a,token:l}of n)if(a>=0){let c=o.from+a,u=c+l.length;o.text[u-o.from]==" "&&u++,s.push({from:c,to:u})}return{changes:s}}return null}var h1=pn.define(),sM=pn.define(),oM=Ae.define(),aM=Ae.define({combine(i){return mn(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),lM=Xt.define({create(){return Vo.empty},update(i,e){let t=e.state.facet(aM),n=e.annotation(h1);if(n){let l=gr.fromTransaction(e,n.selection),c=n.side,u=c==0?i.undone:i.done;return l?u=Kd(u,u.length,t.minDepth,l):u=cx(u,e.startState.selection),new Vo(c==0?n.rest:u,c==0?u:n.rest)}let r=e.annotation(sM);if((r=="full"||r=="before")&&(i=i.isolate()),e.annotation(Oi.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let s=gr.fromTransaction(e),o=e.annotation(Oi.time),a=e.annotation(Oi.userEvent);return s?i=i.addChanges(s,o,a,t,e):e.selection&&(i=i.addSelection(e.startState.selection,o,a,t.newGroupDelay)),(r=="full"||r=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new Vo(i.done.map(gr.fromJSON),i.undone.map(gr.fromJSON))}});function Jd(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let r=t.field(lM,!1);if(!r)return!1;let s=r.pop(i,t,e);return s?(n(s),!0):!1}}var cM=Jd(0,!1),JS=Jd(1,!1),uM=Jd(0,!0),fM=Jd(1,!0);var gr=class i{constructor(e,t,n,r,s){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new i(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new i(e.changes&&Ui.fromJSON(e.changes),[],e.mapped&&ps.fromJSON(e.mapped),e.startSelection&&ce.fromJSON(e.startSelection),e.selectionsAfter.map(ce.fromJSON))}static fromTransaction(e,t){let n=Ln;for(let r of e.startState.facet(oM)){let s=r(e);s.length&&(n=n.concat(s))}return!n.length&&e.changes.empty?null:new i(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,Ln)}static selection(e){return new i(void 0,Ln,void 0,void 0,e)}};function Kd(i,e,t,n){let r=e+1>t+20?e-t-1:0,s=i.slice(r,e);return s.push(n),s}function dM(i,e){let t=[],n=!1;return i.iterChangedRanges((r,s)=>t.push(r,s)),e.iterChangedRanges((r,s,o,a)=>{for(let l=0;l=c&&o<=u&&(n=!0)}}),n}function hM(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function lx(i,e){return i.length?e.length?i.concat(e):i:e}var Ln=[],pM=200;function cx(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-pM));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),Kd(i,i.length-1,1e9,t.setSelAfter(n)))}else return[gr.selection([e])]}function mM(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function d1(i,e){if(!i.length)return i;let t=i.length,n=Ln;for(;t;){let r=gM(i[t-1],e,n);if(r.changes&&!r.changes.empty||r.effects.length){let s=i.slice(0,t);return s[t-1]=r,s}else e=r.mapped,t--,n=r.selectionsAfter}return n.length?[gr.selection(n)]:Ln}function gM(i,e,t){let n=lx(i.selectionsAfter.length?i.selectionsAfter.map(a=>a.map(e)):Ln,t);if(!i.changes)return gr.selection(n);let r=i.changes.map(e),s=e.mapDesc(i.changes,!0),o=i.mapped?i.mapped.composeDesc(s):s;return new gr(r,ze.mapEffects(i.effects,e),o,i.startSelection.map(s),n)}var OM=/^(input\.type|delete)($|\.)/,Vo=class i{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new i(this.done,this.undone):this}addChanges(e,t,n,r,s){let o=this.done,a=o[o.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!n||OM.test(n))&&(!a.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?i.moveByChar(t,e):eh(t,e))}function qi(i){return i.textDirectionAt(i.state.selection.main.head)==Ct.LTR}var dx=i=>fx(i,!qi(i)),hx=i=>fx(i,qi(i));function px(i,e){return Or(i,t=>t.empty?i.moveByGroup(t,e):eh(t,e))}var vM=i=>px(i,!qi(i)),yM=i=>px(i,qi(i));var SK=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function bM(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function th(i,e,t){let n=vi(i).resolveInner(e.head),r=t?qe.closedBy:qe.openedBy;for(let l=e.head;;){let c=t?n.childAfter(l):n.childBefore(l);if(!c)break;bM(i,c,r)?n=c:l=t?c.to:c.from}let s=n.type.prop(r),o,a;return s&&(o=t?mr(i,n.from,1):mr(i,n.to,-1))&&o.matched?a=t?o.end.to:o.end.from:a=t?n.to:n.from,ce.cursor(a,t?-1:1)}var _M=i=>Or(i,e=>th(i.state,e,!qi(i))),wM=i=>Or(i,e=>th(i.state,e,qi(i)));function mx(i,e){return Or(i,t=>{if(!t.empty)return eh(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}var gx=i=>mx(i,!1),Ox=i=>mx(i,!0);function vx(i){let e=i.scrollDOM.clientHeighto.empty?i.moveVertically(o,e,t.height):eh(o,e));if(r.eq(n.selection))return!1;let s;if(t.selfScroll){let o=i.coordsAtPos(n.selection.main.head),a=i.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;o&&o.top>l&&o.bottomyx(i,!1),p1=i=>yx(i,!0);function Ks(i,e,t){let n=i.lineBlockAt(e.head),r=i.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?n.to:n.from)&&(r=i.moveToLineBoundary(e,t,!1)),!t&&r.head==n.from&&n.length){let s=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;s&&e.head!=n.from+s&&(r=ce.cursor(n.from+s))}return r}var kM=i=>Or(i,e=>Ks(i,e,!0)),SM=i=>Or(i,e=>Ks(i,e,!1)),xM=i=>Or(i,e=>Ks(i,e,!qi(i))),PM=i=>Or(i,e=>Ks(i,e,qi(i))),CM=i=>Or(i,e=>ce.cursor(i.lineBlockAt(e.head).from,1)),EM=i=>Or(i,e=>ce.cursor(i.lineBlockAt(e.head).to,-1));function TM(i,e,t){let n=!1,r=Ka(i.selection,s=>{let o=mr(i,s.head,-1)||mr(i,s.head,1)||s.head>0&&mr(i,s.head-1,1)||s.headTM(i,e,!1);function $n(i,e){let t=Ka(i.state.selection,n=>{let r=e(n);return ce.range(n.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(Yr(i.state,t)),!0)}function bx(i,e){return $n(i,t=>i.moveByChar(t,e))}var _x=i=>bx(i,!qi(i)),wx=i=>bx(i,qi(i));function kx(i,e){return $n(i,t=>i.moveByGroup(t,e))}var DM=i=>kx(i,!qi(i)),QM=i=>kx(i,qi(i));var RM=i=>$n(i,e=>th(i.state,e,!qi(i))),MM=i=>$n(i,e=>th(i.state,e,qi(i)));function Sx(i,e){return $n(i,t=>i.moveVertically(t,e))}var xx=i=>Sx(i,!1),Px=i=>Sx(i,!0);function Cx(i,e){return $n(i,t=>i.moveVertically(t,e,vx(i).height))}var tx=i=>Cx(i,!1),ix=i=>Cx(i,!0),IM=i=>$n(i,e=>Ks(i,e,!0)),NM=i=>$n(i,e=>Ks(i,e,!1)),jM=i=>$n(i,e=>Ks(i,e,!qi(i))),ZM=i=>$n(i,e=>Ks(i,e,qi(i))),zM=i=>$n(i,e=>ce.cursor(i.lineBlockAt(e.head).from)),qM=i=>$n(i,e=>ce.cursor(i.lineBlockAt(e.head).to)),nx=({state:i,dispatch:e})=>(e(Yr(i,{anchor:0})),!0),rx=({state:i,dispatch:e})=>(e(Yr(i,{anchor:i.doc.length})),!0),sx=({state:i,dispatch:e})=>(e(Yr(i,{anchor:i.selection.main.anchor,head:0})),!0),ox=({state:i,dispatch:e})=>(e(Yr(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),LM=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),$M=({state:i,dispatch:e})=>{let t=ih(i).map(({from:n,to:r})=>ce.range(n,Math.min(r+1,i.doc.length)));return e(i.update({selection:ce.create(t),userEvent:"select"})),!0},FM=({state:i,dispatch:e})=>{let t=Ka(i.selection,n=>{var r;let s=vi(i).resolveStack(n.from,1);for(let o=s;o;o=o.next){let{node:a}=o;if((a.from=n.to||a.to>n.to&&a.from<=n.from)&&(!((r=a.parent)===null||r===void 0)&&r.parent))return ce.range(a.to,a.from)}return n});return e(Yr(i,t)),!0},BM=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=ce.create([t.main]):t.main.empty||(n=ce.create([ce.cursor(t.main.head)])),n?(e(Yr(i,n)),!0):!1};function Wc(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,r=n.changeByRange(s=>{let{from:o,to:a}=s;if(o==a){let l=e(s);lo&&(t="delete.forward",l=Gd(i,l,!0)),o=Math.min(o,l),a=Math.max(a,l)}else o=Gd(i,o,!1),a=Gd(i,a,!0);return o==a?{range:s}:{changes:{from:o,to:a},range:ce.cursor(o,or(i)))n.between(e,e,(r,s)=>{re&&(e=t?s:r)});return e}var Ex=(i,e,t)=>Wc(i,n=>{let r=n.from,{state:s}=i,o=s.doc.lineAt(r),a,l;if(t&&!e&&r>o.from&&rEx(i,!1,!0);var Tx=i=>Ex(i,!0,!1),Ax=(i,e)=>Wc(i,t=>{let n=t.head,{state:r}=i,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let a=null;;){if(n==(e?s.to:s.from)){n==t.head&&s.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let l=ui(s.text,n-s.from,e)+s.from,c=s.text.slice(Math.min(n,l)-s.from,Math.max(n,l)-s.from),u=o(c);if(a!=null&&u!=a)break;(c!=" "||n!=t.head)&&(a=u),n=l}return n}),Dx=i=>Ax(i,!1),VM=i=>Ax(i,!0),WM=i=>Wc(i,e=>{let t=i.lineBlockAt(e.head).to;return e.headWc(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),YM=i=>Wc(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:ut.of(["",""])},range:ce.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},HM=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let r=n.from,s=i.doc.lineAt(r),o=r==s.from?r-1:ui(s.text,r-s.from,!1)+s.from,a=r==s.to?r+1:ui(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:a,insert:i.doc.slice(r,a).append(i.doc.slice(o,r))},range:ce.cursor(a)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ih(i){let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.from),s=i.doc.lineAt(n.to);if(!n.empty&&n.to==s.from&&(s=i.doc.lineAt(n.to-1)),t>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(n)}else e.push({from:r.from,to:s.to,ranges:[n]});t=s.number+1}return e}function Qx(i,e,t){if(i.readOnly)return!1;let n=[],r=[];for(let s of ih(i)){if(t?s.to==i.doc.length:s.from==0)continue;let o=i.doc.lineAt(t?s.to+1:s.from-1),a=o.length+1;if(t){n.push({from:s.to,to:o.to},{from:s.from,insert:o.text+i.lineBreak});for(let l of s.ranges)r.push(ce.range(Math.min(i.doc.length,l.anchor+a),Math.min(i.doc.length,l.head+a)))}else{n.push({from:o.from,to:s.from},{from:s.to,insert:i.lineBreak+o.text});for(let l of s.ranges)r.push(ce.range(l.anchor-a,l.head-a))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:ce.create(r,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}var GM=({state:i,dispatch:e})=>Qx(i,e,!1),KM=({state:i,dispatch:e})=>Qx(i,e,!0);function Rx(i,e,t){if(i.readOnly)return!1;let n=[];for(let r of ih(i))t?n.push({from:r.from,insert:i.doc.slice(r.from,r.to)+i.lineBreak}):n.push({from:r.to,insert:i.lineBreak+i.doc.slice(r.from,r.to)});return e(i.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}var JM=({state:i,dispatch:e})=>Rx(i,e,!1),eI=({state:i,dispatch:e})=>Rx(i,e,!0),tI=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(ih(e).map(({from:r,to:s})=>(r>0?r--:s{let s;if(i.lineWrapping){let o=i.lineBlockAt(r.head),a=i.coordsAtPos(r.head,r.assoc||1);a&&(s=o.bottom+i.documentTop-a.bottom+i.defaultLineHeight/2)}return i.moveVertically(r,!0,s)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function iI(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=vi(i).resolveInner(e),n=t.childBefore(e),r=t.childAfter(e),s;return n&&r&&n.to<=e&&r.from>=e&&(s=n.type.prop(qe.closedBy))&&s.indexOf(r.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(r.from).from&&!/\S/.test(i.sliceDoc(n.to,r.from))?{from:n.to,to:r.from}:null}var nI=Mx(!1),rI=Mx(!0);function Mx(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{let{from:s,to:o}=r,a=e.doc.lineAt(s),l=!i&&s==o&&iI(e,s);i&&(s=o=(o<=a.to?a:e.doc.lineAt(o)).to);let c=new Fo(e,{simulateBreak:s,simulateDoubleBreak:!!l}),u=Yd(c,s);for(u==null&&(u=Ls(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));oa.from&&s{let r=[];for(let o=n.from;o<=n.to;){let a=i.doc.lineAt(o);a.number>t&&(n.empty||n.to>a.from)&&(e(a,r,n),t=a.number),o=a.to+1}let s=i.changes(r);return{changes:r,range:ce.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}})}var sI=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new Fo(i,{overrideIndentation:s=>{let o=t[s];return o??-1}}),r=v1(i,(s,o,a)=>{let l=Yd(n,s.from);if(l==null)return;/\S/.test(s.text)||(l=0);let c=/^\s*/.exec(s.text)[0],u=Ha(i,l);(c!=u||a.fromi.readOnly?!1:(e(i.update(v1(i,(t,n)=>{n.push({from:t.from,insert:i.facet($c)})}),{userEvent:"input.indent"})),!0),Nx=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(v1(i,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let s=Ls(r,i.tabSize),o=0,a=Ha(i,Math.max(0,s-Fc(i)));for(;o({mac:i.key,run:i.run,shift:i.shift}))),jx=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:_M,shift:RM},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:wM,shift:MM},{key:"Alt-ArrowUp",run:GM},{key:"Shift-Alt-ArrowUp",run:JM},{key:"Alt-ArrowDown",run:KM},{key:"Shift-Alt-ArrowDown",run:eI},{key:"Escape",run:BM},{key:"Mod-Enter",run:rI},{key:"Alt-l",mac:"Ctrl-l",run:$M},{key:"Mod-i",run:FM,preventDefault:!0},{key:"Mod-[",run:Nx},{key:"Mod-]",run:Ix},{key:"Mod-Alt-\\",run:sI},{key:"Shift-Mod-k",run:tI},{key:"Shift-Mod-\\",run:AM},{key:"Mod-/",run:KR},{key:"Alt-A",run:eM}].concat(aI),Zx={key:"Tab",run:Ix,shift:Nx};var _1=class i{constructor(e,t,n,r,s,o,a,l,c,u=0,f){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let r=e.parser.context;return new i(e,[],t,n,n,0,[],0,r?new nh(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,r=e&65535,{parser:s}=this.p,o=s.dynamicPrecedence(r);if(o&&(this.score+=o),n==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(l==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(r,l)}storeNode(e,t,n,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(t==n)return;if(o.buffer[a-2]>=t){o.buffer[a-2]=n;return}}}if(!s||this.pos==n)this.buffer.push(e,t,n,r);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>n;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=n,this.buffer[o+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let s=e,{parser:o}=this.p;(r>this.pos||t<=o.maxNode)&&(this.pos=r,o.stateFlag(s,1)||(this.reducePos=r)),this.pushState(s,n),this.shiftContext(t,n),t<=o.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new i(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new w1(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let s=0,o;sl&1&&a==o)||r.push(t[s],o)}t=r}let n=[];for(let r=0;r>19,r=t&65535,s=this.stack.length-n*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,s)=>{if(!t.includes(r))return t.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=n(o,s+1);if(a!=null)return a}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},nh=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},w1=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},k1=class i{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new i(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}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]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new i(this.stack,this.pos,this.index)}};function Xc(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,r=0;n=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}t?t[r++]=s:t=new e(s)}return t}var Ja=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},zx=new Ja,S1=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=zx,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,s=this.pos+e;for(;sn.to:s>=n.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-n.to,n=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t=this.chunk2Pos&&na.to&&(this.chunk2=this.chunk2.slice(0,a.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=zx,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},Js=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;Bx(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};Js.prototype.contextual=Js.prototype.fallback=Js.prototype.extend=!1;var el=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?Xc(e):e}token(e,t){let n=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(Bx(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};el.prototype.contextual=Js.prototype.fallback=Js.prototype.extend=!1;var Wo=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function Bx(i,e,t,n,r,s){let o=0,a=1<0){let p=i[h];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||cI(p,e.token.value,r,s))){e.acceptToken(p);break}}let u=e.next,f=0,d=i[o+2];if(e.next<0&&d>f&&i[c+d*3-3]==65535){o=i[c+d*3-1];continue e}for(;f>1,p=c+h+(h<<1),m=i[p],g=i[p+1]||65536;if(u=g)f=h+1;else{o=i[p+2],e.advance();continue e}}break}}function qx(i,e,t){for(let n=e,r;(r=i[n])!=65535;n++)if(r==t)return n-e;return-1}function cI(i,e,t,n){let r=qx(t,n,e);return r<0||qx(t,n,i)e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(i.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:i.length}}var x1=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Lx(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Lx(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof ri){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+s.length}}},P1=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new Ja)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;cf.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let d=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!u.extend&&(n=f,t>d))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!n&&e.pos==this.stream.end&&(n=new Ja,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Ja,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:s}=n.p;for(let o=0;o=0&&n.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let s=0;se.bufferLength*4?new x1(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)n.push(a);else{if(this.advanceStack(a,n,e))continue;{r||(r=[],s=[]),r.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!n.length){let o=r&&uI(r);if(o)return En&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw En&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,n);if(o)return En&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((a,l)=>l.score-a.score);n.length>o;)n.pop();n.some(a=>a.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)n.splice(l--,1);else{n.splice(o--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let f=this.fragments.nodeAt(r);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(d>-1&&f.length&&(!c||(f.prop(qe.contextHash)||0)==u))return e.useNode(f,d),En&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof ri)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof ri&&f.positions[0]==0)f=h;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),En&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;cr?t.push(p):n.push(p)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return $x(e,t),!0}}runRecovery(e,t,n){let r=null,s=!1;for(let o=0;o ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),En&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,n))))continue;let f=a.split(),d=u;for(let h=0;f.forceReduce()&&h<10&&(En&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,n));h++)En&&(d=this.stackID(f)+" -> ");for(let h of a.recoverByInsert(l))En&&console.log(u+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,n);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),En&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),$x(a,n)):(!r||r.scorei,rh=class{constructor(e){this.start=e.start,this.shift=e.shift||b1,this.reduce=e.reduce||b1,this.reuse=e.reuse||b1,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},sh=class i extends Xa{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;ae.topRules[a][1]),r=[];for(let a=0;a=0)s(u,l,a[c++]);else{let f=a[c+-u];for(let d=-u;d>0;d--)s(a[c++],l,f);c++}}}this.nodeSet=new Mc(t.map((a,l)=>zi.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:n.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let o=Xc(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;atypeof a=="number"?new Js(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new C1(this,e,t,n);for(let s of this.wrappers)r=s(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let s=r[t+1];;){let o=r[s++],a=o&1,l=r[s++];if(a&&n)return l;for(let c=s+(o>>1);s0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Os(this.data,s+2);else break;r=t(Os(this.data,s+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=Os(this.data,n+2);else break;if(!(this.data[n+2]&1)){let r=this.data[n+1];t.some((s,o)=>o&1&&s==r)||t.push(this.data[n],r)}}return t}configure(e){let t=Object.assign(Object.create(i.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let r=e.tokenizers.find(s=>s.from==n);return r?r.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,r)=>{let s=e.specializers.find(a=>a.from==n.external);if(!s)return n;let o=Object.assign(Object.assign({},n),{external:s.to});return t.specializers[r]=Fx(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let s of e.split(" ")){let o=t.indexOf(s);o>=0&&(n[o]=!0)}let r=null;for(let s=0;sn)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scorei.external(t,n)<<1|e}return i.get}var fI=310,Vx=1,dI=2,hI=3,pI=311,mI=313,gI=314,OI=4,vI=5,yI=0,A1=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],Wx=125,bI=59,D1=47,_I=42,wI=43,kI=45,SI=60,xI=44,PI=new rh({start:!1,shift(i,e){return e==OI||e==vI||e==mI?i:e==gI},strict:!1}),CI=new Wo((i,e)=>{let{next:t}=i;(t==Wx||t==-1||e.context)&&i.acceptToken(pI)},{contextual:!0,fallback:!0}),EI=new Wo((i,e)=>{let{next:t}=i,n;A1.indexOf(t)>-1||t==D1&&((n=i.peek(1))==D1||n==_I)||t!=Wx&&t!=bI&&t!=-1&&!e.context&&i.acceptToken(fI)},{contextual:!0}),TI=new Wo((i,e)=>{let{next:t}=i;if((t==wI||t==kI)&&(i.advance(),t==i.next)){i.advance();let n=!e.context&&e.canShift(Vx);i.acceptToken(n?Vx:dI)}},{contextual:!0});function T1(i,e){return i>=65&&i<=90||i>=97&&i<=122||i==95||i>=192||!e&&i>=48&&i<=57}var AI=new Wo((i,e)=>{if(i.next!=SI||!e.dialectEnabled(yI)||(i.advance(),i.next==D1))return;let t=0;for(;A1.indexOf(i.next)>-1;)i.advance(),t++;if(T1(i.next,!0)){for(i.advance(),t++;T1(i.next,!1);)i.advance(),t++;for(;A1.indexOf(i.next)>-1;)i.advance(),t++;if(i.next==xI)return;for(let n=0;;n++){if(n==7){if(!T1(i.next,!0))return;break}if(i.next!="extends".charCodeAt(n))break;i.advance(),t++}}i.acceptToken(hI,-t)}),DI=Bd({"get set async static":L.modifier,"for while do if else switch try catch finally return throw break continue default case":L.controlKeyword,"in of await yield void typeof delete instanceof":L.operatorKeyword,"let var const using function class extends":L.definitionKeyword,"import export from":L.moduleKeyword,"with debugger as new":L.keyword,TemplateString:L.special(L.string),super:L.atom,BooleanLiteral:L.bool,this:L.self,null:L.null,Star:L.modifier,VariableName:L.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":L.function(L.variableName),VariableDefinition:L.definition(L.variableName),Label:L.labelName,PropertyName:L.propertyName,PrivatePropertyName:L.special(L.propertyName),"CallExpression/MemberExpression/PropertyName":L.function(L.propertyName),"FunctionDeclaration/VariableDefinition":L.function(L.definition(L.variableName)),"ClassDeclaration/VariableDefinition":L.definition(L.className),PropertyDefinition:L.definition(L.propertyName),PrivatePropertyDefinition:L.definition(L.special(L.propertyName)),UpdateOp:L.updateOperator,"LineComment Hashbang":L.lineComment,BlockComment:L.blockComment,Number:L.number,String:L.string,Escape:L.escape,ArithOp:L.arithmeticOperator,LogicOp:L.logicOperator,BitOp:L.bitwiseOperator,CompareOp:L.compareOperator,RegExp:L.regexp,Equals:L.definitionOperator,Arrow:L.function(L.punctuation),": Spread":L.punctuation,"( )":L.paren,"[ ]":L.squareBracket,"{ }":L.brace,"InterpolationStart InterpolationEnd":L.special(L.brace),".":L.derefOperator,", ;":L.separator,"@":L.meta,TypeName:L.typeName,TypeDefinition:L.definition(L.typeName),"type enum interface implements namespace module declare":L.definitionKeyword,"abstract global Privacy readonly override":L.modifier,"is keyof unique infer":L.operatorKeyword,JSXAttributeValue:L.attributeValue,JSXText:L.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":L.angleBracket,"JSXIdentifier JSXNameSpacedName":L.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":L.attributeName,"JSXBuiltin/JSXIdentifier":L.standard(L.tagName)}),QI={__proto__:null,export:18,as:23,from:31,default:34,async:39,function:40,extends:52,this:56,true:64,false:64,null:76,void:80,typeof:84,super:102,new:136,delete:154,yield:163,await:167,class:172,public:229,private:229,protected:229,readonly:231,instanceof:250,satisfies:253,in:254,const:256,import:288,keyof:341,unique:345,infer:351,is:387,abstract:407,implements:409,type:411,let:414,var:416,using:419,interface:425,enum:429,namespace:435,module:437,declare:441,global:445,for:464,of:473,while:476,with:480,do:484,if:488,else:490,switch:494,case:500,try:506,catch:510,finally:514,return:518,throw:522,break:526,continue:530,debugger:534},RI={__proto__:null,async:123,get:125,set:127,declare:189,public:191,private:191,protected:191,static:193,abstract:195,override:197,readonly:203,accessor:205,new:391},MI={__proto__:null,"<":145},Xx=sh.deserialize({version:14,states:"$=dO%TQ^OOO%[Q^OOO'_Q`OOP(lOWOOO*zQ?NdO'#ChO+RO!bO'#CiO+aO#tO'#CiO+oO!0LbO'#D^O.QQ^O'#DdO.bQ^O'#DoO%[Q^O'#DzO0fQ^O'#ESOOQ?Mr'#E['#E[O1PQWO'#EXOOQO'#Em'#EmOOQO'#If'#IfO1XQWO'#GnO1dQWO'#ElO1iQWO'#ElO3kQ?NdO'#JjO6[Q?NdO'#JkO6xQWO'#F[O6}Q&jO'#FrOOQ?Mr'#Fd'#FdO7YO,YO'#FdO7hQ7[O'#FyO9UQWO'#FxOOQ?Mr'#Jk'#JkOOQ?Mp'#Jj'#JjO9ZQWO'#GrOOQU'#KW'#KWO9fQWO'#ISO9kQ?MxO'#ITOOQU'#JX'#JXOOQU'#IX'#IXQ`Q^OOO`Q^OOO9sQMnO'#DsO9zQ^O'#EOO:RQ^O'#EQO9aQWO'#GnO:YQ7[O'#CnO:hQWO'#EkO:sQWO'#EvO:xQ7[O'#FcO;gQWO'#GnOOQO'#KX'#KXO;lQWO'#KXO;zQWO'#GvO;zQWO'#GwO;zQWO'#GyO9aQWO'#G|OYQWO'#CdO>jQWO'#H]O>rQWO'#HcO>rQWO'#HeO`Q^O'#HgO>rQWO'#HiO>rQWO'#HlO>wQWO'#HrO>|Q?MyO'#HxO%[Q^O'#HzO?XQ?MyO'#H|O?dQ?MyO'#IOO9kQ?MxO'#IQO?oQ?NdO'#ChO@qQ`O'#DiQOQWOOO%[Q^O'#EQOAXQWO'#ETO:YQ7[O'#EkOAdQWO'#EkOAoQpO'#FcOOQU'#Cf'#CfOOQ?Mp'#Dn'#DnOOQ?Mp'#Jn'#JnO%[Q^O'#JnOOQO'#Jr'#JrOOQO'#Ic'#IcOBoQ`O'#EdOOQ?Mp'#Ec'#EcOOQ?Mp'#Ju'#JuOCkQ?NQO'#EdOCuQ`O'#EWOOQO'#Jq'#JqODZQ`O'#JrOEhQ`O'#EWOCuQ`O'#EdPEuO#@ItO'#CaPOOO)CDv)CDvOOOO'#IY'#IYOFQO!bO,59TOOQ?Mr,59T,59TOOOO'#IZ'#IZOF`O#tO,59TO%[Q^O'#D`OOOO'#I]'#I]OFnO!0LbO,59xOOQ?Mr,59x,59xOF|Q^O'#I^OGaQWO'#JlOIcQrO'#JlO+}Q^O'#JlOIjQWO,5:OOJQQWO'#EmOJ_QWO'#J{OJjQWO'#JzOJjQWO'#JzOJrQWO,5;ZOJwQWO'#JyOOQ?Mv,5:Z,5:ZOKOQ^O,5:ZOMPQ?NdO,5:fOMpQWO,5:nONZQ?MxO'#JxONbQWO'#JwO9ZQWO'#JwONvQWO'#JwO! OQWO,5;YO! TQWO'#JwO!#]QrO'#JkOOQ?Mr'#Ch'#ChO%[Q^O'#ESO!#{QpO,5:sOOQO'#Js'#JsOOQO-EnOOQU'#Ja'#JaOOQU,5>o,5>oOOQU-EfQ?NdO,5:jO%[Q^O,5:jO!APQ?NdO,5:lOOQO,5@s,5@sO!ApQ7[O,5=YO!BOQ?MxO'#JbO9UQWO'#JbO!BaQ?MxO,59YO!BlQ`O,59YO!BtQ7[O,59YO:YQ7[O,59YO!CPQWO,5;WO!CXQWO'#H[O!CmQWO'#K]O%[Q^O,5;{O!9jQ`O,5;}O!CuQWO,5=uO!CzQWO,5=uO!DPQWO,5=uO9kQ?MxO,5=uO;zQWO,5=eOOQO'#Cu'#CuO!D_Q`O,5=bO!DgQ7[O,5=cO!DrQWO,5=eO!DwQpO,5=hO!EPQWO'#KXO>wQWO'#HRO9aQWO'#HTO!EUQWO'#HTO:YQ7[O'#HVO!EZQWO'#HVOOQU,5=k,5=kO!E`QWO'#HWO!EqQWO'#CnO!EvQWO,59OO!FQQWO,59OO!HVQ^O,59OOOQU,59O,59OO!HgQ?MxO,59OO%[Q^O,59OO!JrQ^O'#H_OOQU'#H`'#H`OOQU'#Ha'#HaO`Q^O,5=wO!KYQWO,5=wO`Q^O,5=}O`Q^O,5>PO!K_QWO,5>RO`Q^O,5>TO!KdQWO,5>WO!KiQ^O,5>^OOQU,5>d,5>dO%[Q^O,5>dO9kQ?MxO,5>fOOQU,5>h,5>hO# sQWO,5>hOOQU,5>j,5>jO# sQWO,5>jOOQU,5>l,5>lO#!aQ`O'#D[O%[Q^O'#JnO#!kQ`O'#JnO##YQ`O'#DjO##kQ`O'#DjO#%|Q^O'#DjO#&TQWO'#JmO#&]QWO,5:TO#&bQWO'#EqO#&pQWO'#J|O#&xQWO,5;[O#&}Q`O'#DjO#'[Q`O'#EVOOQ?Mr,5:o,5:oO%[Q^O,5:oO#'cQWO,5:oO>wQWO,5;VO!BlQ`O,5;VO!BtQ7[O,5;VO:YQ7[O,5;VO#'kQWO,5@YO#'pQ(CWO,5:sOOQO-ExO+}Q^O,5>xOOQO,5?O,5?OO#*xQ^O'#I^OOQO-E<[-E<[O#+VQWO,5@WO#+_QrO,5@WO#+fQWO,5@fOOQ?Mr1G/j1G/jO%[Q^O,5@gO#+nQWO'#IdOOQO-ErQWO1G3mO$5xQ^O1G3oO$9|Q^O'#HnOOQU1G3r1G3rO$:ZQWO'#HtO>wQWO'#HvOOQU1G3x1G3xO$:cQ^O1G3xO9kQ?MxO1G4OOOQU1G4Q1G4QOOQ?Mp'#GZ'#GZO9kQ?MxO1G4SO9kQ?MxO1G4UO$>jQWO,5@YO!*mQ^O,5;]O9ZQWO,5;]O>wQWO,5:UO!*mQ^O,5:UO!BlQ`O,5:UO$>oQ07bO,5:UOOQO,5;],5;]O$>yQ`O'#I_O$?aQWO,5@XOOQ?Mr1G/o1G/oO$?iQ`O'#IeO$?sQWO,5@hOOQ?Mp1G0v1G0vO##kQ`O,5:UOOQO'#Ib'#IbO$?{Q`O,5:qOOQ?Mv,5:q,5:qO#'fQWO1G0ZOOQ?Mr1G0Z1G0ZO%[Q^O1G0ZOOQ?Mr1G0q1G0qO>wQWO1G0qO!BlQ`O1G0qO!BtQ7[O1G0qOOQ?Mp1G5t1G5tO!BaQ?MxO1G0^OOQO1G0j1G0jO%[Q^O1G0jO$@SQ?MxO1G0jO$@_Q?MxO1G0jO!BlQ`O1G0^OCuQ`O1G0^O$@mQ?MxO1G0jOOQO1G0^1G0^O$ARQ?NdO1G0jPOOO-ExO$AoQWO1G5rO$AwQWO1G6QO$BPQrO1G6RO9ZQWO,5?OO$BZQ?NdO1G6OO%[Q^O1G6OO$BkQ?MxO1G6OO$B|QWO1G5}O$B|QWO1G5}O9ZQWO1G5}O$CUQWO,5?RO9ZQWO,5?ROOQO,5?R,5?RO$CjQWO,5?RO$*oQWO,5?ROOQO-EYOOQU,5>Y,5>YO%[Q^O'#HoO%;tQWO'#HqOOQU,5>`,5>`O9ZQWO,5>`OOQU,5>b,5>bOOQU7+)d7+)dOOQU7+)j7+)jOOQU7+)n7+)nOOQU7+)p7+)pO%;yQ`O1G5tO%<_Q07bO1G0wO%wQWO1G/pO!*mQ^O'#DjOOQO,5>y,5>yOOQO-E<]-E<]OOQO,5?P,5?POOQO-EwQWO7+&]O!BlQ`O7+&]OOQO7+%x7+%xO$ARQ?NdO7+&UOOQO7+&U7+&UO%[Q^O7+&UO%=OQ?MxO7+&UO!BaQ?MxO7+%xO!BlQ`O7+%xO%=ZQ?MxO7+&UO%=iQ?NdO7++jO%[Q^O7++jO%=yQWO7++iO%=yQWO7++iOOQO1G4m1G4mO9ZQWO1G4mO%>RQWO1G4mOOQO7+%}7+%}O#'fQWO<aQWO<iQWO<tQ?NdO,5?ZO%APQ?NdO,5?]O%C[Q?NdO1G2[O%EmQ?NdO1G2nO%GxQ?NdO1G2pO%JTQ7[O,5>zOOQO-E<^-E<^O%J_QrO,5>{O%[Q^O,5>{OOQO-E<_-E<_O%JiQWO1G5vOOQ?Mr<ZOOQU,5>],5>]O&wQWO7+%[OOQ?Mr<wQWO<wQWO7+)fO'*yQWO<PO#w$WO(q#}O(r$OO~P#>POP$^OZ$eOn$RO|#zO}#{O!P#|O!i$TO!j#xO!l#yO!p$^O#k$PO#l$QO#m$QO#n$QO#o$SO#p$TO#q$TO#r$dO#s$TO#u$UO#w$WO#y$YO(YVO(q#}O(r$OO~O`#ji!Y#ji#z#ji's#ji(j#ji'q#ji!V#ji!k#jir#ji![#ji%d#ji!d#ji~P#@wOP[XZ[Xn[X|[X}[X!P[X!i[X!j[X!l[X!p[X#][X#heX#k[X#l[X#m[X#n[X#o[X#p[X#q[X#r[X#s[X#u[X#w[X#y[X#z[X$P[X(Y[X(j[X(q[X(r[X!Y[X!Z[X~O#}[X~P#CbOP$^OZ;SOn:vO|#zO}#{O!P#|O!i:xO!j#xO!l#yO!p$^O#k:tO#l:uO#m:uO#n:uO#o:wO#p:xO#q:xO#r;RO#s:xO#u:yO#w:{O#y:}O#z;OO(YVO(j$[O(q#}O(r$OO~O#}.xO~P#EoO#];TO$P;TO#}(_X!Z(_X~P! cO`'^a!Y'^a's'^a'q'^a!k'^a!V'^ar'^a!['^a%d'^a!d'^a~P!:ROP#jiZ#ji`#jin#ji}#ji!Y#ji!i#ji!j#ji!l#ji!p#ji#k#ji#l#ji#m#ji#n#ji#o#ji#p#ji#q#ji#r#ji#s#ji#u#ji#w#ji#y#ji#z#ji's#ji(Y#ji(j#ji'q#ji!V#ji!k#jir#ji![#ji%d#ji!d#ji~P#/OO`$Oi!Y$Oi's$Oi'q$Oi!V$Oi!k$Oir$Oi![$Oi%d$Oi!d$Oi~P!:RO$Z.}O$].}O~O$Z/OO$]/OO~O!d)eO#]/PO![$aX$X$aX$Z$aX$]$aX$d$aX~O!X/QO~O![)hO$X/SO$Z)gO$])gO$d/TO~O!Y;PO!Z(^X~P#EoO!Z/UO~O!d)eO$d(sX~O$d/WO~Ot)wO(Z)xO([/ZO~O!V/_O~P!&kO(q%OOj%[a|%[a!P%[a(r%[a!Y%[a#]%[a~Of%[a#}%[a~P#NPO(r%QOj%^a|%^a!P%^a(q%^a!Y%^a#]%^a~Of%^a#}%^a~P#NrO!YeX!deX!keX!k$vX(jeX~P!/{O!X/hO!Y(YO'|/gO!V(nP!V(xP~P!1sOn*pO!_*nO!`*gO!a*gO!l*_O#X*oO%Z*jO'}!lO~Oo'XO!P/iO!X+VO!Z*mO(OTO(RUO(];cO!Z(pP~P$!]O!k/jO~P#/OO!Y/kO!d#vO(j'mO!k(wX~O!k/pO~O!P%fO!X*[O![%gO'|%eO!k(wP~O#h/rO~O!V$vX!Y$vX!d$}X~P!/{O!Y/sO!V(xX~P#/OO!d/uO~O!V/wO~Og%WOn/{O!d#vO!l%cO(j'mO~O'|/}O~O!d+eO~O`%lO!Y0RO's%lO~O!Z0TO~P!5gO!`0UO!a0UO'}!lO(]!mO~O!P0WO(]!mO~O#X0XO~Of%[a!Y%[a#]%[a#}%[a~P!1UOf%^a!Y%^a#]%^a#}%^a~P!1UO'|&WOf'gX!Y'gX~O!Y*vOf(Va~Of0bO~O|0cO}0cO!P0dOjya(qya(rya!Yya#]ya~Ofya#}ya~P$(OO|)|O!P)}Oj$oa(q$oa(r$oa!Y$oa#]$oa~Of$oa#}$oa~P$(tO|)|O!P)}Oj$qa(q$qa(r$qa!Y$qa#]$qa~Of$qa#}$qa~P$)gO#h0fO~Of%Pa!Y%Pa#]%Pa#}%Pa~P!1UO!d#vO~O#h0iO~O!Y+XO`(|a's(|a~O|#zO}#{O!P#|O!j#xO!l#yO(YVOP!riZ!rin!ri!Y!ri!i!ri!p!ri#k!ri#l!ri#m!ri#n!ri#o!ri#p!ri#q!ri#r!ri#s!ri#u!ri#w!ri#y!ri#z!ri(j!ri(q!ri(r!ri~O`!ri's!ri'q!ri!V!ri!k!rir!ri![!ri%d!ri!d!ri~P$+UOg%WOn$uOo$tOp$tOv%YOx%ZOz;YO!P$|O![$}O!fX#>_#>e#>s#?Y#@w#AV#A^#Br#CQ#Dl#Dz#EQ#EW#E^#Eh#En#Et#FO#Fb#FhPPPPPPPPPP#FnPPPPPPP#Gc#Jj#Ky#LQ#LYPPPP$#`$&W$,p$,s$,v$-c$-f$-i$-p$-xP$.OP$.l$.p$/h$0v$0{$1cPP$1h$1n$1rP$1u$1y$1}$2s$3[$3s$3w$3z$3}$4T$4W$4[$4`R!|RoqOXst!Z#d%k&o&q&r&t,m,r2P2SY!vQ']-_1d5fQ%rvQ%zyQ&R|Q&g!VS'T!e-VQ'c!iS'i!r!yU*g$}*X*lQ+k%{Q+x&TQ,^&aQ-]'[Q-g'dQ-o'jQ0U*nQ1n,_R;b:o%QdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#y#|$P$Q$R$S$T$U$V$W$X$Y$Z$b$f%k%r&P&h&k&o&q&r&t&x'Q'_'o(P(R(X(`(t(x(|){+S+W,j,m,r-c-k-y.P.q.x/i0d0i0y1g1w1x1z1|2P2S2U2u2{3c5c5m5}6O6R6f8P8U8e8oS#q]:l!r)^$]$n'U)p-O-R/Q2e3x5a6]9`9q:k:n:o:r:s:t:u:v:w:x:y:z:{:|:};O;P;T;b;d;e;g;o;p;y;z < TypeParamList TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . ?. PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression TypeArgList CompareOp < ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies in const CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast ArrowFunction TypeParamList SequenceExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:373,context:PI,nodeProps:[["isolate",-8,4,5,13,33,35,48,50,52,""],["group",-26,8,16,18,65,202,206,210,211,213,216,219,229,231,237,239,241,243,246,252,258,260,262,264,266,268,269,"Statement",-33,12,13,28,31,32,38,48,51,52,54,59,67,69,76,80,82,84,85,107,108,117,118,135,138,140,141,142,143,145,146,165,166,168,"Expression",-23,27,29,33,37,39,41,169,171,173,174,176,177,178,180,181,182,184,185,186,196,198,200,201,"Type",-3,88,100,106,"ClassItem"],["openedBy",22,"<",34,"InterpolationStart",53,"[",57,"{",73,"(",158,"JSXStartCloseTag"],["closedBy",23,">",36,"InterpolationEnd",47,"]",58,"}",74,")",163,"JSXEndTag"]],propSources:[DI],skippedNodes:[0,4,5,272],repeatNodeCount:37,tokenData:"$HR07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$.S!c!}Er!}#O$/^#O#P$0h#P#Q$6P#Q#R$7Z#R#SEr#S#T$8h#T#o$9r#o#p$>S#p#q$>x#q#r$@Y#r#s$Af#s$f%Z$f$g+g$g#BYEr#BY#BZ$Bp#BZ$ISEr$IS$I_$Bp$I_$I|Er$I|$I}$E{$I}$JO$E{$JO$JTEr$JT$JU$Bp$JU$KVEr$KV$KW$Bp$KW&FUEr&FU&FV$Bp&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$Bp?HUOEr(n%d_$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$g&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$g&j(S!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(S!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$g&j(PpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(PpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Pp(S!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$g&j(Pp(S!b'u0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(Q#S$g&j'v0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$g&j(Pp(S!b'v0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$g&j!p),Q(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#u(Ch$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#u(Ch$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(O':f$g&j(S!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$g&j(S!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$g&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$b`$g&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$b``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$b`$g&j(S!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(S!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$b`(S!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$g&j(Pp(S!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXVS$g&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSVSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWVS(S!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]VS$g&j(PpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWVS(PpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYVS(Pp(S!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$g&j!U7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!U7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!U7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$g&j(S!b!U7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(S!b!U7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(S!b!U7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(S!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$g&j(S!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$g&j(Pp(S!bo'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$g&j(Pp(S!bo'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$g&j(Pp(S!bo'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$g&j(Pp(S!bo'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!d$b$g&j#})Lv(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_`l$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^g#)`!i-PP;=`<%l$9r#Jf$>]X![#Hb(Pp(S!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g,#x$?Ta(q+JY$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`Ka!`#O%Z#O#P&c#P#o%Z#o#p*g#p#q$,u#q;'S%Z;'S;=`+a<%lO%Z(Kd$@g_!Z(Cdr`$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$Aq_!q7`$g&j(Pp(S!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$CR|$g&j(Pp(S!b'u0/l$Z#t'|,2j(]$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$Bp#BZ$ISEr$IS$I_$Bp$I_$JTEr$JT$JU$Bp$JU$KVEr$KV$KW$Bp$KW&FUEr&FU&FV$Bp&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$Bp?HUOEr07[$F^k$g&j(Pp(S!b'v0/l$Z#t'|,2j(]$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[EI,TI,AI,2,3,4,5,6,7,8,9,10,11,12,13,14,CI,new el("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOt~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!R~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO([~~",141,333),new el("j~RQYZXz{^~^O'y~~aP!P!Qd~iO'z~~",25,316)],topRules:{Script:[0,6],SingleExpression:[1,270],SingleClassItem:[2,271]},dialects:{jsx:0,ts:14840},dynamicPrecedences:{70:1,80:1,82:1,166:1,194:1},specialized:[{term:320,get:i=>QI[i]||-1},{term:335,get:i=>RI[i]||-1},{term:71,get:i=>MI[i]||-1}],tokenPrec:14864});var ah=class{constructor(e,t,n){this.state=e,this.pos=t,this.explicit=n,this.abortListeners=[]}tokenBefore(e){let t=vi(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),s=r.search(tP(e,!1));return s<0?null:{from:n+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}};function Yx(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function II(i){let e=Object.create(null),t=Object.create(null);for(let{label:r}of i){e[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[t,n]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:II(e);return r=>{let s=r.matchBefore(n);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:t}:null}}var lh=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function eo(i){return i.selection.main.from}function tP(i,e){var t;let{source:n}=i,r=e&&n[0]!="^",s=n[n.length-1]!="$";return!r&&!s?i:new RegExp(`${r?"^":""}(?:${n})${s?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}var iP=pn.define();function jI(i,e,t,n){let{main:r}=i.selection,s=t-r.from,o=n-r.from;return Object.assign(Object.assign({},i.changeByRange(a=>a!=r&&t!=n&&i.sliceDoc(a.from+s,a.from+o)!=i.sliceDoc(t,n)?{range:a}:{changes:{from:a.from+s,to:n==r.from?a.to:a.from+o,insert:e},range:ce.cursor(a.from+s+e.length)})),{scrollIntoView:!0,userEvent:"input.complete"})}var Ux=new WeakMap;function ZI(i){if(!Array.isArray(i))return i;let e=Ux.get(i);return e||Ux.set(i,e=NI(i)),e}var ch=ze.define(),Yc=ze.define(),M1=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&k<=57||k>=97&&k<=122?2:k>=65&&k<=90?1:0:(w=fc(k))!=w.toLowerCase()?1:w!=w.toUpperCase()?2:0;(!_||x==1&&g||P==0&&x!=0)&&(t[f]==k||n[f]==k&&(d=!0)?o[f++]=_:o.length&&(O=!1)),P=x,_+=Yi(k)}return f==l&&o[0]==0&&O?this.result(-100+(d?-200:0),o,e):h==l&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):h==l?this.ret(-900-e.length,[p,m]):f==l?this.result(-100+(d?-200:0)+-700+(O?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],s=0;for(let o of t){let a=o+(this.astral?Yi(gi(n,o)):1);s&&r[s-1]==o?r[s-1]=a:(r[s++]=o,r[s++]=a)}return this.ret(e-n.length,r)}},I1=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:zI,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Hx(e(n),t(n)),optionClass:(e,t)=>n=>Hx(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Hx(i,e){return i?e?i+" "+e:i:e}function zI(i,e,t,n,r,s){let o=i.textDirection==Ct.RTL,a=o,l=!1,c="top",u,f,d=e.left-r.left,h=r.right-e.right,p=n.right-n.left,m=n.bottom-n.top;if(a&&d=m||_>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let g=(e.bottom-e.top)/s.offsetHeight,O=(e.right-e.left)/s.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${f/O}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":a?"left":"right")}}function qI(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;cl&&o.appendChild(document.createTextNode(a.slice(l,u)));let d=o.appendChild(document.createElement("span"));d.appendChild(document.createTextNode(a.slice(u,f))),d.className="cm-completionMatchedText",l=f}return lt.position-n.position).map(t=>t.render)}function Q1(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}var N1=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:s,selected:o}=r.open,a=e.state.facet(Di);this.optionContent=qI(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=Q1(s.length,o,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,f;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(f=/-(\d+)$/.exec(u.id))&&+f[1]{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Di).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Yc.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:s,selected:o,disabled:a}=n.open;(!r.open||r.open.options!=s)&&(this.range=Q1(s.length,o,e.state.facet(Di).maxRenderedOptions),this.showOptions(s,n.id)),this.updateSel(),a!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected=this.range.to)&&(this.range=Q1(t.options.length,t.selected,this.view.state.facet(Di).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:r}=n;if(!r)return;let s=typeof r=="string"?document.createTextNode(r):r(n);if(!s)return;"then"in s?s.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,n)}).catch(o=>Ai(this.view.state,o,"completion info")):this.addInfoPane(s,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;n.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!="LI"||!n.id?r--:r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected");return t&&$I(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.defaultView||window;s={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return r.top>Math.min(s.bottom,t.bottom)-10||r.bottomn.from||n.from==0))if(s=d,typeof c!="string"&&c.header)r.appendChild(c.header(c));else{let h=r.appendChild(document.createElement("completion-section"));h.textContent=d}}let u=r.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let f=this.optionClass(a);f&&(u.className=f);for(let d of this.optionContent){let h=d(a,this.view.state,this.view,l);h&&u.appendChild(h)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.tonew N1(t,i,e)}function $I(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),r=t.height/i.offsetHeight;n.topt.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/r)}function Gx(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function FI(i,e){let t=[],n=null,r=c=>{t.push(c);let{section:u}=c.completion;if(u){n||(n=[]);let f=typeof u=="string"?u:u.name;n.some(d=>d.name==f)||n.push(typeof u=="string"?{name:f}:u)}},s=e.facet(Di);for(let c of i)if(c.hasResult()){let u=c.result.getMatch;if(c.result.filter===!1)for(let f of c.result.options)r(new lh(f,c.source,u?u(f):[],1e9-t.length));else{let f=e.sliceDoc(c.from,c.to),d,h=s.filterStrict?new I1(f):new M1(f);for(let p of c.result.options)if(d=h.match(p.label)){let m=p.displayLabel?u?u(p,d.matched):[]:d.matched;r(new lh(p,c.source,m,d.score+(p.boost||0)))}}}if(n){let c=Object.create(null),u=0,f=(d,h)=>{var p,m;return((p=d.rank)!==null&&p!==void 0?p:1e9)-((m=h.rank)!==null&&m!==void 0?m:1e9)||(d.namef.score-u.score||l(u.completion,f.completion))){let u=c.completion;!a||a.label!=u.label||a.detail!=u.detail||a.type!=null&&u.type!=null&&a.type!=u.type||a.apply!=u.apply||a.boost!=u.boost?o.push(c):Gx(c.completion)>Gx(a)&&(o[o.length-1]=c),a=c.completion}return o}var j1=class i{constructor(e,t,n,r,s,o){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new i(this.options,Kx(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,r,s){let o=FI(e,t);if(!o.length)return r&&e.some(l=>l.state==1)?new i(r.options,r.attrs,r.tooltip,r.timestamp,r.selected,!0):null;let a=t.facet(Di).selectOnOpen?0:-1;if(r&&r.selected!=a&&r.selected!=-1){let l=r.options[r.selected].completion;for(let c=0;cc.hasResult()?Math.min(l,c.from):l,1e8),create:YI,above:s.aboveCursor},r?r.timestamp:Date.now(),a,!1)}map(e){return new i(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}},Z1=class i{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new i(WI,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(Di),s=(n.override||t.languageDataAt("autocomplete",eo(t)).map(ZI)).map(a=>(this.active.find(c=>c.source==a)||new Ur(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));s.length==this.active.length&&s.every((a,l)=>a==this.active[l])&&(s=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!BI(s,this.active)?o=j1.build(s,t,this.id,o,n):o&&o.disabled&&!s.some(a=>a.state==1)&&(o=null),!o&&s.every(a=>a.state!=1)&&s.some(a=>a.hasResult())&&(s=s.map(a=>a.hasResult()?new Ur(a.source,0):a));for(let a of e.effects)a.is(rP)&&(o=o&&o.setSelected(a.value,this.id));return s==this.active&&o==this.open?this:new i(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:VI}};function BI(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t-1&&(t["aria-activedescendant"]=i+"-"+e),t}var WI=[];function z1(i,e){if(i.isUserEvent("input.complete")){let t=i.annotation(iP);if(t&&e.activateOnCompletion(t))return"input"}return i.isUserEvent("input.type")?"input":i.isUserEvent("delete.backward")?"delete":null}var Ur=class i{constructor(e,t,n=-1){this.source=e,this.state=t,this.explicitPos=n}hasResult(){return!1}update(e,t){let n=z1(e,t),r=this;n?r=r.handleUserEvent(e,n,t):e.docChanged?r=r.handleChange(e):e.selection&&r.state!=0&&(r=new i(r.source,0));for(let s of e.effects)if(s.is(ch))r=new i(r.source,1,s.value?eo(e.state):-1);else if(s.is(Yc))r=new i(r.source,0);else if(s.is(nP))for(let o of s.value)o.source==r.source&&(r=o);return r}handleUserEvent(e,t,n){return t=="delete"||!n.activateOnTyping?this.map(e.changes):new i(this.source,1)}handleChange(e){return e.changes.touchesRange(eo(e.startState))?new i(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new i(this.source,this.state,e.mapPos(this.explicitPos))}},uh=class i extends Ur{constructor(e,t,n,r,s){super(e,2,t),this.result=n,this.from=r,this.to=s}hasResult(){return!0}handleUserEvent(e,t,n){var r;let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let o=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),l=eo(e.state);if((this.explicitPos<0?l<=o:la||!s||t=="delete"&&eo(e.startState)==this.from)return new Ur(this.source,t=="input"&&n.activateOnTyping?1:0);let c=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos);return XI(s.validFor,e.state,o,a)?new i(this.source,c,s,o,a):s.update&&(s=s.update(s,o,a,new ah(e.state,l,c>=0)))?new i(this.source,c,s,s.from,(r=s.to)!==null&&r!==void 0?r:eo(e.state)):new Ur(this.source,1,c)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new Ur(this.source,0):this.map(e.changes)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new i(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Ur(this.source,0)}};function XI(i,e,t,n){if(!i)return!1;let r=e.sliceDoc(t,n);return typeof i=="function"?i(r,t,n,e):tP(i,!0).test(r)}var nP=ze.define({map(i,e){return i.map(t=>t.map(e))}}),rP=ze.define(),gn=Xt.define({create(){return Z1.start()},update(i,e){return i.update(e)},provide:i=>[Qc.from(i,e=>e.tooltip),Se.contentAttributes.from(i,e=>e.attrs)]});function L1(i,e){let t=e.completion.apply||e.completion.label,n=i.state.field(gn).active.find(r=>r.source==e.source);return n instanceof uh?(typeof t=="string"?i.dispatch(Object.assign(Object.assign({},jI(i.state,t,n.from,n.to)),{annotations:iP.of(e.completion)})):t(i,e.completion,n.from,n.to),!0):!1}var YI=LI(gn,L1);function oh(i,e="option"){return t=>{let n=t.state.field(gn,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp-1?n.open.selected+r*(i?1:-1):i?0:o-1;return a<0?a=e=="page"?0:o-1:a>=o&&(a=e=="page"?o-1:0),t.dispatch({effects:rP.of(a)}),!0}}var UI=i=>{let e=i.state.field(gn,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampi.state.field(gn,!1)?(i.dispatch({effects:ch.of(!0)}),!0):!1,GI=i=>{let e=i.state.field(gn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Yc.of(null)}),!0)},q1=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},KI=50,JI=1e3,e9=di.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(gn).active)e.state==1&&this.startQuery(e)}update(i){let e=i.state.field(gn),t=i.state.facet(Di);if(!i.selectionSet&&!i.docChanged&&i.startState.field(gn)==e)return;let n=i.transactions.some(s=>(s.selection||s.docChanged)&&!z1(s,t));for(let s=0;sKI&&Date.now()-o.time>JI){for(let a of o.context.abortListeners)try{a()}catch(l){Ai(this.view.state,l)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(s=>s.effects.some(o=>o.is(ch)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.state==1&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of i.transactions)z1(s,t)=="input"?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(gn);for(let t of e.active)t.state==1&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t)}startQuery(i){let{state:e}=this.view,t=eo(e),n=new ah(e,t,i.explicitPos==t),r=new q1(i,n);this.running.push(r),Promise.resolve(i.source(n)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Yc.of(null)}),Ai(this.view.state,s)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Di).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Di);for(let n=0;no.source==r.active.source);if(s&&s.state==1)if(r.done==null){let o=new Ur(r.active.source,0);for(let a of r.updates)o=o.update(a,t);o.state!=1&&e.push(o)}else this.startQuery(s)}e.length&&this.view.dispatch({effects:nP.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(gn,!1);if(e&&e.tooltip&&this.view.state.facet(Di).closeOnBlur){let t=e.open&&Z0(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Yc.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:ch.of(!1)}),20),this.composing=0}}}),t9=typeof navigator=="object"&&/Win/.test(navigator.platform),i9=fr.highest(Se.domEventHandlers({keydown(i,e){let t=e.state.field(gn,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(t9&&i.altKey)||i.metaKey)return!1;let n=t.open.options[t.open.selected],r=t.active.find(o=>o.source==n.source),s=n.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(i.key)>-1&&L1(e,n),!1}})),n9=Se.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});var Uc={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Xo=ze.define({map(i,e){let t=e.mapPos(i,-1,Ei.TrackAfter);return t??void 0}}),$1=new class extends ur{};$1.startSide=1;$1.endSide=-1;var sP=Xt.define({create(){return kt.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(Xo)&&(i=i.update({add:[$1.range(t.value,t.value+1)]}));return i}});function oP(){return[s9,sP]}var R1="()[]{}<>";function aP(i){for(let e=0;e{if((r9?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let r=i.state.selection.main;if(n.length>2||n.length==2&&Yi(gi(n,0))==1||e!=r.from||t!=r.to)return!1;let s=a9(i.state,n);return s?(i.dispatch(s),!0):!1}),o9=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=lP(i,i.selection.main.head).brackets||Uc.brackets,r=null,s=i.changeByRange(o=>{if(o.empty){let a=l9(i.doc,o.head);for(let l of n)if(l==a&&fh(i.doc,o.head)==aP(gi(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:ce.cursor(o.head-l.length)}}return{range:r=o}});return r||e(i.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},cP=[{key:"Backspace",run:o9}];function a9(i,e){let t=lP(i,i.selection.main.head),n=t.brackets||Uc.brackets;for(let r of n){let s=aP(gi(r,0));if(e==r)return s==r?f9(i,r,n.indexOf(r+r+r)>-1,t):c9(i,r,s,t.before||Uc.before);if(e==s&&uP(i,i.selection.main.from))return u9(i,r,s)}return null}function uP(i,e){let t=!1;return i.field(sP).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function fh(i,e){let t=i.sliceString(e,e+2);return t.slice(0,Yi(gi(t,0)))}function l9(i,e){let t=i.sliceString(e-2,e);return Yi(gi(t,0))==t.length?t:t.slice(1)}function c9(i,e,t,n){let r=null,s=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Xo.of(o.to+e.length),range:ce.range(o.anchor+e.length,o.head+e.length)};let a=fh(i.doc,o.head);return!a||/\s/.test(a)||n.indexOf(a)>-1?{changes:{insert:e+t,from:o.head},effects:Xo.of(o.head+e.length),range:ce.cursor(o.head+e.length)}:{range:r=o}});return r?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function u9(i,e,t){let n=null,r=i.changeByRange(s=>s.empty&&fh(i.doc,s.head)==t?{changes:{from:s.head,to:s.head+t.length,insert:t},range:ce.cursor(s.head+t.length)}:n={range:s});return n?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function f9(i,e,t,n){let r=n.stringPrefixes||Uc.stringPrefixes,s=null,o=i.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Xo.of(a.to+e.length),range:ce.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=fh(i.doc,l),u;if(c==e){if(Jx(i,l))return{changes:{insert:e+e,from:l},effects:Xo.of(l+e.length),range:ce.cursor(l+e.length)};if(uP(i,l)){let d=t&&i.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+d.length,insert:d},range:ce.cursor(l+d.length)}}}else{if(t&&i.sliceDoc(l-2*e.length,l)==e+e&&(u=eP(i,l-2*e.length,r))>-1&&Jx(i,u))return{changes:{insert:e+e+e+e,from:l},effects:Xo.of(l+e.length),range:ce.cursor(l+e.length)};if(i.charCategorizer(l)(c)!=Pt.Word&&eP(i,l,r)>-1&&!d9(i,l,e,r))return{changes:{insert:e+e,from:l},effects:Xo.of(l+e.length),range:ce.cursor(l+e.length)}}return{range:s=a}});return s?null:i.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Jx(i,e){let t=vi(i).resolveInner(e+1);return t.parent&&t.from==e}function d9(i,e,t,n){let r=vi(i).resolveInner(e,-1),s=n.reduce((o,a)=>Math.max(o,a.length),0);for(let o=0;o<5;o++){let a=i.sliceDoc(r.from,Math.min(r.to,r.from+t.length+s)),l=a.indexOf(t);if(!l||l>-1&&n.indexOf(a.slice(0,l))>-1){let u=r.firstChild;for(;u&&u.from==r.from&&u.to-u.from>t.length+l;){if(i.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function eP(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=Pt.Word)return e;for(let r of t){let s=e-r.length;if(i.sliceDoc(s,e)==r&&n(i.sliceDoc(s-1,s))!=Pt.Word)return s}return-1}function fP(i={}){return[i9,gn,Di.of(i),e9,h9,n9]}var F1=[{key:"Ctrl-Space",run:HI},{key:"Escape",run:GI},{key:"ArrowDown",run:oh(!0)},{key:"ArrowUp",run:oh(!1)},{key:"PageDown",run:oh(!0,"page")},{key:"PageUp",run:oh(!1,"page")},{key:"Enter",run:UI}],h9=fr.highest(Dc.computeN([Di],i=>i.facet(Di).defaultKeymap?[F1]:[]));var dP=Vd.define({name:"javascript",parser:Xx.configure({props:[c1.add({IfStatement:Ud({except:/^\s*({|else\b)/}),TryStatement:Ud({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:NS,SwitchBody:i=>{let e=i.textAfter,t=/^\s*\}/.test(e),n=/^\s*(case|default)\b/.test(e);return i.baseIndent+(t?0:n?1:2)*i.unit},Block:MS({closing:"}"}),ArrowFunction:i=>i.baseIndent+i.unit,"TemplateString BlockComment":()=>null,"Statement Property":Ud({except:/^{/}),JSXElement(i){let e=/^\s*<\//.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},JSXEscape(i){let e=/\s*\}/.test(i.textAfter);return i.lineIndent(i.node.from)+(e?0:i.unit)},"JSXOpenTag JSXSelfClosingTag"(i){return i.column(i.node.from)+i.unit}}),u1.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":ZS,BlockComment(i){return{from:i.from+2,to:i.to-2}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}});var $K=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent);function St(){var i=arguments[0];typeof i=="string"&&(i=document.createElement(i));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=t[n];typeof r=="string"?i.setAttribute(n,r):r!=null&&(i[n]=r)}e++}for(;ei.normalize("NFKD"):i=>i,io=class{constructor(e,t,n=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=s?a=>s(pP(a)):pP,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return gi(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=fc(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Yi(e);let r=this.normalize(t);for(let s=0,o=n;;s++){let a=r.charCodeAt(s),l=this.match(a,o,this.bufferPos+this.bufferStart);if(s==r.length-1){if(l)return this.value=l,this;break}o==n&&sthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Oh(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(nthis.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=n||r.to<=t){let a=new i(t,e.sliceString(t,n));return B1.set(e,a),a}if(r.from==t&&r.to==n)return r;let{text:s,from:o}=r;return o>t&&(s=e.sliceString(t,o)+s,o=t),r.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,r=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this.matchPos=Oh(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=mh.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(ph.prototype[Symbol.iterator]=gh.prototype[Symbol.iterator]=function(){return this});function p9(i){try{return new RegExp(i,H1),!0}catch{return!1}}function Oh(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e=56320&&n<57344;)e++;return e}function V1(i){let e=String(i.state.doc.lineAt(i.state.selection.main.head).number),t=St("input",{class:"cm-textfield",name:"line",value:e}),n=St("form",{class:"cm-gotoLine",onkeydown:s=>{s.keyCode==27?(s.preventDefault(),i.dispatch({effects:vh.of(!1)}),i.focus()):s.keyCode==13&&(s.preventDefault(),r())},onsubmit:s=>{s.preventDefault(),r()}},St("label",i.state.phrase("Go to line"),": ",t)," ",St("button",{class:"cm-button",type:"submit"},i.state.phrase("go")));function r(){let s=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!s)return;let{state:o}=i,a=o.doc.lineAt(o.selection.main.head),[,l,c,u,f]=s,d=u?+u.slice(1):0,h=c?+c:a.number;if(c&&f){let g=h/100;l&&(g=g*(l=="-"?-1:1)+a.number/o.doc.lines),h=Math.round(o.doc.lines*g)}else c&&l&&(h=h*(l=="-"?-1:1)+a.number);let p=o.doc.line(Math.max(1,Math.min(o.doc.lines,h))),m=ce.cursor(p.from+Math.max(0,Math.min(d,p.length)));i.dispatch({effects:[vh.of(!1),Se.scrollIntoView(m.from,{y:"center"})],selection:m}),i.focus()}return{dom:n}}var vh=ze.define(),mP=Xt.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(vh)&&(i=t.value);return i},provide:i=>zo.from(i,e=>e?V1:null)}),m9=i=>{let e=qo(i,V1);if(!e){let t=[vh.of(!0)];i.state.field(mP,!1)==null&&t.push(ze.appendConfig.of([mP,g9])),i.dispatch({effects:t}),e=qo(i,V1)}return e&&e.dom.querySelector("input").select(),!0},g9=Se.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),O9={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},yP=Ae.define({combine(i){return mn(i,O9,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function bP(i){let e=[w9,_9];return i&&e.push(yP.of(i)),e}var v9=je.mark({class:"cm-selectionMatch"}),y9=je.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function gP(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=Pt.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=Pt.Word)}function b9(i,e,t,n){return i(e.sliceDoc(t,t+1))==Pt.Word&&i(e.sliceDoc(n-1,n))==Pt.Word}var _9=di.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(yP),{state:t}=i,n=t.selection;if(n.ranges.length>1)return je.none;let r=n.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return je.none;let l=t.wordAt(r.head);if(!l)return je.none;o=t.charCategorizer(r.head),s=t.sliceDoc(l.from,l.to)}else{let l=r.to-r.from;if(l200)return je.none;if(e.wholeWords){if(s=t.sliceDoc(r.from,r.to),o=t.charCategorizer(r.head),!(gP(o,t,r.from,r.to)&&b9(o,t,r.from,r.to)))return je.none}else if(s=t.sliceDoc(r.from,r.to),!s)return je.none}let a=[];for(let l of i.visibleRanges){let c=new io(t.doc,s,l.from,l.to);for(;!c.next().done;){let{from:u,to:f}=c.value;if((!o||gP(o,t,u,f))&&(r.empty&&u<=r.from&&f>=r.to?a.push(y9.range(u,f)):(u>=r.to||f<=r.from)&&a.push(v9.range(u,f)),a.length>e.maxMatches))return je.none}}return je.set(a)}},{decorations:i=>i.decorations}),w9=Se.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),k9=({state:i,dispatch:e})=>{let{selection:t}=i,n=ce.create(t.ranges.map(r=>i.wordAt(r.head)||ce.cursor(r.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function S9(i,e){let{main:t,ranges:n}=i.selection,r=i.wordAt(t.head),s=r&&r.from==t.from&&r.to==t.to;for(let o=!1,a=new io(i.doc,e,n[n.length-1].to);;)if(a.next(),a.done){if(o)return null;a=new io(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),o=!0}else{if(o&&n.some(l=>l.from==a.value.from))continue;if(s){let l=i.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}var x9=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(s=>s.from===s.to))return k9({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(s=>i.sliceDoc(s.from,s.to)!=n))return!1;let r=S9(i,n);return r?(e(i.update({selection:i.selection.addRange(ce.range(r.from,r.to),!1),effects:Se.scrollIntoView(r.to)})),!0):!1},nl=Ae.define({combine(i){return mn(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new U1(e),scrollToMatch:e=>Se.scrollIntoView(e)})}});var yh=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||p9(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?` `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new X1(this):new W1(this)}getCursor(e,t=0,n){let r=e.doc?e:At.create({doc:e});return n==null&&(n=r.doc.length),this.regexp?il(this,r,t,n):tl(this,r,t,n)}},bh=class{constructor(e){this.spec=e}};function tl(i,e,t,n){return new io(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:r=>r.toLowerCase(),i.wholeWord?P9(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function P9(i,e){return(t,n,r,s)=>((s>t||s+r.length=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let s=tl(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}};function il(i,e,t,n){return new ph(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?C9(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function _h(i,e){return i.slice(ui(i,e,!1),e)}function wh(i,e){return i.slice(e,ui(i,e))}function C9(i){return(e,t,n)=>!n[0].length||(i(_h(n.input,n.index))!=Pt.Word||i(wh(n.input,n.index))!=Pt.Word)&&(i(wh(n.input,n.index+n[0].length))!=Pt.Word||i(_h(n.input,n.index+n[0].length))!=Pt.Word)}var X1=class extends bh{nextMatch(e,t,n){let r=il(this.spec,e,n,e.doc.length).next();return r.done&&(r=il(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let s=Math.max(t,n-r*1e4),o=il(this.spec,e,s,n),a=null;for(;!o.next().done;)a=o.value;if(a&&(s==t||a.from>s+10))return a;if(s==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,(t,n)=>n=="$"?"$":n=="&"?e.match[0]:n!="0"&&+n=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let s=il(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}},Gc=ze.define(),G1=ze.define(),to=Xt.define({create(i){return new Hc(Y1(i).create(),null)},update(i,e){for(let t of e.effects)t.is(Gc)?i=new Hc(t.value.create(),i.panel):t.is(G1)&&(i=new Hc(i.query,t.value?K1:null));return i},provide:i=>zo.from(i,e=>e.panel)});var Hc=class{constructor(e,t){this.query=e,this.panel=t}},E9=je.mark({class:"cm-searchMatch"}),T9=je.mark({class:"cm-searchMatch cm-searchMatch-selected"}),A9=di.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(to))}update(i){let e=i.state.field(to);(e!=i.startState.field(to)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return je.none;let{view:t}=this,n=new jr;for(let r=0,s=t.visibleRanges,o=s.length;rs[r+1].from-2*250;)l=s[++r].to;i.highlight(t.state,a,l,(c,u)=>{let f=t.state.selection.ranges.some(d=>d.from==c&&d.to==u);n.add(c,u,f?T9:E9)})}return n.finish()}},{decorations:i=>i.decorations});function Kc(i){return e=>{let t=e.state.field(to,!1);return t&&t.query.spec.valid?i(e,t):kP(e)}}var kh=Kc((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let r=ce.single(n.from,n.to),s=i.state.facet(nl);return i.dispatch({selection:r,effects:[J1(i,n),s.scrollToMatch(r.main,i)],userEvent:"select.search"}),wP(i),!0}),Sh=Kc((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,r=e.prevMatch(t,n,n);if(!r)return!1;let s=ce.single(r.from,r.to),o=i.state.facet(nl);return i.dispatch({selection:s,effects:[J1(i,r),o.scrollToMatch(s.main,i)],userEvent:"select.search"}),wP(i),!0}),D9=Kc((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:ce.create(t.map(n=>ce.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Q9=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:r}=t.main,s=[],o=0;for(let a=new io(i.doc,i.sliceDoc(n,r));!a.next().done;){if(s.length>1e3)return!1;a.value.from==n&&(o=s.length),s.push(ce.range(a.value.from,a.value.to))}return e(i.update({selection:ce.create(s,o),userEvent:"select.search.matches"})),!0},OP=Kc((i,{query:e})=>{let{state:t}=i,{from:n,to:r}=t.selection.main;if(t.readOnly)return!1;let s=e.nextMatch(t,n,n);if(!s)return!1;let o=[],a,l,c=[];if(s.from==n&&s.to==r&&(l=t.toText(e.getReplacement(s)),o.push({from:s.from,to:s.to,insert:l}),s=e.nextMatch(t,s.from,s.to),c.push(Se.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+"."))),s){let u=o.length==0||o[0].from>=s.to?0:s.to-s.from-l.length;a=ce.single(s.from-u,s.to-u),c.push(J1(i,s)),c.push(t.facet(nl).scrollToMatch(a.main,i))}return i.dispatch({changes:o,selection:a,effects:c,userEvent:"input.replace"}),!0}),R9=Kc((i,{query:e})=>{if(i.state.readOnly)return!1;let t=e.matchAll(i.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:Se.announce.of(n),userEvent:"input.replace.all"}),!0});function K1(i){return i.state.facet(nl).createPanel(i)}function Y1(i,e){var t,n,r,s,o;let a=i.selection.main,l=a.empty||a.to>a.from+100?"":i.sliceDoc(a.from,a.to);if(e&&!l)return e;let c=i.facet(nl);return new yh({search:((t=e?.literal)!==null&&t!==void 0?t:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(n=e?.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:c.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:c.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:c.wholeWord})}function _P(i){let e=qo(i,K1);return e&&e.dom.querySelector("[main-field]")}function wP(i){let e=_P(i);e&&e==i.root.activeElement&&e.select()}var kP=i=>{let e=i.state.field(to,!1);if(e&&e.panel){let t=_P(i);if(t&&t!=i.root.activeElement){let n=Y1(i.state,e.query.spec);n.valid&&i.dispatch({effects:Gc.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[G1.of(!0),e?Gc.of(Y1(i.state,e.query.spec)):ze.appendConfig.of(I9)]});return!0},SP=i=>{let e=i.state.field(to,!1);if(!e||!e.panel)return!1;let t=qo(i,K1);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:G1.of(!1)}),!0},xP=[{key:"Mod-f",run:kP,scope:"editor search-panel"},{key:"F3",run:kh,shift:Sh,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:kh,shift:Sh,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:SP,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Q9},{key:"Mod-Alt-g",run:m9},{key:"Mod-d",run:x9,preventDefault:!0}],U1=class{constructor(e){this.view=e;let t=this.query=e.state.field(to).query.spec;this.commit=this.commit.bind(this),this.searchField=St("input",{value:t.search,placeholder:Tn(e,"Find"),"aria-label":Tn(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=St("input",{value:t.replace,placeholder:Tn(e,"Replace"),"aria-label":Tn(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=St("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=St("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=St("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,s,o){return St("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=St("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,n("next",()=>kh(e),[Tn(e,"next")]),n("prev",()=>Sh(e),[Tn(e,"previous")]),n("select",()=>D9(e),[Tn(e,"all")]),St("label",null,[this.caseField,Tn(e,"match case")]),St("label",null,[this.reField,Tn(e,"regexp")]),St("label",null,[this.wordField,Tn(e,"by word")]),...e.state.readOnly?[]:[St("br"),this.replaceField,n("replace",()=>OP(e),[Tn(e,"replace")]),n("replaceAll",()=>R9(e),[Tn(e,"replace all")])],St("button",{name:"close",onclick:()=>SP(e),"aria-label":Tn(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new yh({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Gc.of(e)}))}keydown(e){nS(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Sh:kh)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),OP(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(Gc)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(nl).top}};function Tn(i,e){return i.state.phrase(e)}var dh=30,hh=/[\s\.,:;?!]/;function J1(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),r=i.state.doc.lineAt(t).to,s=Math.max(n.from,e-dh),o=Math.min(r,t+dh),a=i.state.sliceDoc(s,o);if(s!=n.from){for(let l=0;la.length-dh;l--)if(!hh.test(a[l-1])&&hh.test(a[l])){a=a.slice(0,l);break}}return Se.announce.of(`${i.state.phrase("current match")}. ${a} ${i.state.phrase("on line")} ${n.number}.`)}var M9=Se.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),I9=[to,fr.low(A9),M9];var eO=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},Yo=class i{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let r=e,s=n.facet(AP).markerFilter;s&&(r=s(r,n));let o=je.set(r.map(a=>a.from==a.to||a.from==a.to-1&&n.doc.lineAt(a.from).to==a.from?je.widget({widget:new tO(a),diagnostic:a}).range(a.from):je.mark({attributes:{class:"cm-lintRange cm-lintRange-"+a.severity+(a.markClass?" "+a.markClass:"")},diagnostic:a,inclusive:!0}).range(a.from,a.to)),!0);return new i(o,t,rl(o))}};function rl(i,e=null,t=0){let n=null;return i.between(t,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostic!=e))return n=new eO(r,s,o.diagnostic),!1}),n}function N9(i,e){let t=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(n=>n.is(CP))||i.changes.touchesRange(t.from,t.to))}function j9(i,e){return i.field(An,!1)?e:e.concat(ze.appendConfig.of(V9))}var CP=ze.define(),iO=ze.define(),EP=ze.define(),An=Xt.define({create(){return new Yo(je.none,null,null)},update(i,e){if(e.docChanged){let t=i.diagnostics.map(e.changes),n=null;if(i.selected){let r=e.changes.mapPos(i.selected.from,1);n=rl(t,i.selected.diagnostic,r)||rl(t,null,r)}i=new Yo(t,i.panel,n)}for(let t of e.effects)t.is(CP)?i=Yo.init(t.value,i.panel,e.state):t.is(iO)?i=new Yo(i.diagnostics,t.value?Ch.open:null,i.selected):t.is(EP)&&(i=new Yo(i.diagnostics,i.panel,t.value));return i},provide:i=>[zo.from(i,e=>e.panel),Se.decorations.from(i,e=>e.diagnostics)]});var Z9=je.mark({class:"cm-lintRange cm-lintRange-active",inclusive:!0});function z9(i,e,t){let{diagnostics:n}=i.state.field(An),r=[],s=2e8,o=0;n.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{e>=l&&e<=c&&(l==c||(e>l||t>0)&&(eQP(i,t,!1)))}var L9=i=>{let e=i.state.field(An,!1);(!e||!e.panel)&&i.dispatch({effects:j9(i.state,[iO.of(!0)])});let t=qo(i,Ch.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},PP=i=>{let e=i.state.field(An,!1);return!e||!e.panel?!1:(i.dispatch({effects:iO.of(!1)}),!0)},$9=i=>{let e=i.state.field(An,!1);if(!e)return!1;let t=i.state.selection.main,n=e.diagnostics.iter(t.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)};var TP=[{key:"Mod-Shift-m",run:L9,preventDefault:!0},{key:"F8",run:$9}];var AP=Ae.define({combine(i){return Object.assign({sources:i.map(e=>e.source).filter(e=>e!=null)},mn(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))}});function DP(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;ns.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function QP(i,e,t){var n;let r=t?DP(e.actions):[];return St("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},St("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(n=e.actions)===null||n===void 0?void 0:n.map((s,o)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let h=rl(i.state.field(An).diagnostics,e);h&&s.apply(i,h.from,h.to)},{name:c}=s,u=r[o]?c.indexOf(r[o]):-1,f=u<0?c:[c.slice(0,u),St("u",c.slice(u,u+1)),c.slice(u+1)];return St("button",{type:"button",class:"cm-diagnosticAction",onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${r[o]})"`}.`},f)}),e.source&&St("div",{class:"cm-diagnosticSource"},e.source))}var tO=class extends dr{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return St("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}},Ph=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=QP(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Ch=class i{constructor(e){this.view=e,this.items=[];let t=r=>{if(r.keyCode==27)PP(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=DP(s.actions);for(let a=0;a{for(let s=0;sPP(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(An).selected;if(!e)return-1;for(let t=0;t{let c=-1,u;for(let f=n;fn&&(this.items.splice(n,c-n),r=!0)),t&&u.diagnostic==t.diagnostic?u.dom.hasAttribute("aria-selected")||(u.dom.setAttribute("aria-selected","true"),s=u):u.dom.hasAttribute("aria-selected")&&u.dom.removeAttribute("aria-selected"),n++});n({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:a})=>{let l=a.height/this.list.offsetHeight;o.topa.bottom&&(this.list.scrollTop+=(o.bottom-a.bottom)/l)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(An),n=rl(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:EP.of(n)})}static open(e){return new i(e)}};function F9(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(i)}')`}function xh(i){return F9(``,'width="6" height="3"')}var B9=Se.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:xh("#d11")},".cm-lintRange-warning":{backgroundImage:xh("orange")},".cm-lintRange-info":{backgroundImage:xh("#999")},".cm-lintRange-hint":{backgroundImage:xh("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});var V9=[An,Se.decorations.compute([An],i=>{let{selected:e,panel:t}=i.field(An);return!e||!t||e.from==e.to?je.none:je.set([Z9.range(e.from,e.to)])}),hS(z9,{hideOn:N9}),B9];var Eh=[dP,WS(),lS(),fS(),jS(),Ga(YS,{fallback:!0}),Se.lineWrapping,KS(),oP(),fP(),dS(),bP(),Dc.of([...cP,...jx,...xP,...ux,Zx,...FS,...F1,...TP])].filter(i=>i);var W9="#abb2bf",X9="#7d8799",Y9="#ffffff",U9="#21252b",nO="rgba(0, 0, 0, 0.5)",H9="#292d3e",rO="#353a42",G9="rgba(128, 203, 196, 0.2)",RP="#ffcc00",K9=Se.theme({"&":{color:"#ffffff",backgroundColor:H9},".cm-content":{caretColor:RP},"&.cm-focused .cm-cursor":{borderLeftColor:RP},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:G9},".cm-panels":{backgroundColor:U9,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:nO},".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:nO},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:rO},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:rO,borderBottomColor:rO},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:nO,color:W9}}},{dark:!0}),J9=Gs.define([{tag:L.keyword,color:"#c792ea"},{tag:L.operator,color:"#89ddff"},{tag:L.special(L.variableName),color:"#eeffff"},{tag:L.typeName,color:"#f07178"},{tag:L.atom,color:"#f78c6c"},{tag:L.number,color:"#ff5370"},{tag:L.definition(L.variableName),color:"#82aaff"},{tag:L.string,color:"#c3e88d"},{tag:L.special(L.string),color:"#f07178"},{tag:L.comment,color:X9},{tag:L.variableName,color:"#f07178"},{tag:L.tagName,color:"#ff5370"},{tag:L.bracket,color:"#a2a1a4"},{tag:L.meta,color:"#ffcb6b"},{tag:L.attributeName,color:"#c792ea"},{tag:L.propertyName,color:"#c792ea"},{tag:L.className,color:"#decb6b"},{tag:L.invalid,color:Y9}]),MP=[K9,Ga(J9)];var IP="#2e3440",uO="#3b4252",NP="#434c5e",Th="#4c566a";var jP="#e5e9f0",cO="#eceff4",sO="#8fbcbb",ZP="#88c0d0",eN="#81a1c1",vr="#5e81ac",tN="#bf616a",sl="#d08770",oO="#ebcb8b",zP="#a3be8c",iN="#b48ead",qP="#d30102",fO=cO,aO=fO,nN="#ffffff",lO=uO,rN=fO,LP=uO,dO=Se.theme({"&":{color:IP,backgroundColor:nN},".cm-content":{caretColor:LP},".cm-cursor, .cm-dropCursor":{borderLeftColor:LP},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:rN},".cm-panels":{backgroundColor:fO,color:Th},".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 ${Th}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:jP},".cm-activeLine":{backgroundColor:aO},".cm-selectionMatch":{backgroundColor:jP},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${Th}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:cO},".cm-gutters":{backgroundColor:cO,color:IP,border:"none"},".cm-activeLineGutter":{backgroundColor:aO},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:lO},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:lO,borderBottomColor:lO},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:aO,color:Th}}},{dark:!1}),sN=Gs.define([{tag:L.keyword,color:vr},{tag:[L.name,L.deleted,L.character,L.propertyName,L.macroName],color:sl},{tag:[L.variableName],color:sl},{tag:[L.function(L.variableName)],color:vr},{tag:[L.labelName],color:eN},{tag:[L.color,L.constant(L.name),L.standard(L.name)],color:vr},{tag:[L.definition(L.name),L.separator],color:zP},{tag:[L.brace],color:sO},{tag:[L.annotation],color:qP},{tag:[L.number,L.changed,L.annotation,L.modifier,L.self,L.namespace],color:ZP},{tag:[L.typeName,L.className],color:oO},{tag:[L.operator,L.operatorKeyword],color:zP},{tag:[L.tagName],color:iN},{tag:[L.squareBracket],color:tN},{tag:[L.angleBracket],color:sl},{tag:[L.attributeName],color:oO},{tag:[L.regexp],color:vr},{tag:[L.quote],color:uO},{tag:[L.string],color:sl},{tag:L.link,color:sO,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[L.url,L.escape,L.special(L.string)],color:sl},{tag:[L.meta],color:ZP},{tag:[L.comment],color:NP,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold",color:vr},{tag:L.emphasis,fontStyle:"italic",color:vr},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.heading,fontWeight:"bold",color:vr},{tag:L.special(L.heading1),fontWeight:"bold",color:vr},{tag:L.heading1,fontWeight:"bold",color:vr},{tag:[L.heading2,L.heading3,L.heading4],fontWeight:"bold",color:vr},{tag:[L.heading5,L.heading6],color:vr},{tag:[L.atom,L.bool,L.special(L.variableName)],color:sl},{tag:[L.processingInstruction,L.inserted],color:sO},{tag:[L.contentSeparator],color:oO},{tag:L.invalid,color:NP,borderBottom:`1px dotted ${qP}`}]),OJ=[dO,Ga(sN)];function $P(i,e){document.body.hasClass("theme-dark")?Eh.push(MP):Eh.push(dO);let t=[...Eh];e&&t.push(e);let n=new Se({state:At.create({doc:i.value,extensions:t})});return i.parentNode.appendChild(n.dom),i.style.display="none",i.form&&i.form.addEventListener("submit",()=>{i.value=n.state.doc.toString()}),n}var Ah=class extends Hr.Modal{constructor(){super(...arguments);te(this,"header");te(this,"editing");te(this,"editor");te(this,"canceled",!1)}onOpen(){this.titleEl.setText(this.editing?"Edit Header":"Create Header"),this.display()}display(){if(this.contentEl.empty(),new Hr.Setting(this.contentEl).setName("Display Text").addText(t=>t.setValue(this.header.text).onChange(n=>{this.header.text=n})),new Hr.Setting(this.contentEl).setName("Linked Property").addText(t=>t.setValue(this.header.field).onChange(n=>this.header.field=n)),new Hr.Setting(this.contentEl).setName("Sort Type").setDesc("This determines how the field is sorted. Use the appropriate type for the data type of the field.").addDropdown(t=>{t.addOption("0","String"),t.addOption("1","Number"),t.addOption("2","Custom"),t.setValue(`${this.header.type}`).onChange(n=>{this.header.type=Number(n),this.header.type==2?this.header.func="":delete this.header.func,this.display()})}),"func"in this.header){new Hr.Setting(this.contentEl).setName("Custom Sorting Function").setDesc(createFragment(n=>{n.createSpan({text:"Specify a custom sorting JavaScript function."}),n.createEl("br"),n.createEl("br"),n.createSpan({text:"This function receives two monster objects, "}),n.createEl("code",{text:"a"}),n.createSpan({text:" and "}),n.createEl("code",{text:"b"}),n.createSpan({text:", and must return a number. The number determines sort order."})}));let t=new Hr.TextAreaComponent(this.contentEl).setValue(this.header.func);t.inputEl.addClass("initiative-tracker-textarea"),this.editor=$P(t.inputEl,Se.updateListener.of(n=>{n.docChanged&&(this.header.func=n.state.doc.toString())}))}new Hr.Setting(this.contentEl).addButton(t=>{t.setButtonText("Cancel").setCta().onClick(()=>{this.canceled=!0,this.close()})})}close(){this.editor?.destroy(),super.close()}};function oN(i){se(i,"svelte-1s0cntl",".header-container.svelte-1s0cntl{margin:0 0.5rem}.header.svelte-1s0cntl .header-desc{display:flex;align-items:center;gap:0.25rem}.header.svelte-1s0cntl .header-desc *:has(svg){display:flex;align-items:center}.cancel-button.svelte-1s0cntl{display:flex;justify-content:flex-end}")}function FP(i,e,t){let n=i.slice();return n[13]=e[t],n}function BP(i,e){let t,n,r,s,o,a=X,l,c;return{key:i,first:null,c(){t=b("div"),n=b("div"),s=R(),v(n,"class","header svelte-1s0cntl"),this.first=t},m(u,f){A(u,t,f),y(t,n),y(t,s),l||(c=H(r=e[5].call(null,n,e[13])),l=!0)},p(u,f){e=u,r&&Ge(r.update)&&f&1&&r.update.call(null,e[13])},r(){o=t.getBoundingClientRect()},f(){Dr(t),a()},a(){a(),a=Ar(t,o,Nr,{duration:hO})},d(u){u&&T(t),l=!1,c()}}}function aN(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p=[],m=new Map,g,O,_,S,P,k,w,x=fe(i[0]),C=M=>M[13].id;for(let M=0;MOrganize your headers here. Headers can be drag-and-dropped!",l=R(),c=b("div"),u=b("div"),d=R(),h=b("section");for(let M=0;M{let O=new Ah(app);return O.header=g??zs.defaultState,g&&(O.editing=!0),O.open(),new Promise(_=>{O.onClose=()=>{O.canceled?_():_(O.header)}})},c=g=>{switch(g){case 0:return Ap;case 1:return Dp;case 2:return"function-square"}},u=g=>{new Gr.Setting(g).setName(createFragment(O=>{let _=O.createDiv("header-desc");(0,Gr.setIcon)(_.createDiv(),c(sc.type)),_.createSpan({text:sc.text})})).setDesc(createFragment(O=>{O.createEl("em",{text:sc.field})}))},f=(g,O)=>{let{header:_,id:S}=O;new Gr.Setting(g).setName(createFragment(P=>{let k=P.createDiv("header-desc");(0,Gr.setIcon)(k.createDiv(),c(_.type)),k.createSpan({text:_.text})})).setDesc(createFragment(P=>{P.createEl("em",{text:_.field})})).addExtraButton(P=>{P.setIcon("edit").onClick(async()=>{let k=await l(_);k&&k.text?.length&&k.field?.length&&(k.type!=2||k?.func?.length)&&(s.splice(s.findIndex(w=>w.id==S),1,{id:xt(),header:k}),t(0,s))})}).addExtraButton(P=>P.setIcon("trash").onClick(()=>{t(0,s=s.filter(k=>k.id!=S))}))},d=g=>{new Gr.Setting(g).setName("Add Header").addExtraButton(O=>O.setIcon("plus-circle").onClick(async()=>{let _=await l();_&&_.text?.length&&_.field?.length&&(_.type!=2||_?.func?.length)&&(s.push({id:xt(),header:_}),t(0,s))}))},h=g=>{new Gr.Setting(g).setName("Reset Headers").setDesc("Reset table headers to defaults.").addExtraButton(O=>O.setIcon("reset").onClick(()=>{n("reset")}))},p=g=>{new Gr.ButtonComponent(g).setButtonText("Cancel").setCta()},m=()=>n("cancel");return i.$$set=g=>{"headers"in g&&t(9,r=g.headers)},i.$$.update=()=>{i.$$.dirty&1&&n("update",s.reduce((g,O)=>(g.push(O.header),g),[]))},[s,n,o,a,u,f,d,h,p,r,m]}var pO=class extends ne{constructor(e){super(),re(this,e,lN,aN,ie,{headers:9},oN)}},VP=pO;var Dh=class extends WP.Modal{constructor(t){super(app);this.headers=t;te(this,"canceled",!1);te(this,"reset",!1)}onOpen(){this.titleEl.setText("Edit Headers");let t=new VP({target:this.contentEl,props:{headers:ci(this.headers)}});t.$on("update",n=>{this.headers=ci(n.detail)}),t.$on("cancel",()=>{this.canceled=!0,this.close()}),t.$on("reset",()=>{this.reset=!0,this.close()})}};var wO=require("obsidian");var vs=require("obsidian");function cN(i){se(i,"svelte-n90cbf",".filter-container.svelte-n90cbf.svelte-n90cbf{flex-grow:1;flex-basis:0;display:grid;grid-template-columns:1fr auto;gap:0.5rem;align-items:center}.filter-container.svelte-n90cbf:hover .context.svelte-n90cbf{opacity:1}.name-container.svelte-n90cbf.svelte-n90cbf{display:flex;flex-flow:row nowrap;gap:0.5rem;align-items:center}.description-container.svelte-n90cbf.svelte-n90cbf{display:flex;align-items:center;gap:0.25rem;--icon-size:14px}.icon.svelte-n90cbf.svelte-n90cbf{display:flex;align-items:center}.warning-icon.svelte-n90cbf.svelte-n90cbf{color:var(--text-error)}.context.svelte-n90cbf.svelte-n90cbf{opacity:0;transition:opacity 0.25s;display:flex;align-items:center;gap:0.25rem}")}function uN(i){let e,t,n,r;return{c(){e=b("div"),v(e,"class","icon svelte-n90cbf")},m(s,o){A(s,e,o),n||(r=H(t=i[9].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function fN(i){let e,t,n,r,s,o;return{c(){e=b("div"),n=R(),r=b("span"),r.textContent="No fields",v(e,"class","warning-icon icon svelte-n90cbf"),v(r,"class","warning-icon svelte-n90cbf")},m(a,l){A(a,e,l),A(a,n,l),A(a,r,l),s||(o=H(t=i[8].call(null,e)),s=!0)},p:X,d(a){a&&(T(e),T(n),T(r)),s=!1,o()}}}function dN(i){let e=i[3].fields.join(", ")+"",t;return{c(){t=ae(e)},m(n,r){A(n,t,r)},p:X,d(n){n&&T(t)}}}function hN(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P,k,w,x=i[3].derive&&uN(i);function C(Q,D){return Q[3].fields.length?dN:fN}let Z=C(i,-1)(i);return{c(){e=b("div"),t=b("div"),n=b("div"),r=b("div"),o=R(),a=b("div"),l=b("span"),l.textContent=`${i[3].text}`,c=R(),u=b("div"),f=b("small"),d=b("em"),x&&x.c(),h=R(),Z.c(),p=R(),m=b("div"),g=b("div"),_=R(),S=b("div"),v(r,"class","icon svelte-n90cbf"),v(a,"class","text"),v(n,"class","name-container svelte-n90cbf"),v(d,"class","description-container svelte-n90cbf"),v(t,"class","filter"),v(g,"class","icon svelte-n90cbf"),v(S,"class","icon svelte-n90cbf"),v(m,"class","context svelte-n90cbf"),v(e,"class","filter-container svelte-n90cbf")},m(Q,D){A(Q,e,D),y(e,t),y(t,n),y(n,r),y(n,o),y(n,a),y(a,l),y(t,c),y(t,u),y(u,f),y(f,d),x&&x.m(d,null),y(d,h),Z.m(d,null),y(e,p),y(e,m),y(m,g),y(m,_),y(m,S),k||(w=[H(s=i[4].call(null,r)),H(O=i[5].call(null,g)),Y(g,"click",i[10]),H(P=i[7].call(null,S)),Y(S,"click",i[11])],k=!0)},p(Q,[D]){Z.p(Q,D)},i:X,o:X,d(Q){Q&&T(e),x&&x.d(),Z.d(),k=!1,de(w)}}}function pN(i,e,t){let n,r=Fe(),s=Ye("filterStore"),{filters:o}=s;ke(i,o,O=>t(12,n=O));let{id:a}=e,l=n.get(a).filter,c=O=>{switch(l.type){case 0:return(0,vs.setIcon)(O,"sliders-horizontal");case 1:return(0,vs.setIcon)(O,"search");case 2:return(0,vs.setIcon)(O,"list")}},u=O=>{new vs.ExtraButtonComponent(O).setIcon("pencil")},f=()=>{let O=new Qh(l);O.onClose=()=>{O.canceled||(s.update(l.id,O.filter),r("edit"))},O.open()},d=O=>{new vs.ExtraButtonComponent(O).setIcon("trash")},h=O=>{(0,vs.setIcon)(O,"alert-triangle")},p=O=>{(0,vs.setIcon)(O,"package-search")},m=()=>f(),g=()=>r("deleted",a);return i.$$set=O=>{"id"in O&&t(0,a=O.id)},[a,r,o,l,c,u,f,d,h,p,m,g]}var mO=class extends ne{constructor(e){super(),re(this,e,pN,hN,ie,{id:0},cN)}},XP=mO;function mN(i){se(i,"svelte-1l1v7ik","section.svelte-1l1v7ik{padding:0.4em;overflow-y:auto;height:auto;width:100%}section.inline.svelte-1l1v7ik{display:flex;justify-content:space-between;flex-flow:row;gap:0.5rem}")}function YP(i,e,t){let n=i.slice();return n[10]=e[t],n}function gN(i){let e,t;return e=new XP({props:{id:i[1].id}}),e.$on("deleted",i[9]),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p(n,r){let s={};r&2&&(s.id=n[1].id),e.$set(s)},i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function ON(i){let e,t=[],n=new Map,r,s,o,a,l=fe(i[1].nested.filter(i[7])),c=u=>u[10].id;for(let u=0;u{o[u]=null}),Te(),t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),$(t,1),t.m(n.parentNode,n))},i(l){r||($(t),r=!0)},o(l){V(t),r=!1},d(l){l&&T(n),o[e].d(l)}}}var gO=300;function yN(i,e,t){let{layout:n}=e,{block:r}=e,{inline:s=!1}=e,o=Fe();function a(h){r.type=="nested"&&t(1,r.nested=h.detail.items,r)}function l(h){r.type=="nested"&&t(1,r.nested=h.detail.items,r),t(0,n=[...n]),o("update")}let c=h=>{r.type!="filter"&&(t(1,r.nested=r.nested.filter(p=>p.id!=h),r),t(0,n=[...n]),o("update"))},u=h=>h.id!==Gl,f=h=>c(h.detail),d=h=>o("deleted",h.detail);return i.$$set=h=>{"layout"in h&&t(0,n=h.layout),"block"in h&&t(1,r=h.block),"inline"in h&&t(2,s=h.inline)},[n,r,s,o,a,l,c,u,f,d]}var Rh=class extends ne{constructor(e){super(),re(this,e,yN,vN,ie,{layout:0,block:1,inline:2},mN)}},HP=Rh;var Jc=require("obsidian");function GP(i,e,t){let n=i.slice();return n[11]=e[t],n}function KP(i){let e,t;return e=new HP({props:{layout:i[0],block:i[11],inline:!0}}),e.$on("update",i[8]),{c(){ye(e.$$.fragment)},m(n,r){Oe(e,n,r),t=!0},p(n,r){let s={};r&1&&(s.layout=n[0]),r&1&&(s.block=n[11]),e.$set(s)},i(n){t||($(e.$$.fragment,n),t=!0)},o(n){V(e.$$.fragment,n),t=!1},d(n){ve(e,n)}}}function JP(i){let e,t,n=fe(i[0]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){for(let o=0;ot(7,r=p));let l=Fe();Vi("filterStore",s),a.subscribe(()=>{n&&t(0,n=[...n])});let c=p=>{new Jc.Setting(p).setName("Restore Default Layout").addExtraButton(m=>{m.setIcon("reset").onClick(()=>{s.resetLayout(!0)})})},u=p=>{new Jc.Setting(p).setName("Add New Filter").addExtraButton(m=>{m.setIcon("plus-circle").onClick(()=>{let g=xt(),O={...ig,id:g};n.push({type:"nested",id:xt(),nested:[{type:"filter",id:g}]}),s.add(O)})})},f=p=>{new Jc.ButtonComponent(p).setButtonText("Cancel").setCta()},d=()=>l("update",n),h=()=>l("cancel");return i.$$set=p=>{"filterStore"in p&&t(6,s=p.filterStore)},i.$$.update=()=>{i.$$.dirty&128&&t(0,n=ci(r)),i.$$.dirty&1&&l("update",n)},[n,o,l,c,u,f,s,r,d,h]}var OO=class extends ne{constructor(e){super(),re(this,e,_N,bN,ie,{filterStore:6})}},e4=OO;var Fn=require("obsidian");var n4=require("obsidian");function wN(i){se(i,"svelte-1uki7d6",".draggable-fields.svelte-1uki7d6{margin:0 1rem}")}function t4(i,e,t){let n=i.slice();return n[8]=e[t],n}function i4(i,e){let t,n,r,s,o,a=X,l,c;return{key:i,first:null,c(){t=b("div"),n=b("div"),s=R(),v(n,"class","draggable-field"),this.first=t},m(u,f){A(u,t,f),y(t,n),y(t,s),l||(c=H(r=e[3].call(null,n,e[8])),l=!0)},p(u,f){e=u,r&&Ge(r.update)&&f&1&&r.update.call(null,e[8])},r(){o=t.getBoundingClientRect()},f(){Dr(t),a()},a(){a(),a=Ar(t,o,Nr,{duration:vO})},d(u){u&&T(t),l=!1,c()}}}function kN(i){let e,t=[],n=new Map,r,s,o,a=fe(i[0].filter(i[6])),l=c=>c[8].id;for(let c=0;cd.field))}let l=(f,d)=>{let{field:h,id:p}=d;new n4.Setting(f).setName(h).addExtraButton(m=>m.setIcon("trash").onClick(()=>{t(0,s=s.filter(g=>g.id!=p)),r("update",s.map(g=>g.field))}))},c=xt(),u=({id:f})=>f!=Gl;return i.$$set=f=>{"fields"in f&&t(5,n=f.fields)},[s,o,a,l,c,n,u]}var yO=class extends ne{constructor(e){super(),re(this,e,SN,kN,ie,{fields:5},wN)}},bO=yO;function r4(i){let e,t,n,r,s=[PN,xN],o=[];function a(l,c){return l[0].type==0?0:l[0].type==2?1:-1}return~(e=a(i,-1))&&(t=o[e]=s[e](i)),{c(){t&&t.c(),n=tt()},m(l,c){~e&&o[e].m(l,c),A(l,n,c),r=!0},p(l,c){let u=e;e=a(l,c),e===u?~e&&o[e].p(l,c):(t&&(Ee(),V(o[u],1,1,()=>{o[u]=null}),Te()),~e?(t=o[e],t?t.p(l,c):(t=o[e]=s[e](l),t.c()),$(t,1),t.m(n.parentNode,n)):t=null)},i(l){r||($(t),r=!0)},o(l){V(t),r=!1},d(l){l&&T(n),~e&&o[e].d(l)}}}function xN(i){let e,t,n,r,s,o,a;return r=new bO({props:{fields:i[0].options}}),r.$on("update",i[17]),{c(){e=b("div"),n=R(),ye(r.$$.fragment)},m(l,c){A(l,e,c),A(l,n,c),Oe(r,l,c),s=!0,o||(a=H(t=i[9].call(null,e)),o=!0)},p(l,c){let u={};c&1&&(u.fields=l[0].options),r.$set(u)},i(l){s||($(r.$$.fragment,l),s=!0)},o(l){V(r.$$.fragment,l),s=!1},d(l){l&&(T(e),T(n)),ve(r,l),o=!1,a()}}}function PN(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[11].call(null,e)),n=!0)},p:X,i:X,o:X,d(s){s&&T(e),n=!1,r()}}}function s4(i){let e,t,n,r,s,o,a,l,c;e=new bO({props:{fields:i[0].fields}}),e.$on("update",i[16]);let u=!i[0].derive&&r4(i);return{c(){ye(e.$$.fragment),t=R(),n=b("div"),s=R(),u&&u.c(),o=tt()},m(f,d){Oe(e,f,d),A(f,t,d),A(f,n,d),A(f,s,d),u&&u.m(f,d),A(f,o,d),a=!0,l||(c=H(r=i[8].call(null,n)),l=!0)},p(f,d){let h={};d&1&&(h.fields=f[0].fields),e.$set(h),f[0].derive?u&&(Ee(),V(u,1,1,()=>{u=null}),Te()):u?(u.p(f,d),d&1&&$(u,1)):(u=r4(f),u.c(),$(u,1),u.m(o.parentNode,o))},i(f){a||($(e.$$.fragment,f),$(u),a=!0)},o(f){V(e.$$.fragment,f),V(u),a=!1},d(f){f&&(T(t),T(n),T(s),T(o)),ve(e,f),u&&u.d(f),l=!1,c()}}}function CN(i){let e,t,n,r,s,o,a,l,c,u,f,d,h=i[0],p,m,g,O,_,S,P,k=s4(i);return{c(){e=b("div"),n=R(),r=b("div"),o=R(),a=b("div"),c=R(),u=b("div"),d=R(),k.c(),p=R(),m=b("div"),g=b("div"),v(m,"class","cancel-button")},m(w,x){A(w,e,x),A(w,n,x),A(w,r,x),A(w,o,x),A(w,a,x),A(w,c,x),A(w,u,x),A(w,d,x),k.m(w,x),A(w,p,x),A(w,m,x),y(m,g),_=!0,S||(P=[H(t=i[2].call(null,e)),H(s=i[3].call(null,r)),H(l=i[4].call(null,a)),H(f=i[6].call(null,u)),H(O=i[12].call(null,g)),Y(g,"click",i[18])],S=!0)},p(w,[x]){x&1&&ie(h,h=w[0])?(Ee(),V(k,1,1,X),Te(),k=s4(w),k.c(),$(k,1),k.m(p.parentNode,p)):k.p(w,x)},i(w){_||($(k),_=!0)},o(w){V(k),_=!1},d(w){w&&(T(e),T(n),T(r),T(o),T(a),T(c),T(u),T(d),T(p),T(m)),k.d(w),S=!1,de(P)}}}function EN(i,e,t){let n,{filter:r}=e,{original:s}=e,o=Fe(),a=w=>{new Fn.Setting(w).setName("Reset").addExtraButton(x=>{x.setIcon("reset").onClick(()=>{t(0,r=ci(s))})})},l=w=>{new Fn.Setting(w).setName("Filter Type").addDropdown(x=>{x.addOption("0","Range"),x.addOption("2","Options"),x.addOption("1","Search"),x.setValue(`${r.type}`).onChange(C=>{switch(t(0,r.type=Number(C),r),r.type){case 0:t(0,r.options=[0,0],r);break;case 1:t(0,r.options="",r);break;case 2:t(0,r.options=[],r);break}})})},c=w=>{new Fn.Setting(w).setName("Display Text").addText(x=>{x.setValue(r.text).onChange(C=>t(0,r.text=C,r))})},u=$e(""),f;ke(i,u,w=>t(15,n=w));let d=w=>{let x=r,C;new Fn.Setting(w).setName("Fields").addText(M=>{C=M.onChange(Z=>Ke(u,n=Z,n))}).addExtraButton(M=>t(14,f=M.setIcon("plus-circle").onClick(()=>{if(x.fields.includes(n)){new Fn.Notice(createFragment(Z=>{Z.createSpan({text:"The field "}),Z.createEl("code",{text:n}),Z.createSpan(" has already been added to the options for this filter.")}));return}x.fields=[...x.fields,n],t(0,r={...r}),Ke(u,n="",n),C.setValue(n)})))},h=w=>{t(0,r.fields=w,r)},p=w=>{r.type!=1&&new Fn.Setting(w).setName("Derive Options").addToggle(x=>{x.setValue(r.derive).onChange(C=>t(0,r.derive=C,r))})},m=w=>{new Fn.Setting(w).setName("Options").addText(x=>x).addExtraButton(x=>x.setIcon("plus-circle"))},g=w=>{t(0,r.options=w,r)},O=w=>{if(r.type!=0)return;let x=r;new Fn.Setting(w).setName("Options").addText(C=>C.setValue(`${x.options[0]}`).onChange(M=>x.options[0]=Number(M)).inputEl.type="number").addText(C=>C.setValue(`${x.options[1]}`).onChange(M=>x.options[1]=Number(M)).inputEl.type="number")},_=w=>{new Fn.ButtonComponent(w).setButtonText("Cancel").setCta()},S=w=>h(w.detail),P=w=>g(w.detail),k=()=>o("cancel");return i.$$set=w=>{"filter"in w&&t(0,r=w.filter),"original"in w&&t(13,s=w.original)},i.$$.update=()=>{i.$$.dirty&49152&&f?.setDisabled(!n?.length),i.$$.dirty&1&&o("update",r)},[r,o,a,l,c,u,d,h,p,m,g,O,_,s,f,n,S,P,k]}var _O=class extends ne{constructor(e){super(),re(this,e,EN,CN,ie,{filter:0,original:13})}},o4=_O;var Mh=class extends wO.Modal{constructor(t,n){super(app);this.filterStore=n;te(this,"canceled",!1);te(this,"reset",!1);te(this,"layout");this.layout=ci(t)}onOpen(){this.titleEl.setText("Edit Filters");let t=new e4({target:this.contentEl,props:{filterStore:this.filterStore}});t.$on("update",n=>{this.layout=ci(n.detail)}),t.$on("cancel",()=>{this.canceled=!0,this.close()})}},Qh=class extends wO.Modal{constructor(t){super(app);this.original=t;te(this,"canceled",!1);te(this,"filter");this.filter=ci(t)}onOpen(){this.titleEl.setText("Edit Filter");let t=new o4({target:this.contentEl,props:{filter:this.filter,original:this.original}});t.$on("update",n=>{this.filter=n.detail}),t.$on("cancel",n=>{this.canceled=!0,this.close()})}};var Q5=xp(S5());var x5={$ref:"#/definitions/BuilderState",$schema:"http://json-schema.org/draft-07/schema#",definitions:{BuilderState:{additionalProperties:!1,properties:{filters:{additionalProperties:!1,properties:{filters:{items:{$ref:"#/definitions/Filter"},type:"array"},layout:{$ref:"#/definitions/FilterLayout"}},required:["layout","filters"],type:"object"},headers:{items:{$ref:"#/definitions/TableHeaderState"},type:"array"},showParty:{type:"boolean"},showXP:{type:"boolean"},sidebarIcon:{type:"boolean"}},required:["sidebarIcon","showXP","showParty"],type:"object"},Filter:{additionalProperties:!1,properties:{derive:{type:"boolean"},fields:{items:{type:"string"},type:"array"},id:{type:"string"},options:{type:["string","number","boolean","integer","object","array"]},text:{type:"string"},type:{type:"number"}},required:["derive","fields","id","options","text","type"],type:"object"},FilterLayout:{items:{$ref:"#/definitions/NestedFilterLayoutItem"},type:"array"},FilterLayoutItem:{additionalProperties:!1,properties:{id:{type:"string"},type:{const:"filter",type:"string"}},required:["id","type"],type:"object"},NestedFilterLayoutItem:{additionalProperties:!1,properties:{id:{type:"string"},nested:{items:{$ref:"#/definitions/FilterLayoutItem"},type:"array"},type:{const:"nested",type:"string"}},required:["id","nested","type"],type:"object"},SortFunctions:{enum:[0,1,2],type:"number"},TableHeaderState:{additionalProperties:!1,properties:{field:{type:"string"},func:{type:"string"},text:{type:"string"},type:{$ref:"#/definitions/SortFunctions"}},required:["text","field","type"],type:"object"}}};function SL(i){se(i,"svelte-rwomh",".filters.svelte-rwomh{margin:1rem 0}.table-header.svelte-rwomh{display:flex;gap:0.25rem}.has-icon.svelte-rwomh{display:flex;align-items:center}table.svelte-rwomh{width:100%}")}function P5(i,e,t){let n=i.slice();return n[26]=e[t],n}function C5(i,e,t){let n=i.slice();return n[29]=e[t],n}function E5(i){let e,t,n=[],r=new Map,s,o,a,l=fe(i[4]),c=h=>h[29].text;for(let h=0;hV(f[h],1,1,()=>{f[h]=null});return{c(){e=b("table"),t=b("thead");for(let h=0;h{a=null}),Te());let u={};c[0]&1&&(u.slice=l[0]),c[0]&4&&(u.page=l[2]),c[0]&8&&(u.pages=l[3]),s.$set(u)},i(l){o||($(t.$$.fragment,l),$(a),$(s.$$.fragment,l),o=!0)},o(l){V(t.$$.fragment,l),V(a),V(s.$$.fragment,l),o=!1},d(l){l&&(T(e),T(n),T(r)),ve(t),a&&a.d(l),ve(s,l)}}}function EL(i,e,t){let n,r,s,o,a,l,c=Ye("table");ke(i,c,E=>t(21,s=E));let{sortDir:u,allHeaders:f}=c;ke(i,u,E=>t(5,l=E)),ke(i,f,E=>t(4,a=E));let d=Ye("filters"),{filtered:h,layout:p}=d;ke(i,h,E=>t(1,r=E)),ke(i,p,E=>t(22,o=E));let m=Ye("plugin"),g=50,O=E=>{(0,uo.setIcon)(E,"chevron-up")},_=E=>{(0,uo.setIcon)(E,"chevron-down")},S=E=>{let j=new uo.Menu;j.addItem(z=>{z.setTitle("Edit Headers").onClick(()=>{k()})}).addItem(z=>{z.setTitle("Edit Filters").onClick(()=>{P()})}).addSeparator().addItem(z=>{z.setTitle("Export").onClick(()=>{let q=createEl("a"),G=new Blob([JSON.stringify(m.data.builder)],{type:"json"}),U=URL.createObjectURL(G);q.href=U,q.download="initiative-tracker-encounter-builder.json",q.click()})}).addItem(z=>{z.setTitle("Import").onClick(()=>{let G=new Q5.default().compile(x5),U=createEl("input",{attr:{type:"file",name:"builder_state",accept:".json"}});U.onchange=async()=>{let{files:le}=U;if(!le.length)return;let xe=new FileReader;xe.onload=async ue=>{if(typeof ue.target.result=="string"){let B;try{B=JSON.parse(ue.target.result)}catch{new uo.Notice("There was an issue parsing the file as JSON.")}G(B)?(m.data.builder={...B},await m.saveSettings(),d.resetLayout()):(console.log(...G.errors.map(J=>J.message)),new uo.Notice("This file does not match the builder state schema."))}},xe.readAsText(le[0])},U.click()})}),j.showAtMouseEvent(E.detail)},P=()=>{let E=new Mh(o,d);E.open(),E.onClose=()=>{E.canceled||Ke(p,o=E.layout,o)}},k=()=>{let E=new Dh(s.map(j=>j.toState()));E.open(),E.onClose=()=>{if(!E.canceled){if(E.reset){c.resetToDefault();return}c.setHeadersFromState(E.headers)}}},w=1,x=E=>S(E),C=E=>{c.sort(E)},M=E=>t(0,g=E.detail),Z=()=>t(2,w=w-1),Q=()=>t(2,w=Math.min(w+1,n)),D=E=>t(2,w=E.detail);return i.$$.update=()=>{i.$$.dirty[0]&3&&t(3,n=Math.ceil(r.length/g))},[g,r,w,n,a,l,c,u,f,h,p,O,_,S,x,C,M,Z,Q,D]}var ty=class extends ne{constructor(e){super(),re(this,e,EL,CL,ie,{},SL,[-1,-1])}},R5=ty;var Ft=require("obsidian");var kr=require("obsidian");function TL(i){se(i,"svelte-17aw8iw",".encounter-creature-container.svelte-17aw8iw{display:grid;align-items:center;justify-content:center;grid-template-columns:min-content 1fr 10% 10% auto auto auto;gap:0.5rem}.encounter-creature.svelte-17aw8iw{display:flex;align-items:center;gap:0.5rem}.encounter-creature-context.svelte-17aw8iw{text-align:right}.encounter-creature-controls.svelte-17aw8iw{display:flex;align-items:center;gap:0.5rem}input.svelte-17aw8iw{text-align:center;width:40px}.contains-icon.svelte-17aw8iw{display:flex;align-items:center}")}function M5(i,e,t){let n=i.slice();return n[28]=e[t],n}function I5(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon svelte-17aw8iw"),v(e,"aria-label",t="This creature is hidden.")},m(o,a){A(o,e,a),r||(s=H(n=i[12].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function N5(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon svelte-17aw8iw"),v(e,"aria-label",t="This creature is an ally.")},m(o,a){A(o,e,a),r||(s=H(n=i[14].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function j5(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon svelte-17aw8iw"),v(e,"aria-label",t=`${i[1]>1?"These creatures are":"This creature is"} significantly under the average party level and might not contribute much to the fight.`)},m(o,a){A(o,e,a),r||(s=H(n=i[15].call(null,e)),r=!0)},p(o,a){a&2&&t!==(t=`${o[1]>1?"These creatures are":"This creature is"} significantly under the average party level and might not contribute much to the fight.`)&&v(e,"aria-label",t)},d(o){o&&T(e),r=!1,s()}}}function Z5(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon svelte-17aw8iw"),v(e,"aria-label",t=`${i[1]>1?"These creatures are":"This creature is"} significantly over the average party level and might prove a challenge.`)},m(o,a){A(o,e,a),r||(s=H(n=i[16].call(null,e)),r=!0)},p(o,a){a&2&&t!==(t=`${o[1]>1?"These creatures are":"This creature is"} significantly over the average party level and might prove a challenge.`)&&v(e,"aria-label",t)},d(o){o&&T(e),r=!1,s()}}}function z5(i){let e,t,n=i[28]+"",r;return{c(){e=b("div"),t=b("span"),r=ae(n),v(e,"class","encounter-creature-context svelte-17aw8iw")},m(s,o){A(s,e,o),y(e,t),y(t,r)},p(s,o){o&5&&n!==(n=s[28]+"")&&me(r,n)},d(s){s&&T(e)}}}function AL(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m=i[0].name+"",g,O,_,S,P,k,w,x,C,M,Z,Q,D,E,j,z,q,G,U,le,xe,ue=i[0].hidden&&I5(i),B=i[0].friendly&&N5(i),J=i[4]&&j5(i),pe=i[3]&&Z5(i),Re=fe(i[7].getAdditionalCreatureDifficultyStats(i[0],i[2])),oe=[];for(let we=0;wet(18,o=z));let{average:c}=l;ke(i,c,z=>t(19,a=z));let u=Ye("plugin"),f=Si(u),d=z=>{new kr.ExtraButtonComponent(z).setIcon("minus-circle")},h=z=>{new kr.ExtraButtonComponent(z).setIcon("plus-with-circle")},p=z=>{new kr.ExtraButtonComponent(z).setIcon("trash-2")},m=z=>{new kr.ExtraButtonComponent(z).setIcon(Jn)},g=z=>{(0,kr.setIcon)(z,Jn)},O=z=>{new kr.ExtraButtonComponent(z).setIcon(er)},_=z=>{(0,kr.setIcon)(z,er)},{count:S}=e,{creature:P}=e,k=z=>(0,kr.setIcon)(z,"baby"),w=z=>(0,kr.setIcon)(z,"skull"),x=()=>{u.openCombatant(Ne.from(P))},C=()=>ii.remove(P);function M(){S=pi(this.value),t(1,S)}let Z=z=>ii.set(P,Number(z.currentTarget.value)),Q=()=>ii.add(P),D=()=>t(0,P.hidden=!P.hidden,P),E=()=>{t(0,P.friendly=!P.friendly,P),ii.update(P)},j=()=>ii.delete(P);return i.$$set=z=>{"count"in z&&t(1,S=z.count),"creature"in z&&t(0,P=z.creature)},i.$$.update=()=>{i.$$.dirty&524289&&t(4,n="cr"in P&&P.cr&&hi(P.cr)a+3),i.$$.dirty&262144&&t(2,s=o.filter(z=>z.enabled).map(z=>z.level))},[P,S,s,r,n,l,c,f,d,h,p,m,g,O,_,k,w,x,o,a,C,M,Z,Q,D,E,j]}var iy=class extends ne{constructor(e){super(),re(this,e,DL,AL,ie,{count:1,creature:0},TL)}},q5=iy;function QL(i){se(i,"svelte-1s1acwo",".encounter-name.svelte-1s1acwo{display:flex;align-items:center}.encounter-header.svelte-1s1acwo{display:flex;align-items:center;justify-content:space-between}.encounter-creatures.svelte-1s1acwo{display:flex;gap:0.5rem;flex-flow:column nowrap}.encounter-header.svelte-1s1acwo .is-disabled{cursor:not-allowed}.encounter-controls.svelte-1s1acwo{display:flex;gap:0.5rem;align-items:center}")}function L5(i,e,t){let n=i.slice();return n[31]=e[t][0],n[32]=e[t][1],n}function RL(i){let e,t,n,r,s,o,a;return{c(){e=b("h5"),t=ae(i[1]),n=R(),r=b("div"),v(e,"class","built-encounter")},m(l,c){A(l,e,c),y(e,t),A(l,n,c),A(l,r,c),o||(a=[H(s=i[11].call(null,r)),Y(r,"click",i[26])],o=!0)},p(l,c){c[0]&2&&me(t,l[1])},d(l){l&&(T(e),T(n),T(r)),o=!1,de(a)}}}function ML(i){let e,t,n,r,s,o,a,l,c;return{c(){e=b("input"),t=R(),n=b("div"),s=R(),o=b("div"),v(e,"type","text"),v(e,"placeholder",i[1])},m(u,f){A(u,e,f),Xe(e,i[2]),A(u,t,f),A(u,n,f),A(u,s,f),A(u,o,f),l||(c=[Y(e,"input",i[25]),H(r=i[12].call(null,n)),Y(n,"click",i[8]),H(a=i[14].call(null,o)),Y(o,"click",i[9])],l=!0)},p(u,f){f[0]&2&&v(e,"placeholder",u[1]),f[0]&4&&e.value!==u[2]&&Xe(e,u[2])},d(u){u&&(T(e),T(t),T(n),T(s),T(o)),l=!1,de(c)}}}function IL(i){let e,t,n=fe(i[0]),r=[];for(let o=0;oV(r[o],1,1,()=>{r[o]=null});return{c(){e=b("div");for(let o=0;o{j[U]=null}),Te(),k=j[P],k?k.p(q,G):(k=j[P]=E[P](q),k.c()),$(k,1),k.m(w.parentNode,w))},i(q){x||($(k),x=!0)},o(q){V(k),x=!1},d(q){q&&(T(e),T(S),T(w)),D.d(),j[P].d(q),C=!1,de(M)}}}function ZL(i,e,t){let n,r,s,o,a,l;ke(i,ii,U=>t(24,r=U));let{players:c}=ii;ke(i,c,U=>t(28,s=U));let u=Ye("plugin"),f=$e("Encounter");ke(i,f,U=>t(1,o=U));let d=$e("");ke(i,d,U=>t(2,a=U));let h=$e(!1);ke(i,h,U=>t(3,l=U));let p=()=>{Ke(h,l=!1,l),Ke(f,o=a.length?a:o,o),Ke(d,a="",a)},m=()=>{Ke(h,l=!1,l),Ke(d,a="",a)},g=u.data.rollHP,O,_=U=>{t(20,O=new Ft.ExtraButtonComponent(U).setIcon(ls).onClick(async()=>{u.view||await u.addTrackerView();let le=u.view,xe=[],ue=[];for(let[B,J]of n){let pe=Ne.from(B),Re=Math.max(isNaN(Number(J))?1:Number(J),1);xe.push(...[...Array(Re).keys()].map(oe=>Ne.new(pe)))}for(let B of[...s.map(J=>u.getPlayerByName(J.name)??Ne.from(J)),...xe])ue.push(B.toJSON());he.new(u,{creatures:ue,name:o,round:1,state:!1,logFile:null,newLog:!0,roll:!0,rollHP:g}),u.app.workspace.revealLeaf(le.leaf)}))},S=U=>{new Ft.ExtraButtonComponent(U).setIcon("pencil")},P,k=U=>{t(21,P=new Ft.ExtraButtonComponent(U).setIcon("save"))},w=()=>{let U=new Ft.Modal(app);U.titleEl.setText("Save Encounter");let le=o!="Encounter"?o:`Encounter ${Object.keys(u.data.encounters).length}`;new Ft.Setting(U.contentEl).setName("Encounter Name").addText(ue=>{ue.setPlaceholder(le).onChange(B=>le=B)});let xe=()=>{try{let ue=[...[...s].map(B=>Ne.from(B)),...[...r.entries()].map(B=>[...Array(B[1]).keys()].map(()=>Ne.from(B[0]))).flat()];u.addEncounter(le,{creatures:[...ue.map(B=>B.toJSON())],state:!1,name:le,round:1,roll:!0,rollHP:u.data.rollHP,logFile:null,timestamp:Date.now()}),u.saveSettings(),new Ft.Notice(`Encounter "${le}" saved.`),U.close()}catch{new Ft.Notice("There was an issue saving the encounter.")}};new Ft.Setting(U.contentEl).addButton(ue=>ue.setButtonText("Save").onClick(()=>{if(le in u.data.encounters){let B=new Ft.Modal(app);B.titleEl.setText("Are you sure?"),B.contentEl.createEl("p",{text:"This will overwrite an existing encounter. Are you sure?"}),new Ft.Setting(B.contentEl).addButton(J=>J.setButtonText("Overwrite").onClick(()=>{B.close(),xe()})).addExtraButton(J=>J.setIcon("cross").onClick(()=>{B.close()})),B.open()}else xe()})),U.open()},x=U=>{new Ft.ExtraButtonComponent(U).setIcon("cross-in-box")},C,M=U=>{t(22,C=new Ft.ExtraButtonComponent(U).setIcon("copy"))},Z,Q=U=>{t(23,Z=new Ft.ExtraButtonComponent(U).setIcon("upload").setTooltip("Load Encounter"))},D=U=>{let le=new Ft.Menu;for(let xe of Object.values(u.data.encounters))le.addItem(ue=>{ue.setTitle(xe.name).onClick(()=>{Ke(f,o=xe.name,o),ii.empty(),c.empty();for(let B of xe.creatures)B.player?c.addFromState(B):ii.add(Ne.fromJSON(B,u))})});le.showAtMouseEvent(U)},E=U=>{new Ft.ExtraButtonComponent(U).setIcon("eraser").setTooltip("Clear Encounter")},j=async()=>{let U={};o?.length&&(U.name=o),s?.length&&(U.players=s.filter(le=>le.enabled).map(le=>le.name)),r?.size&&(U.creatures=[...r.entries()].map(([le,xe])=>({[Number(xe)]:`${le.name}${le.friendly?", friendly":""}${le.hidden?", hidden":""}`})));try{await navigator.clipboard.writeText(`\`\`\`encounter ${(0,Ft.stringifyYaml)(U)}\`\`\``),new Ft.Notice("Encounter saved to clipboard")}catch(le){console.error(le),new Ft.Notice("Could not save encounter, please check console for errors")}};function z(){a=this.value,d.set(a)}let q=()=>Ke(h,l=!0,l),G=()=>{ii.empty(),Ke(f,o="Encounter",o)};return i.$$.update=()=>{i.$$.dirty[0]&16777216&&t(0,n=[...r.entries()]),i.$$.dirty[0]&1048577&&O&&(n.length?(O.setDisabled(!1),O.setTooltip("Start Encounter")):(O.setDisabled(!0),O.setTooltip(""))),i.$$.dirty[0]&18874368&&P?.setDisabled(r.size==0),i.$$.dirty[0]&4194305&&C&&(n.length?(C.setDisabled(!1),C.setTooltip("Copy Encounter Block")):(C.setDisabled(!0),C.setTooltip(""))),i.$$.dirty[0]&8388608&&Z?.setDisabled(Object.keys(u.data.encounters).length==0)},[n,o,a,l,c,f,d,h,p,m,_,S,k,w,x,M,Q,D,E,j,O,P,C,Z,r,z,q,G]}var ny=class extends ne{constructor(e){super(),re(this,e,ZL,jL,ie,{},QL,[-1,-1])}},F5=ny;function zL(i){se(i,"svelte-r6lzam","details.svelte-r6lzam>summary.svelte-r6lzam.svelte-r6lzam{outline:none;display:flex !important;align-items:center;justify-content:space-between;gap:0.25rem;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-r6lzam>summary.svelte-r6lzam.svelte-r6lzam::-webkit-details-marker,details.svelte-r6lzam>summary.svelte-r6lzam.svelte-r6lzam::marker{display:none !important}details.svelte-r6lzam>summary.svelte-r6lzam>.collapser.svelte-r6lzam{position:relative;display:flex;align-items:center}details.svelte-r6lzam>summary .collapser.svelte-r6lzam>.handle.svelte-r6lzam{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:var(--admonition-details-icon);mask-image:var(--admonition-details-icon);width:20px;height:20px}details[open].svelte-r6lzam>summary .collapser.svelte-r6lzam>.handle.svelte-r6lzam{transform:rotate(90deg)}details.svelte-r6lzam>summary.svelte-r6lzam.svelte-r6lzam{border-bottom:1px solid var(--background-modifier-border)}details.svelte-r6lzam>summary.svelte-r6lzam.svelte-r6lzam{border-bottom:1px solid var(--background-modifier-border)}")}var qL=i=>({}),B5=i=>({}),LL=i=>({}),V5=i=>({});function $L(i){let e,t,n,r,s,o,a,l,c=i[2].title,u=Gt(c,i,i[1],V5),f=i[2].content,d=Gt(f,i,i[1],B5);return{c(){e=b("details"),t=b("summary"),u&&u.c(),n=R(),r=b("div"),r.innerHTML='
',s=R(),d&&d.c(),v(r,"class","collapser svelte-r6lzam"),v(t,"class","svelte-r6lzam"),e.open=i[0],v(e,"class","svelte-r6lzam")},m(h,p){A(h,e,p),y(e,t),u&&u.m(t,null),y(t,n),y(t,r),y(e,s),d&&d.m(e,null),o=!0,a||(l=Y(e,"toggle",i[3]),a=!0)},p(h,[p]){u&&u.p&&(!o||p&2)&&Jt(u,c,h,h[1],o?Kt(c,h[1],p,LL):ei(h[1]),V5),d&&d.p&&(!o||p&2)&&Jt(d,f,h,h[1],o?Kt(f,h[1],p,qL):ei(h[1]),B5),(!o||p&1)&&(e.open=h[0])},i(h){o||($(u,h),$(d,h),o=!0)},o(h){V(u,h),V(d,h),o=!1},d(h){h&&T(e),u&&u.d(h),d&&d.d(h),a=!1,l()}}}function FL(i,e,t){let{$$slots:n={},$$scope:r}=e,{open:s}=e;function o(a){ht.call(this,i,a)}return i.$$set=a=>{"open"in a&&t(0,s=a.open),"$$scope"in a&&t(1,r=a.$$scope)},[s,r,n,o]}var ry=class extends ne{constructor(e){super(),re(this,e,FL,$L,ie,{open:0},zL)}},hp=ry;function BL(i){se(i,"svelte-1x58p02",".title-container.svelte-1x58p02{display:flex;flex-flow:column nowrap;gap:0.1rem}.title.svelte-1x58p02{margin-bottom:0}.content.svelte-1x58p02{display:flex;flex-flow:column nowrap;gap:0.25rem}.filtered.svelte-1x58p02{font-size:smaller;color:var(--text-muted)}.xp-container.svelte-1x58p02{margin-left:auto}.xp.svelte-1x58p02{display:flex;gap:1rem}.thresholds.svelte-1x58p02{display:flex;flex-flow:column;gap:0.5rem}.experience-amount.svelte-1x58p02{margin-left:auto}.encounter-difficulty.svelte-1x58p02{display:flex;flex-flow:column nowrap;gap:0.5rem;margin-bottom:1rem}.container.svelte-1x58p02{display:flex;flex-flow:column nowrap}.header.svelte-1x58p02{text-transform:uppercase;font-weight:bolder}")}function W5(i,e,t){let n=i.slice();return n[10]=e[t],n}function X5(i,e,t){let n=i.slice();return n[10]=e[t],n}function Y5(i,e,t){let n=i.slice();return n[15]=e[t],n}function U5(i){let e,t=i[5].displayName+"",n,r;return{c(){e=ae("("),n=ae(t),r=ae(")")},m(s,o){A(s,e,o),A(s,n,o),A(s,r,o)},p:X,d(s){s&&(T(e),T(n),T(r))}}}function H5(i){let e,t,n,r,s=i[2]>1?"s":"",o;return{c(){e=b("span"),t=ae("Filtering "),n=ae(i[2]),r=ae(" allied creature"),o=ae(s),v(e,"class","filtered svelte-1x58p02")},m(a,l){A(a,e,l),y(e,t),y(e,n),y(e,r),y(e,o)},p(a,l){l&4&&me(n,a[2]),l&4&&s!==(s=a[2]>1?"s":"")&&me(o,s)},d(a){a&&T(e)}}}function VL(i){let e,t,n,r,s,o=i[1].data.rpgSystem!="dnd5e"&&U5(i),a=i[2]>0&&H5(i);return{c(){e=b("div"),t=b("h5"),t.textContent="Experience",n=R(),r=b("span"),o&&o.c(),s=R(),a&&a.c(),v(t,"class","title svelte-1x58p02"),v(e,"class","title-container svelte-1x58p02"),v(e,"slot","title")},m(l,c){A(l,e,c),y(e,t),y(e,n),y(e,r),o&&o.m(r,null),y(e,s),a&&a.m(e,null)},p(l,c){l[1].data.rpgSystem!="dnd5e"?o?o.p(l,c):(o=U5(l),o.c(),o.m(r,null)):o&&(o.d(1),o=null),l[2]>0?a?a.p(l,c):(a=H5(l),a.c(),a.m(e,null)):a&&(a.d(1),a=null)},d(l){l&&T(e),o&&o.d(),a&&a.d()}}}function G5(i){let e,t,n=i[15].label+"",r,s,o,a=i[15].value.toLocaleString()+"",l;return{c(){e=b("div"),t=b("strong"),r=ae(n),s=R(),o=b("span"),l=ae(a),v(t,"class","header svelte-1x58p02"),v(e,"class","adjusted container svelte-1x58p02")},m(c,u){A(c,e,u),y(e,t),y(t,r),y(e,s),y(e,o),y(o,l)},p(c,u){u&8&&n!==(n=c[15].label+"")&&me(r,n),u&8&&a!==(a=c[15].value.toLocaleString()+"")&&me(l,a)},d(c){c&&T(e)}}}function K5(i){let e,t,n=i[10].displayName+"",r,s,o,a=i[5].formatDifficultyValue(i[10].minValue,!0)+"",l,c,u;return{c(){e=b("div"),t=b("strong"),r=ae(n),s=R(),o=b("span"),l=ae(a),c=R(),v(t,"class","experience-name header svelte-1x58p02"),v(o,"class","experience-amount svelte-1x58p02"),v(e,"class",u="experience-threshold "+i[10].displayName.toLowerCase()+" container svelte-1x58p02")},m(f,d){A(f,e,d),y(e,t),y(t,r),y(e,s),y(e,o),y(o,l),y(e,c)},p(f,d){d&1&&n!==(n=f[10].displayName+"")&&me(r,n),d&1&&a!==(a=f[5].formatDifficultyValue(f[10].minValue,!0)+"")&&me(l,a),d&1&&u!==(u="experience-threshold "+f[10].displayName.toLowerCase()+" container svelte-1x58p02")&&v(e,"class",u)},d(f){f&&T(e)}}}function J5(i){let e,t=i[10].displayName+"",n,r,s,o=i[5].formatDifficultyValue(i[10].minValue,!0)+"",a,l;return{c(){e=b("h5"),n=ae(t),r=R(),s=b("span"),a=ae(o),l=R(),v(e,"class","experience-name"),v(s,"class","experience-amount svelte-1x58p02")},m(c,u){A(c,e,u),y(e,n),A(c,r,u),A(c,s,u),y(s,a),y(s,l)},p(c,u){u&1&&t!==(t=c[10].displayName+"")&&me(n,t),u&1&&o!==(o=c[5].formatDifficultyValue(c[10].minValue,!0)+"")&&me(a,o)},d(c){c&&(T(e),T(r),T(s))}}}function WL(i){let e,t,n,r,s,o,a,l=i[3].displayName+"",c,u,f,d,h,p=i[3].title+"",m,g,O,_=i[5].formatDifficultyValue(i[3].value)+"",S,P,k,w,x,C,M,Z=fe(i[3].intermediateValues),Q=[];for(let q=0;qt(7,o=h)),ke(i,ii,h=>t(8,a=h));let l=Ye("plugin"),c=l.data.builder.showXP,u=Si(l),f=0,d=()=>t(1,l.data.builder.showXP=!l.data.builder.showXP,l);return i.$$.update=()=>{if(i.$$.dirty&256&&t(6,n=new Map([...a.entries()].map(([h,p])=>h.friendly?[h,0]:[h,p]))),i.$$.dirty&324){t(2,f=0);for(let[h,p]of n)p===0&&t(2,f+=a.get(h)??0)}i.$$.dirty&128&&t(0,r=o.filter(h=>h.enabled).map(h=>h.level)),i.$$.dirty&65&&t(3,s=u.getEncounterDifficulty(n,r))},[r,l,f,s,c,u,n,o,a,d]}var sy=class extends ne{constructor(e){super(),re(this,e,YL,XL,ie,{},BL)}},eC=sy;var fo=require("obsidian");function UL(i){se(i,"svelte-wi0lrc",".players.svelte-wi0lrc.svelte-wi0lrc{display:flex;flex-flow:column;gap:0.25rem}.player.svelte-wi0lrc.svelte-wi0lrc{display:flex;justify-content:space-between;align-items:center}input.svelte-wi0lrc.svelte-wi0lrc{text-align:center;width:40px}.disabled.svelte-wi0lrc>.player-name.svelte-wi0lrc{text-decoration:line-through}.disabled.svelte-wi0lrc.svelte-wi0lrc{color:var(--text-faint)}.player-right.svelte-wi0lrc.svelte-wi0lrc{display:flex;align-items:center;gap:0.25rem}.add-player.svelte-wi0lrc.svelte-wi0lrc{display:flex;align-items:center;justify-content:flex-end}")}function tC(i,e,t){let n=i.slice();return n[21]=e[t],n[23]=t,n}function iC(i,e,t){let n=i.slice();return n[21]=e[t],n}function HL(i){let e;return{c(){e=b("h5"),e.textContent="Players",v(e,"class","player-header"),v(e,"slot","title")},m(t,n){A(t,e,n)},p:X,d(t){t&&T(e)}}}function GL(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[7].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function KL(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[8].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function JL(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[9].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function nC(i,e){let t,n,r=e[21].name+"",s,o,a,l,c=e[21].level+"",u,f,d,h,p,m;function g(P,k){return P[21].enabled?JL:KL}let O=g(e,-1),_=O(e);function S(){return e[14](e[21])}return{key:i,first:null,c(){t=b("div"),n=b("span"),s=ae(r),o=R(),a=b("div"),l=b("span"),u=ae(c),f=R(),d=b("div"),_.c(),v(n,"class","player-name svelte-wi0lrc"),v(d,"class","clickable-icon setting-editor-extra-setting-button"),v(d,"aria-label",h=e[21].enabled?"Disable":"Enable"),v(a,"class","player-right svelte-wi0lrc"),v(t,"class","player svelte-wi0lrc"),ge(t,"disabled",!e[21].enabled),this.first=t},m(P,k){A(P,t,k),y(t,n),y(n,s),y(t,o),y(t,a),y(a,l),y(l,u),y(a,f),y(a,d),_.m(d,null),p||(m=Y(d,"click",S),p=!0)},p(P,k){e=P,k&2&&r!==(r=e[21].name+"")&&me(s,r),k&2&&c!==(c=e[21].level+"")&&me(u,c),O!==(O=g(e,k))&&(_.d(1),_=O(e),_&&(_.c(),_.m(d,null))),k&2&&h!==(h=e[21].enabled?"Disable":"Enable")&&v(d,"aria-label",h),k&2&&ge(t,"disabled",!e[21].enabled)},d(P){P&&T(t),_.d(),p=!1,m()}}}function e$(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[8].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function t$(i){let e,t,n,r;return{c(){e=b("div")},m(s,o){A(s,e,o),n||(r=H(t=i[9].call(null,e)),n=!0)},d(s){s&&T(e),n=!1,r()}}}function rC(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g,O,_,S,P,k,w,x;function C(...z){return i[15](i[21],...z)}function M(...z){return i[16](i[21],...z)}function Z(z,q){return z[21].enabled?t$:e$}let Q=Z(i,-1),D=Q(i);function E(){return i[17](i[21])}function j(){return i[18](i[21])}return{c(){e=b("div"),t=b("input"),r=R(),s=b("span"),s.textContent="Player(s)",o=R(),a=b("div"),c=R(),u=b("span"),u.textContent="Level",f=R(),d=b("input"),p=R(),m=b("div"),g=b("div"),D.c(),_=R(),S=b("div"),P=b("div"),v(t,"type","number"),t.value=n=i[21].count,v(t,"min","1"),v(t,"class","svelte-wi0lrc"),v(d,"type","number"),d.value=h=i[21].level,v(d,"min","1"),v(d,"class","svelte-wi0lrc"),v(g,"class","clickable-icon setting-editor-extra-setting-button"),v(g,"aria-label",O=i[21].enabled?"Disable":"Enable"),v(S,"class","clickable-icon setting-editor-extra-setting-button"),v(m,"class","player-right svelte-wi0lrc"),v(e,"class","player svelte-wi0lrc"),ge(e,"disabled",!i[21].enabled)},m(z,q){A(z,e,q),y(e,t),y(e,r),y(e,s),y(e,o),y(e,a),y(e,c),y(e,u),y(e,f),y(e,d),y(e,p),y(e,m),y(m,g),D.m(g,null),y(m,_),y(m,S),y(S,P),w||(x=[Y(t,"input",C),H(l=i[12].call(null,a)),Y(d,"input",M),Y(g,"click",E),H(k=i[13].call(null,P)),Y(S,"click",j)],w=!0)},p(z,q){i=z,q&4&&n!==(n=i[21].count)&&t.value!==n&&(t.value=n),q&4&&h!==(h=i[21].level)&&d.value!==h&&(d.value=h),Q!==(Q=Z(i,q))&&(D.d(1),D=Q(i),D&&(D.c(),D.m(g,null))),q&4&&O!==(O=i[21].enabled?"Disable":"Enable")&&v(g,"aria-label",O),q&4&&ge(e,"disabled",!i[21].enabled)},d(z){z&&T(e),D.d(),w=!1,de(x)}}}function i$(i){let e,t,n,r,s=[],o=new Map,a,l,c,u,f,d,h,p=i[6].length&&GL(i),m=fe(i[1]),g=S=>S[21].name;for(let S=0;St(1,n=C)),ke(i,o,C=>t(2,r=C));let a=Ye("plugin"),l=a.data.builder.showParty,c=a.data.defaultParty,u=a.data.parties;return a.getPlayersForParty(c).forEach(C=>{ji.add({level:C.level,name:C.name,...C.creature,isPlayer:!0,enabled:!0,count:1})}),[a,n,r,s,o,l,u,C=>{new fo.Setting(C).setName("Select a party").addDropdown(M=>{M.addOption("none","None").addOptions(Object.fromEntries(u.map(Z=>[Z.name,Z.name]))).onChange(Z=>{ji.switchParty(a.getPlayersForParty(Z).map(Q=>({level:Q.level,name:Q.name,...Q.creature,isPlayer:!0,enabled:!0,count:1})))}),c&&M.setValue(c)})},C=>{(0,fo.setIcon)(C,Tl)},C=>{(0,fo.setIcon)(C,El)},C=>{(0,fo.setIcon)(C,"plus-with-circle")},()=>{ji.add({isPlayer:!1,level:1,count:1,enabled:!0})},C=>{(0,fo.setIcon)(C,"x")},C=>{(0,fo.setIcon)(C,"x-square")},C=>ji.toggleEnabled(C),(C,M)=>ji.set(C,Number(M.currentTarget.value)),(C,M)=>ji.setLevel(C,Number(M.currentTarget.value)),C=>ji.toggleEnabled(C),C=>ji.remove(C),()=>t(0,a.data.builder.showParty=!a.data.builder.showParty,a)]}var oy=class extends ne{constructor(e){super(),re(this,e,r$,n$,ie,{},UL)}},sC=oy;function s$(i){se(i,"svelte-jz7gin",".players-xp.svelte-jz7gin{display:grid;grid-template-columns:1fr 1fr}")}function o$(i){let e,t,n,r,s,o;return n=new sC({}),s=new eC({}),{c(){e=b("div"),t=b("div"),ye(n.$$.fragment),r=R(),ye(s.$$.fragment),v(t,"class","players-xp svelte-jz7gin"),v(e,"class","player-component-container")},m(a,l){A(a,e,l),y(e,t),Oe(n,t,null),y(t,r),Oe(s,t,null),o=!0},p:X,i(a){o||($(n.$$.fragment,a),$(s.$$.fragment,a),o=!0)},o(a){V(n.$$.fragment,a),V(s.$$.fragment,a),o=!1},d(a){a&&T(e),ve(n),ve(s)}}}var ay=class extends ne{constructor(e){super(),re(this,e,null,o$,ie,{},s$)}},oC=ay;function a$(i){se(i,"svelte-95ft2e",".encounter-builder.svelte-95ft2e{margin:1rem}")}function l$(i){let e,t,n,r,s,o,a;return t=new oC({}),r=new F5({}),o=new R5({}),{c(){e=b("div"),ye(t.$$.fragment),n=R(),ye(r.$$.fragment),s=R(),ye(o.$$.fragment),v(e,"class","initiative-tracker encounter-builder markdown-rendered svelte-95ft2e")},m(l,c){A(l,e,c),Oe(t,e,null),y(e,n),Oe(r,e,null),y(e,s),Oe(o,e,null),a=!0},p:X,i(l){a||($(t.$$.fragment,l),$(r.$$.fragment,l),$(o.$$.fragment,l),a=!0)},o(l){V(t.$$.fragment,l),V(r.$$.fragment,l),V(o.$$.fragment,l),a=!1},d(l){l&&T(e),ve(t),ve(r),ve(o)}}}function c$(i,e,t){let{plugin:n}=e,r=n.bestiary,s=Jw(n,[...r]);Vi("table",s);let o=cw(s.creatures,n);return Vi("filters",o),n.data.builder||(n.data.builder={sidebarIcon:!0,showParty:!0,showXP:!0}),Vi("plugin",n),of(()=>{ji.empty()}),i.$$set=a=>{"plugin"in a&&t(0,n=a.plugin)},[n]}var ly=class extends ne{constructor(e){super(),re(this,e,c$,l$,ie,{plugin:0},a$)}},cy=ly;var vl=class extends aC.ItemView{constructor(t,n){super(t);this.plugin=n;te(this,"ui")}getState(){return[...ct(ii).entries()]}async setState(t,n){t&&Array.isArray(t)&&ii.setMultiple(t),super.setState(t,n)}async onOpen(){if(this.plugin.canUseStatBlocks&&!window.FantasyStatblocks.isResolved()){this.contentEl.addClasses(["waiting-for-bestiary","is-loading"]);let t=this.contentEl.createEl("p",{text:"Waiting for Fantasy Statblocks Bestiary..."}),n=window.FantasyStatblocks.onResolved(()=>{this.contentEl.removeClasses(["waiting-for-bestiary","is-loading"]),t.detach(),this.ui=new cy({target:this.contentEl,props:{plugin:this.plugin}}),n()})}else this.ui=new cy({target:this.contentEl,props:{plugin:this.plugin}})}async onClose(){this.ui?.$destroy()}getDisplayText(){return"Encounter Builder"}getIcon(){return Er}getViewType(){return Er}};var pC=require("obsidian");var Eu=require("obsidian");function u$(i){se(i,"svelte-1frc5is",".full-center.svelte-1frc5is{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.initiative-tracker-table.svelte-1frc5is{padding:0.5rem;align-items:center;gap:0.25rem 0.5rem;width:100%;margin-left:0rem;table-layout:fixed;border-collapse:separate;border-spacing:0 2px;font-size:larger}.left.svelte-1frc5is{text-align:left}.name.svelte-1frc5is,.name.svelte-1frc5is>svg{display:flex;align-items:center;gap:0.5rem}.center.svelte-1frc5is{text-align:center}.healthy.svelte-1frc5is{color:var(--text-success)}.hurt.svelte-1frc5is{color:var(--text-warning)}.bloodied.svelte-1frc5is{color:var(--text-error)}.defeated.svelte-1frc5is{color:var(--text-faint)}.active.svelte-1frc5is{background-color:rgba(0, 0, 0, 0.1)}.theme-dark .active.svelte-1frc5is{background-color:rgba(255, 255, 255, 0.1)}")}function cC(i,e,t){let n=i.slice();return n[14]=e[t],n}function uC(i){let e,t,n,r,s;return{c(){e=b("div"),v(e,"class","contains-icon"),v(e,"aria-label",t="This creature is an ally.")},m(o,a){A(o,e,a),r||(s=H(n=i[11].call(null,e)),r=!0)},d(o){o&&T(e),r=!1,s()}}}function f$(i){let e,t=i[8](i[14].hp,i[14].max)+"",n;return{c(){e=b("span"),n=ae(t)},m(r,s){A(r,e,s),y(e,n)},p(r,s){s&1&&t!==(t=r[8](r[14].hp,r[14].max)+"")&&me(n,t)},d(r){r&&T(e)}}}function d$(i){let e,t=i[14].hpDisplay+"";return{c(){e=b("div"),v(e,"class","center svelte-1frc5is")},m(n,r){A(n,e,r),e.innerHTML=t},p(n,r){r&1&&t!==(t=n[14].hpDisplay+"")&&(e.innerHTML=t)},d(n){n&&T(e)}}}function fC(i,e){let t,n,r=e[14].initiative+"",s,o,a,l,c=e[10](e[14])+"",u,f,d,h,p,m,g=[...e[14].status].map(dC).join(", ")+"",O,_,S=e[14].friendly&&uC(e);function P(x,C){return x[14].player&&x[2].diplayPlayerHPValues?d$:f$}let k=P(e,-1),w=k(e);return{key:i,first:null,c(){t=b("tr"),n=b("td"),s=ae(r),o=R(),a=b("td"),S&&S.c(),l=R(),u=ae(c),f=R(),d=b("td"),w.c(),p=R(),m=b("td"),O=ae(g),_=R(),v(n,"class","center svelte-1frc5is"),v(a,"class","name svelte-1frc5is"),v(d,"class",h=un(e[8](e[14].hp,e[14].max).toLowerCase())+" svelte-1frc5is"),ge(d,"center",!0),v(m,"class","center svelte-1frc5is"),v(t,"class","svelte-1frc5is"),ge(t,"active",e[9](e[14])&&e[1]),this.first=t},m(x,C){A(x,t,C),y(t,n),y(n,s),y(t,o),y(t,a),S&&S.m(a,null),y(a,l),y(a,u),y(t,f),y(t,d),w.m(d,null),y(t,p),y(t,m),y(m,O),y(t,_)},p(x,C){e=x,C&1&&r!==(r=e[14].initiative+"")&&me(s,r),e[14].friendly?S||(S=uC(e),S.c(),S.m(a,l)):S&&(S.d(1),S=null),C&1&&c!==(c=e[10](e[14])+"")&&me(u,c),k===(k=P(e,C))&&w?w.p(e,C):(w.d(1),w=k(e),w&&(w.c(),w.m(d,null))),C&1&&h!==(h=un(e[8](e[14].hp,e[14].max).toLowerCase())+" svelte-1frc5is")&&v(d,"class",h),C&1&&ge(d,"center",!0),C&1&&g!==(g=[...e[14].status].map(dC).join(", ")+"")&&me(O,g),C&515&&ge(t,"active",e[9](e[14])&&e[1])},d(x){x&&T(t),S&&S.d(),w.d()}}}function h$(i){let e,t,n,r,s,o,a,l,c,u,f,d,h,p,m,g=[],O=new Map,_,S,P,k,w=fe(i[0]),x=C=>C[14].id;for(let C=0;CName",l=R(),c=b("th"),u=b("strong"),d=R(),h=b("th"),h.innerHTML="Statuses",p=R(),m=b("tbody");for(let C=0;C{S&&(_||(_=So(e,zf,{},!0)),_.run(1))}),S=!0)},o(C){C&&(_||(_=So(e,zf,{},!1)),_.run(0)),S=!1},d(C){C&&T(e);for(let M=0;Mi.name;function p$(i,e,t){let n,r,s,o,{state:a,ordered:l,data:c}=he;ke(i,a,O=>t(1,s=O)),ke(i,l,O=>t(12,r=O)),ke(i,c,O=>t(2,o=O));let u=O=>{(0,Eu.setIcon)(O,an)},f=O=>{(0,Eu.setIcon)(O,tr)},d=O=>{(0,Eu.setIcon)(O,wo)},h=(O,_)=>O?O<=0?"Defeated":O<_/2?"Bloodied":O<_?"Hurt":"Healthy":"",p=O=>{if(O.hidden)return!1;if(O.active)return!0;let _=r.findIndex(k=>k.active),S=r.indexOf(O);return _==-1||_k.hidden)},m=O=>O.getName(),g=O=>{(0,Eu.setIcon)(O,er)};return i.$$.update=()=>{i.$$.dirty&4096&&t(0,n=r.filter(O=>O.enabled&&!O.hidden))},[n,s,o,a,l,c,u,d,h,p,m,g,r]}var uy=class extends ne{constructor(e){super(),re(this,e,p$,h$,ie,{},u$)}},hC=uy;var Tu=class extends pC.ItemView{constructor(t,n){super(t);this.leaf=t;this.plugin=n;te(this,"_app")}getDisplayText(){return"Player View"}getViewType(){return _o}getIcon(){return"lucide-view"}async onOpen(){this._app=new hC({target:this.contentEl,props:{}})}};var mp=require("obsidian");var pp=class extends mp.EditorSuggest{constructor(t){super(t.app);this.plugin=t;te(this,"_context",5);te(this,"_encounter",{})}getSuggestions(t){let n=[];switch(this._context){case 4:{n=[];break}case 0:n=[...this.plugin.players.keys()].filter(r=>!this._encounter.players?.includes(r));break;case 1:n=this.plugin.bestiaryNames;break;case 2:n=["false",...this.plugin.data.parties?.map(r=>r.name)];break;case 3:n=["true","false"];break;case 5:n=["players","creatures","party","rollHP","name"].filter(r=>!(r in this._encounter));break}return n.filter(r=>!t.query.length||r.toLowerCase().contains(t.query.toLowerCase()))}renderSuggestion(t,n){n.createSpan({text:t})}selectSuggestion(t,n){if(this.context){switch(this._context){case 5:{t=`${t}:`,/^(players|creatures):/.test(t)?t=`${t} - `:t=`${t} `;break}case 1:case 0:{let r=this.context.editor.getLine(this.context.start.line).search(/\S/);t=`${t} ${" ".repeat(r)}- `;break}case 2:case 3:{t=`${/\s$/.test(this.context.editor.getLine(this.context.start.line))?"":" "}${t.trim()}`;break}case 4:break}this.context.editor.replaceRange(`${t}`,this.context.start,{...this.context.end,ch:this.context.start.ch+this.context.query.length},"initiative-tracker"),this.context.editor.setCursor(this.context.start.line,this.context.start.ch+t.length),this.close()}}onTrigger(t,n,r){this._context=5;let s=n.getRange({line:0,ch:0},t);if(s.indexOf("```encounter\n")===-1)return null;let o=s.split(` `),a=!1,l;for(let u=o.length-1;u>=0;u--){let f=o[u];if(/^```$/.test(f))return null;if(/^```encounter/.test(f)){a=!0,l=u;break}}if(!a)return null;try{let u=n.getValue().split(` `);u.splice(t.line,1),u=u.slice(l+1);let f=u.findIndex(d=>/^```$/.test(d));f<0&&(f=u.length),this._encounter=(0,mp.parseYaml)(u.slice(0,f).join(` `))}catch{this._encounter={}}this._encounter||(this._encounter={});let c=n.getLine(t.line);if(/^name/.test(c))return null;if(/^rollHP:/.test(c)){this._context=3;let[u,f]=c.match(/^rollHP:\s?(.*)$/);return f==="true"||f==="false"?null:{end:t,start:{ch:c.length-f.length,line:t.line},query:f}}if(/^party:/.test(c)){this._context=2;let[u,f]=c.match(/^party:\s?(.*)$/);return this.plugin.data.parties.find(d=>d.name===f)?null:{end:t,start:{ch:c.length-f.length,line:t.line},query:f}}if(/\s+- (?:\d:)?/.test(c)){let u=!1;for(let h=o.length-1;h>=0;h--){let p=o[h];if(/^```$/.test(p)||/^```encounter/.test(p))return null;if(/^players:/.test(p)){this._context=0,u=!0;break}if(/^creatures:/.test(p)){this._context=1,u=!0;break}}if(!u)return null;let[f,d]=c.match(/^\s+- (?:\d:)?(.*)$/);return{end:t,start:{ch:c.length-d.length,line:t.line},query:d}}return{end:t,start:{ch:0,line:t.line},query:c}}};var Au,gp=class{constructor(e){this.plugin=e;Pl(this,Au,he);(window.InitiativeTracker=this)&&this.plugin.register(()=>delete window.InitiativeTracker)}addCreatures(e,t=this.plugin.data.rollHP){if(!e||!Array.isArray(e)||!e.length)throw new Error("Creatures must be an array.");Zu(this,Au).add(this.plugin,t,...e.map(n=>Ne.from(n)))}newEncounter(e){e?.creatures&&(e.creatures=e.creatures.map(t=>Ne.from(t).toJSON())),Zu(this,Au).new(this.plugin,e)}};Au=new WeakMap;var Op=class extends tn.Plugin{constructor(){super(...arguments);te(this,"api",new gp(this));te(this,"data");te(this,"tracker",he);te(this,"playerCreatures",new Map);te(this,"watchers",new Map);te(this,"_builderIcon")}getRoller(t){if(!this.canUseDiceRoller)return;let n=window.DiceRoller.getRoller(t,"statblock");return n===null?null:n}get canUseDiceRoller(){if(window.DiceRoller!=null)if(!window.DiceRoller.getRoller)new tn.Notice("Please update Dice Roller to the latest version to use with Initiative Tracker.");else return!0;return!1}getInitiativeValue(t=0){let n=Math.floor(Math.random()*19+1)+[t].flat().reduce((a,l)=>a+l,0);if(!this.canUseDiceRoller)return n;let r=this.data.initiative;if(typeof t=="number")r=r.replace(/%mod\d?%/g,`${t}`);else for(let a=0;an.name===t)?.players??[]}getPlayersForParty(t){return this.data.parties?.find(n=>n.name==t)?.players.map(n=>this.getPlayerByName(n))?.filter(n=>n)??[]}get canUseStatBlocks(){return this.app.plugins.enabledPlugins.has("obsidian-5e-statblocks")?(window.FantasyStatblocks?.getVersion()?.major??0)>=4:!1}get statblockVersion(){return window.FantasyStatblocks?.getVersion()??{major:0}}get statblock_creatures(){return window.FantasyStatblocks?window.FantasyStatblocks.getBestiaryCreatures():[]}get bestiary(){return this.statblock_creatures.filter(t=>!t.player&&t.bestiary!==!1)}addEncounter(t,n){this.data.encounters[t]=n,this.registerCommand(t)}removeEncounter(t){delete this.data.encounters[t],this.unregisterCommandsFor(t)}registerCommand(t){this.addCommand({id:`start-${t}`,name:`Start ${t}`,checkCallback:n=>{if(n)return t in this.data.encounters;t in this.data.encounters&&he.new(this,this.data.encounters[t])}})}unregisterCommandsFor(t){this.app.commands.findCommand(`initiative-tracker:start-${t}`)&&delete this.app.commands.commands[`initiative-tracker:start-${t}`]}get bestiaryNames(){return window.FantasyStatblocks?window.FantasyStatblocks.getBestiaryNames():[]}get view(){let t=this.app.workspace.getLeavesOfType(bo),n=t?.length?t[0]:null;if(n&&n.view&&n.view instanceof Ra)return n.view}get combatant(){let t=this.app.workspace.getLeavesOfType(pa),n=t?.length?t[0]:null;if(n&&n.view&&n.view instanceof tc)return n.view}get defaultParty(){return this.data.parties.find(t=>t.name==this.data.defaultParty)}getBaseCreatureFromBestiary(t){try{if(this.canUseStatBlocks&&window.FantasyStatblocks.hasCreature(t))return window.FantasyStatblocks.getCreatureFromBestiary(t)}catch{}return null}getCreatureFromBestiary(t){let n=this.getBaseCreatureFromBestiary(t);if(n)return Ne.from(n)}getCreatureFromBestiaryByDefinition(t){return t.player&&this.playerCreatures.has(t.name)?this.playerCreatures.get(t.name):this.getCreatureFromBestiary(t.name)??Ne.from(t)}get statblock_players(){return this.statblock_creatures.filter(t=>t.player).map(t=>[t.name,Ne.from(t)])}get players(){return new Map([...this.playerCreatures.entries(),...this.statblock_players])}async onload(){gy(),await this.loadSettings(),this.setBuilderIcon(),this.addSettingTab(new Ll(this)),this.registerView(bo,t=>new Ra(t,this)),this.registerView(_o,t=>new Tu(t,this)),this.registerView(pa,t=>new tc(t,this)),this.registerView(Er,t=>new vl(t,this)),this.addCommands(),this.addEvents(),this.registerEditorSuggest(new pp(this)),this.registerMarkdownCodeBlockProcessor("encounter",(t,n,r)=>{if(this.canUseStatBlocks&&!window.FantasyStatblocks.isResolved()){n.addClasses(["waiting-for-bestiary","is-loading"]);let s=n.createEl("p",{text:"Waiting for Fantasy Statblocks Bestiary..."}),o=window.FantasyStatblocks.onResolved(()=>{n.removeClasses(["waiting-for-bestiary","is-loading"]),s.detach();let a=new xo(this,t,n);r.addChild(a),o()})}else{let s=new xo(this,t,n);r.addChild(s)}}),this.registerMarkdownCodeBlockProcessor("encounter-table",(t,n,r)=>{if(this.canUseStatBlocks&&!window.FantasyStatblocks.isResolved()){n.addClasses(["waiting-for-bestiary","is-loading"]);let s=n.createEl("p",{text:"Waiting for Fantasy Statblocks Bestiary..."}),o=window.FantasyStatblocks.onResolved(()=>{n.removeClasses(["waiting-for-bestiary","is-loading"]),s.detach();let a=new xo(this,t,n,!0);r.addChild(a),o()})}else{let s=new xo(this,t,n,!0);r.addChild(s)}}),this.registerMarkdownPostProcessor(async(t,n)=>{if(!t||!t.firstElementChild)return;let r=t.querySelectorAll("code");if(!r||!r.length)return;let s=Array.from(r).filter(o=>/^encounter:\s/.test(o.innerText));if(s.length)for(let o of s){let a=createSpan("initiative-tracker-encounter-line");o.replaceWith(a);let l=async()=>{let c=o.innerText.replace("encounter:",""),u=(0,tn.parseYaml)("["+c.trim()+"]"),d=await new ql(this).parse({creatures:u});if(!d||!d.creatures||!d.creatures.size){a.setText("No creatures found.");return}new pb({target:a,props:{...d,plugin:this}})};if(this.canUseStatBlocks&&!window.FantasyStatblocks.isResolved()){let c=a.createSpan("waiting-for-bestiary inline"),u=Math.floor(200*Math.random());(0,tn.setIcon)(c.createDiv({cls:"icon",attr:{style:`animation-delay: ${u}ms`}}),"loader-2"),c.createEl("em",{text:"Loading Bestiary..."});let f=window.FantasyStatblocks.onResolved(()=>{t.removeClasses(["waiting-for-bestiary","inline"]),c.detach(),l(),f()})}else l()}}),this.playerCreatures=new Map(this.data.players.map(t=>[t.name,Ne.from(t)])),this.app.workspace.onLayoutReady(async()=>{this.addTrackerView();for(let t of this.data.players){if(t.path||!t.note)continue;let n=await this.app.metadataCache.getFirstLinkpathDest(t.note,"");if(!n||!this.app.metadataCache.getFileCache(n)?.frontmatter){new tn.Notice(`Initiative Tracker: There was an issue with the linked note for ${t.name}. Please re-link it in settings.`);continue}}this.registerEvent(this.app.metadataCache.on("changed",t=>{if(!(t instanceof tn.TFile))return;let n=this.data.players.filter(s=>s.path==t.path);if(!n.length)return;let r=this.app.metadataCache.getFileCache(t)?.frontmatter;if(r)for(let s of n){let{ac:o,hp:a,modifier:l,level:c,name:u}=r;if(s.ac=o,s.hp=a,s.modifier=l,s.level=c,s.name=u||s.name,s["statblock-link"]=r["statblock-link"],this.playerCreatures.set(s.name,Ne.from(s)),this.view){let f=he.getOrderedCreatures().find(d=>d.name==s.name);f&&he.updateCreatures({creature:f,change:{set_max_hp:s.hp,ac:s.ac}})}}})),this.registerEvent(this.app.vault.on("rename",(t,n)=>{if(!(t instanceof tn.TFile))return;let r=this.data.players.filter(s=>s.path==n);if(r.length)for(let s of r)s.path=t.path,s.note=t.basename})),this.registerEvent(this.app.vault.on("delete",t=>{if(!(t instanceof tn.TFile))return;let n=this.data.players.filter(r=>r.path==t.path);if(n.length)for(let r of n)r.path=null,r.note=null}))}),console.log("Initiative Tracker v"+this.manifest.version+" loaded")}addCommands(){this.addCommand({id:"open-tracker",name:"Open Initiative Tracker",checkCallback:t=>{if(!this.view)return t||this.addTrackerView(),!0}}),this.addCommand({id:"open-builder",name:"Open Encounter Builder",checkCallback:t=>{if(!this.builder)return t||this.addBuilderView(),!0}}),this.addCommand({id:"toggle-encounter",name:"Toggle Encounter",checkCallback:t=>{if(this.view)return t||he.toggleState(),!0}}),this.addCommand({id:"next-combatant",name:"Next Combatant",checkCallback:t=>{if(this.view&&he.getState())return t||he.goToNext(),!0}}),this.addCommand({id:"prev-combatant",name:"Previous Combatant",checkCallback:t=>{if(this.view&&he.getState())return t||he.goToPrevious(),!0}});for(let t in this.data.encounters)this.registerCommand(t)}addEvents(){this.registerEvent(this.app.workspace.on("initiative-tracker:should-save",async()=>await this.saveSettings())),this.registerEvent(app.workspace.on("initiative-tracker:save-state",async t=>{this.data.state=t,await this.saveSettings()})),this.registerEvent(this.app.workspace.on("initiative-tracker:start-encounter",async t=>{try{let n=t.map(s=>Ne.from(s).toJSON()),r=this.view;r||await this.addTrackerView(),r?(he?.new(this,{creatures:n,state:!1,name:null,round:1,logFile:null,roll:!0}),this.app.workspace.revealLeaf(r.leaf)):new tn.Notice("Could not find the Initiative Tracker. Try reloading the note!")}catch(n){new tn.Notice(`There was an issue launching the encounter. `+n.message),console.error(n);return}}))}async onunload(){await this.saveSettings(),this.app.workspace.trigger("initiative-tracker:unloaded"),console.log("Initiative Tracker unloaded")}async addTrackerView(){this.app.workspace.getLeavesOfType(bo)?.length||await this.app.workspace.getRightLeaf(!1).setViewState({type:bo})}get builder(){let t=this.app.workspace.getLeavesOfType(Er),n=t.length?t[0]:null;if(n&&n.view&&n.view instanceof vl)return n.view}async addBuilderView(){this.app.workspace.getLeavesOfType(Er)?.length||(await this.app.workspace.getLeaf(!0).setViewState({type:Er}),this.app.workspace.revealLeaf(this.builder.leaf))}async updatePlayer(t,n){if(!this.playerCreatures.has(t.name)){await this.savePlayer(n);return}let r=this.playerCreatures.get(t.name);r.update(n),this.data.players.splice(this.data.players.indexOf(t),1,n),this.playerCreatures.delete(t.name),this.playerCreatures.set(n.name,r),this.view&&he.updateState(),await this.saveSettings()}async savePlayer(t){this.data.players.push(t),this.playerCreatures.set(t.name,Ne.from(t)),await this.saveSettings()}async savePlayers(...t){for(let n of t)this.data.players.push(n),this.playerCreatures.set(n.name,Ne.from(n));await this.saveSettings()}async deletePlayer(t){this.data.players=this.data.players.filter(n=>n!=t),this.playerCreatures.delete(t.name),await this.saveSettings()}async loadSettings(){let t=Object.assign({},{...my},await this.loadData());if(this.data=t,this.data.statuses?.some(n=>!n.id)){for(let n of this.data.statuses)n.id=n.id??os.find(r=>r.name==n.name)?.id??xt();await this.saveSettings()}this.data.version=this.manifest.version.split(".").map(n=>Number(n))}async saveSettings(){await this.saveData(this.data),he.setData(this.data)}async openCombatant(t){if(!this.canUseStatBlocks)return;this.combatant||await this.app.workspace.getRightLeaf(!0).setViewState({type:pa}),await this.combatant.render(t),this.app.workspace.revealLeaf(this.combatant.leaf)}setBuilderIcon(){this.data.builder.sidebarIcon?this._builderIcon=this.addRibbonIcon(Er,"Initiative Tracker Encounter Builder",()=>{this.addBuilderView()}):this._builderIcon?.detach()}}; /*! Bundled license information: uri-js/dist/es5/uri.all.js: (** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js *) */ /* nosourcemap */